~ubuntu-branches/debian/experimental/cuneiform/experimental

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/stic_frt.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
/*      STIC_FRT.C      28.01.1994      from STIC_DIS.C                 */
 
59
/*----------------------------------------------------------------------*/
 
60
#define mk_80_for_CUT   80
 
61
/*----------------------------------------------------------------------*/
 
62
 
 
63
#include "nt_types.h"
 
64
 
 
65
  #include <stdlib.h>
 
66
  #include <string.h>
 
67
 
 
68
  #include "func.h"
 
69
  #include "stick.h"
 
70
  #include "ligas.h"
 
71
  #include "tuner.h"
 
72
#include "minmax.h"
 
73
extern BYTE multy_language;
 
74
 
 
75
extern INT pitchsize ;
 
76
 
 
77
extern INT nIncline  ;
 
78
extern BYTE fax1x2;     // MK NEW 05.01.1993
 
79
extern int  inc_num_EEM;        // in ST_TOOLS.C
 
80
extern int  dis_LIMIT_EEM;      // in ST_TOOLS.C;
 
81
/*......................................................................*/
 
82
#ifdef  MKPRINT_ENABLE                          // MK OTLADKA Variables
 
83
extern WORD     mkm1, mkm2, mkm3, mkm4, mkm5;
 
84
extern WORD     mkma, mkmb, mkmc, mkmd;
 
85
///extern WORD  d,d0,d1,d2,d3,d4,d5,d6,d7,d8,d9;
 
86
#endif
 
87
/*......................................................................*/
 
88
extern  WORD    left_mode_EEM;  // NOTA BENE:  NEPORJADOK; see ST_TOOLS, CHA;
 
89
/*......................................................................*/
 
90
#define MIN_ADD_DIS  10         /* max discrim for adding '(',')','!'   */
 
91
#define MAX_ADD_DIS  30         /* max discrim for adding '�','1'       */
 
92
/*----------------------------------------------------------------------*/
 
93
#include "stic-mac.h"
 
94
#include "stic-frt.h"
 
95
/*----------------------------------------------------------------------*/
 
96
INT     dis_f (STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s);
 
97
INT     dis_r (STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s);
 
98
INT     dis_t (STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s, INT sign_f);
 
99
 
 
100
INT     find_beam (STICK_CHARS *l, STICK_CHARS *r,INT lim_long);
 
101
INT     find_neck (STICK_CHARS *l, STICK_CHARS *r,INT lim_long);
 
102
/*----------------------------------------------------------------------*/
 
103
 
 
104
/* ���������������������������������������������������������������� */
 
105
/* ���                                                          ��� */
 
106
/* ���          functions for wide sticks                       ��� */
 
107
/* ���                                                          ��� */
 
108
/* ���������������������������������������������������������������� */
 
109
 
 
110
INT     dis_f (STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s)
 
111
{
 
112
INT     i, dis=0, t, lm, rm, dy=s->height;
 
113
INT     lf=l->num_flags, lc=l->num_concs, rf=r->num_flags;
 
114
INT     wid=s->stick_width, inc=s->inc;
 
115
BYTE    Flag_bad_overlay=0;     // MK
 
116
 
 
117
if ( s->l_f_symptom>1 && s->r_f_symptom>1 )  return(0); /* good symptoms */
 
118
 
 
119
if ( lf==0 && lc==0 )
 
120
        dis += tab_f[11];       /* similar 'F' */                       // 70
 
121
else    /* exist left concaves or flags     */
 
122
{
 
123
t=find_beam(l,r,2);             /* long beam */
 
124
if( t<0 )
 
125
        t=find_beam(l,r,1);     /* short beam */
 
126
if( t<0 )  {
 
127
        t=find_beam(l,r,0);
 
128
        if( t<0 )
 
129
                dis += tab_f[0];        /* no beam : true stick */      // 40
 
130
        else  {
 
131
            lm = l->mount[t];  rm = r->mount[t];
 
132
            if( t==0 && s->r_f_symptom==0 && s->l_f_symptom<2 ||
 
133
                t>0 )  {
 
134
                if( t==0 && lm>0 && rm>0 )
 
135
                        dis += tab_f[0];        // beam belong 0-zone   // 40
 
136
                if( lm+rm>1 )  {        /* first flag>1 , second flag=0 */
 
137
                        dis += t ? tab_f[1] : 0 ;                       // 20,0
 
138
                        if( t==0 && r->mb_pos[0]<2 &&
 
139
                            lf==0 && rf==2 && (r->mount[3] || r->mount[4]) )
 
140
                                dis += tab_f[13]; /* similar '[' */     // 100
 
141
                        if( rf==2 && lf==0 && r->mount[4] )
 
142
                                dis += tab_f[10]; /* right half 't' */  // 60
 
143
                        }
 
144
                else    {
 
145
                        if (lm+rm==1 )  /* first flag=1, second flag=0 */
 
146
                                dis += wid<4 ? tab_f[2]>>1 : tab_f[2];  // 10,20
 
147
                        else            /* no flags */
 
148
                                dis += (lm+rm)?tab_f[2]:tab_f[2]<<2;   //40,160
 
149
                        }
 
150
                if( lm==0 && rm && r->mb_pos[0]<2 && r->mount[4]>0 &&
 
151
                    r->mount[3]==0 && r->mount[2]==0 && r->mount[1]==0 )
 
152
//////                  dis += r->up_hook?tab_f[0]<<2:tab_f[0];       //160,40
 
153
                        if (!fax1x2)            // OLD OLEG
 
154
                            dis += r->up_hook?tab_f[0]<<2:tab_f[0];   //160,40
 
155
                        else                    // NEW MK PROBA
 
156
                            dis += tab_f[0];    // 160 (4*40) ==> 40    // 40
 
157
                        /* true stick + upper dust */
 
158
                }
 
159
 
 
160
 
 
161
             }
 
162
        }
 
163
/*......................................................................*/
 
164
else    {       /* normal beam */
 
165
        lm = l->mount[t];  rm = r->mount[t];
 
166
        if( l->mb_pos[t]>r->me_pos[t]+1 ||
 
167
            r->mb_pos[t]>l->me_pos[t]+1 )   /* bad overlay beam-flags */
 
168
                { dis += tab_f[12];  Flag_bad_overlay++; }      // MK   // 80
 
169
        if( lm + rm==2 )
 
170
                {       /* first flag=1, second flag=1 */
 
171
                if( wid>4 )
 
172
                        dis += tab_f[3];                                // 8
 
173
                                /* short beam and wide stick */
 
174
                dis+=((l->m_meandr>1)+(r->m_meandr>2))*
 
175
                      (inc?tab_f[4]:tab_f[5]);                          // 2,4
 
176
                /* meandr and short beam . By inc this DIS decreased */
 
177
                }
 
178
        }
 
179
/*......................................................................*/
 
180
if( t>0 )     /* normal beam ; for zones 1,2,3,4 */
 
181
        {
 
182
        for( lm=rm=i=0;i<t;i++)  {      /* 0,...,t-1 zones */
 
183
                if( lm<l->mount[i] )  lm = l->mount[i];
 
184
                if( rm<r->mount[i] )  rm = r->mount[i];
 
185
                }
 
186
 
 
187
        if( lm==1 && l->mount[t]==1  )  /* left upper short flags */
 
188
                dis += tab_f[6];                                        // 10
 
189
        else if( lm>1 && lm>=l->mount[t] )  /* greater left top flags */
 
190
                dis += tab_f[7];                                        // 40
 
191
 
 
192
        if( rm==0 && l->conc[0]==0 )    /* no right upper flags */
 
193
                dis += tab_f[8];                                        // 40
 
194
        else if( rm==1 && wid<6 && rm*3<r->mount[t] )
 
195
                dis += tab_f[9];        /* short right upper flags */   // 4
 
196
 
 
197
        if ( r->down_hook && r->mount[4] &&     // OLD
 
198
             rm > r->mount[0] )         // 27.07.1993 for good 'f'
 
199
                dis += tab_f[10];       /* similar 't' */               // 60
 
200
 
 
201
                        // 20.01.1993: fax25/16 r.m[2]=r.m[4]=1; ?????
 
202
//////  if( l->mount[4]==0 & r->mount[4]>r->mount[t]-1 )        // OLD OLEG
 
203
        if( l->mount[4]==0 &&
 
204
            r->mount[4] > MAX (r->mount[t], 2) - 1 )            // 20.01.1993
 
205
                dis += r->mount[0]<r->mount[t] ? tab_f[10]<<1 : tab_f[10];
 
206
                /* similar 't' : right downer long flag */            //120,60
 
207
 
 
208
        if( s->base_2!=-1 )     /* base lines known */
 
209
                {
 
210
                INT h_beam = (l->m_pos[t]+r->m_pos[t])>>1;
 
211
                if (Flag_bad_overlay)   {               // MK 14/20.01.1992
 
212
//////              h_beam = (lm>rm)  ?  l->m_pos[t]  :  r->m_pos[t]; ######
 
213
                    if (l->mount[t] > r->mount[t])      h_beam = l->m_pos[t];
 
214
                    else if (l->mount[t] < r->mount[t]) h_beam = r->m_pos[t];
 
215
                    else h_beam = MIN (l->m_pos[t], r->m_pos[t]);
 
216
                    }
 
217
                if ((l->down_serif + r->down_serif) < 4)  // DL==DR==2 ???
 
218
                    {                                   // OLD OLEG VARIANT:
 
219
                    if (s->base_2 > MAX(dy/6,3) &&
 
220
                        h_beam > s->base_2+wid )
 
221
                            dis += tab_f[14];                   // 100 => 60
 
222
                    }
 
223
                else                                    // NEW MK VARIANT:
 
224
                    if (s->base_2 > MAX(dy/6,3) &&
 
225
//////                  h_beam > MAX((h_beam>s->base_2+wid),    // OLEG ######
 
226
                        h_beam > MAX((s->base_2+wid),           // OLEG
 
227
                                     (dy/2)))                   // MISA
 
228
                            dis += tab_f[14];                   // 100 => 60
 
229
                }
 
230
        }
 
231
else
 
232
        {       /* beam belong 0-zone */
 
233
        if( l->mount[0] && l->mb_pos[0]==0 &&
 
234
            r->mount[0] && r->mb_pos[0]==0  )
 
235
                dis +=  tab_f[11];
 
236
        }
 
237
}
 
238
 
 
239
if( ( r->down_hook || r->mount[4]>2 ) && l->mount[0]>1 )
 
240
                dis += tab_f[10]; /* similar    'l' */
 
241
 
 
242
                        // 22.01.1993   DISPROPORTION: GLISTA 1-3-1 zB
 
243
                        // 'l' 32*5(1-3-1) stdj7/27(34) "Parallel" (last 'l')
 
244
                        // 'E' ...*12(1-10-1)
 
245
                        // 'f' 26*5(1-3-1) stdj8/16(18) ......
 
246
        if ((!l->num_long_flags && !r->num_long_flags) &&
 
247
            ( (dy>26 || s->width>=10) ||
 
248
              (dy>16 && ((!l->num_flags) || (!r->num_flags)) ) ))
 
249
                dis += tab_f[15];                               // 80 (BP)
 
250
 
 
251
//////  if ( l->up_serif == 2 )                         // 17.02.1993 PROBA
 
252
//////          dis += 222;                             // 222
 
253
 
 
254
/*......................................................................*/
 
255
 
 
256
if( s->l_f_symptom>0 && s->r_f_symptom>1 )
 
257
        dis = (dis * plus_f[1])>>4 ;
 
258
        /* decrease DIS if good right symptom and delicate left symptom */
 
259
 
 
260
{                               // 11.03.1993 SOPLI about {f'}; NE NA MESTE !!!
 
261
INT     l12 = MAX (l->mount[1],l->mount[2]);
 
262
INT     r12 = MAX (r->mount[1],r->mount[2]);
 
263
        if ( r->mount[0] >              // fax23/14(16) "Cardiff's"
 
264
//////       MAX (l12,l->mount[4]) + wid + MAX (r12,r->mount[4]) )      // a)
 
265
             MAX (l12,l->mount[4]) + wid + MAX (r12,r->mount[4]) + 4)   // b)
 
266
                dis += 222;                                             // 222
 
267
}
 
268
 
 
269
                                        // 15.10.1993 similar 'F'
 
270
        if (wid>4  &&  l->conc[0]<2  && // k11/14 "OF"  21*12 wid=5
 
271
            (r->mount[0]>4 ? 1 : 0) +   // 18.10.1993 fax4/9 "modified"
 
272
            (r->mount[1]>4 ? 1 : 0) +
 
273
            (r->mount[2]>4 ? 1 : 0) == 2  &&
 
274
            l->mount[1]<3  && l->mount[2]<3)  // 20.10.1993 fax18/20(25) manuf
 
275
                dis += 40;                                              // 40
 
276
 
 
277
        if (s->cut_r  &&                // 21.10.1993 for similar 'D' (CUT)
 
278
            r->mount[0]==r->mount[4]  &&
 
279
            MAX(r->mount[1],r->mount[2])*3 < r->mount[0])
 
280
                dis += mk_80_for_CUT;                                   // 80
 
281
 
 
282
        if (s->cut_r  &&                // 18.11.1993 for similar 'E' (CUT)
 
283
            r->mount[4]>5)              // j8/13(14); really "B/" (CUT)
 
284
                dis += mk_80_for_CUT;                                   // 80
 
285
 
 
286
return (dis);           // dis_f
 
287
}
 
288
/*----------------------------------------------------------------------*/
 
289
INT     dis_r (STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s)  {
 
290
                                                        // 27.01.1994
 
291
INT     nl=l->num_long_flags, nr=r->num_long_flags;
 
292
INT     wid=s->stick_width, inc=s->inc;
 
293
INT     dis=0, wid_2=wid>>1, dy=s->height;      // t
 
294
INT     lmu, rmu;       // 26.01.1994 (OLD lm, rm);
 
295
INT     lmd, rmd;       // 25.01.1994
 
296
 
 
297
//////printf (" r(%d,%d) ", r->mount[0], r->mount[4]);
 
298
 
 
299
lmu = MAX(l->mount[0],l->mount[1]);     // "UPPER ZONE: 0 or 1
 
300
rmu = MAX(r->mount[0],r->mount[1]);
 
301
 
 
302
lmd = l->mount [4];     rmd = r->mount [4];     // 25.01.1994, DOWN ZONE;
 
303
 
 
304
if( lmu>=1 && rmu>=1 )  {
 
305
//////  if( lm*3>rm*4 && lm>3 )                 // OLD OLEG
 
306
//////          dis += (lm-rm)/2*tab_r[0];      // l.flag > r.flag      // *8
 
307
 
 
308
        if ( lmu>=3)  {                         // 24.03.1993 MK PROBA
 
309
            if (!inc)  {
 
310
                if ( lmu >= rmu - (lmu>=wid) )  // NO INC:  NEW
 
311
                    dis += tab_r[16];           // l.flag > r.flag      // 80
 
312
                }
 
313
            else if ( lmu>3 && lmu>rmu )        // IF INC:  MODIFY
 
314
                dis += (lmu-rmu)*tab_r[0];      // l.flag > r.flag      // *20
 
315
            }                                   // 25.10.1993 (OLD *8)
 
316
 
 
317
        if ( rmu==1 && r->mount[0]==r->mount[1] )
 
318
                dis += tab_r[11];                                       // 10
 
319
 
 
320
        if (lmu==2  &&  rmu==1)                 // 25.10.1993
 
321
                dis += tab_r[17];       // too short upper flags        // 40
 
322
 
 
323
        if( rmu==1 && lmu==1 && l->m_meandr>1 &&
 
324
            (r->m_meandr>1||r->mount[3]||r->mount[4]) )
 
325
                dis += tab_r[12];       /* too short upper flags */     // 40
 
326
 
 
327
//////  if( (lmu<3||!inc) && lmu>1 && lmu==rmu && nr==1 && nl==1 )
 
328
                                // 17.01.1994   PROBA CORRECT for SMALL 'r':
 
329
        if ((!inc  ||  lmu<3 && (inc_num_EEM!=1 || dy>16))  &&
 
330
            lmu>1 && lmu==rmu && nr==1 && nl==1)        // OLD OLEG CONDITIONS
 
331
                dis += tab_r[13];       /* simmetrial upper zone */     // 100
 
332
        }
 
333
else
 
334
        {
 
335
        if( rmu==1 )
 
336
                dis += r->m_meandr?tab_r[1]<<4 :tab_r[1] ;              //32,2
 
337
                /* too little right upper flags */
 
338
        if( rmu==0 )
 
339
                dis += tab_r[2] ; /* no right upper flags */            // 70
 
340
        }
 
341
 
 
342
        if(l->mount[2]>wid_2 )dis += tab_r[3];  // left center flag     // 10
 
343
//////  if( r->mount[2]>wid_2 )dis += tab_r[4]; // right center flag    // 10
 
344
                                                // 07.01.1994:
 
345
        if (r->mount[2]>wid_2)                  // right center flag
 
346
//////          dis += (r->mount[2]<wid) ? 10 : 100;            // 10/100
 
347
//////          dis += (r->mount[2]<=wid) ? 10 : 100;           // 10/100
 
348
                dis += (r->mount[2]<=wid) ? 10 : 80;            // 10/80
 
349
 
 
350
dis += ((nr>2)+(nl>2))*tab_r[5];        // too many left or right flags // *6
 
351
 
 
352
/****************************** 21.01.1994      MK_PROBA_DELETE (2 Places)
 
353
//////if (r->down_serif && l->down_serif==0 ||
 
354
if ((r->down_serif || r->mount[4]>2) && l->down_serif==0 ||     // 07.01.1994
 
355
    l->down_serif && r->down_serif==0 )  {
 
356
        if( abs(r->mount[4]-l->mount[4])>wid_2+1 )
 
357
                dis += tab_r[6] ;       // too different down flags     // 4
 
358
//////  if( l->mount[4]==0 && r->mount[4]>1 )
 
359
        if (l->mount[4]==0 && r->mount[4] > (inc ? 2 : 1))  {   // 20.11.1993
 
360
static  BYTE    OTL_similar_t=0;
 
361
                dis += tab_r[10];                                       // 20
 
362
//////          if (r->mount[4]>wid)            // 07.01.1994 similar 't'
 
363
                if (r->mount[4]>wid &&          // 07.01.1994 similar 't'
 
364
                    OTL_similar_t==1)           // 17.01.1994 FOR DEBUG;
 
365
                        dis += 30;                                      // 30
 
366
                }
 
367
//////  DIS_CURVE(l,r,4,1,tab_r[7]);                                    // 10
 
368
        DIS_CURVE_MK(l,r,4,1,tab_r[7]);         // 27.07.1993           // 10
 
369
        }
 
370
*****************************************************************************/
 
371
 
 
372
if( r->mount[0]==0 && r->mount[1] >0 && r->mb_pos[1]>dy/6 )
 
373
        dis += tab_r[8]; /* for bad catting parts */                    // 60
 
374
 
 
375
//////if (lm+rm<2 && wid>3)     // OLD OLEG
 
376
/////  || (wid>8 && rm<2) )     // and NEW MK 10.05.1993: first PROBA (||);
 
377
if (wid>3 && rmu<2)             // MK 11.05.1993
 
378
        dis += tab_r[9];        /* too small beam */                    // 80
 
379
 
 
380
/****************************** 21.01.1994      MK_PROBA_DELETE (2 Places)
 
381
t=r->mount[4];
 
382
//////if( t>rm && l->mount[4]<2 )               // before 24.03.1993
 
383
//////  dis += tab_r[10]*(t-rm);        // too long right downer flag   // *20
 
384
//////if( t>=rm && l->mount[4]<2 )              //   from 24.03.1993
 
385
if( t>=rmu && l->mount[4]<2 && l->mount[3]<2)   //   from 09.01.1994
 
386
        dis += tab_r[10]*(t-rmu+2);     // too long right downer flag   // *20
 
387
                        // NOTA BENE: DOUBLE ABOVE  "too different down flags"
 
388
                        //                      and "similar 't'" (SEE!!!);
 
389
***************************************************************************/
 
390
 
 
391
//////if( abs( lmu-l->mount[4])<2 && abs(rmu-r->mount[4])<2 && lmu>1 && rmu>1 )
 
392
if (abs(lmu-lmd)<2 && abs(rmu-rmd)<2 && lmu>1 && rmu>1 &&       // MK EDITION
 
393
    (rmu+rmd) - (lmu+lmd) < 4)  // 27.01.1994 MK ADD CONDITION;
 
394
        dis += tab_r[14];       // similar 'I'                          // 50
 
395
/*......................................................................*/
 
396
                                                // 27.01.1994
 
397
                                                // 26.01.1994
 
398
                                                // 25.01.1994   NEW CHARGES:
 
399
                                                // (see DIFFS 21.01.1994)
 
400
 
 
401
if (rmd>3)  {                   // RIGTH DOWN   // 25/26.01.1994
 
402
        if (lmd<2)              // zB 1/3
 
403
                dis += 50;                                              // 50
 
404
//////  if (rmu<=rmd)           // 25/26.01.1994
 
405
        if (rmu+lmd<=rmd)       // 27.01.1994
 
406
                dis += 100;     // really 't'                           // 100
 
407
        }
 
408
 
 
409
if (rmd==3)  {                  // RIGTH DOWN   // 26.01.1994
 
410
        if (lmd==0 ||           // 0/3
 
411
            lmd==1 && wid<4)    // 1/3, NOT BIG WID
 
412
                dis += 50;                                              // 50
 
413
        if (rmu<=rmd)           // really 't';
 
414
                dis += 100;                                             // 100
 
415
        }
 
416
 
 
417
if (rmd<3 && rmu<=rmd &&        // 26.01.1994 for GLUE 'u' (zB)
 
418
    lmu==0 && lmd==0)           // fax26/14 "solutions"
 
419
        dis += (rmd==1) ? 10:   // RMD=1        m.b. more ???           // 10
 
420
                          30;   // RMD=2        m.b. other ???          // 30
 
421
 
 
422
if (wid>=3)  {                  // 26.01.1994 for GLUE 'm' (zB)
 
423
        if (rmu<2)              // m16/3 "comforting" (see both 'o', 'm')
 
424
                dis += 30;      // for def Laterne ???                  // 30
 
425
        /*......*/
 
426
        }
 
427
 
 
428
if (dy>=16)  {                  // 26.01.1994 for GLUE
 
429
        if (rmu<2)              // m16/3 "comforting" (see 'n')
 
430
                dis += 100;     // for def Laterne ???                  // 100
 
431
        /*......*/
 
432
        }
 
433
 
 
434
//////if (lmd>=3 && rmd<=1)     // 26.01.1994   k19/5 "traditional" (4/2)
 
435
if (lmd>=3 && rmd==0)           // 27.01.1994   k19/5 "traditional" (4/2)
 
436
        dis += 60;              // as OLD for GLUE "r.";                // 60
 
437
 
 
438
if (s->t_TOP)                   // t^
 
439
//////  dis += 50;              // 25.01.1994                           // 50
 
440
        dis += 20;              // 25.01.1994                           // 20
 
441
 
 
442
if (rmu>=wid*4  &&              // 'c' cutted or not glued
 
443
    wid<3)                      // 27.01.1994 m25/16(22) "prepare" ('r' 3/12)
 
444
        dis += 50;                                                      // 50
 
445
 
 
446
return (dis);           // dis_r
 
447
}
 
448
/*----------------------------------------------------------------------*/
 
449
/*      sign_f = 1 - 'f' belong list of versions */
 
450
INT     dis_t (STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s, INT sign_f)
 
451
{                                                       // 10.01.1994
 
452
INT i, dis=0, t, lm, rm, dy=s->height, dx=s->width, t2;
 
453
INT     nl=l->num_long_flags, nr=r->num_long_flags;
 
454
INT     sl=l->num_flags, sr=r->num_flags;
 
455
INT     wid=s->stick_width, inc=s->inc;
 
456
INT     tpos;   // 18.11.1993 (old - use the same {t}, how for zone)
 
457
 
 
458
t = find_beam (l, r, 1);
 
459
/*......................................................................*/
 
460
if( t<0 )  {                                            // BAD BEAM:
 
461
        t=find_beam(l,r,0);
 
462
//////  lm = l->mount[t];       // ###### but if t<0 - ?????? QWERTY ######
 
463
//////  rm = r->mount[t];       // 23.03.1993 make it more akkuratno !!!
 
464
        if( t<0 )  {
 
465
                dis += tab_t[0];  /* no flag long >=1  */               // 40
 
466
                lm = rm = 0;    // MK 23.03.1993 about SHURIK g20/51 s->r ERR
 
467
                }
 
468
            else  { lm = l->mount[t];  rm = r->mount[t]; }      // 23.03.1993
 
469
 
 
470
        if( lm+rm>1 )  {        /* first flag>=2, second flag=0 */
 
471
//////          dis += lm ? lm*tab_t[1] : tab_t[1];                   // *20,20
 
472
                /************************************************************
 
473
                dis += lm ? lm*tab_t[1] :               // 18.10.1993:  // *20
 
474
                            ((s->cut_l || s->cut_r) ? tab_t[32] :       // 60
 
475
                                                tab_t[1]);              // 20
 
476
                                                *****************************/
 
477
                                        // 19.10.1993 after FARA-078:
 
478
                if (lm) dis += lm*tab_t[1];                     // *20
 
479
                else
 
480
                  if ((s->cut_l || s->cut_r) && rm<3 && // 19.10.1993
 
481
                      rm>r->mount[4])                   // 20.10.1993
 
482
//////                  dis += tab_t[32];       // 19.10.1993   // 60
 
483
//////                  dis += tab_t[32];       // 20.10.1993   // 44
 
484
                                // 20.11.1993 fax8/19(21) "using" 'n' => "tl"
 
485
                        dis += (wid>=5 ? 88 : 44);              // 88/44
 
486
                else    dis += tab_t[1];                        // 20
 
487
 
 
488
                if( t==0 && r->mb_pos[0]<2 &&
 
489
//////              !(s->base_2!=-1 && abs(r->m_pos[0]-s->base_2)<2 ) &&
 
490
                    !(s->base_2!=-1 &&                  // 18.11.1993
 
491
                      abs(r->m_pos[0]-s->base_2) < (fax1x2 ? 3 : 2 )) &&
 
492
                    !(r->m_pos[0]>dy/6&&r->me_pos[0]>dy/3) )
 
493
                        dis += tab_t[24];                               //100
 
494
                                //long right flag belong 0-zone
 
495
                                          /* MANY KNOTs !!! */
 
496
                }
 
497
        else    {               /* first flag=1, second flag=0  */
 
498
                if( rm )
 
499
                        dis += wid>2 ? tab_t[2] : tab_t[20] ;        // 50,4
 
500
                else
 
501
                        dis += tab_t[17];                             // 120
 
502
                if( wid<3 )  {
 
503
                        if( t==2 && r->mount[3] )
 
504
                                dis += tab_t[20];                       // 4
 
505
                        if( r->m_meandr>2 ||
 
506
                            r->m_meandr==2 && r->mount[4]==0 )
 
507
                                dis += tab_t[25];                       // 40
 
508
                        }
 
509
                if( rm && lm==0 && t>0 && l->mount[0] )
 
510
                        dis += tab_t[2];                                // 50
 
511
                }
 
512
        }
 
513
/*......................................................................*/
 
514
else    {                                               // NORMAL BEAM:
 
515
        lm = l->mount[t];   rm = r->mount[t];
 
516
 
 
517
                                // MK PROBA 03.02.1993 about 'r'=>'t'
 
518
        if ((t==0) && (wid>=4) && (lm<=1) && (rm>=4) &&
 
519
            (r->mount[4]<5))    // 07.01.1994 EDITION
 
520
//////          dis += 122;     // MK PROBA 03.02.1993          // ###########
 
521
                dis += 22;      // MK PROBA 04.02.1993                  // 22
 
522
 
 
523
if (!fax1x2)    {                               // OTLADKA 20.01.1993
 
524
        if ( (l->me_pos[t] - l->mb_pos[t]) > dx &&      // OLD ###########
 
525
             (r->me_pos[t] - r->mb_pos[t]) > dx )
 
526
                dis += tab_t[21]; /* bad overlay beam-flags */        // 100
 
527
        }
 
528
if (fax1x2)     {                               // OTLADKA 20.01.1993
 
529
        if ( ((l->mb_pos[t] - r->me_pos[t]) > 1) ||     // NEW PROBA
 
530
             ((r->mb_pos[t] - l->me_pos[t]) > 1) )
 
531
                dis += tab_t[21]; /* bad overlay beam-flags */        // 100
 
532
        }
 
533
 
 
534
/* N.B. in TC-interface base lines are not known */
 
535
  if( s->base_2!=-1 )  {  /* base lines known */
 
536
    t2=2;
 
537
if( multy_language ) t2=4;
 
538
            if (s->base_2>MAX(s->height/6,3) &&
 
539
    (MAX(l->m_pos[t],r->m_pos[t]) < s->base_2-t2 ||
 
540
//////           MIN(l->m_pos[t],r->m_pos[t]) > s->base_2+4))   // 18.10.1993
 
541
//////           MAX(l->m_pos[t],r->m_pos[t]) > s->base_2+4))   // 18.10.1993
 
542
                 MAX(l->mb_pos[t],r->mb_pos[t]) > s->base_2+4)) // 19.10.1993
 
543
                        dis += tab_t[18];                             // 100
 
544
            else if (inc_num_EEM>=2  &&         // 18.11.1993 similar '7'
 
545
                     t==0  &&                   // j10/29 "08/77" first '7'
 
546
                     l->mb_pos[0] <= 1 &&
 
547
                     l->me_pos[0] + 2 <= r->me_pos[0]  &&
 
548
                     l->me_pos[0] + 2 <= s->base_2)
 
549
                        dis += tab_t[18];                             // 100
 
550
            }
 
551
 
 
552
        if( lm+rm>3 )   /* flags : 1,2  2,1 2,2  ... */
 
553
                {       /* long flags */
 
554
                INT im,ma;
 
555
                if( lm*3>rm*4 && lm>3 )
 
556
                        dis += tab_t[3];  /* left>right */              // 4
 
557
 
 
558
                for(i=0;i<3;i++)  {
 
559
                        if( i==t )continue;
 
560
                        if( l->mount[i]>=l->mount[t]) break;
 
561
                        }
 
562
 
 
563
                                        // 26.08.1993   INCREASE for "ft"
 
564
                if (i==0  &&  nl==2  &&  nr==2  &&
 
565
                    t>0  &&  s->cut_l  &&
 
566
                    (!inc && l->mount[0]==lm || inc && l->mount[0]>lm)  &&
 
567
//////              rm>wid  &&  r->mount[4]>=wid)       // first variant
 
568
                    rm>=3  &&  r->mount[4]>=3)          // second variant
 
569
                        return (-444);  // NOTA BENE:  INCREASE !!!!!!!!!!
 
570
                        /************************************************/
 
571
 
 
572
                if ( i<3 )  {  /* exist left top long flag  */
 
573
                        if ( l->mount[t]>1 )
 
574
                                dis += tab_t[4];                        // 30
 
575
                        else if( !inc )
 
576
                                dis += tab_t[4]>>2;                     // 7
 
577
                        }
 
578
                        /* exist big flag and beam */
 
579
 
 
580
                for (im=ma=-1,i=0;i<3;i++)  {
 
581
                        if( i==t )continue;
 
582
                        if( r->mount[i]>=r->mount[t]) break;
 
583
                        if( r->mount[i]>ma)
 
584
                                ma = r->mount[(im=i)];
 
585
                        }
 
586
 
 
587
                if( i<3 )  {  /* exist long right upper flag */
 
588
                        dis += ( r->me_pos[i]-r->mb_pos[i])*tab_t[14]; // *15
 
589
                        }
 
590
 
 
591
                if( s->width>4 && im==0 && ma>=r->mount[t]-1 &&
 
592
                    !(ma==1&&inc) )
 
593
                        dis += tab_t[23];                               // 20
 
594
                }
 
595
 
 
596
        else if( lm + rm==2 )   {
 
597
                for(i=0;i<3;i++)  {
 
598
                        if( i==t )continue;
 
599
                        if( l->mount[i]>1) break;
 
600
                        if( r->mount[i]>2) break;
 
601
                        }
 
602
                if( i<3 )
 
603
                        dis += tab_t[4];                                // 30
 
604
                        /* exist big flag and beam */
 
605
                if( wid>4 )
 
606
                        dis += tab_t[5]; // short beam and wide stick   // 2
 
607
                if( s->width>2 && !(l->mount[3]==1&&l->conc[4]) )
 
608
                        dis+=((sl>1)+(sr>2))*
 
609
                             (inc ? tab_t[6] :                          // *2
 
610
                                    (s->width<4?tab_t[26]:tab_t[7])); //*20,40
 
611
                else if( sl>1 || sr>2  )
 
612
                        dis += tab_t[20];                               // 4
 
613
                /* meandr and narrow beam */
 
614
                if( inc && wid<5 &&
 
615
                    (l->me_pos[t]<=r->mb_pos[t]||r->me_pos[t]<=l->mb_pos[t]))
 
616
                        dis += tab_t[22];                               // 40
 
617
                }
 
618
        }       // IF ELSE: NORMAL BEEM;
 
619
/*......................................................................*/
 
620
        dis += ((nr>3)+(nl>1))*tab_t[8];                               // *24
 
621
        /* too many left or right flags */
 
622
        if( l->mount[4]>1 && !inc || l->mount[4]>2 && inc )
 
623
                dis += tab_t[10] ;  /* left downer flag */              // 40
 
624
if( t<2 )
 
625
        DIS_CENTER_FLAGS(l,r,2,wid,inc,tab_t[11],tab_t[12]);         //40,4
 
626
 
 
627
if( t>0 && t<3 && dx<<2 < dy*3 )
 
628
        {  /* KNOT : find big flags of beam - part bold 'H' */
 
629
        if( l->num_flags==1 && l->me_pos[t]-l->mb_pos[t]+1>dy/3 &&
 
630
            s->cut_l   ||
 
631
            r->num_flags==1 && r->me_pos[t]-r->mb_pos[t]+1>dy/3 &&
 
632
            s->cut_r   )
 
633
                dis += tab_t[28];                                       // 40
 
634
        }
 
635
 
 
636
if( l->up_serif==2 && l->down_serif==2 &&
 
637
    r->up_serif==0 && r->down_serif==0 &&  t<2 )
 
638
        dis += tab_t[15];  /* similar    ],) */                         // 60
 
639
 
 
640
//////t = MAX( l->m_pos[t], r->m_pos[t])+1;
 
641
tpos = MAX( l->m_pos[t], r->m_pos[t])+1;        // 18.11.1993
 
642
if( tpos>dy>>1 )
 
643
        dis += tab_t[13]*(tpos-(dy>>1)); /* too low beam */          // *16
 
644
/* ----------------- FIND f-CONFIGURATIONS ------------------- */
 
645
 
 
646
//////if (tpos>(dy>>2) && r->mount[0]>2 && r->mount[1]>2 && l->conc[0]>0 )
 
647
if (t>0 &&              // 18.11.1993 PROBA for f10/15 "of"
 
648
    r->mount[0] > (wid>2 ? 2 : 1) &&
 
649
    l->conc[0]>0 )
 
650
        dis += tab_t[14];   /* head : similar to 'f' */                 // 14
 
651
                // NB: include THIN STICK, but EXCLUDE SOME OTHER CASES;
 
652
 
 
653
/**********************************
 
654
if( (s->l_f_symptom>0 && s->l_f_symptom<3 &&
 
655
     s->r_f_symptom==1 ||
 
656
     s->l_f_symptom==3 && s->r_f_symptom==2 ||
 
657
     sl==1 && s->r_f_symptom && (!inc || s->l_f_symptom) )
 
658
    && sign_f && r->down_hook==0 )
 
659
        dis += tab_t[16];       // similar 'f' ! MANY KNOTs             // 70
 
660
    **********************************************/
 
661
if ( s->r_f_symptom==2 )        // similar 'f'          // 10.02.1993
 
662
        if (r->up_serif==2)
 
663
                dis += tab_t[16];                                       // 70
 
664
        else if ( r->up_serif==1 && s->l_f_symptom )
 
665
                dis += tab_t[30];                                       // 16
 
666
        else    dis += tab_t[31];                                       // 8
 
667
 
 
668
if( s->l_f_symptom==2 && s->r_f_symptom==2 && sign_f &&
 
669
    r->mount[4]==0 )
 
670
        dis += tab_t[19];    /* similar 'f' */                          // 10
 
671
 
 
672
if (l->down_hook ||                     // 04/07.06.1993
 
673
////l->mount[4]>1)                      // 04.06.1993
 
674
    l->mount[4] >= 2 + inc + fax1x2)    // 07.06.1993
 
675
        dis += tab_t[16];               // similar 'f'                  // 70
 
676
        // NB: I can use SERIF==2, SERIF==1, !INC in combinations with L.M.4
 
677
 
 
678
/* ----------------- FIND l-CONFIGURATIONS ------------------- */
 
679
 
 
680
if( l->m_meandr==1 && l->num_flags==1 && l->mount[4] &&
 
681
    r->m_meandr==1 && r->num_flags==1 && r->mount[0] )
 
682
        dis += tab_t[27];   /* head : similar to 'f' */                 // 40
 
683
 
 
684
/*......................................................................*/
 
685
{                               // MK: TOO LONG HOOK: for "t." ==> 't'
 
686
///INT  n1, n2;                 // NB: tab_t[29]=80 (fax12/32 "document.")
 
687
///     n1 = MAX (wid, (lm+rm));
 
688
//////  n2 = (n1<4) ? (n1+4) : (n1*2);  // 4 - MK VOLUNTAR.     before 9.3.1993
 
689
///     n2 = (n1<4) ? (n1+4) : (n1*2)-2; // 4 - MK VOLUNTAR.    from 09.03.1993
 
690
//////  if (r->mount[4]>n2)  dis += tab_t [29]; // before 26.01.1993    // 80
 
691
//////  if (r->mount[4]>=n2) dis += tab_t [29]; // from 26.01.1993      // 80
 
692
        if ((r->mount[4]>=lm+wid+rm) &&         // 10.03.1993
 
693
//////      (r->mb_pos[4]+wid > dy))            // 10.03.1993 no big hook
 
694
            (r->m_pos[4]+wid+3 > dy))           // 11.03.1993 no big hook
 
695
                dis += tab_t [29];                                   //80=>100
 
696
                        // fax12/32     "document." 1-5-4 / 11
 
697
                        // fax41/72     "support."  2-5-4 / 12
 
698
                        // fax35/21(24) "format."   2-4-3 / 9
 
699
                        // b18/27       "this"      1-4-3 / 6
 
700
                        // d19/35(36)   "with"      2-3-2 / 7, BIG HOOK (-7)
 
701
}
 
702
/*......................................................................*/
 
703
        /********************************************************************
 
704
        if (s->neck==1)                 // 18.10.1993 for d7/2
 
705
                dis += 10;                                              // 10
 
706
        if (s->neck>=2)                 // 18.10.1993 for d7/2
 
707
                dis += 40;                                              // 40
 
708
                *************************************************************/
 
709
 
 
710
        if (s->neck>=2)                 // 20.10.1993
 
711
                dis += 20;                                              // 20
 
712
/*......................................................................*/
 
713
                                                // 10.01.1994   BONUS:
 
714
        if (dis==0      &&      // NO DISCRIM;
 
715
            s->t_TOP    &&      // t^
 
716
            l->mount[0] &&      // LMU EXIST;
 
717
            l->conc[4]  &&      // LDC EXIST;
 
718
            s->base_2mk>0  &&   // BASE_2 1 or 2;
 
719
            s->base_2mk<=2)
 
720
                dis = -32;      // BONUS !!!!!!!!!!!!
 
721
/*......................................................................*/
 
722
return(dis);
 
723
}
 
724
/*----------------------------------------------------------------------*/
 
725
/* ���������������������������������������������������������������� */
 
726
/* ���                                                          ��� */
 
727
/* ���          auxiliary functions                             ��� */
 
728
/* ���                                                          ��� */
 
729
/* ���������������������������������������������������������������� */
 
730
/*----------------------------------------------------------------------*/
 
731
/* find beam (lim_long - width of beam-flag) in stick */
 
732
INT     find_beam (STICK_CHARS *l, STICK_CHARS *r,INT lim_long)
 
733
{
 
734
INT i,num,maxim,m,rr,ll;
 
735
 
 
736
for(num=-1,maxim=m=i=0;i<3;i++)
 
737
        {
 
738
        rr=r->mount[i];
 
739
        ll=l->mount[i];
 
740
        m = ll + rr;
 
741
        if( rr>=lim_long && ll>=lim_long &&
 
742
            maxim<=m ) /* two flags>=lim_long, find last maximum */
 
743
                {
 
744
                maxim = m;
 
745
                num = i;
 
746
                }
 
747
        }
 
748
 
 
749
return( num );
 
750
}
 
751
/*----------------------------------------------------------------------*/
 
752
INT     find_neck(STICK_CHARS *l, STICK_CHARS *r,INT lim_long)
 
753
{
 
754
INT i,num,minim,m,rr,ll;
 
755
 
 
756
for(num=-1,minim=m=i=0;i<3;i++)
 
757
        {
 
758
        rr=r->conc[i];
 
759
        ll=l->conc[i];
 
760
        m = ll + rr;
 
761
        if( rr>=lim_long && ll>=lim_long &&
 
762
            minim>=m ) /* two flags>lim_long, find last minimum */
 
763
                {
 
764
                minim = m;
 
765
                num = i;
 
766
                }
 
767
        }
 
768
 
 
769
return( num );
 
770
}
 
771
/*----------------------------------------------------------------------*/
 
772
        // END of STIC_FRT.C
 
773
/*----------------------------------------------------------------------*/