| 1 |
/* |
| 2 |
Copyright (c) 1993-2008, Cognitive Technologies |
| 3 |
All rights reserved. |
| 4 |
|
| 5 |
Разрешается повторное распространение и использование как в виде исходного кода, |
| 6 |
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий: |
| 7 |
|
| 8 |
* При повторном распространении исходного кода должны оставаться указанное |
| 9 |
выше уведомление об авторском праве, этот список условий и последующий |
| 10 |
отказ от гарантий. |
| 11 |
* При повторном распространении двоичного кода в документации и/или в |
| 12 |
других материалах, поставляемых при распространении, должны сохраняться |
| 13 |
указанная выше информация об авторском праве, этот список условий и |
| 14 |
последующий отказ от гарантий. |
| 15 |
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут |
| 16 |
быть использованы в качестве средства поддержки и/или продвижения |
| 17 |
продуктов, основанных на этом ПО, без предварительного письменного |
| 18 |
разрешения. |
| 19 |
|
| 20 |
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК |
| 21 |
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ, |
| 22 |
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ |
| 23 |
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ |
| 24 |
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ |
| 25 |
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ |
| 26 |
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ |
| 27 |
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ, |
| 28 |
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ |
| 29 |
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ, |
| 30 |
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ |
| 31 |
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ. |
| 32 |
|
| 33 |
Redistribution and use in source and binary forms, with or without modification, |
| 34 |
are permitted provided that the following conditions are met: |
| 35 |
|
| 36 |
* Redistributions of source code must retain the above copyright notice, |
| 37 |
this list of conditions and the following disclaimer. |
| 38 |
* Redistributions in binary form must reproduce the above copyright notice, |
| 39 |
this list of conditions and the following disclaimer in the documentation |
| 40 |
and/or other materials provided with the distribution. |
| 41 |
* Neither the name of the Cognitive Technologies nor the names of its |
| 42 |
contributors may be used to endorse or promote products derived from this |
| 43 |
software without specific prior written permission. |
| 44 |
|
| 45 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 46 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 47 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 48 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 49 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 50 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 51 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 52 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 53 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 54 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 55 |
*/ |
| 56 |
|
| 57 |
/********** Заголовок **********/ |
| 58 |
/* Автор : Александр Михайлов */ |
| 59 |
/* Редакция : 30.11.99 */ |
| 60 |
/* Файл : 'VerifyLn.CPP' */ |
| 61 |
/* Содержание : Функции алгоритма верификации линий. */ |
| 62 |
/* Назначение : Верхний уровень алгоритмов верификации линий. */ |
| 63 |
/*----------------------------------------------------------------------------*/ |
| 64 |
#include <stdio.h> |
| 65 |
#include <math.h> |
| 66 |
/*#include <windows.h>*/ |
| 67 |
#include <stdlib.h> |
| 68 |
/* interface our-other */ |
| 69 |
#include "lnsdefs.h" |
| 70 |
#include "ctiimage.h" |
| 71 |
/* interface our-my */ |
| 72 |
/* interface my */ |
| 73 |
#include "am_err.h" |
| 74 |
#include "am_comm.h" |
| 75 |
#include "vl_rule.h" |
| 76 |
/* interface our util */ |
| 77 |
#include "skew1024.h" |
| 78 |
/*----------------------------------------------------------------------------*/ |
| 79 |
#define MaxZherOnLine 50 |
| 80 |
typedef struct tagAM_ZHERTVY |
| 81 |
{ |
| 82 |
int nZher; |
| 83 |
int iZher[MaxZherOnLine]; |
| 84 |
Point16 LinBeg[MaxZherOnLine]; |
| 85 |
Point16 LinEnd[MaxZherOnLine]; |
| 86 |
}AM_ZHERTVY; |
| 87 |
/*------------extern functions------------------------------------------------*/ |
| 88 |
Bool HaveLinePartAtReg (Point16 *pA, Point16 *pB, Rect16 *pRc, int32_t Skew |
| 89 |
, int NearHor, int NearVer); |
| 90 |
int InvestShortLineWithRastr_rv_pne (Handle hCPage, LineInfo *pLns); |
| 91 |
/*------------own functions---------------------------------------------------*/ |
| 92 |
void ChoiseQuasiLetters (Rect16 *pRc, int *pWhatDo, int nComp); |
| 93 |
void OldFormalVerification (LineInfo *pLns, int Lent); |
| 94 |
void FormalVerification (LineInfo *pLns, int Lent); |
| 95 |
void PutNewFlagOfLine (LineInfo *pLns, uint32_t Flag); |
| 96 |
void GetAllZhertvy (LineInfo *pLns, AM_ZHERTVY *pZher, Rect16 *pRc |
| 97 |
, int *pWhatDo, int nComp, int Near, Bool Hori); |
| 98 |
void MakeNormOrderForZher (LineInfo *pLns, AM_ZHERTVY *pZher); |
| 99 |
int FindNormParts (LineInfo *pLns, AM_ZHERTVY *pZher, Point16 *pBeg |
| 100 |
, Point16 *pEnd, int MinLent); |
| 101 |
void InvestLongLineWithBoxes (LineInfo *pLns, Rect16 *pRc, int *pWhatDo |
| 102 |
, int nComp, int *nZher, int *iZher, AM_ZHERTVY *pZher |
| 103 |
, int MaxZher, Bool Hori, int Lent); |
| 104 |
void WriteResForLines (void *vLti); |
| 105 |
void New_MarkVerifiedLines (void *vLti, Handle hCPage, Rect16 *pRc, int *pWhatDo |
| 106 |
, int nComp, int *nZher, int *iZher, int MaxZher, Bool AbleShortVert); |
| 107 |
/*----------------------------------------------------------------------------*/ |
| 108 |
void ChoiseQuasiLetters (Rect16 *pRc, int *pWhatDo, int nComp) |
| 109 |
{ |
| 110 |
int i, h, w; |
| 111 |
for (i=0; i<nComp; i++) |
| 112 |
{ |
| 113 |
h = pRc[i].bottom - pRc[i].top + 1; |
| 114 |
w = pRc[i].right - pRc[i].left + 1; |
| 115 |
pWhatDo[i] = FALSE; |
| 116 |
if ((pRc[i].top<10)||(pRc[i].left<10)) |
| 117 |
continue; |
| 118 |
pWhatDo[i] = TRUE; |
| 119 |
if ((h<=4)&&(w<=20)&&(w>=10)) //тире |
| 120 |
continue; |
| 121 |
pWhatDo[i] = FALSE; |
| 122 |
if ((w<7)||(w>120)) |
| 123 |
continue; |
| 124 |
if ((h<10)||(h>100)) |
| 125 |
continue; |
| 126 |
if (h > (int)(2.4*w + .5)) |
| 127 |
continue; |
| 128 |
if ((h<20)&&(w > (int)(2.1*h + .5))) |
| 129 |
continue; |
| 130 |
pWhatDo[i] = TRUE; |
| 131 |
} |
| 132 |
} |
| 133 |
/*----------------------------------------------------------------------------*/ |
| 134 |
void OldFormalVerification (LineInfo *pLns, int Lent) |
| 135 |
{ |
| 136 |
int Qual; |
| 137 |
while (1) |
| 138 |
{ |
| 139 |
if (Lent>256) |
| 140 |
{ |
| 141 |
Qual = 1; |
| 142 |
break; |
| 143 |
} |
| 144 |
if (Lent<=80) |
| 145 |
{ |
| 146 |
Qual = 0; |
| 147 |
break; |
| 148 |
} |
| 149 |
if ((Lent>=128)&&(pLns->SegCnt>=2)) |
| 150 |
{ |
| 151 |
Qual = 2; |
| 152 |
break; |
| 153 |
} |
| 154 |
if (pLns->SegCnt>1) |
| 155 |
{ |
| 156 |
Qual = 0; |
| 157 |
break; |
| 158 |
} |
| 159 |
Qual = 1; |
| 160 |
break; |
| 161 |
} |
| 162 |
if (Qual) |
| 163 |
{ |
| 164 |
if (Qual==TRUE) |
| 165 |
pLns->Flags |= LI_IsTrue; |
| 166 |
} |
| 167 |
else |
| 168 |
pLns->Flags |= LI_IsFalse; |
| 169 |
} |
| 170 |
/*----------------------------------------------------------------------------*/ |
| 171 |
void FormalVerification (LineInfo *pLns, int Lent) |
| 172 |
{ |
| 173 |
int Qual; |
| 174 |
Qual = 2; |
| 175 |
if ((Lent>=256)||(pLns->SegCnt==1)) |
| 176 |
Qual = TRUE; |
| 177 |
if ((pLns->SegCnt==2)&&(Lent<128)) |
| 178 |
Qual = FALSE; |
| 179 |
if ((pLns->SegCnt>2)&&(Lent<256)) |
| 180 |
Qual = FALSE; |
| 181 |
if (Qual) |
| 182 |
{ |
| 183 |
if (Qual==TRUE) |
| 184 |
pLns->Flags |= LI_IsTrue; |
| 185 |
} |
| 186 |
else |
| 187 |
pLns->Flags |= LI_IsFalse; |
| 188 |
} |
| 189 |
/*----------------------------------------------------------------------------*/ |
| 190 |
void PutNewFlagOfLine (LineInfo *pLns, uint32_t Flag) |
| 191 |
{ |
| 192 |
uint32_t AntiFalse, AntiTrue; |
| 193 |
AntiFalse = 0xFFFFFFFF; |
| 194 |
AntiFalse ^= LI_IsFalse; |
| 195 |
AntiTrue = 0xFFFFFFFF; |
| 196 |
AntiTrue ^= LI_IsTrue; |
| 197 |
switch (Flag) |
| 198 |
{ |
| 199 |
case 0 : |
| 200 |
pLns->Flags &= AntiTrue; |
| 201 |
pLns->Flags &= AntiFalse; |
| 202 |
break; |
| 203 |
case LI_IsFalse : |
| 204 |
pLns->Flags &= AntiTrue; |
| 205 |
pLns->Flags |= LI_IsFalse; |
| 206 |
break; |
| 207 |
case LI_IsTrue : |
| 208 |
pLns->Flags &= AntiFalse; |
| 209 |
pLns->Flags |= LI_IsTrue; |
| 210 |
break; |
| 211 |
case LI_NOTWHOLE : |
| 212 |
pLns->Flags &= AntiFalse; |
| 213 |
pLns->Flags |= LI_IsTrue; |
| 214 |
pLns->Flags |= LI_NOTWHOLE; |
| 215 |
break; |
| 216 |
case LI_COMPLEX : |
| 217 |
pLns->Flags &= AntiFalse; |
| 218 |
pLns->Flags |= LI_IsTrue; |
| 219 |
pLns->Flags |= LI_COMPLEX; |
| 220 |
break; |
| 221 |
default : |
| 222 |
break; |
| 223 |
} |
| 224 |
} |
| 225 |
/*----------------------------------------------------------------------------*/ |
| 226 |
void GetAllZhertvy (LineInfo *pLns, AM_ZHERTVY *pZher, Rect16 *pRc |
| 227 |
, int *pWhatDo, int nComp, int Near, Bool Hori) |
| 228 |
{ |
| 229 |
int i; |
| 230 |
Bool Cross; |
| 231 |
pZher->nZher = 0; |
| 232 |
for (i=0; i<nComp; i++) |
| 233 |
{ |
| 234 |
if (pZher->nZher>=MaxZherOnLine) |
| 235 |
return; |
| 236 |
if (!pWhatDo[i]) |
| 237 |
continue; |
| 238 |
pZher->LinBeg[pZher->nZher].x = pLns->A.x; |
| 239 |
pZher->LinBeg[pZher->nZher].y = pLns->A.y; |
| 240 |
pZher->LinEnd[pZher->nZher].x = pLns->B.x; |
| 241 |
pZher->LinEnd[pZher->nZher].y = pLns->B.y; |
| 242 |
Cross = HaveLinePartAtReg (&(pZher->LinBeg[pZher->nZher]) |
| 243 |
, &(pZher->LinEnd[pZher->nZher]), &(pRc[i]), 0, Near, Near); |
| 244 |
if (!Cross) |
| 245 |
continue; |
| 246 |
if (Hori) |
| 247 |
{ |
| 248 |
pZher->LinBeg[pZher->nZher].x -= 11; |
| 249 |
pZher->LinEnd[pZher->nZher].x += 11; |
| 250 |
} |
| 251 |
else |
| 252 |
{ |
| 253 |
pZher->LinBeg[pZher->nZher].y -= 11; |
| 254 |
pZher->LinEnd[pZher->nZher].y += 11; |
| 255 |
} |
| 256 |
pZher->iZher[pZher->nZher] = i; |
| 257 |
(pZher->nZher)++; |
| 258 |
} |
| 259 |
} |
| 260 |
/*----------------------------------------------------------------------------*/ |
| 261 |
void MakeNormOrderForZher (LineInfo *pLns, AM_ZHERTVY *pZher) |
| 262 |
{ |
| 263 |
int i, k, Dist, best_i, best_dist, a; |
| 264 |
Point16 CurBeg, CurEnd; |
| 265 |
for (k=0; k<pZher->nZher; k++) |
| 266 |
{ |
| 267 |
if (k==0) |
| 268 |
{ |
| 269 |
CurBeg.x = pLns->A.x; |
| 270 |
CurBeg.y = pLns->A.y; |
| 271 |
} |
| 272 |
else |
| 273 |
{ |
| 274 |
CurBeg.x = pZher->LinEnd[k-1].x; |
| 275 |
CurBeg.y = pZher->LinEnd[k-1].y; |
| 276 |
} |
| 277 |
best_dist = 1000000; |
| 278 |
best_i = k; |
| 279 |
for (i=k; i<pZher->nZher; i++) |
| 280 |
{ |
| 281 |
CurEnd.x = pZher->LinBeg[i].x; |
| 282 |
CurEnd.y = pZher->LinBeg[i].y; |
| 283 |
Dist = (CurBeg.x - CurEnd.x) * (CurBeg.x - CurEnd.x); |
| 284 |
Dist += (CurBeg.y - CurEnd.y) * (CurBeg.y - CurEnd.y); |
| 285 |
Dist = (int) sqrt ((double)Dist); |
| 286 |
if (Dist > best_dist) |
| 287 |
continue; |
| 288 |
best_dist = Dist; |
| 289 |
best_i = i; |
| 290 |
} |
| 291 |
if (best_i==k) |
| 292 |
continue; |
| 293 |
a = pZher->iZher[best_i]; |
| 294 |
pZher->iZher[best_i] = pZher->iZher[k]; |
| 295 |
pZher->iZher[k] = a; |
| 296 |
a = pZher->LinBeg[best_i].x; |
| 297 |
pZher->LinBeg[best_i].x = pZher->LinBeg[k].x; |
| 298 |
pZher->LinBeg[k].x = a; |
| 299 |
a = pZher->LinBeg[best_i].y; |
| 300 |
pZher->LinBeg[best_i].y = pZher->LinBeg[k].y; |
| 301 |
pZher->LinBeg[k].y = a; |
| 302 |
a = pZher->LinEnd[best_i].x; |
| 303 |
pZher->LinEnd[best_i].x = pZher->LinEnd[k].x; |
| 304 |
pZher->LinEnd[k].x = a; |
| 305 |
a = pZher->LinEnd[best_i].y; |
| 306 |
pZher->LinEnd[best_i].y = pZher->LinEnd[k].y; |
| 307 |
pZher->LinEnd[k].y = a; |
| 308 |
} |
| 309 |
} |
| 310 |
/*----------------------------------------------------------------------------*/ |
| 311 |
int FindNormParts (LineInfo *pLns, AM_ZHERTVY *pZher, Point16 *pBeg |
| 312 |
, Point16 *pEnd, int MinLent) |
| 313 |
{ |
| 314 |
int nNorm, i, Lent; |
| 315 |
Point16 CurBeg, CurEnd; |
| 316 |
nNorm = 0; |
| 317 |
for (i=0; i<=pZher->nZher; i++) |
| 318 |
{ |
| 319 |
if (i==0) |
| 320 |
{ |
| 321 |
CurBeg.x = pLns->A.x; |
| 322 |
CurBeg.y = pLns->A.y; |
| 323 |
} |
| 324 |
else |
| 325 |
{ |
| 326 |
CurBeg.x = pZher->LinEnd[i-1].x; |
| 327 |
CurBeg.y = pZher->LinEnd[i-1].y; |
| 328 |
} |
| 329 |
if (i==pZher->nZher) |
| 330 |
{ |
| 331 |
CurEnd.x = pLns->B.x; |
| 332 |
CurEnd.y = pLns->B.y; |
| 333 |
} |
| 334 |
else |
| 335 |
{ |
| 336 |
CurEnd.x = pZher->LinBeg[i].x; |
| 337 |
CurEnd.y = pZher->LinBeg[i].y; |
| 338 |
} |
| 339 |
Lent = (CurBeg.x - CurEnd.x) * (CurBeg.x - CurEnd.x); |
| 340 |
Lent += (CurBeg.y - CurEnd.y) * (CurBeg.y - CurEnd.y); |
| 341 |
Lent = (int) sqrt ((double)Lent); |
| 342 |
if (Lent < MinLent) |
| 343 |
continue; |
| 344 |
pBeg[nNorm].x = CurBeg.x; |
| 345 |
pBeg[nNorm].y = CurBeg.y; |
| 346 |
pEnd[nNorm].x = CurEnd.x; |
| 347 |
pEnd[nNorm].y = CurEnd.y; |
| 348 |
nNorm++; |
| 349 |
} |
| 350 |
return nNorm; |
| 351 |
} |
| 352 |
/*----------------------------------------------------------------------------*/ |
| 353 |
void InvestLongLineWithBoxes (LineInfo *pLns, Rect16 *pRc, int *pWhatDo |
| 354 |
, int nComp, int *nZher, int *iZher, AM_ZHERTVY *pZher |
| 355 |
, int MaxZher, Bool Hori, int Lent) |
| 356 |
{ |
| 357 |
Point16 LinBeg[MaxZherOnLine + 1]; |
| 358 |
Point16 LinEnd[MaxZherOnLine + 1]; |
| 359 |
int j, Near, nSimpParts; |
| 360 |
uint32_t Flag; |
| 361 |
Near = 0; |
| 362 |
if (Hori) |
| 363 |
{ |
| 364 |
if (Lent<55) |
| 365 |
return; |
| 366 |
if (Lent<=2000) |
| 367 |
Near = 1; |
| 368 |
} |
| 369 |
else |
| 370 |
{ |
| 371 |
if (Lent<44) |
| 372 |
return; |
| 373 |
} |
| 374 |
GetAllZhertvy (pLns, pZher, pRc, pWhatDo, nComp, Near, Hori); |
| 375 |
if (pZher->nZher > 0) |
| 376 |
{ |
| 377 |
if (pZher->nZher > 1) |
| 378 |
MakeNormOrderForZher (pLns, pZher); |
| 379 |
nSimpParts = FindNormParts (pLns, pZher, LinBeg, LinEnd, 50); |
| 380 |
if (nSimpParts==0) |
| 381 |
Flag = LI_IsFalse; |
| 382 |
if (nSimpParts==1) |
| 383 |
{ |
| 384 |
pLns->Anew.x = LinBeg[0].x; |
| 385 |
pLns->Anew.y = LinBeg[0].y; |
| 386 |
pLns->Bnew.x = LinEnd[0].x; |
| 387 |
pLns->Bnew.y = LinEnd[0].y; |
| 388 |
Flag = LI_NOTWHOLE; |
| 389 |
} |
| 390 |
if (nSimpParts >1) |
| 391 |
{ |
| 392 |
Flag = LI_COMPLEX; |
| 393 |
for (j=0; j<pZher->nZher; j++) |
| 394 |
{ |
| 395 |
if (*nZher>=MaxZher) |
| 396 |
break; |
| 397 |
iZher[*nZher] = pZher->iZher[j]; |
| 398 |
(*nZher)++; |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
else |
| 403 |
{ |
| 404 |
Flag = LI_IsTrue; |
| 405 |
if ((!Hori)&&(Lent<=70)) |
| 406 |
Flag = 0; |
| 407 |
/* if (Hori&&(!AM_Skip (AM_GetKeyOfRule (RU_VL_Debug)))) |
| 408 |
{//отладка нецелых линий |
| 409 |
pLns->Anew.x = pLns->A.x; |
| 410 |
pLns->Anew.y = pLns->Anew.y; |
| 411 |
pLns->Bnew.x = (int16_t)((pLns->A.x+pLns->B.x)*.5); |
| 412 |
pLns->Bnew.y = (int16_t)((pLns->A.y+pLns->B.y)*.5); |
| 413 |
Flag = LI_NOTWHOLE; |
| 414 |
}*/ |
| 415 |
} |
| 416 |
PutNewFlagOfLine (pLns, Flag); |
| 417 |
} |
| 418 |
/*----------------------------------------------------------------------------*/ |
| 419 |
void WriteResForLines (void *vLti) |
| 420 |
{ |
| 421 |
int i, n, rot; |
| 422 |
int L_Bad, L_Doubt, L_Good; |
| 423 |
LineInfo *pLns; |
| 424 |
LinesTotalInfo *pLti; |
| 425 |
char str[256]; |
| 426 |
pLti = (LinesTotalInfo *)vLti; |
| 427 |
/***************** горизонтальная ******************************/ |
| 428 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 429 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, " <4 Н Гор.Линии\n"); |
| 430 |
n = pLti->Hor.Cnt; |
| 431 |
L_Bad = 0; L_Doubt = 0; L_Good = 0; |
| 432 |
pLns = pLti->Hor.Lns; |
| 433 |
for (i=0; i<n; i++) |
| 434 |
{ |
| 435 |
if (pLns->Flags & LI_IsFalse) |
| 436 |
{ |
| 437 |
L_Bad++; |
| 438 |
sprintf (str, " <4 О 1 %c %4d %4d %4d %4d %4d\n" |
| 439 |
, '-', pLns->A.x, pLns->A.y, pLns->B.x, pLns->B.y, pLns->Thickness); |
| 440 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 441 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 442 |
} |
| 443 |
else |
| 444 |
{ |
| 445 |
if ((!(pLns->Flags & LI_IsTrue)) |
| 446 |
||(pLns->Flags & LI_NOTWHOLE)||(pLns->Flags & LI_COMPLEX)) |
| 447 |
{ |
| 448 |
L_Doubt++; |
| 449 |
sprintf (str, " <4 О 1 %c %4d %4d %4d %4d %4d\n" |
| 450 |
, '?', pLns->A.x, pLns->A.y, pLns->B.x, pLns->B.y, pLns->Thickness); |
| 451 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 452 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 453 |
} |
| 454 |
else |
| 455 |
{ |
| 456 |
L_Good++; |
| 457 |
sprintf (str, " <4 О 1 %c %4d %4d %4d %4d %4d\n" |
| 458 |
, '+', pLns->A.x, pLns->A.y, pLns->B.x, pLns->B.y, pLns->Thickness); |
| 459 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 460 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 461 |
} |
| 462 |
} |
| 463 |
pLns++; |
| 464 |
} |
| 465 |
sprintf (str, " <4 Р %4d %4d %4d\n", L_Good, L_Doubt, L_Bad); |
| 466 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 467 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 468 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 469 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, " <4 К Гор.Линии\n"); |
| 470 |
/***************** вериткальная ******************************/ |
| 471 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 472 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, " <4 Н Вер.Линии\n"); |
| 473 |
n = pLti->Ver.Cnt; |
| 474 |
L_Bad = 0; L_Doubt = 0; L_Good = 0; |
| 475 |
pLns = pLti->Ver.Lns; |
| 476 |
for (i=0; i<n; i++) |
| 477 |
{ |
| 478 |
if (pLns->Flags & LI_IsFalse) |
| 479 |
{ |
| 480 |
L_Bad++; |
| 481 |
sprintf (str, " <4 О 1 %c %4d %4d %4d %4d %4d\n" |
| 482 |
, '-', pLns->A.x, pLns->A.y, pLns->B.x, pLns->B.y, pLns->Thickness); |
| 483 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 484 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 485 |
} |
| 486 |
else |
| 487 |
{ |
| 488 |
if ((!(pLns->Flags & LI_IsTrue)) |
| 489 |
||(pLns->Flags & LI_NOTWHOLE)||(pLns->Flags & LI_COMPLEX)) |
| 490 |
{ |
| 491 |
L_Doubt++; |
| 492 |
sprintf (str, " <4 О 1 %c %4d %4d %4d %4d %4d\n" |
| 493 |
, '?', pLns->A.x, pLns->A.y, pLns->B.x, pLns->B.y, pLns->Thickness); |
| 494 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 495 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 496 |
} |
| 497 |
else |
| 498 |
{ |
| 499 |
L_Good++; |
| 500 |
sprintf (str, " <4 О 1 %c %4d %4d %4d %4d %4d\n" |
| 501 |
, '+', pLns->A.x, pLns->A.y, pLns->B.x, pLns->B.y, pLns->Thickness); |
| 502 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 503 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 504 |
} |
| 505 |
} |
| 506 |
pLns++; |
| 507 |
} |
| 508 |
sprintf (str, " <4 Р %4d %4d %4d\n", L_Good, L_Doubt, L_Bad); |
| 509 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 510 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, str); |
| 511 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_D_WrResLine))) |
| 512 |
rot = AM_WriteRes_rv_fte (RU_VL_D_WrResLine, " <4 К Вер.Линии\n"); |
| 513 |
} |
| 514 |
/*----------------------------------------------------------------------------*/ |
| 515 |
void New_MarkVerifiedLines (void *vLti, Handle hCPage, Rect16 *pRc, int *pWhatDo |
| 516 |
, int nComp, int *nZher, int *iZher, int MaxZher, Bool AbleShortVert) |
| 517 |
{ |
| 518 |
int i, n, Lent, ret; |
| 519 |
LineInfo *pLns; |
| 520 |
LinesTotalInfo *pLti; |
| 521 |
AM_ZHERTVY ZherOfLine; |
| 522 |
uint32_t AntiFalse, AntiTrue, AntiPoin; |
| 523 |
Bool WasPointed, WasLongPointed; |
| 524 |
AntiFalse = 0xFFFFFFFF; |
| 525 |
AntiFalse ^= LI_IsFalse; |
| 526 |
AntiTrue = 0xFFFFFFFF; |
| 527 |
AntiTrue ^= LI_IsTrue; |
| 528 |
AntiPoin = 0xFFFFFFFF; |
| 529 |
AntiPoin ^= LI_Pointed; |
| 530 |
pLti = (LinesTotalInfo *)vLti; |
| 531 |
ChoiseQuasiLetters (pRc, pWhatDo, nComp); |
| 532 |
*nZher = 0; |
| 533 |
/***************** горизонтальная ******************************/ |
| 534 |
n = pLti->Hor.Cnt; |
| 535 |
pLns = pLti->Hor.Lns; |
| 536 |
for (i=0; i<n; i++) |
| 537 |
{ |
| 538 |
Lent = (pLns->A.x - pLns->B.x) * (pLns->A.x - pLns->B.x); |
| 539 |
Lent += (pLns->A.y - pLns->B.y) * (pLns->A.y - pLns->B.y); |
| 540 |
Lent = (int) sqrt ((double)Lent); |
| 541 |
/* определение отточий - обжалованию не подлежит */ //пора переиграть |
| 542 |
/* if ( AM_Skip (AM_GetKeyOfRule (RU_VL_U_NoPointedLines))) |
| 543 |
{ |
| 544 |
if ((pLns->SegCnt==1)&&(pLns->Quality==255)&&(pLns->Thickness==2)) |
| 545 |
{ |
| 546 |
pLns->Flags |= LI_Pointed; |
| 547 |
pLns++; |
| 548 |
continue; |
| 549 |
} |
| 550 |
if ((pLns->SegCnt==2)&&(pLns->Quality>=240)&&(pLns->Thickness==1)) |
| 551 |
{ |
| 552 |
pLns->Flags |= LI_Pointed; |
| 553 |
pLns->Flags |= LI_Doubt; |
| 554 |
pLns++; |
| 555 |
continue; |
| 556 |
} |
| 557 |
}*/ //Almi 13.09.01 |
| 558 |
/* верификация формальная (для всех) */ |
| 559 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_U_NewFormalVerify))) |
| 560 |
FormalVerification (pLns, Lent); |
| 561 |
else |
| 562 |
OldFormalVerification (pLns, Lent); |
| 563 |
/* верификация по тифу (для коротких) */ |
| 564 |
ret = RV_EMPTY; |
| 565 |
if ((Lent>60)&&(Lent<=350)&&(AM_Skip (AM_GetKeyOfRule (RU_VL_U_NoInvestImage)))) |
| 566 |
ret = InvestShortLineWithRastr_rv_pne (hCPage, pLns); |
| 567 |
if (ret==RV_NEGATIVE) |
| 568 |
PutNewFlagOfLine (pLns, LI_IsFalse); |
| 569 |
if (ret==RV_POSITIVE) |
| 570 |
PutNewFlagOfLine (pLns, LI_IsTrue); |
| 571 |
/* верификация по коробкам (для длинных и не отифенных коротких) */ |
| 572 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_U_AbleHoriZher))) |
| 573 |
{ |
| 574 |
if (((Lent>350)||(ret==RV_EMPTY))&&(AM_Skip (AM_GetKeyOfRule (RU_VL_U_NoInvestLongLines)))) |
| 575 |
InvestLongLineWithBoxes (pLns, pRc, pWhatDo, nComp, nZher, iZher |
| 576 |
, &ZherOfLine, MaxZher, TRUE, Lent); |
| 577 |
} |
| 578 |
pLns++; |
| 579 |
} |
| 580 |
//******** горизонтальные отточия проверим ********// |
| 581 |
pLns = pLti->Hor.Lns; |
| 582 |
WasPointed = FALSE; |
| 583 |
WasLongPointed = FALSE; |
| 584 |
for (i=0; i<n; i++) |
| 585 |
{ |
| 586 |
if (!(pLns[i].Flags & LI_Pointed)) |
| 587 |
continue; |
| 588 |
WasPointed = TRUE; |
| 589 |
if (abs(pLns[i].A.x - pLns[i].B.x)>100) |
| 590 |
WasLongPointed = TRUE; |
| 591 |
} |
| 592 |
if (WasPointed&!WasLongPointed) |
| 593 |
{ |
| 594 |
pLns = pLti->Hor.Lns; |
| 595 |
for (i=0; i<n; i++) |
| 596 |
{ |
| 597 |
if ((pLns[i].Flags & LI_Pointed)) |
| 598 |
pLns[i].Flags &= AntiPoin; |
| 599 |
} |
| 600 |
} |
| 601 |
/***************** вертикальная ******************************/ |
| 602 |
n = pLti->Ver.Cnt; |
| 603 |
pLns = pLti->Ver.Lns; |
| 604 |
for (i=0; i<n; i++) |
| 605 |
{ |
| 606 |
Lent = (pLns->A.x - pLns->B.x) * (pLns->A.x - pLns->B.x); |
| 607 |
Lent += (pLns->A.y - pLns->B.y) * (pLns->A.y - pLns->B.y); |
| 608 |
Lent = (int) sqrt ((double)Lent); |
| 609 |
if (!AM_Skip (AM_GetKeyOfRule (RU_VL_U_NewFormalVerify))) |
| 610 |
FormalVerification (pLns, Lent); |
| 611 |
else |
| 612 |
OldFormalVerification (pLns, Lent); |
| 613 |
if (AM_Skip (AM_GetKeyOfRule (RU_VL_U_NoInvestLongLines))) |
| 614 |
{ |
| 615 |
if (Lent<=100) |
| 616 |
if (pLns->Flags & LI_IsFalse) |
| 617 |
pLns->Flags &= AntiFalse; |
| 618 |
} |
| 619 |
if (AM_Skip (AM_GetKeyOfRule (RU_VL_U_NoInvestLongLines))) |
| 620 |
{ |
| 621 |
if (AbleShortVert&&(Lent>=94)) |
| 622 |
InvestLongLineWithBoxes (pLns, pRc, pWhatDo, nComp, nZher, iZher |
| 623 |
, &ZherOfLine, MaxZher, FALSE, Lent); |
| 624 |
else |
| 625 |
if (pLns->Flags & LI_IsTrue) |
| 626 |
pLns->Flags &= AntiTrue; |
| 627 |
} |
| 628 |
pLns++; |
| 629 |
} |
| 630 |
} |
| 631 |
/*----------------------------------------------------------------------------*/ |