tesseract  4.0.0-1-g2a2b
chopper.h File Reference
#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_t 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 287 of file chopper.cpp.

287  {
288  int length;
289  int index;
290 
291  length = seams.size();
292  for (index = 0; index < length; index++)
293  if (seam->SharesPosition(*seams[index])) return TRUE;
294  return FALSE;
295 }
int size() const
Definition: genericvector.h:71
#define TRUE
Definition: capi.h:51
#define FALSE
Definition: capi.h:52
bool SharesPosition(const SEAM &other) const
Definition: seam.h:95

◆ check_blob()

int check_blob ( TBLOB blob)

Definition at line 303 of file chopper.cpp.

303  {
304  TESSLINE *outline;
305  EDGEPT *edgept;
306 
307  for (outline = blob->outlines; outline != nullptr; outline = outline->next) {
308  edgept = outline->loop;
309  do {
310  if (edgept == nullptr)
311  break;
312  edgept = edgept->next;
313  }
314  while (edgept != outline->loop);
315  if (edgept == nullptr)
316  return 1;
317  }
318  return 0;
319 }
TESSLINE * next
Definition: blobs.h:265
EDGEPT * loop
Definition: blobs.h:264
Definition: blobs.h:83
TESSLINE * outlines
Definition: blobs.h:384
EDGEPT * next
Definition: blobs.h:176

◆ preserve_outline()

void preserve_outline ( EDGEPT start)

Definition at line 72 of file chopper.cpp.

72  {
73  EDGEPT *srcpt;
74 
75  if (start == nullptr)
76  return;
77  srcpt = start;
78  do {
79  srcpt->flags[1] = 1;
80  srcpt = srcpt->next;
81  }
82  while (srcpt != start);
83  srcpt->flags[1] = 2;
84 }
Definition: blobs.h:83
char flags[EDGEPTFLAGS]
Definition: blobs.h:175
EDGEPT * next
Definition: blobs.h:176

◆ preserve_outline_tree()

void preserve_outline_tree ( TESSLINE srcline)

Definition at line 88 of file chopper.cpp.

88  {
89  TESSLINE *outline;
90 
91  for (outline = srcline; outline != nullptr; outline = outline->next) {
92  preserve_outline (outline->loop);
93  }
94 }
TESSLINE * next
Definition: blobs.h:265
void preserve_outline(EDGEPT *start)
Definition: chopper.cpp:72
EDGEPT * loop
Definition: blobs.h:264

◆ restore_outline()

EDGEPT* restore_outline ( EDGEPT start)

Definition at line 102 of file chopper.cpp.

102  {
103  EDGEPT *srcpt;
104  EDGEPT *real_start;
105 
106  if (start == nullptr)
107  return nullptr;
108  srcpt = start;
109  do {
110  if (srcpt->flags[1] == 2)
111  break;
112  srcpt = srcpt->next;
113  }
114  while (srcpt != start);
115  real_start = srcpt;
116  do {
117  srcpt = srcpt->next;
118  if (srcpt->prev->flags[1] == 0) {
119  remove_edgept(srcpt->prev);
120  }
121  }
122  while (srcpt != real_start);
123  return real_start;
124 }
void remove_edgept(EDGEPT *point)
Definition: split.cpp:206
Definition: blobs.h:83
EDGEPT * prev
Definition: blobs.h:177
char flags[EDGEPTFLAGS]
Definition: blobs.h:175
EDGEPT * next
Definition: blobs.h:176

◆ restore_outline_tree()

void restore_outline_tree ( TESSLINE srcline)

Definition at line 128 of file chopper.cpp.

128  {
129  TESSLINE *outline;
130 
131  for (outline = srcline; outline != nullptr; outline = outline->next) {
132  outline->loop = restore_outline (outline->loop);
133  outline->start = outline->loop->pos;
134  }
135 }
TESSLINE * next
Definition: blobs.h:265
TPOINT pos
Definition: blobs.h:170
TPOINT start
Definition: blobs.h:262
EDGEPT * loop
Definition: blobs.h:264
EDGEPT * restore_outline(EDGEPT *start)
Definition: chopper.cpp:102

◆ total_containment()

int16_t total_containment ( TBLOB blob1,
TBLOB blob2 
)

Definition at line 657 of file chopper.cpp.

657  {
658  TBOX box1 = blob1->bounding_box();
659  TBOX box2 = blob2->bounding_box();
660  return box1.contains(box2) || box2.contains(box1);
661 }
Definition: rect.h:34
TBOX bounding_box() const
Definition: blobs.cpp:478
bool contains(const FCOORD pt) const
Definition: rect.h:333