~ubuntu-branches/ubuntu/precise/cuneiform/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, c-assert.diff, slovenian-slv.diff
  • Date: 2011-01-26 21:53:07 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110126215307-62x61mcesr607qb7
Tags: 1.0.0+dfsg-2
* Upload to unstable.
* Explicitly build-depend on pkg-config. Thanks to Stefano Rivera for the
  bug report.
* Add Vcs-* fields.
* Use the standard C assert() macro, rather than custom Cuneiform one.
  [c-assert.diff]
* Pass CFLAGS, CXXFLAGS and LDFLAGS (get from dpkg-buildflags) to cmake
  (closes: #608345). Thanks to Sami Liedes for the bug report.
  + Build depend on dpkg-dev (>= 1.15.7).
* Pass --parallel to dh.
  + Bump debhelper minimum version to 7.4.10.
* Update debian/copyright to the latest DEP-5 version.
* Bump year in debian/copyright.
* Explicitly link to GraphicsMagick (rather than via the ImageMagick
  compatibility layer).
* Don't ship /usr/lib/cuneiform/*.so symlinks. These libraries are
  considered private, at least until #598616 is fixed.
* Rename some private variables in debian/rules to make them lowercase.
* Update patch headers.
* Provide proper ‘build-arch’ and ‘build-indep’ targets in debian/rules.
* Document input format in the manual page (closes: #572061). Thanks to
  Janusz S. Bień for the bug report.
* Use ‘slv’ (rather than ‘slo’) as language code for Slovenian.
  [slovenian-slv.diff]
* Fix package description: Slovenian is supported, Slovak is not.
* Improve documentation of the language (-l) option (closes: #602512).
  Thanks to Jari Aalto for the bug report.
* Install reasons file for vrms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 1993-2008, Cognitive Technologies
3
3
All rights reserved.
4
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
 
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
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
32
 
33
33
Redistribution and use in source and binary forms, with or without modification,
34
34
are permitted provided that the following conditions are met:
56
56
 
57
57
 
58
58
 
59
 
/*  ������������������������������������������������������������������ */
60
 
/*  ��                                                              �� */
61
 
/*  ��  SPEC_SYM.C  recognize special symbols (bullet,*)  04.11.92. �� */
62
 
/*  ��                                                              �� */
63
 
/*  ������������������������������������������������������������������ */
 
59
/*  °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° */
 
60
/*  °°                                                              °° */
 
61
/*  °°  SPEC_SYM.C  recognize special symbols (bullet,*)  04.11.92. °° */
 
62
/*  °°                                                              °° */
 
63
/*  °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° */
64
64
 
65
65
 
66
66
#include <stdlib.h>
67
67
#include <string.h>
68
68
 
69
 
#include "nt_types.h"
 
69
 
70
70
#include "struct.h"
71
71
#include "func.h"
72
72
#include "status.h"
80
80
 
81
81
/* results compare abris-arrays with curves and vert lines  */
82
82
/* -1 - non compare, 0 - not similar, 1 - similar           */
83
 
static INT flag_abris_curve_left, flag_abris_curve_right,
 
83
static int16_t flag_abris_curve_left, flag_abris_curve_right,
84
84
           flag_abris_line_left, flag_abris_line_right;
85
85
 
86
 
static INT comp_is_bullet(cell *c );
 
86
static int16_t comp_is_bullet(cell *c );
87
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);
 
88
static Bool comp_is_triangle(uchar left[],uchar right[],int16_t h,int16_t w);
 
89
static Bool comp_is_rectangle(uchar left[],uchar right[],int16_t h);
 
90
static Bool comp_is_ellipse(uchar left[],uchar right[],int16_t n,int16_t w);
 
91
static Bool abris_line(uchar fun[],int16_t n, int16_t denominator);
 
92
static int16_t place_fun_limit(uchar fun[],int16_t n);
 
93
static int16_t place_fun(uchar fun[],int16_t n);
 
94
static int16_t limit_place(uchar left[],uchar right[],int16_t h);
 
95
static void find_abris(cell *c,int16_t wid,uchar left[],uchar right[]);
 
96
static int16_t 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 int16_t context_next(cell *c);
 
100
static int16_t context_prev(cell *c);
 
101
static Bool context_bullet(cell *c);
 
102
static int16_t conv_size_capital_let(uchar let,int16_t wide);
103
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);
 
104
static Bool comp_is_star5(cell *c);
 
105
static Bool pit(uchar fun[],int16_t h);
 
106
static Bool concave_line(uchar fun[],int16_t h);
 
107
static Bool ray_head_and_hands(uchar left[],uchar right[],int16_t h);
 
108
static Bool ray_head_and_feets(cell *c);
109
109
 
110
110
#define NON_BULLET       0
111
111
#define BAD_RECTANGLE    1
117
117
#define BAD_CODE         126
118
118
#define CODE_BULLET      liga_bull
119
119
 
120
 
extern BYTE fax1x2;
 
120
extern uchar fax1x2;
121
121
#define INC_FAX( val )            \
122
122
        if( fax1x2 ) val += 2;
123
123
#define DEC_FAX( val )            \
124
124
        if( fax1x2 ) val -= 2;
125
125
 
126
126
/* is letter bullet ? */
127
 
INT chkbullet( BYTE let )
 
127
int16_t chkbullet( uchar let )
128
128
{
129
129
return( let==liga_bull);
130
130
}
131
131
 
132
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  ����������                           */
 
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
152
 
153
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                */
 
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
165
 
166
166
/*  for any cell in string-list set bullet code if */
167
167
/*  similar RECTANGLE,ELLIPSE,TRIANGLE             */
210
210
        {
211
211
        if( c->nvers==0 || !(c->flg&(c_f_let|c_f_bad)) ||
212
212
            c->vers[0].let=='1' || c->vers[0].let=='t')
213
 
                {                    /*   �     or     dust       */
 
213
                {                    /*   °     or     dust       */
214
214
                if( comp_is_star5(c)==TRUE )
215
215
                        new_vers(c,'*', GOOD_CODE );
216
216
                }
217
 
        //AK! c/g �������� ������� - c->next �� NULL
 
217
        //AK! c/g порваная цепочка - c->next на NULL
218
218
        if (c->next == NULL )
219
219
                AKCheckChain();                             //break;
220
220
 
222
222
return;
223
223
}
224
224
 
225
 
static INT comp_is_bullet(cell *c)
 
225
static int16_t comp_is_bullet(cell *c)
226
226
{
227
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;
 
228
uchar left[LIMIT_HEIGHT],right[LIMIT_HEIGHT];
 
229
int16_t height=c->h, width=c->w;
 
230
Bool i1=FALSE, i2=FALSE, i3=FALSE;
 
231
int16_t place_limit, place=(height-2)*width;
232
232
B_LINES bl;
233
 
INT center_bl,center_bul,top,bot;
 
233
int16_t center_bl,center_bul,top,bot;
234
234
 
235
235
if( height<6 || width<6     ) return(0);      /* no bullet : small c_comp */
236
236
if( comp_glue(c)==TRUE      ) return(0);      /* no bullet : c_comp glue  */
251
251
filtr_shave( left, height);
252
252
filtr_shave(right, height);
253
253
{
254
 
INT i;
 
254
int16_t i;
255
255
for(i=0;i<height;i++)
256
256
  {
257
257
  if( left[i]==0 )
326
326
                return(ELLIPSE);
327
327
if( i1==TRUE )
328
328
        {
329
 
        INT corr= ( place_limit>10 ? 10 : 5) ;
 
329
        int16_t corr= ( place_limit>10 ? 10 : 5) ;
330
330
 
331
331
        if( place_limit < place/corr )
332
332
                return(RECTANGLE);
338
338
return(NON_BULLET);
339
339
}
340
340
 
341
 
static BOOL context_bullet(cell *c)
 
341
static Bool context_bullet(cell *c)
342
342
{
343
 
INT r1  = context_prev(c), r2 = context_next(c) ;
 
343
int16_t r1  = context_prev(c), r2 = context_next(c) ;
344
344
 
345
345
return ( r1==2 || r1>=1 && r2>=1 );
346
346
/* return TRUE if not exist near next or prev cell */
349
349
/* return  2 - prev cell non exist  */
350
350
/*         1 - prev cell is far     */
351
351
/*         0 - prev cell is near    */
352
 
static INT context_prev(cell *c)
 
352
static int16_t context_prev(cell *c)
353
353
{
354
354
cell *cc=c->prev;
355
 
INT k=16,d=9,scc,ww;
 
355
int16_t k=16,d=9,scc,ww;
356
356
 
357
357
if( cc==cell_f() )
358
358
        return(2);              /* not exist left c_comp   */
380
380
/* return  2 - next cell non exist    */
381
381
/*         1 - next cell is far       */
382
382
/*         0 - next cell is near      */
383
 
static INT context_next(cell *c)
 
383
static int16_t context_next(cell *c)
384
384
{
385
385
cell *cc=c->next;
386
 
INT  k=16,d=9,scc,ww;
 
386
int16_t  k=16,d=9,scc,ww;
387
387
 
388
388
if( cc==cell_l() )
389
389
        return(2);              /* not exist right c_comp  */
409
409
}
410
410
 
411
411
/* decrease size for capital letter */
412
 
static INT conv_size_capital_let(BYTE let,INT wide)
 
412
static int16_t conv_size_capital_let(uchar let,int16_t wide)
413
413
{
414
414
return( let<91 ? (wide*2)/3 : wide);
415
415
}
416
416
 
417
 
static BOOL comp_glue(cell *c)
 
417
static Bool comp_glue(cell *c)
418
418
{
419
419
cell *cc=c->next;
420
420
if( cc!=cell_l() )
432
432
return(FALSE);
433
433
}
434
434
 
435
 
static BOOL comp_projections_overlay(cell *c1, cell *c2)
 
435
static Bool comp_projections_overlay(cell *c1, cell *c2)
436
436
{
437
 
INT b1 = c1->col, b2 = c2->col;
438
 
INT e1 = b1 + c1->w, e2 = b2 + c2->w;
 
437
int16_t b1 = c1->col, b2 = c2->col;
 
438
int16_t e1 = b1 + c1->w, e2 = b2 + c2->w;
439
439
if( b1<=b2 && b2<=e1 )return(TRUE);
440
440
if( b2<=b1 && b1<=e2 )return(TRUE);
441
441
return( FALSE );
442
442
}
443
443
 
444
 
static BOOL comp_is_ellipse(BYTE left[],BYTE right[],INT h,INT w)
 
444
static Bool comp_is_ellipse(uchar left[],uchar right[],int16_t h,int16_t w)
445
445
{
446
446
if( flag_abris_curve_left<0 )
447
447
        flag_abris_curve_left = abris_curve(left,h,w);
450
450
return flag_abris_curve_left && flag_abris_curve_right ;
451
451
}
452
452
 
453
 
static BOOL comp_is_rectangle(BYTE left[],BYTE right[],INT h)
 
453
static Bool comp_is_rectangle(uchar left[],uchar right[],int16_t h)
454
454
{
455
455
if( flag_abris_line_left<0 )
456
456
        flag_abris_line_left = abris_line(left,h,4);
463
463
return flag_abris_line_left && flag_abris_line_right ;
464
464
}
465
465
 
466
 
static BOOL comp_is_triangle(BYTE left[],BYTE right[],INT h,INT w)
 
466
static Bool comp_is_triangle(uchar left[],uchar right[],int16_t h,int16_t w)
467
467
{
468
468
if( flag_abris_curve_left<0 )
469
469
        flag_abris_curve_left = abris_curve(left,h,w);
479
479
 
480
480
/* limit_place : sum of limit points in box (size h*w) */
481
481
/*               left(right) - array left(right) abris */
482
 
static INT limit_place(BYTE left[],BYTE right[],INT h)
 
482
static int16_t limit_place(uchar left[],uchar right[],int16_t h)
483
483
{
484
484
return ( place_fun_limit(left,h) + place_fun_limit(right,h) ) ;
485
485
}
486
486
 
487
 
static INT place_fun_limit(BYTE fun[],INT n )
 
487
static int16_t place_fun_limit(uchar fun[],int16_t n )
488
488
{
489
 
INT i,s,vert_line=1,nn=(n-2)>>1; /* nn-1/2 heigh of c_comp             */
 
489
int16_t i,s,vert_line=1,nn=(n-2)>>1; /* nn-1/2 heigh of c_comp             */
490
490
for(s=0,i=1;i<n-1;i++)           /* first and last lines skipped     */
491
491
        {
492
492
        s+= fun[i];
501
501
}
502
502
 
503
503
 
504
 
static INT place_fun(BYTE fun[],INT n)
 
504
static int16_t place_fun(uchar fun[],int16_t n)
505
505
{
506
 
INT i,s;
 
506
int16_t i,s;
507
507
for(s=i=0;i<n;i++)
508
508
        s+= fun[i];
509
509
return( s );
510
510
}
511
511
 
512
 
BOOL abris_curve(BYTE fun[],INT n,INT w)
 
512
Bool abris_curve(uchar fun[],int16_t n,int16_t w)
513
513
{
514
 
BYTE i=n>>2,minim,ff,fo,imin;
 
514
uchar i=n>>2,minim,ff,fo,imin;
515
515
 
516
 
minim = (BYTE)find_minimum( fun, n, &imin );
 
516
minim = (uchar)find_minimum( fun, n, &imin );
517
517
 
518
518
if( imin<i || imin>(n-i) )
519
519
        return(FALSE) ;     /* max of fun belong [n/4, 3n/4] */
538
538
return(TRUE);                           /* similar arc       */
539
539
}
540
540
 
541
 
static BOOL abris_line(BYTE fun[],INT n,INT denominator)
 
541
static Bool abris_line(uchar fun[],int16_t n,int16_t denominator)
542
542
{
543
543
#define NUM_OF_LEAP (n/denominator)
544
 
INT i,hist=0;
 
544
int16_t i,hist=0;
545
545
n -= 2;
546
546
for( i=0; i<n; i++)
547
547
        if( fun[i+1]>1 )
551
551
}
552
552
 
553
553
 
554
 
static INT one_line_in_comp(cell *c)
 
554
static int16_t one_line_in_comp(cell *c)
555
555
{
556
 
 BYTE fill[LIMIT_HEIGHT];
 
556
 uchar fill[LIMIT_HEIGHT];
557
557
 lnhead *line;
558
558
 interval *inter;
559
 
 INT ind,i,ll,h,max_h=c->h,num_int;
 
559
 int16_t ind,i,ll,h,max_h=c->h,num_int;
560
560
 
561
561
 if (!tsimple(c))
562
562
    return 0;
566
566
 memset(fill, 0, max_h-- );
567
567
 
568
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))
 
569
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
570
        (ll=line->lth)>0; line=(lnhead *)((pchar)line+ll))
571
571
#ifdef INTERSEPTOR
572
572
  if( line->h>1 )
573
573
#endif
574
 
 for( h=line->h,i=0, inter=(interval *)((PCHAR)line+sizeof(lnhead));
 
574
 for( h=line->h,i=0, inter=(interval *)((pchar)line+sizeof(lnhead));
575
575
        i<h;i++,inter++)             /* one line                          */
576
576
        {
577
577
        ind = line->row + i;         /* skipped first and last lines      */
593
593
return( num_int==max_h-1 );          /* TRUE if all rows good, else FALSE */
594
594
}
595
595
 
596
 
static void find_abris(cell *c,INT wid,BYTE left[],BYTE right[])
 
596
static void find_abris(cell *c,int16_t wid,uchar left[],uchar right[])
597
597
{
598
598
 lnhead *line;
599
 
 INT i,ll,ind;
 
599
 int16_t i,ll,ind;
600
600
 interval *inter;
601
 
 BYTE l,r,h;
 
601
 uchar l,r,h;
602
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++)
 
603
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
604
                        (ll=line->lth)>0; line=(lnhead *)((pchar)line+ll))
 
605
 if( (h=(uchar)line->h)>1 )                         /* long line        */
 
606
 for( i=0, inter=(interval *)((pchar)line+sizeof(lnhead));i<h;i++,inter++)
607
607
        {
608
608
        r= wid - inter->e;                   /* current interval */
609
609
        l = inter->e - inter->l;
614
614
return ;
615
615
}
616
616
 
617
 
static BOOL comp_is_star5(cell *c)
 
617
static Bool comp_is_star5(cell *c)
618
618
{
619
619
B_LINES bl;
620
 
BYTE left[LIMIT_HEIGHT],right[LIMIT_HEIGHT];
621
 
INT height=c->h, width=c->w ;
 
620
uchar left[LIMIT_HEIGHT],right[LIMIT_HEIGHT];
 
621
int16_t height=c->h, width=c->w ;
622
622
 
623
623
if( height<6 || width<6 ) return(0);      /* no star : small c_comp      */
624
624
#define NUMER 4
651
651
}
652
652
 
653
653
 
654
 
static BOOL ray_head_and_hands(BYTE left[],BYTE right[],INT h)
 
654
static Bool ray_head_and_hands(uchar left[],uchar right[],int16_t h)
655
655
{
656
656
return pit(left,h) & pit(right,h) ;
657
657
}
658
658
 
659
 
static BOOL ray_head_and_feets(cell *c )
 
659
static Bool ray_head_and_feets(cell *c )
660
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;
 
661
uchar work[LIMIT_HEIGHT];    /* number of intervals in row              */
 
662
int16_t height=c->h;
 
663
int16_t h_c=height/5;           /* height of ray                           */
 
664
int16_t skip_h =  height - h_c;
665
665
lnhead *line;
666
666
interval *inter;
667
 
INT ll,h,i,l;
 
667
int16_t ll,h,i,l;
668
668
 
669
669
memset(work, 0, height);
670
670
 
671
 
for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
672
 
                        (ll=line->lth)>0; line=(lnhead *)((PCHAR)line+ll))
 
671
for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
672
                        (ll=line->lth)>0; line=(lnhead *)((pchar)line+ll))
673
673
 if( (h=line->h)>0 )        /*                  long line              */
674
 
 for( i=0, inter=(interval *)((PCHAR)line+sizeof(lnhead));
 
674
 for( i=0, inter=(interval *)((pchar)line+sizeof(lnhead));
675
675
                        i<h;i++,inter++)
676
676
                work[line->row+i] ++;
677
677
 
697
697
return( (i>=height/4) && (l>skip_h/2) && (ll>h_c-((fax1x2)?1:0)) );
698
698
}
699
699
 
700
 
static BOOL pit(BYTE fun[],INT h)
 
700
static Bool pit(uchar fun[],int16_t h)
701
701
{
702
 
BYTE imin, minim;
703
 
INT wide;
 
702
uchar imin, minim;
 
703
int16_t wide;
704
704
 
705
 
minim = (BYTE)find_minimum( fun, h,  &imin );
 
705
minim = (uchar)find_minimum( fun, h,  &imin );
706
706
while( imin>0 && fun[imin]==minim ) imin--;
707
707
imin++;                                       /* find position horiz ray  */
708
708
 
712
712
if( imin<h/4 || imin>(h*3)/4 )
713
713
        return( FALSE );                      /* too heigh or too low ray */
714
714
 
715
 
return( concave_line( fun, (INT)(imin+1) ) );        /* concave upper area       */
 
715
return( concave_line( fun, (int16_t)(imin+1) ) );        /* concave upper area       */
716
716
}
717
717
 
718
718
/* fun[0] = upper point of head; fun[n-1] = limits point of hand-ray */
719
 
static BOOL concave_line(BYTE fun[],INT n)
 
719
static Bool concave_line(uchar fun[],int16_t n)
720
720
{
721
 
INT st = (fun[0]+fun[n-1])*n/2;        /* place of trapeze         */
722
 
INT sf = place_fun(fun,n);             /* integral of function     */
 
721
int16_t st = (fun[0]+fun[n-1])*n/2;        /* place of trapeze         */
 
722
int16_t sf = place_fun(fun,n);             /* integral of function     */
723
723
return( (n<5 || fax1x2)? (sf >= st) : (sf > st) ); /* fun is up convexity      */
724
724
}