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

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rcutp/sources/main/rcutp_mainfunc.cpp

  • 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:
62
62
#include <string.h>
63
63
#include <assert.h>
64
64
 
65
 
#include "nt_types.h"
66
65
#include "struct.h"
67
66
#include "cuthdr.h"
68
67
#include "cutstr.h"
72
71
#include "recdefs.h"
73
72
#include "minmax.h"
74
73
 
75
 
extern  Int16      minrow,bbs1,bbs2,bbs3,bbs4,Nb1,Nb2,Nb3;
76
 
extern  Word8      language;
 
74
extern  int16_t      minrow,bbs1,bbs2,bbs3,bbs4,Nb1,Nb2,Nb3;
 
75
extern  uchar      language;
77
76
#ifndef max
78
77
#define MAX(a,b)            (((a) > (b)) ? (a) : (b))
79
78
#endif
82
81
#define MIN(a,b)            (((a) < (b)) ? (a) : (b))
83
82
#endif
84
83
 
85
 
extern INT   up_position,dw_position;
86
 
BYTE MemForCutPoints[65536];
87
 
BYTE MemForCutPointsTwo[65536];
88
 
BYTE ForRaster3[R_S];
89
 
extern BYTE  db_status;  // snap presence byte
 
84
extern int16_t   up_position,dw_position;
 
85
uchar MemForCutPoints[65536];
 
86
uchar MemForCutPointsTwo[65536];
 
87
uchar ForRaster3[R_S];
 
88
extern uchar  db_status;  // snap presence byte
90
89
void snap_clear_screen(void);
91
90
 
92
91
 
93
 
static INT GDE_KAK[13][3] = {{1,0,0} ,{4,0,0}  ,{8,0,0} ,
 
92
static int16_t GDE_KAK[13][3] = {{1,0,0} ,{4,0,0}  ,{8,0,0} ,
94
93
                            {1,8,0} ,{8,1,0} ,{8,8,0},
95
94
                            {1,8,8},{8,8,1},{8,1,8},{8,8,8},
96
95
                            {4,8,8},{8,4,8},{8,8,4}};
97
96
 
98
 
INT Alik_define_cut_points(
99
 
  PCHAR raster_frag,
 
97
int16_t Alik_define_cut_points(
 
98
  pchar raster_frag,
100
99
  struct own_cut *ans,
101
 
  INT dx,                  /* ࠡ��� �ਭ� ����          */
102
 
  INT dy,                   /* ࠡ��� ���� ����          */
103
 
  INT row
 
100
  int16_t dx,                  /* ࠡ��� �ਭ� ����          */
 
101
  int16_t dy,                   /* ࠡ��� ���� ����          */
 
102
  int16_t row
104
103
)
105
104
 
106
105
{
107
 
 INT    hor_byte,ver_byte,nshort,CP,i,j,bl_up,bl_dw,tret_h;
108
 
 PINT   penalty,cut_points,adr_cut_points,my_penalty;
109
 
 PCHAR  adrw,adrw_two,product,product_two,trace,adr_raster,stek,adr_ras_two,
 
106
 int16_t    hor_byte,ver_byte,nshort,CP,i,j,bl_up,bl_dw,tret_h;
 
107
 pint16_t   penalty,cut_points,adr_cut_points,my_penalty;
 
108
 pchar  adrw,adrw_two,product,product_two,trace,adr_raster,stek,adr_ras_two,
110
109
        SourceRaster;
111
 
 PBYTE  IntBuf,CountCut,UpBlackPoint;
 
110
 puchar  IntBuf,CountCut,UpBlackPoint;
112
111
 struct own_cut *ans_ptr;
113
112
#ifdef AlikBl
114
 
CHAR snap[380],*buf=snap;
 
113
char snap[380],*buf=snap;
115
114
#endif
116
115
 
117
116
 Z=Z;
118
117
 bl_up=bbs2;
119
118
 bl_dw=bbs3;
120
 
 adr_cut_points=(PINT)ForRaster3;
 
119
 adr_cut_points=(pint16_t)ForRaster3;
121
120
 ans_ptr=ans;
122
121
 hor_byte=(dx+7)>>3;
123
122
 ver_byte=(dy+7)>>3;
125
124
 i=hor_byte*dy;
126
125
 tret_h = (dy<<1)/3;
127
126
 
128
 
 adr_raster=(PCHAR)MemForCutPoints;        /* ��� ��室�� �࠭ᯮ��஢���� ���� */
129
 
 adrw=adr_raster+CP;                /* ��� ��ࠡ�⠭�� �࠭ᯮ��஢���� ���� */
130
 
 trace=adrw+(CP>i?CP:i);            /* ��� ��室  */
131
 
 penalty=(PINT)trace+dx;            /* ��� ����� */
132
 
 product=(PCHAR)(penalty+dx);       /* ��� �ந�������� ��᫥����⥫��� �⮫�殢 */
133
 
 cut_points=(PINT)(product+dx);     /* ��� �窨 ࠧ१���� */
 
127
 adr_raster=(pchar)MemForCutPoints;        /* ��� ��室�� �࠭ᯮ��஢���� ���� */
 
128
 adrw=adr_raster+CP;                /* ��� ��ࠡ�⠭�� �࠭ᯮ��஢���� ���� */
 
129
 trace=adrw+(CP>i?CP:i);            /* ��� ��室  */
 
130
 penalty=(pint16_t)trace+dx;            /* ��� ����� */
 
131
 product=(pchar)(penalty+dx);       /* ��� �ந�������� ��᫥����⥫��� �⮫�殢 */
 
132
 cut_points=(pint16_t)(product+dx);     /* ��� �窨 ࠧ१���� */
134
133
 
135
 
 adrw_two=(PCHAR)MemForCutPointsTwo;
 
134
 adrw_two=(pchar)MemForCutPointsTwo;
136
135
 adr_ras_two = adrw_two+(CP>i?CP:i);
137
 
 product_two = adr_ras_two+(CP>i?CP:i); /* ��� �ந�������� ��᫥����⥫��� �⮫�殢 ᫥�� � �ࠢ�*/
138
 
 UpBlackPoint= (PBYTE)(product_two+dx);
139
 
 CountCut    = (PBYTE)(UpBlackPoint+dx);
140
 
 SourceRaster= (PCHAR)(CountCut+dx);
141
 
 my_penalty  = (PINT)(SourceRaster+(CP>i?CP:i));
142
 
 IntBuf      = (PBYTE)(my_penalty+dx);
 
136
 product_two = adr_ras_two+(CP>i?CP:i); /* ��� �ந�������� ��᫥����⥫��� �⮫�殢 ᫥�� � �ࠢ�*/
 
137
 UpBlackPoint= (puchar)(product_two+dx);
 
138
 CountCut    = (puchar)(UpBlackPoint+dx);
 
139
 SourceRaster= (pchar)(CountCut+dx);
 
140
 my_penalty  = (pint16_t)(SourceRaster+(CP>i?CP:i));
 
141
 IntBuf      = (puchar)(my_penalty+dx);
143
142
 
144
 
 CP = (dx<3||dy<3)? 0 : 1;          /* १��� �� �㤥�, �᫨ ���� ��� �� ������ �� ���ࠢ����� */
 
143
 CP = (dx<3||dy<3)? 0 : 1;          /* १��� �� �㤥�, �᫨ ���� ��� �� ������ �� ���ࠢ����� */
145
144
 
146
145
if(CP)
147
146
 {
148
147
   memcpy(SourceRaster,raster_frag,hor_byte*dy);
149
 
   memset((PBYTE)adr_cut_points,0,R_S);
 
148
   memset((puchar)adr_cut_points,0,R_S);
150
149
   memset(CountCut,0,dx);
151
150
 
152
 
   Alik_tr_bit_matr(ver_byte,dy,raster_frag,adr_raster,hor_byte,dx); /* �࠭ᯮ��஢���� ��室���� ���� */
153
 
   memset((PINT)trace,0,sizeof(INT)*dx);      /* ���㫥��� ���� ���⮢�� ���ᨢ�� */
154
 
   memset(penalty,0,sizeof(INT)*dx);          /* ���㫥��� ���ᨢ� ���䮢 */
155
 
   CP=Alik_del_detail(raster_frag,dx,(INT)(dy*hor_byte),penalty);
 
151
   Alik_tr_bit_matr(ver_byte,dy,raster_frag,adr_raster,hor_byte,dx); /* �࠭ᯮ��஢���� ��室���� ���� */
 
152
   memset((pint16_t)trace,0,sizeof(int16_t)*dx);      /* ���㫥��� ���� ���⮢�� ���ᨢ�� */
 
153
   memset(penalty,0,sizeof(int16_t)*dx);          /* ���㫥��� ���ᨢ� ���䮢 */
 
154
   CP=Alik_del_detail(raster_frag,dx,(int16_t)(dy*hor_byte),penalty);
156
155
   if(!CP && dx>20 && dx<=128) CP=1;   //10-09-96 03:24pm  Alik  cten33.tif
157
 
   if(!CP)                        /* ���� �ᯠ��� */
 
156
   if(!CP)                        /* ���� �ᯠ��� */
158
157
    {
159
 
     memset(penalty,0,sizeof(INT)*dx);        /* ���㫥��� ���ᨢ� ���䮢 */
 
158
     memset(penalty,0,sizeof(int16_t)*dx);        /* ���㫥��� ���ᨢ� ���䮢 */
160
159
     memcpy(adr_raster,adrw,ver_byte*dx);
161
160
    }
162
161
   else
163
 
     Alik_tr_bit_matr(ver_byte,dy,raster_frag,adrw,hor_byte,dx);    /* �࠭ᯮ��஢���� ��⮢�� ������ */
 
162
     Alik_tr_bit_matr(ver_byte,dy,raster_frag,adrw,hor_byte,dx);    /* �࠭ᯮ��஢���� ��⮢�� ������ */
164
163
 
165
164
   if(CP) CP=Alik_search_bound_point_in_raster(adrw,ver_byte,dx);
166
165
 
167
 
   if(CP)       /*  ���� ������ */
 
166
   if(CP)       /*  ���� ������ */
168
167
    {
169
168
     Alik_form_bound(adrw,dx,dy,ver_byte,trace,0);
170
169
     memcpy(adr_ras_two,adrw,ver_byte*dx);
171
170
     memcpy(adrw_two,adrw,ver_byte*dx);
172
 
     memcpy(my_penalty,penalty,sizeof(INT)*dx);
 
171
     memcpy(my_penalty,penalty,sizeof(int16_t)*dx);
173
172
 
174
173
     Alik_CountCut(adrw,dy,dx,CountCut,IntBuf);
175
174
     Alik_UpBlackPoint(adrw,dy,dx,UpBlackPoint);
176
175
     Alik_cut_short(adrw,adrw_two,dx,ver_byte,product,penalty,cut_points,product_two);
177
176
     nshort=*cut_points;
178
177
     Alik_cut_hole(trace,dx,cut_points,nshort,dy,product,penalty,0x00);
179
 
     Alik_del_equal_hole(cut_points,product,(PINT)penalty,dx,dy,nshort);
 
178
     Alik_del_equal_hole(cut_points,product,(pint16_t)penalty,dx,dy,nshort);
180
179
 
181
180
#ifdef AlikBl
182
181
     if( db_status && snap_activity('j') && snap_activity('a'))
184
183
                           product,product_two,penalty);
185
184
#endif
186
185
     if(language==LANG_RUSSIAN)
187
 
       Alik_find_brus(raster_frag,SourceRaster,adr_ras_two,(INT)(bl_dw-bl_up),dy,dx,
 
186
       Alik_find_brus(raster_frag,SourceRaster,adr_ras_two,(int16_t)(bl_dw-bl_up),dy,dx,
188
187
                      product,product_two,penalty,cut_points,CountCut,
189
188
                      UpBlackPoint);
190
189
#ifdef AlikBl
191
190
     buf=snap;
192
191
     buf+=sprintf(buf,"bl_up=%2d,bl_dw=%2d   ",bl_up,bl_dw);
193
192
#endif
194
 
     Alik_my_correct_base_lines(&bl_up,&bl_dw,dy,dx,row,(PBYTE)adr_ras_two,
 
193
     Alik_my_correct_base_lines(&bl_up,&bl_dw,dy,dx,row,(puchar)adr_ras_two,
195
194
                                (PWORD)penalty,IntBuf);
196
195
#ifdef AlikBl
197
196
     buf+=sprintf(buf,"bl_up=%2d,bl_dw=%2d   ",bl_up,bl_dw);
211
210
     if(bl_up>=0 && bl_dw<=dy)
212
211
      {
213
212
       Alik_double_serif(cut_points,trace,product,dx,dy,bl_up,bl_dw,penalty,
214
 
                         (PBYTE)adr_ras_two,IntBuf);
215
 
       Alik_cut_d(trace+dx,cut_points,product,dx,dy,bl_up,bl_dw,(PCHAR)penalty);
 
213
                         (puchar)adr_ras_two,IntBuf);
 
214
       Alik_cut_d(trace+dx,cut_points,product,dx,dy,bl_up,bl_dw,(pchar)penalty);
216
215
       Alik_defis(trace,cut_points,dx,dy,bl_up,bl_dw,penalty);
217
216
    if(language==LANG_ENGLISH)
218
217
       Alik_cut_l(cut_points,trace,dx,bl_dw,penalty);
228
227
     Alik_del_equal(cut_points);
229
228
     Alik_del_3_cut(adrw,cut_points,nshort,ver_byte,dx,CountCut);
230
229
    if(abs((row+dy)-(minrow+bbs3))>3)
231
 
     Alik_del_p_cut(adrw,cut_points,dx,dy,nshort,(CHAR)(bl_dw-bl_up-3));
 
230
     Alik_del_p_cut(adrw,cut_points,dx,dy,nshort,(char)(bl_dw-bl_up-3));
232
231
    if(language==LANG_RUSSIAN)
233
232
     Alik_Check_Rus_D(raster_frag,SourceRaster,dy,dx,cut_points,IntBuf,row,
234
233
                      product,product_two,penalty,CountCut);
237
236
 
238
237
     if(CP)
239
238
      {
240
 
       CP=Alik_sort(cut_points,(PINT)adr_cut_points,dx);
241
 
       if(CP)  CP=Alik_del_doubl_cut((PINT)adr_cut_points,product,penalty,CP);
 
239
       CP=Alik_sort(cut_points,(pint16_t)adr_cut_points,dx);
 
240
       if(CP)  CP=Alik_del_doubl_cut((pint16_t)adr_cut_points,product,penalty,CP);
242
241
      }
243
242
     CP=MIN(STK_H-2,CP);
244
243
 
247
246
 
248
247
 if(CP)
249
248
  {
250
 
   Alik_cor_pnt((PINT)adr_cut_points,penalty,cut_points,CP,dx,dy,ver_byte,(PCHAR)adrw,(PCHAR)trace);
 
249
   Alik_cor_pnt((pint16_t)adr_cut_points,penalty,cut_points,CP,dx,dy,ver_byte,(pchar)adrw,(pchar)trace);
251
250
   Alik_form_bound(adr_raster,dx,dy,ver_byte,trace,1);
252
 
         stek=(PCHAR)(penalty+((CP+1)<<2)-(CP+1));  /* ��९��뢠�� �ࠣ����� ����� ��室� */
 
251
         stek=(pchar)(penalty+((CP+1)<<2)-(CP+1));  /* ��९��뢠�� �ࠣ����� ����� ��室� */
253
252
         cut_points=penalty+3*(CP-1)+1;
254
253
         for (j=CP; j>0; j--, cut_points-=4,stek++)
255
254
      {
256
 
       *stek=(CHAR)*cut_points++;
 
255
       *stek=(char)*cut_points++;
257
256
       if (*stek) (*stek)--;
258
257
       *++stek=dy-*cut_points;
259
258
       if (*stek) (*stek)--;
260
259
      }
261
 
   trace=(PCHAR)(penalty+((CP+1)<<2)-(CP+1));
 
260
   trace=(pchar)(penalty+((CP+1)<<2)-(CP+1));
262
261
 
263
262
   for(j=CP-1,i=0; j>=0; j--,i+=2)
264
263
    {
265
 
     ans_ptr->x   = (CHAR)*((PINT)adr_cut_points+j);
 
264
     ans_ptr->x   = (char)*((pint16_t)adr_cut_points+j);
266
265
     ans_ptr->h   = dy - *(trace+i);
267
266
     ans_ptr->dh  = dy+1 - *(trace+i+1)-*(trace+i);
268
 
     ans_ptr->dh  = (CHAR)MIN(ans_ptr->dh,dy);
 
267
     ans_ptr->dh  = (char)MIN(ans_ptr->dh,dy);
269
268
     ans_ptr->dh  = MIN(ans_ptr->dh,ans_ptr->h);
270
269
     if (ans_ptr->dh < tret_h)   ans_ptr->var=1;
271
270
     else                        ans_ptr->var=8;
284
283
 return CP;
285
284
}
286
285
 
287
 
void Alik_new_points(INT *CP,struct own_cut *a,struct own_cut *ptr,INT dy,
288
 
                     INT dx,PINT pen,PCHAR prod)
 
286
void Alik_new_points(int16_t *CP,struct own_cut *a,struct own_cut *ptr,int16_t dy,
 
287
                     int16_t dx,pint16_t pen,pchar prod)
289
288
{
290
 
INT i,j,count,min_pen,min_prod,real_x,Ix,IIx;
 
289
int16_t i,j,count,min_pen,min_prod,real_x,Ix,IIx;
291
290
 
292
291
 count = *CP;
293
292
 for(i=0; i<count; i++)
316
315
     if(real_x>MINCOL && real_x<dx-MINCOL)
317
316
      {
318
317
       ptr->x   = real_x+1;
319
 
       ptr->h   = (CHAR)dy;
320
 
       ptr->dh  = (CHAR)dy;
 
318
       ptr->h   = (char)dy;
 
319
       ptr->dh  = (char)dy;
321
320
       ptr->var = 40;
322
321
       ++ptr; (*CP)++;
323
322
      }
326
325
 ptr->x=127;
327
326
}
328
327
 
329
 
void Alik_cor_height_and_var(INT CP,struct own_cut *ans,PINT pen,INT dx,
330
 
                             INT dy)
 
328
void Alik_cor_height_and_var(int16_t CP,struct own_cut *ans,pint16_t pen,int16_t dx,
 
329
                             int16_t dy)
331
330
{
332
 
INT i,Count;
 
331
int16_t i,Count;
333
332
 
334
333
 Count=CP;
335
334
 for(i=0;i<Count;++i,++ans)
338
337
     (ans->x>1 && *(pen+ans->x-1)<0) ||
339
338
     (ans->x<dx-1 && *(pen+ans->x+1)<0))
340
339
     {
341
 
      ans->h   = (CHAR)dy;
342
 
      ans->dh  = (CHAR)dy;
 
340
      ans->h   = (char)dy;
 
341
      ans->dh  = (char)dy;
343
342
      ans->var = 40;
344
343
     }
345
344
  }
354
353
 return 0;
355
354
}
356
355
 
357
 
void Alik_set_method_for_cut_points(struct own_cut *ans,INT dy,INT dx,
358
 
                                    PBYTE CountCut)
 
356
void Alik_set_method_for_cut_points(struct own_cut *ans,int16_t dy,int16_t dx,
 
357
                                    puchar CountCut)
359
358
{
360
 
BYTE CountGrupElem,n,i,j,m,gde,flag4;
361
 
INT  min_dh;
 
359
uchar CountGrupElem,n,i,j,m,gde,flag4;
 
360
int16_t  min_dh;
362
361
struct own_cut oct[STK_H],*ptr;
363
362
 
364
363
 min_dh=dy;
381
380
   CountGrupElem=j-i+1;
382
381
   if(CountGrupElem<=3)
383
382
   {                                        // OLEG : case CountGrupElem==0 ????
384
 
     gde=Alik_gde_i_kak_naxodjatsa_tochki((BYTE)(CountGrupElem-1),&oct[i],dy,min_dh);
385
 
     for(m=i;m<=j;m++)  oct[m].var=(CHAR)GDE_KAK[gde][m-i];
 
383
     gde=Alik_gde_i_kak_naxodjatsa_tochki((uchar)(CountGrupElem-1),&oct[i],dy,min_dh);
 
384
     for(m=i;m<=j;m++)  oct[m].var=(char)GDE_KAK[gde][m-i];
386
385
    }
387
386
   else
388
387
    {
411
410
  }
412
411
}
413
412
 
414
 
BYTE Alik_gde_i_kak_naxodjatsa_tochki(BYTE CountGrupElem,struct own_cut *ans,
415
 
                                      INT height,INT min_dh)
 
413
uchar Alik_gde_i_kak_naxodjatsa_tochki(uchar CountGrupElem,struct own_cut *ans,
 
414
                                      int16_t height,int16_t min_dh)
416
415
{
417
 
BYTE i;
418
 
INT  max_h,h_h,tret_h,dve_tret_h,chetvert_h,two_min_dh,begin[3],end[3];
 
416
uchar i;
 
417
int16_t  max_h,h_h,tret_h,dve_tret_h,chetvert_h,two_min_dh,begin[3],end[3];
419
418
 
420
419
 h_h        = ((height+1)>>1);
421
420
 tret_h     = height/3 +1;
432
431
 
433
432
 switch(CountGrupElem)
434
433
  {
435
 
   /******************** ���� �窠*******************************/
 
434
   /******************** ���� �窠*******************************/
436
435
   /*        0       1         2                                 */
437
436
   /*    {1,0,0} ,{4,0,0} ,{8,0,0}                              */
438
437
   /**************************************************************/
439
 
   case 0: /* ���� �窠 */
 
438
   case 0: /* ���� �窠 */
440
439
        if(ans->dh < min_dh+3)     return 0;
441
440
        if(ans->dh <= two_min_dh)  return 1;
442
441
                                   return 2;
443
 
   /******************** ��� �窨 *******************************/
 
442
   /******************** ��� �窨 *******************************/
444
443
   /*        3         4          5                              */
445
444
   /*    {1,8,0} ,{8,1,0} ,{8,8,0}                           */
446
445
   /**************************************************************/
447
446
   case 1:
448
 
        /* ���� min */
 
447
        /* ���� min */
449
448
        if(ans->dh<min_dh+3 || (ans+1)->dh<min_dh+3 )
450
449
         {
451
450
          if(ans->dh<(min_dh+3) && ans->dh<(ans+1)->dh)  return 3;
452
451
          return 4;
453
452
         }
454
453
 
455
 
        /* ������� ��� ���⪨� ���������� */
 
454
        /* ������� ��� ���⪨� ���������� */
456
455
        if((ans->dh<=min_dh || (ans+1)->dh<=min_dh) &&
457
456
           end[0]<tret_h    &&  end[1]  <tret_h)
458
457
         {
460
459
          else                     return 4;
461
460
         }
462
461
 
463
 
        /* � �।��� ��� ���⪨� ���������� */
 
462
        /* � �।��� ��� ���⪨� ���������� */
464
463
        if((ans->dh<=min_dh  || (ans+1)->dh<=min_dh) &&
465
464
          begin[0]>=tret_h   && begin[1]>=tret_h    &&
466
465
          end[0]<=dve_tret_h && end[1]<=dve_tret_h)
469
468
            else                     return 4;
470
469
           }
471
470
 
472
 
        /* � �।��� ��� ������� */
 
471
        /* � �।��� ��� ������� */
473
472
        if(ans->dh>=tret_h      && (ans+1)->dh>=tret_h     &&
474
473
           begin[0]>=chetvert_h && begin[1]>=chetvert_h    &&
475
474
           ans->h  >=chetvert_h && (ans+1)->h>=chetvert_h)
476
475
        return 5;
477
476
 
478
 
        /*����� ��� ���⪨� ����������*/
 
477
        /*����� ��� ���⪨� ����������*/
479
478
        if(ans->h <= chetvert_h && (ans+1)->h <= chetvert_h)
480
479
         {
481
480
          if(ans->dh<(ans+1)->dh)  return 4;
487
486
 
488
487
        return 5;
489
488
 
490
 
   /******************** �� �窨 *******************************/
 
489
   /******************** �� �窨 *******************************/
491
490
   /*          6         7         8          9                  */
492
491
   /*   {1,8,8},{8,8,4},{8,1,8},{8,8,8}                 */
493
492
   /**************************************************************/
494
493
   case 2:
495
 
        /* ���� min */
 
494
        /* ���� min */
496
495
        if(ans->dh==min_dh || (ans+1)->dh==min_dh || (ans+2)->dh==min_dh)
497
496
         {
498
497
          if(ans->dh==min_dh)      return 6;
499
498
          if((ans+1)->dh==min_dh)  return 8;
500
499
          return 7;
501
500
         }
502
 
        /* ���� min+2 */
 
501
        /* ���� min+2 */
503
502
        if(ans->dh<min_dh+3 || (ans+1)->dh<min_dh+3 || (ans+2)->dh<min_dh+3)
504
503
         {
505
504
          if(ans->dh<min_dh+3)      return 10;
507
506
          return 12;
508
507
         }
509
508
 
510
 
        /*������� �� ���⪨� ����������*/
 
509
        /*������� �� ���⪨� ����������*/
511
510
        if(end[0]<=tret_h && end[1]<=tret_h && end[2]<=tret_h)
512
511
         {
513
512
           if(ans->h==min_dh && (ans+1)->h==min_dh && (ans+2)->h==min_dh)
518
517
           return 8;
519
518
         }
520
519
 
521
 
        /*� �।��� �� ���⪨� ���������� � ���ꥬ��*/
 
520
        /*� �।��� �� ���⪨� ���������� � ���ꥬ��*/
522
521
        if(ans->dh<chetvert_h && (ans+1)->dh<chetvert_h && (ans+2)->dh<chetvert_h &&
523
522
           begin[0]>=tret_h   && begin[1]>=tret_h       && begin[2]>=tret_h       &&
524
523
           end[0]<=dve_tret_h && end[1]<=dve_tret_h     && end[2]<=dve_tret_h     &&
525
524
           ans->h<(ans+1)->h  && (ans+1)->h < (ans+2)->h)
526
525
        return 9;
527
526
 
528
 
        /*� �।��� �� �������*/
 
527
        /*� �।��� �� �������*/
529
528
        if(ans->dh>=tret_h  && (ans+1)->dh>=tret_h &&  (ans+2)->dh>=tret_h &&
530
529
           begin[0]>=chetvert_h && begin[1]>=chetvert_h && begin[2]>=chetvert_h &&
531
530
           ans->h  >=chetvert_h && (ans+1)->h>=chetvert_h && (ans+2)->h>=chetvert_h)
532
531
        return 9;
533
532
 
534
 
        /*�� �ᥩ ���� �� �������*/
 
533
        /*�� �ᥩ ���� �� �������*/
535
534
        if(abs(ans->dh-height)<4 && abs((ans+1)->dh-height)<4 &&
536
535
           abs((ans+2)->dh-height)<4)
537
536
        return 8;
538
537
 
539
 
        /*����� �� ���⪨� ����������*/
 
538
        /*����� �� ���⪨� ����������*/
540
539
        if(ans->h<=chetvert_h && (ans+1)->h<=chetvert_h && (ans+2)->h<=chetvert_h)
541
540
         {
542
541
           max_h=MAX(MAX(ans->h,(ans+1)->h),MAX((ans+1)->h,(ans+2)->h));