Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
chopper.h File Reference
#include "cutil.h"
#include "matrix.h"
#include "seam.h"
#include "states.h"
#include "stopper.h"

Go to the source code of this file.

Functions

void preserve_outline (EDGEPT *start)
 
void preserve_outline_tree (TESSLINE *srcline)
 
EDGEPTrestore_outline (EDGEPT *start)
 
void restore_outline_tree (TESSLINE *srcline)
 
int any_shared_split_points (SEAMS seam_list, SEAM *seam)
 
int check_blob (TBLOB *blob)
 
inT16 check_seam_order (TBLOB *blob, SEAM *seam)
 
inT16 total_containment (TBLOB *blob1, TBLOB *blob2)
 

Function Documentation

int any_shared_split_points ( SEAMS  seam_list,
SEAM seam 
)

Definition at line 289 of file chopper.cpp.

289  {
290  int length;
291  int index;
292 
293  length = array_count (seam_list);
294  for (index = 0; index < length; index++)
295  if (shared_split_points ((SEAM *) array_value (seam_list, index), seam))
296  return TRUE;
297  return FALSE;
298 }
int shared_split_points(SEAM *seam1, SEAM *seam2)
Definition: seam.cpp:507
#define FALSE
Definition: capi.h:28
#define array_count(a)
Definition: tessarray.h:74
#define array_value(a, i)
Definition: tessarray.h:132
#define TRUE
Definition: capi.h:27
int check_blob ( TBLOB blob)

Definition at line 306 of file chopper.cpp.

306  {
307  TESSLINE *outline;
308  EDGEPT *edgept;
309 
310  for (outline = blob->outlines; outline != NULL; outline = outline->next) {
311  edgept = outline->loop;
312  do {
313  if (edgept == NULL)
314  break;
315  edgept = edgept->next;
316  }
317  while (edgept != outline->loop);
318  if (edgept == NULL)
319  return 1;
320  }
321  return 0;
322 }
EDGEPT * next
Definition: blobs.h:106
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
TESSLINE * outlines
Definition: blobs.h:227
Definition: blobs.h:72
EDGEPT * loop
Definition: blobs.h:170
inT16 check_seam_order ( TBLOB blob,
SEAM seam 
)

Definition at line 539 of file chopper.cpp.

539  {
540  TESSLINE *outline;
541  TESSLINE *last_outline;
542  inT8 found_em[3];
543 
544  if (seam->split1 == NULL || seam->split1 == NULL || blob == NULL)
545  return (TRUE);
546 
547  found_em[0] = found_em[1] = found_em[2] = FALSE;
548 
549  for (outline = blob->outlines; outline; outline = outline->next) {
550  if (!found_em[0] &&
551  ((seam->split1 == NULL) ||
552  is_split_outline (outline, seam->split1))) {
553  found_em[0] = TRUE;
554  }
555  if (!found_em[1] &&
556  ((seam->split2 == NULL) ||
557  is_split_outline (outline, seam->split2))) {
558  found_em[1] = TRUE;
559  }
560  if (!found_em[2] &&
561  ((seam->split3 == NULL) ||
562  is_split_outline (outline, seam->split3))) {
563  found_em[2] = TRUE;
564  }
565  last_outline = outline;
566  }
567 
568  if (!found_em[0] || !found_em[1] || !found_em[2])
569  return (FALSE);
570  else
571  return (TRUE);
572 }
SPLIT * split2
Definition: seam.h:47
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
#define FALSE
Definition: capi.h:28
TESSLINE * outlines
Definition: blobs.h:227
SPLIT * split1
Definition: seam.h:46
#define is_split_outline(outline, split)
Definition: makechop.h:44
SIGNED char inT8
Definition: host.h:98
SPLIT * split3
Definition: seam.h:48
#define TRUE
Definition: capi.h:27
void preserve_outline ( EDGEPT start)

Definition at line 65 of file chopper.cpp.

65  {
66  EDGEPT *srcpt;
67 
68  if (start == NULL)
69  return;
70  srcpt = start;
71  do {
72  srcpt->flags[1] = 1;
73  srcpt = srcpt->next;
74  }
75  while (srcpt != start);
76  srcpt->flags[1] = 2;
77 }
EDGEPT * next
Definition: blobs.h:106
#define NULL
Definition: host.h:144
Definition: blobs.h:72
char flags[EDGEPTFLAGS]
Definition: blobs.h:105
void preserve_outline_tree ( TESSLINE srcline)

Definition at line 81 of file chopper.cpp.

81  {
82  TESSLINE *outline;
83 
84  for (outline = srcline; outline != NULL; outline = outline->next) {
85  preserve_outline (outline->loop);
86  }
87 }
void preserve_outline(EDGEPT *start)
Definition: chopper.cpp:65
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
EDGEPT * loop
Definition: blobs.h:170
EDGEPT* restore_outline ( EDGEPT start)

Definition at line 95 of file chopper.cpp.

95  {
96  EDGEPT *srcpt;
97  EDGEPT *real_start;
98  EDGEPT *deadpt;
99 
100  if (start == NULL)
101  return NULL;
102  srcpt = start;
103  do {
104  if (srcpt->flags[1] == 2)
105  break;
106  srcpt = srcpt->next;
107  }
108  while (srcpt != start);
109  real_start = srcpt;
110  do {
111  if (srcpt->flags[1] == 0) {
112  deadpt = srcpt;
113  srcpt = srcpt->next;
114  srcpt->prev = deadpt->prev;
115  deadpt->prev->next = srcpt;
116  deadpt->prev->vec.x = srcpt->pos.x - deadpt->prev->pos.x;
117  deadpt->prev->vec.y = srcpt->pos.y - deadpt->prev->pos.y;
118  delete deadpt;
119  }
120  else
121  srcpt = srcpt->next;
122  }
123  while (srcpt != real_start);
124  return real_start;
125 }
EDGEPT * next
Definition: blobs.h:106
EDGEPT * prev
Definition: blobs.h:107
#define NULL
Definition: host.h:144
VECTOR vec
Definition: blobs.h:101
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
Definition: blobs.h:72
TPOINT pos
Definition: blobs.h:100
char flags[EDGEPTFLAGS]
Definition: blobs.h:105
void restore_outline_tree ( TESSLINE srcline)

Definition at line 129 of file chopper.cpp.

129  {
130  TESSLINE *outline;
131 
132  for (outline = srcline; outline != NULL; outline = outline->next) {
133  outline->loop = restore_outline (outline->loop);
134  outline->start = outline->loop->pos;
135  }
136 }
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
TPOINT start
Definition: blobs.h:168
TPOINT pos
Definition: blobs.h:100
EDGEPT * restore_outline(EDGEPT *start)
Definition: chopper.cpp:95
EDGEPT * loop
Definition: blobs.h:170
inT16 total_containment ( TBLOB blob1,
TBLOB blob2 
)

Definition at line 1050 of file chopper.cpp.

1050  {
1051  TBOX box1 = blob1->bounding_box();
1052  TBOX box2 = blob2->bounding_box();
1053  return box1.contains(box2) || box2.contains(box1);
1054 }
bool contains(const FCOORD pt) const
Definition: rect.h:323
Definition: rect.h:29
TBOX bounding_box() const
Definition: blobs.cpp:384