~ubuntu-branches/debian/wheezy/cuneiform/wheezy

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/spec_sym.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-10 17:58:10 UTC
  • Revision ID: james.westby@ubuntu.com-20090710175810-rqc89d2i3tki9m89
Tags: upstream-0.7.0+dfsg
ImportĀ upstreamĀ versionĀ 0.7.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 1993-2008, Cognitive Technologies
 
3
All rights reserved.
 
4
 
 
5
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½,
 
6
ļæ½ļæ½ļæ½ ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½:
 
7
 
 
8
      * ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
9
        ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
10
        ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
 
11
      * ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½
 
12
        ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
13
        ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½
 
14
        ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
 
15
      * ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ Cognitive Technologies, ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
 
16
        ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
17
        ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
18
        ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
 
19
 
 
20
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ "ļæ½ļæ½ļæ½
 
21
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½" ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½-ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
 
22
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ļæ½
 
23
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½. ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
24
ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½
 
25
ļæ½ļæ½ŃØļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½
 
26
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
27
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ (ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
 
28
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½-ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
 
29
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
 
30
ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½), ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
 
31
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
 
32
 
 
33
Redistribution and use in source and binary forms, with or without modification,
 
34
are permitted provided that the following conditions are met:
 
35
 
 
36
    * Redistributions of source code must retain the above copyright notice,
 
37
      this list of conditions and the following disclaimer.
 
38
    * Redistributions in binary form must reproduce the above copyright notice,
 
39
      this list of conditions and the following disclaimer in the documentation
 
40
      and/or other materials provided with the distribution.
 
41
    * Neither the name of the Cognitive Technologies nor the names of its
 
42
      contributors may be used to endorse or promote products derived from this
 
43
      software without specific prior written permission.
 
44
 
 
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
55
*/
 
56
 
 
57
 
 
58
 
 
59
/*  ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ */
 
60
/*  ļæ½ļæ½                                                              ļæ½ļæ½ */
 
61
/*  ļæ½ļæ½  SPEC_SYM.C  recognize special symbols (bullet,*)  04.11.92. ļæ½ļæ½ */
 
62
/*  ļæ½ļæ½                                                              ļæ½ļæ½ */
 
63
/*  ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ */
 
64
 
 
65
 
 
66
#include <stdlib.h>
 
67
#include <string.h>
 
68
 
 
69
#include "nt_types.h"
 
70
#include "struct.h"
 
71
#include "func.h"
 
72
#include "status.h"
 
73
#include "msgerr.h"
 
74
#include "ligas.h"
 
75
#include "tuner.h"
 
76
#include "minmax.h"
 
77
 
 
78
/* incline of string NOT USED !!!                           */
 
79
/* BULLET hav one line ONLY, otherwise non study c_comp !!!   */
 
80
 
 
81
/* results compare abris-arrays with curves and vert lines  */
 
82
/* -1 - non compare, 0 - not similar, 1 - similar           */
 
83
static INT flag_abris_curve_left, flag_abris_curve_right,
 
84
           flag_abris_line_left, flag_abris_line_right;
 
85
 
 
86
static INT comp_is_bullet(cell *c );
 
87
static void init_bullet_functions(void);
 
88
static BOOL comp_is_triangle(BYTE left[],BYTE right[],INT h,INT w);
 
89
static BOOL comp_is_rectangle(BYTE left[],BYTE right[],INT h);
 
90
static BOOL comp_is_ellipse(BYTE left[],BYTE right[],INT n,INT w);
 
91
static BOOL abris_line(BYTE fun[],INT n, INT denominator);
 
92
static INT place_fun_limit(BYTE fun[],INT n);
 
93
static INT place_fun(BYTE fun[],INT n);
 
94
static INT limit_place(BYTE left[],BYTE right[],INT h);
 
95
static void find_abris(cell *c,INT wid,BYTE left[],BYTE right[]);
 
96
static INT one_line_in_comp(cell *c);
 
97
static BOOL comp_glue(cell *c);
 
98
static BOOL comp_projections_overlay(cell *c1, cell *c2);
 
99
static INT context_next(cell *c);
 
100
static INT context_prev(cell *c);
 
101
static BOOL context_bullet(cell *c);
 
102
static INT conv_size_capital_let(BYTE let,INT wide);
 
103
 
 
104
static BOOL comp_is_star5(cell *c);
 
105
static BOOL pit(BYTE fun[],INT h);
 
106
static BOOL concave_line(BYTE fun[],INT h);
 
107
static BOOL ray_head_and_hands(BYTE left[],BYTE right[],INT h);
 
108
static BOOL ray_head_and_feets(cell *c);
 
109
 
 
110
#define NON_BULLET       0
 
111
#define BAD_RECTANGLE    1
 
112
#define RECTANGLE        2
 
113
#define ELLIPSE          3
 
114
#define TRIANGLE         4
 
115
#define LIMIT_HEIGHT     128
 
116
#define GOOD_CODE        254
 
117
#define BAD_CODE         126
 
118
#define CODE_BULLET      liga_bull
 
119
 
 
120
extern BYTE fax1x2;
 
121
#define INC_FAX( val )            \
 
122
        if( fax1x2 ) val += 2;
 
123
#define DEC_FAX( val )            \
 
124
        if( fax1x2 ) val -= 2;
 
125
 
 
126
/* is letter bullet ? */
 
127
INT chkbullet( BYTE let )
 
128
{
 
129
return( let==liga_bull);
 
130
}
 
131
 
 
132
/* bullet                                                            */
 
133
/*   ļæ½ļæ½ļæ½ new_vers (file S_TOOLS.C)                                   */
 
134
/*   ļæ½ļæ½ļæ½ comp_is_bullet                                              */
 
135
/*         ļæ½ļæ½ļæ½ comp_glue                                             */
 
136
/*         ļæ½       ļæ½ļæ½ļæ½  comp_projections_overlay                     */
 
137
/*         ļæ½ļæ½ļæ½ one_line_in_comp                                      */
 
138
/*         ļæ½ļæ½ļæ½ context_bullet                                        */
 
139
/*         ļæ½       ļæ½ļæ½ļæ½  context_prev  ļæ½Äæ                            */
 
140
/*         ļæ½       ļæ½ļæ½ļæ½  context_netx  ļæ½Ä“                            */
 
141
/*         ļæ½                            ļæ½ļæ½ļæ½ conv_size_capital_let    */
 
142
/*         ļæ½ļæ½ļæ½ find_abris                                            */
 
143
/*         ļæ½ļæ½ļæ½ filtr_bullet (file S_TOOLS.C)                         */
 
144
/*         ļæ½ļæ½ļæ½ limit_place                                           */
 
145
/*         ļæ½ļæ½ļæ½ get_b_lines  (A.Leman)                                */
 
146
/*         ļæ½ļæ½ļæ½ init_bullet_functions                                 */
 
147
/*         ļæ½ļæ½ļæ½ comp_is_rectangle ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½Äæ                           */
 
148
/*         ļæ½ļæ½ļæ½ comp_is_ellipse   ļæ½ļæ½Äæ    ļæ½                           */
 
149
/*         ļæ½ļæ½ļæ½ comp_is_triangle  Äæ ļæ½    ļæ½                           */
 
150
/*              ļæ½   abris_curve ļæ½ļæ½ļæ½ļæ½ļæ½    ļæ½                           */
 
151
/*              ļæ½ļæ½ļæ½ abris_line  ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½                           */
 
152
 
 
153
/*      star                                                         */
 
154
/*        ļæ½ļæ½ļæ½ new_vers (file S_TOOLS.C)                              */
 
155
/*        ļæ½ļæ½ļæ½ comp_is_star5                                          */
 
156
/*              ļæ½ļæ½ļæ½ comp_glue                                        */
 
157
/*              ļæ½       ļæ½ļæ½ļæ½ comp_proections_overlay                  */
 
158
/*              ļæ½ļæ½ļæ½ find_abris                                       */
 
159
/*              ļæ½ļæ½ļæ½ ray_head_and_feets                               */
 
160
/*              ļæ½ļæ½ļæ½ ray_head_and_hands                               */
 
161
/*                      ļæ½ļæ½ļæ½ pit                                      */
 
162
/*                           ļæ½ļæ½ļæ½ find_minimum  (file S_TOOLS.C)      */
 
163
/*                           ļæ½ļæ½ļæ½ concave_line                        */
 
164
/*                                      ļæ½ļæ½ļæ½ place_fun                */
 
165
 
 
166
/*  for any cell in string-list set bullet code if */
 
167
/*  similar RECTANGLE,ELLIPSE,TRIANGLE             */
 
168
void bullet(void)
 
169
{
 
170
cell *c=cell_f();
 
171
 
 
172
while( (c=c->next) != cell_l() )
 
173
        {
 
174
        switch( comp_is_bullet(c)  )
 
175
           {
 
176
           case BAD_RECTANGLE  :
 
177
/*              new_vers(c,CODE_BULLET,BAD_CODE); */
 
178
/*              NOT USED in next passes           */
 
179
                break;
 
180
           case RECTANGLE  :
 
181
                new_vers(c,CODE_BULLET,GOOD_CODE);
 
182
                break;
 
183
           case ELLIPSE  :
 
184
                new_vers(c,CODE_BULLET,GOOD_CODE);
 
185
                break;
 
186
           case TRIANGLE :
 
187
                new_vers(c,CODE_BULLET,GOOD_CODE);
 
188
                break;
 
189
           default :
 
190
                break;
 
191
           }
 
192
 
 
193
        }
 
194
return;
 
195
}
 
196
 
 
197
static void init_bullet_functions(void)
 
198
{
 
199
flag_abris_line_left  = flag_abris_line_right  =
 
200
flag_abris_curve_left = flag_abris_curve_right = -1;
 
201
return;
 
202
}
 
203
 
 
204
/*  for any cell in string-list set    */
 
205
/* star code if similar 5-ray star     */
 
206
void star(void)
 
207
{
 
208
cell *c=cell_f();
 
209
while( (c=c->next) != cell_l() )
 
210
        {
 
211
        if( c->nvers==0 || !(c->flg&(c_f_let|c_f_bad)) ||
 
212
            c->vers[0].let=='1' || c->vers[0].let=='t')
 
213
                {                    /*   ļæ½     or     dust       */
 
214
                if( comp_is_star5(c)==TRUE )
 
215
                        new_vers(c,'*', GOOD_CODE );
 
216
                }
 
217
        //AK! c/g ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ - c->next ļæ½ļæ½ NULL
 
218
        if (c->next == NULL )
 
219
                AKCheckChain();                             //break;
 
220
 
 
221
        }
 
222
return;
 
223
}
 
224
 
 
225
static INT comp_is_bullet(cell *c)
 
226
{
 
227
 
 
228
BYTE left[LIMIT_HEIGHT],right[LIMIT_HEIGHT];
 
229
INT height=c->h, width=c->w;
 
230
BOOL i1=FALSE, i2=FALSE, i3=FALSE;
 
231
INT place_limit, place=(height-2)*width;
 
232
B_LINES bl;
 
233
INT center_bl,center_bul,top,bot;
 
234
 
 
235
if( height<6 || width<6     ) return(0);      /* no bullet : small c_comp */
 
236
if( comp_glue(c)==TRUE      ) return(0);      /* no bullet : c_comp glue  */
 
237
if( one_line_in_comp(c)!=1  ) return(0);      /* no bullet : >1 lines   */
 
238
if( !context_bullet(c)      ) return(0);      /* no bullet : near c_comp  */
 
239
if( c->nvers==1 && c->vers[0].let=='*' &&
 
240
    c->vers[0].prob==254    ) return(0);      /* it is my 5-ray star    */
 
241
 
 
242
memset(left,0xFF,height);
 
243
memset(right,0xFF,height);
 
244
 
 
245
find_abris(c, width, left, right);
 
246
if( left[height-1]+right[height-1]+1==width )
 
247
        height--;                             /* shave upper pimple     */
 
248
filtr_bullet( left, height);
 
249
filtr_bullet(right, height);
 
250
#ifdef INTERSEPTOR
 
251
filtr_shave( left, height);
 
252
filtr_shave(right, height);
 
253
{
 
254
INT i;
 
255
for(i=0;i<height;i++)
 
256
  {
 
257
  if( left[i]==0 )
 
258
    left[i]=1;
 
259
   if( right[i]==0 )
 
260
    right[i]=1;
 
261
  }
 
262
}
 
263
#endif
 
264
place_limit=limit_place(left,right,height);
 
265
 
 
266
top = c->row; bot = top + height;
 
267
get_b_lines(c,&bl);
 
268
center_bl = (bl.b3+bl.b2)/2;
 
269
center_bul = top+c->h/2;
 
270
 
 
271
if (bot<center_bl)
 
272
 return(0);
 
273
 
 
274
if( center_bul>center_bl &&
 
275
    (place_limit>height/2 || place_limit>=3 && bl.b3-bot<=2) )
 
276
        {
 
277
        /* 1. downer area                    */
 
278
        if(height<=bl.ps/2+1 || width<=bl.ps/2+1 )
 
279
                              return(0);      /* no bullet : small c_comp */
 
280
        }
 
281
 
 
282
if( width<8 && height<8 || MAX(width,height)<=8 && MIN(width,height)>=6 )
 
283
        {       /* too small  c_comp */
 
284
        if( abs(width-height)>2 )
 
285
                return(0);     /* no bullet : c_comp hav bad proportions   */
 
286
        /* 2.     no square                 */
 
287
        if( top<bl.b2 || bot>bl.b3 )
 
288
        /* 3. small c_comp overlay 2 base line */
 
289
        /* 4. small c_comp overlay 3 base line */
 
290
                return(0);     /* no bullet : c_comp overlay base line 2,3 */
 
291
        if( top>=bl.bm || bot<=bl.bm )
 
292
        /* 5. c_comp not overlay central base line */
 
293
                return(0);     /* no bullet : upper or downer small c_comp */
 
294
        }
 
295
 
 
296
else
 
297
        { /* nornal sizes        */
 
298
#define NUMERV 9
 
299
#define DENOMV 16         /* vertical treshold NUMERV/DENOMV */
 
300
#define NUMERH 4
 
301
#define DENOMH 5          /* horizontal treshold NUMERH/DENOMH */
 
302
 
 
303
        INC_FAX(height);
 
304
        if(width*DENOMV < NUMERV*height || height*DENOMH < NUMERH*width ||
 
305
                place_limit*4>=place )
 
306
                return(0);      /* no bullet : too big places of limit or */
 
307
                                /*   bad proportionals                    */
 
308
        DEC_FAX(height);
 
309
 
 
310
#undef NUMERV
 
311
#undef DENOMV
 
312
#undef NUMERH
 
313
#undef DENOMH
 
314
        }
 
315
 
 
316
init_bullet_functions();
 
317
i2=comp_is_ellipse(left,right,height,width);
 
318
if( i2==FALSE )
 
319
        i1=comp_is_rectangle(left,right,height);
 
320
if( i1==FALSE )
 
321
        i3=comp_is_triangle(left,right,height,width);
 
322
 
 
323
if( i3==TRUE )
 
324
                return(TRIANGLE);
 
325
if( i2==TRUE )
 
326
                return(ELLIPSE);
 
327
if( i1==TRUE )
 
328
        {
 
329
        INT corr= ( place_limit>10 ? 10 : 5) ;
 
330
 
 
331
        if( place_limit < place/corr )
 
332
                return(RECTANGLE);
 
333
        else
 
334
                return(BAD_RECTANGLE);
 
335
        }
 
336
 
 
337
 
 
338
return(NON_BULLET);
 
339
}
 
340
 
 
341
static BOOL context_bullet(cell *c)
 
342
{
 
343
INT r1  = context_prev(c), r2 = context_next(c) ;
 
344
 
 
345
return ( r1==2 || r1>=1 && r2>=1 );
 
346
/* return TRUE if not exist near next or prev cell */
 
347
}
 
348
 
 
349
/* return  2 - prev cell non exist  */
 
350
/*         1 - prev cell is far     */
 
351
/*         0 - prev cell is near    */
 
352
static INT context_prev(cell *c)
 
353
{
 
354
cell *cc=c->prev;
 
355
INT k=16,d=9,scc,ww;
 
356
 
 
357
if( cc==cell_f() )
 
358
        return(2);              /* not exist left c_comp   */
 
359
 
 
360
ww = ( cc->vers[0].let==bad_char )?MIN(cc->w,cc->h):cc->w;
 
361
if(   (c->col - cc->col - cc->w)*2 < conv_size_capital_let(cc->vers[0].let,ww) )
 
362
        return(0);              /* near components       */
 
363
 
 
364
while( cc!=cell_f() && cc->flg!=c_f_let )
 
365
        cc = cc->prev;          /* find prev letter-c_comp */
 
366
 
 
367
if( cc!=NULL && c->h < conv_size_capital_let(cc->vers[0].let,cc->h)/2 )
 
368
        {                       /* high c_comp             */
 
369
        if( cc->row + cc->h - c->row - c->h >= cc->h/4+1 )
 
370
                {k=4;d=1;}      /* upper zone            */
 
371
        scc = conv_size_capital_let(cc->vers[0].let,cc->w) *
 
372
              conv_size_capital_let(cc->vers[0].let,cc->h);
 
373
        if( c->w * c->h * k < scc * d )
 
374
                return(0);      /* small component       */
 
375
        }
 
376
 
 
377
return(1);                      /* good tandem           */
 
378
}
 
379
 
 
380
/* return  2 - next cell non exist    */
 
381
/*         1 - next cell is far       */
 
382
/*         0 - next cell is near      */
 
383
static INT context_next(cell *c)
 
384
{
 
385
cell *cc=c->next;
 
386
INT  k=16,d=9,scc,ww;
 
387
 
 
388
if( cc==cell_l() )
 
389
        return(2);              /* not exist right c_comp  */
 
390
 
 
391
ww = ( cc->vers[0].let==bad_char )?MIN(cc->w,cc->h):cc->w;
 
392
if( (cc->col - c->col - c->w)*2 < conv_size_capital_let(cc->vers[0].let,ww) )
 
393
        return(0);              /* near components       */
 
394
 
 
395
while( cc!=cell_l() && cc->flg!=c_f_let )
 
396
        cc = cc->next;          /* find next letter-c_comp */
 
397
 
 
398
if( cc!=cell_l() && c->h < conv_size_capital_let(cc->vers[0].let,cc->h)/2 )
 
399
        {                       /* high c_comp             */
 
400
        if( cc->row + cc->h - c->row - c->h >= cc->h/4+1 )
 
401
                {k=4; d=1;}     /* upper zone            */
 
402
        scc = conv_size_capital_let(cc->vers[0].let,cc->w) *
 
403
              conv_size_capital_let(cc->vers[0].let,cc->h);
 
404
        if( c->w * c->h * k < scc * d )
 
405
                return(0);      /* small  component      */
 
406
        }
 
407
 
 
408
return(1);                      /* good tandem           */
 
409
}
 
410
 
 
411
/* decrease size for capital letter */
 
412
static INT conv_size_capital_let(BYTE let,INT wide)
 
413
{
 
414
return( let<91 ? (wide*2)/3 : wide);
 
415
}
 
416
 
 
417
static BOOL comp_glue(cell *c)
 
418
{
 
419
cell *cc=c->next;
 
420
if( cc!=cell_l() )
 
421
        {
 
422
        if( comp_projections_overlay(c, cc) )
 
423
                return( TRUE );
 
424
        }
 
425
cc=c->prev;
 
426
if( cc!=cell_f() )
 
427
        {
 
428
        if( comp_projections_overlay(c, cc) )
 
429
                return( TRUE );
 
430
        }
 
431
 
 
432
return(FALSE);
 
433
}
 
434
 
 
435
static BOOL comp_projections_overlay(cell *c1, cell *c2)
 
436
{
 
437
INT b1 = c1->col, b2 = c2->col;
 
438
INT e1 = b1 + c1->w, e2 = b2 + c2->w;
 
439
if( b1<=b2 && b2<=e1 )return(TRUE);
 
440
if( b2<=b1 && b1<=e2 )return(TRUE);
 
441
return( FALSE );
 
442
}
 
443
 
 
444
static BOOL comp_is_ellipse(BYTE left[],BYTE right[],INT h,INT w)
 
445
{
 
446
if( flag_abris_curve_left<0 )
 
447
        flag_abris_curve_left = abris_curve(left,h,w);
 
448
if( flag_abris_curve_right<0 )
 
449
        flag_abris_curve_right = abris_curve(right,h,w);
 
450
return flag_abris_curve_left && flag_abris_curve_right ;
 
451
}
 
452
 
 
453
static BOOL comp_is_rectangle(BYTE left[],BYTE right[],INT h)
 
454
{
 
455
if( flag_abris_line_left<0 )
 
456
        flag_abris_line_left = abris_line(left,h,4);
 
457
if( flag_abris_line_right<0 )
 
458
        flag_abris_line_right = abris_line(right,h,4);
 
459
if( flag_abris_line_left && !flag_abris_line_right )
 
460
    {
 
461
    flag_abris_line_right= abris_line(right,h,3);
 
462
    }
 
463
return flag_abris_line_left && flag_abris_line_right ;
 
464
}
 
465
 
 
466
static BOOL comp_is_triangle(BYTE left[],BYTE right[],INT h,INT w)
 
467
{
 
468
if( flag_abris_curve_left<0 )
 
469
        flag_abris_curve_left = abris_curve(left,h,w);
 
470
if( flag_abris_curve_right<0 )
 
471
        flag_abris_curve_right = abris_curve(right,h,w);
 
472
if( flag_abris_line_left<0 )
 
473
        flag_abris_line_left = abris_line(left,h,4);
 
474
if( flag_abris_line_right<0 )
 
475
        flag_abris_line_right = abris_line(right,h,4);
 
476
return flag_abris_curve_left && flag_abris_line_right ||
 
477
       flag_abris_line_left && flag_abris_curve_right ;
 
478
}
 
479
 
 
480
/* limit_place : sum of limit points in box (size h*w) */
 
481
/*               left(right) - array left(right) abris */
 
482
static INT limit_place(BYTE left[],BYTE right[],INT h)
 
483
{
 
484
return ( place_fun_limit(left,h) + place_fun_limit(right,h) ) ;
 
485
}
 
486
 
 
487
static INT place_fun_limit(BYTE fun[],INT n )
 
488
{
 
489
INT i,s,vert_line=1,nn=(n-2)>>1; /* nn-1/2 heigh of c_comp             */
 
490
for(s=0,i=1;i<n-1;i++)           /* first and last lines skipped     */
 
491
        {
 
492
        s+= fun[i];
 
493
        if( fun[i]>1 ) vert_line = 0;  /*  not vert line             */
 
494
        }
 
495
if( vert_line )                        /* fun[] is vert line         */
 
496
        {
 
497
        if( s>nn )                     /* place pits > place pimples */
 
498
                s = n - 2 - s;         /* pits , not pimples         */
 
499
        }
 
500
return( s );
 
501
}
 
502
 
 
503
 
 
504
static INT place_fun(BYTE fun[],INT n)
 
505
{
 
506
INT i,s;
 
507
for(s=i=0;i<n;i++)
 
508
        s+= fun[i];
 
509
return( s );
 
510
}
 
511
 
 
512
BOOL abris_curve(BYTE fun[],INT n,INT w)
 
513
{
 
514
BYTE i=n>>2,minim,ff,fo,imin;
 
515
 
 
516
minim = (BYTE)find_minimum( fun, n, &imin );
 
517
 
 
518
if( imin<i || imin>(n-i) )
 
519
        return(FALSE) ;     /* max of fun belong [n/4, 3n/4] */
 
520
 
 
521
for(fo=fun[0],i=1;i<imin;i++)
 
522
        {
 
523
        ff=fun[i];
 
524
        if( ff>fo )
 
525
                return(FALSE);          /* fun must decrease */
 
526
        fo=ff;
 
527
        }
 
528
for(fo=fun[imin],i=imin+1;i<n;i++)
 
529
        {
 
530
        ff=fun[i];
 
531
        if( ff<fo )
 
532
                return(FALSE);          /* fun must increase */
 
533
        fo=ff;
 
534
        }
 
535
w=(w>>2)-((fax1x2)?2:1);
 
536
if( (fun[0]-minim)<w || (fun[n-1]-minim)<w )
 
537
        return(FALSE);                  /* flat curve        */
 
538
return(TRUE);                           /* similar arc       */
 
539
}
 
540
 
 
541
static BOOL abris_line(BYTE fun[],INT n,INT denominator)
 
542
{
 
543
#define NUM_OF_LEAP (n/denominator)
 
544
INT i,hist=0;
 
545
n -= 2;
 
546
for( i=0; i<n; i++)
 
547
        if( fun[i+1]>1 )
 
548
                hist++;       /* number of long jumps in abris  */
 
549
return( hist<= NUM_OF_LEAP ); /* TRUE if too few jumps in abris */
 
550
#undef NUM_OF_LEAP
 
551
}
 
552
 
 
553
 
 
554
static INT one_line_in_comp(cell *c)
 
555
{
 
556
 BYTE fill[LIMIT_HEIGHT];
 
557
 lnhead *line;
 
558
 interval *inter;
 
559
 INT ind,i,ll,h,max_h=c->h,num_int;
 
560
 
 
561
 if (!tsimple(c))
 
562
    return 0;
 
563
 if( c->env->nl==1 )
 
564
        return(1);
 
565
 
 
566
 memset(fill, 0, max_h-- );
 
567
 
 
568
 num_int = 0;                        /* number of rows with 1 interval    */
 
569
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
 
570
        (ll=line->lth)>0; line=(lnhead *)((PCHAR)line+ll))
 
571
#ifdef INTERSEPTOR
 
572
  if( line->h>1 )
 
573
#endif
 
574
 for( h=line->h,i=0, inter=(interval *)((PCHAR)line+sizeof(lnhead));
 
575
        i<h;i++,inter++)             /* one line                          */
 
576
        {
 
577
        ind = line->row + i;         /* skipped first and last lines      */
 
578
        if( ind>0 && ind<max_h )
 
579
                {
 
580
                if( inter->l > 1 )   /* long inteval                      */
 
581
                        {
 
582
                if( fill[ind] )      /* non one interval in line          */
 
583
                        return(0);   /* two long intervals                */
 
584
                else                 /* empty line                        */
 
585
                                {
 
586
                                fill[ind] = 1;
 
587
                                num_int++;
 
588
                                }
 
589
                        }
 
590
                }
 
591
        }
 
592
 
 
593
return( num_int==max_h-1 );          /* TRUE if all rows good, else FALSE */
 
594
}
 
595
 
 
596
static void find_abris(cell *c,INT wid,BYTE left[],BYTE right[])
 
597
{
 
598
 lnhead *line;
 
599
 INT i,ll,ind;
 
600
 interval *inter;
 
601
 BYTE l,r,h;
 
602
 
 
603
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
 
604
                        (ll=line->lth)>0; line=(lnhead *)((PCHAR)line+ll))
 
605
 if( (h=(BYTE)line->h)>1 )                         /* long line        */
 
606
 for( i=0, inter=(interval *)((PCHAR)line+sizeof(lnhead));i<h;i++,inter++)
 
607
        {
 
608
        r= wid - inter->e;                   /* current interval */
 
609
        l = inter->e - inter->l;
 
610
        ind = line->row + i;
 
611
        if( right[ind]>r ) right[ind] = r;
 
612
        if( left[ind]>l  ) left[ind]  = l;
 
613
        }
 
614
return ;
 
615
}
 
616
 
 
617
static BOOL comp_is_star5(cell *c)
 
618
{
 
619
B_LINES bl;
 
620
BYTE left[LIMIT_HEIGHT],right[LIMIT_HEIGHT];
 
621
INT height=c->h, width=c->w ;
 
622
 
 
623
if( height<6 || width<6 ) return(0);      /* no star : small c_comp      */
 
624
#define NUMER 4
 
625
#define DENOM 5                           /* treshold NUMER/DENOM      */
 
626
#define NUM   2
 
627
#define DEN   3                           /* treshold NUM/DEN          */
 
628
 
 
629
if(width*DEN < NUM*height || (height+((fax1x2)?2:0))*DENOM < NUMER*width )
 
630
                          return(0);      /* no star : bad proportions */
 
631
#undef NUMER
 
632
#undef DENOM
 
633
#undef NUM
 
634
#undef DEN
 
635
 
 
636
get_b_lines(c,&bl);
 
637
if (c->row>=bl.bm) return(0);             /* no star : low position */
 
638
if( comp_glue(c)==TRUE  ) return(0);      /* no star : c_comp glue       */
 
639
 
 
640
memset(left,0xFF,height);
 
641
memset(right,0xFF,height);
 
642
 
 
643
find_abris(c, width, left, right);
 
644
 
 
645
if( !ray_head_and_feets( c ) )
 
646
        return(FALSE);
 
647
if( !ray_head_and_hands(  left, right, height) )
 
648
        return(FALSE);
 
649
 
 
650
return( TRUE );
 
651
}
 
652
 
 
653
 
 
654
static BOOL ray_head_and_hands(BYTE left[],BYTE right[],INT h)
 
655
{
 
656
return pit(left,h) & pit(right,h) ;
 
657
}
 
658
 
 
659
static BOOL ray_head_and_feets(cell *c )
 
660
{
 
661
BYTE work[LIMIT_HEIGHT];    /* number of intervals in row              */
 
662
INT height=c->h;
 
663
INT h_c=height/5;           /* height of ray                           */
 
664
INT skip_h =  height - h_c;
 
665
lnhead *line;
 
666
interval *inter;
 
667
INT ll,h,i,l;
 
668
 
 
669
memset(work, 0, height);
 
670
 
 
671
for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
 
672
                        (ll=line->lth)>0; line=(lnhead *)((PCHAR)line+ll))
 
673
 if( (h=line->h)>0 )        /*                  long line              */
 
674
 for( i=0, inter=(interval *)((PCHAR)line+sizeof(lnhead));
 
675
                        i<h;i++,inter++)
 
676
                work[line->row+i] ++;
 
677
 
 
678
for( ll=0, i = height-( (work[height-1]!=2) ? ((fax1x2)?3:2) : 1 ) ;
 
679
 i>=0 && work[i]==2 ; i--, ll++);
 
680
                            /* ll - number of 2-interval downer lines  */
 
681
                            /* downer area : 2 feets                   */
 
682
 
 
683
if( ll>=3*(height>>2) ) return(FALSE);
 
684
 
 
685
for( l=0;i>=0;i--)
 
686
        l += (work[i]==1);  /* l - number of 1-interval upper lines     */
 
687
 
 
688
skip_h = height - ll;       /* skip_h - height of upper area            */
 
689
if( work[height-1]!=2 ) skip_h--;
 
690
 
 
691
for( i = 1 ; i<height && work[i]==1 ; i++);
 
692
 
 
693
h_c = ( h_c>3 ? h_c/3 : 1); /* h_c - number of rows with 2 intervals    */
 
694
if( h_c==1 && height<11 && (work[height-1]==2 || work[height-2]==2) )
 
695
        h_c=0; /* for small stars : exist more one row with 2 intervals */
 
696
 
 
697
return( (i>=height/4) && (l>skip_h/2) && (ll>h_c-((fax1x2)?1:0)) );
 
698
}
 
699
 
 
700
static BOOL pit(BYTE fun[],INT h)
 
701
{
 
702
BYTE imin, minim;
 
703
INT wide;
 
704
 
 
705
minim = (BYTE)find_minimum( fun, h,  &imin );
 
706
while( imin>0 && fun[imin]==minim ) imin--;
 
707
imin++;                                       /* find position horiz ray  */
 
708
 
 
709
wide = fun[0] - minim;                        /* find size of horiz ray   */
 
710
if( wide<h/3 )
 
711
        return(FALSE);                        /* too short ray            */
 
712
if( imin<h/4 || imin>(h*3)/4 )
 
713
        return( FALSE );                      /* too heigh or too low ray */
 
714
 
 
715
return( concave_line( fun, (INT)(imin+1) ) );        /* concave upper area       */
 
716
}
 
717
 
 
718
/* fun[0] = upper point of head; fun[n-1] = limits point of hand-ray */
 
719
static BOOL concave_line(BYTE fun[],INT n)
 
720
{
 
721
INT st = (fun[0]+fun[n-1])*n/2;        /* place of trapeze         */
 
722
INT sf = place_fun(fun,n);             /* integral of function     */
 
723
return( (n<5 || fax1x2)? (sf >= st) : (sf > st) ); /* fun is up convexity      */
 
724
}