2
Copyright (c) 1993-2008, Cognitive Technologies
5
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½,
6
ļæ½ļæ½ļæ½ ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½:
8
* ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
9
ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
10
ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
11
* ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½
12
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
13
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½
14
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
15
* ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ Cognitive Technologies, ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
16
ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
17
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
18
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
20
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ "ļæ½ļæ½ļæ½
21
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½" ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½-ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
22
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ļæ½
23
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½. ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
24
ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½
25
ļæ½ļæ½ŃØļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½
26
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
27
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ (ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
28
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½-ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
29
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
30
ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½), ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
31
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
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.
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.
59
/* ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ */
61
/* ļæ½ļæ½ SPEC_SYM.C recognize special symbols (bullet,*) 04.11.92. ļæ½ļæ½ */
63
/* ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ */
78
/* incline of string NOT USED !!! */
79
/* BULLET hav one line ONLY, otherwise non study c_comp !!! */
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;
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);
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);
111
#define BAD_RECTANGLE 1
115
#define LIMIT_HEIGHT 128
116
#define GOOD_CODE 254
118
#define CODE_BULLET liga_bull
121
#define INC_FAX( val ) \
122
if( fax1x2 ) val += 2;
123
#define DEC_FAX( val ) \
124
if( fax1x2 ) val -= 2;
126
/* is letter bullet ? */
127
INT chkbullet( BYTE let )
129
return( let==liga_bull);
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 ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ */
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 */
162
/* ļæ½ļæ½ļæ½ find_minimum (file S_TOOLS.C) */
163
/* ļæ½ļæ½ļæ½ concave_line */
164
/* ļæ½ļæ½ļæ½ place_fun */
166
/* for any cell in string-list set bullet code if */
167
/* similar RECTANGLE,ELLIPSE,TRIANGLE */
172
while( (c=c->next) != cell_l() )
174
switch( comp_is_bullet(c) )
177
/* new_vers(c,CODE_BULLET,BAD_CODE); */
178
/* NOT USED in next passes */
181
new_vers(c,CODE_BULLET,GOOD_CODE);
184
new_vers(c,CODE_BULLET,GOOD_CODE);
187
new_vers(c,CODE_BULLET,GOOD_CODE);
197
static void init_bullet_functions(void)
199
flag_abris_line_left = flag_abris_line_right =
200
flag_abris_curve_left = flag_abris_curve_right = -1;
204
/* for any cell in string-list set */
205
/* star code if similar 5-ray star */
209
while( (c=c->next) != cell_l() )
211
if( c->nvers==0 || !(c->flg&(c_f_let|c_f_bad)) ||
212
c->vers[0].let=='1' || c->vers[0].let=='t')
214
if( comp_is_star5(c)==TRUE )
215
new_vers(c,'*', GOOD_CODE );
217
//AK! c/g ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ - c->next ļæ½ļæ½ NULL
218
if (c->next == NULL )
219
AKCheckChain(); //break;
225
static INT comp_is_bullet(cell *c)
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;
233
INT center_bl,center_bul,top,bot;
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 */
242
memset(left,0xFF,height);
243
memset(right,0xFF,height);
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);
251
filtr_shave( left, height);
252
filtr_shave(right, height);
255
for(i=0;i<height;i++)
264
place_limit=limit_place(left,right,height);
266
top = c->row; bot = top + height;
268
center_bl = (bl.b3+bl.b2)/2;
269
center_bul = top+c->h/2;
274
if( center_bul>center_bl &&
275
(place_limit>height/2 || place_limit>=3 && bl.b3-bot<=2) )
278
if(height<=bl.ps/2+1 || width<=bl.ps/2+1 )
279
return(0); /* no bullet : small c_comp */
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 */
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 */
299
#define DENOMV 16 /* vertical treshold NUMERV/DENOMV */
301
#define DENOMH 5 /* horizontal treshold NUMERH/DENOMH */
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 */
316
init_bullet_functions();
317
i2=comp_is_ellipse(left,right,height,width);
319
i1=comp_is_rectangle(left,right,height);
321
i3=comp_is_triangle(left,right,height,width);
329
INT corr= ( place_limit>10 ? 10 : 5) ;
331
if( place_limit < place/corr )
334
return(BAD_RECTANGLE);
341
static BOOL context_bullet(cell *c)
343
INT r1 = context_prev(c), r2 = context_next(c) ;
345
return ( r1==2 || r1>=1 && r2>=1 );
346
/* return TRUE if not exist near next or prev cell */
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)
358
return(2); /* not exist left c_comp */
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 */
364
while( cc!=cell_f() && cc->flg!=c_f_let )
365
cc = cc->prev; /* find prev letter-c_comp */
367
if( cc!=NULL && c->h < conv_size_capital_let(cc->vers[0].let,cc->h)/2 )
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 */
377
return(1); /* good tandem */
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)
389
return(2); /* not exist right c_comp */
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 */
395
while( cc!=cell_l() && cc->flg!=c_f_let )
396
cc = cc->next; /* find next letter-c_comp */
398
if( cc!=cell_l() && c->h < conv_size_capital_let(cc->vers[0].let,cc->h)/2 )
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 */
408
return(1); /* good tandem */
411
/* decrease size for capital letter */
412
static INT conv_size_capital_let(BYTE let,INT wide)
414
return( let<91 ? (wide*2)/3 : wide);
417
static BOOL comp_glue(cell *c)
422
if( comp_projections_overlay(c, cc) )
428
if( comp_projections_overlay(c, cc) )
435
static BOOL comp_projections_overlay(cell *c1, cell *c2)
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);
444
static BOOL comp_is_ellipse(BYTE left[],BYTE right[],INT h,INT w)
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 ;
453
static BOOL comp_is_rectangle(BYTE left[],BYTE right[],INT h)
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 )
461
flag_abris_line_right= abris_line(right,h,3);
463
return flag_abris_line_left && flag_abris_line_right ;
466
static BOOL comp_is_triangle(BYTE left[],BYTE right[],INT h,INT w)
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 ;
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)
484
return ( place_fun_limit(left,h) + place_fun_limit(right,h) ) ;
487
static INT place_fun_limit(BYTE fun[],INT n )
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 */
493
if( fun[i]>1 ) vert_line = 0; /* not vert line */
495
if( vert_line ) /* fun[] is vert line */
497
if( s>nn ) /* place pits > place pimples */
498
s = n - 2 - s; /* pits , not pimples */
504
static INT place_fun(BYTE fun[],INT n)
512
BOOL abris_curve(BYTE fun[],INT n,INT w)
514
BYTE i=n>>2,minim,ff,fo,imin;
516
minim = (BYTE)find_minimum( fun, n, &imin );
518
if( imin<i || imin>(n-i) )
519
return(FALSE) ; /* max of fun belong [n/4, 3n/4] */
521
for(fo=fun[0],i=1;i<imin;i++)
525
return(FALSE); /* fun must decrease */
528
for(fo=fun[imin],i=imin+1;i<n;i++)
532
return(FALSE); /* fun must increase */
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 */
541
static BOOL abris_line(BYTE fun[],INT n,INT denominator)
543
#define NUM_OF_LEAP (n/denominator)
548
hist++; /* number of long jumps in abris */
549
return( hist<= NUM_OF_LEAP ); /* TRUE if too few jumps in abris */
554
static INT one_line_in_comp(cell *c)
556
BYTE fill[LIMIT_HEIGHT];
559
INT ind,i,ll,h,max_h=c->h,num_int;
566
memset(fill, 0, max_h-- );
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))
574
for( h=line->h,i=0, inter=(interval *)((PCHAR)line+sizeof(lnhead));
575
i<h;i++,inter++) /* one line */
577
ind = line->row + i; /* skipped first and last lines */
578
if( ind>0 && ind<max_h )
580
if( inter->l > 1 ) /* long inteval */
582
if( fill[ind] ) /* non one interval in line */
583
return(0); /* two long intervals */
584
else /* empty line */
593
return( num_int==max_h-1 ); /* TRUE if all rows good, else FALSE */
596
static void find_abris(cell *c,INT wid,BYTE left[],BYTE right[])
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++)
608
r= wid - inter->e; /* current interval */
609
l = inter->e - inter->l;
611
if( right[ind]>r ) right[ind] = r;
612
if( left[ind]>l ) left[ind] = l;
617
static BOOL comp_is_star5(cell *c)
620
BYTE left[LIMIT_HEIGHT],right[LIMIT_HEIGHT];
621
INT height=c->h, width=c->w ;
623
if( height<6 || width<6 ) return(0); /* no star : small c_comp */
625
#define DENOM 5 /* treshold NUMER/DENOM */
627
#define DEN 3 /* treshold NUM/DEN */
629
if(width*DEN < NUM*height || (height+((fax1x2)?2:0))*DENOM < NUMER*width )
630
return(0); /* no star : bad proportions */
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 */
640
memset(left,0xFF,height);
641
memset(right,0xFF,height);
643
find_abris(c, width, left, right);
645
if( !ray_head_and_feets( c ) )
647
if( !ray_head_and_hands( left, right, height) )
654
static BOOL ray_head_and_hands(BYTE left[],BYTE right[],INT h)
656
return pit(left,h) & pit(right,h) ;
659
static BOOL ray_head_and_feets(cell *c )
661
BYTE work[LIMIT_HEIGHT]; /* number of intervals in row */
663
INT h_c=height/5; /* height of ray */
664
INT skip_h = height - h_c;
669
memset(work, 0, height);
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));
676
work[line->row+i] ++;
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 */
683
if( ll>=3*(height>>2) ) return(FALSE);
686
l += (work[i]==1); /* l - number of 1-interval upper lines */
688
skip_h = height - ll; /* skip_h - height of upper area */
689
if( work[height-1]!=2 ) skip_h--;
691
for( i = 1 ; i<height && work[i]==1 ; i++);
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 */
697
return( (i>=height/4) && (l>skip_h/2) && (ll>h_c-((fax1x2)?1:0)) );
700
static BOOL pit(BYTE fun[],INT h)
705
minim = (BYTE)find_minimum( fun, h, &imin );
706
while( imin>0 && fun[imin]==minim ) imin--;
707
imin++; /* find position horiz ray */
709
wide = fun[0] - minim; /* find size of horiz ray */
711
return(FALSE); /* too short ray */
712
if( imin<h/4 || imin>(h*3)/4 )
713
return( FALSE ); /* too heigh or too low ray */
715
return( concave_line( fun, (INT)(imin+1) ) ); /* concave upper area */
718
/* fun[0] = upper point of head; fun[n-1] = limits point of hand-ray */
719
static BOOL concave_line(BYTE fun[],INT n)
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 */