tesseract  4.00.00dev
chopper.h File Reference
#include "cutil.h"
#include "matrix.h"
#include "seam.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 (const GenericVector< SEAM *> &seams, SEAM *seam)
 
int check_blob (TBLOB *blob)
 
inT16 total_containment (TBLOB *blob1, TBLOB *blob2)
 

Function Documentation

◆ any_shared_split_points()

int any_shared_split_points ( const GenericVector< SEAM *> &  seams,
SEAM seam 
)

Definition at line 281 of file chopper.cpp.

281  {
282  int length;
283  int index;
284 
285  length = seams.size();
286  for (index = 0; index < length; index++)
287  if (seam->SharesPosition(*seams[index])) return TRUE;
288  return FALSE;
289 }
#define TRUE
Definition: capi.h:45
bool SharesPosition(const SEAM &other) const
Definition: seam.h:95
int size() const
Definition: genericvector.h:72
#define FALSE
Definition: capi.h:46

◆ check_blob()

int check_blob ( TBLOB blob)

Definition at line 297 of file chopper.cpp.

297  {
298  TESSLINE *outline;
299  EDGEPT *edgept;
300 
301  for (outline = blob->outlines; outline != NULL; outline = outline->next) {
302  edgept = outline->loop;
303  do {
304  if (edgept == NULL)
305  break;
306  edgept = edgept->next;
307  }
308  while (edgept != outline->loop);
309  if (edgept == NULL)
310  return 1;
311  }
312  return 0;
313 }
TESSLINE * next
Definition: blobs.h:258
TESSLINE * outlines
Definition: blobs.h:377
EDGEPT * loop
Definition: blobs.h:257
EDGEPT * next
Definition: blobs.h:169
Definition: blobs.h:76

◆ preserve_outline()

void preserve_outline ( EDGEPT start)

Definition at line 66 of file chopper.cpp.

66  {
67  EDGEPT *srcpt;
68 
69  if (start == NULL)
70  return;
71  srcpt = start;
72  do {
73  srcpt->flags[1] = 1;
74  srcpt = srcpt->next;
75  }
76  while (srcpt != start);
77  srcpt->flags[1] = 2;
78 }
char flags[EDGEPTFLAGS]
Definition: blobs.h:168
EDGEPT * next
Definition: blobs.h:169
Definition: blobs.h:76

◆ preserve_outline_tree()

void preserve_outline_tree ( TESSLINE srcline)

Definition at line 82 of file chopper.cpp.

82  {
83  TESSLINE *outline;
84 
85  for (outline = srcline; outline != NULL; outline = outline->next) {
86  preserve_outline (outline->loop);
87  }
88 }
TESSLINE * next
Definition: blobs.h:258
void preserve_outline(EDGEPT *start)
Definition: chopper.cpp:66
EDGEPT * loop
Definition: blobs.h:257

◆ restore_outline()

EDGEPT* restore_outline ( EDGEPT start)

Definition at line 96 of file chopper.cpp.

96  {
97  EDGEPT *srcpt;
98  EDGEPT *real_start;
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  srcpt = srcpt->next;
112  if (srcpt->prev->flags[1] == 0) {
113  remove_edgept(srcpt->prev);
114  }
115  }
116  while (srcpt != real_start);
117  return real_start;
118 }
char flags[EDGEPTFLAGS]
Definition: blobs.h:168
EDGEPT * prev
Definition: blobs.h:170
void remove_edgept(EDGEPT *point)
Definition: split.cpp:208
EDGEPT * next
Definition: blobs.h:169
Definition: blobs.h:76

◆ restore_outline_tree()

void restore_outline_tree ( TESSLINE srcline)

Definition at line 122 of file chopper.cpp.

122  {
123  TESSLINE *outline;
124 
125  for (outline = srcline; outline != NULL; outline = outline->next) {
126  outline->loop = restore_outline (outline->loop);
127  outline->start = outline->loop->pos;
128  }
129 }
TESSLINE * next
Definition: blobs.h:258
TPOINT pos
Definition: blobs.h:163
TPOINT start
Definition: blobs.h:255
EDGEPT * restore_outline(EDGEPT *start)
Definition: chopper.cpp:96
EDGEPT * loop
Definition: blobs.h:257

◆ total_containment()

inT16 total_containment ( TBLOB blob1,
TBLOB blob2 
)

Definition at line 651 of file chopper.cpp.

651  {
652  TBOX box1 = blob1->bounding_box();
653  TBOX box2 = blob2->bounding_box();
654  return box1.contains(box2) || box2.contains(box1);
655 }
bool contains(const FCOORD pt) const
Definition: rect.h:323
Definition: rect.h:30
TBOX bounding_box() const
Definition: blobs.cpp:482