All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
chopper.cpp File Reference
#include <math.h>
#include "chopper.h"
#include "assert.h"
#include "associate.h"
#include "blobs.h"
#include "callcpp.h"
#include "const.h"
#include "findseam.h"
#include "freelist.h"
#include "globals.h"
#include "render.h"
#include "pageres.h"
#include "seam.h"
#include "stopper.h"
#include "structures.h"
#include "unicharset.h"
#include "wordrec.h"

Go to the source code of this file.

Namespaces

 tesseract
 

Functions

preserve_outline_tree

Copy the list of outlines.

void preserve_outline (EDGEPT *start)
 
void preserve_outline_tree (TESSLINE *srcline)
 
restore_outline_tree

Copy the list of outlines.

EDGEPTrestore_outline (EDGEPT *start)
 
void restore_outline_tree (TESSLINE *srcline)
 
any_shared_split_points

Return true if any of the splits share a point with this one.

int any_shared_split_points (const GenericVector< SEAM * > &seams, SEAM *seam)
 
check_blob
Returns
true if blob has a non whole outline.
int check_blob (TBLOB *blob)
 
inT16 total_containment (TBLOB *blob1, TBLOB *blob2)
 

Function Documentation

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

Definition at line 282 of file chopper.cpp.

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

Definition at line 298 of file chopper.cpp.

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

Definition at line 67 of file chopper.cpp.

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

Definition at line 83 of file chopper.cpp.

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

Definition at line 97 of file chopper.cpp.

97  {
98  EDGEPT *srcpt;
99  EDGEPT *real_start;
100 
101  if (start == NULL)
102  return NULL;
103  srcpt = start;
104  do {
105  if (srcpt->flags[1] == 2)
106  break;
107  srcpt = srcpt->next;
108  }
109  while (srcpt != start);
110  real_start = srcpt;
111  do {
112  srcpt = srcpt->next;
113  if (srcpt->prev->flags[1] == 0) {
114  remove_edgept(srcpt->prev);
115  }
116  }
117  while (srcpt != real_start);
118  return real_start;
119 }
EDGEPT * prev
Definition: blobs.h:170
void remove_edgept(EDGEPT *point)
Definition: split.cpp:203
EDGEPT * next
Definition: blobs.h:169
char flags[EDGEPTFLAGS]
Definition: blobs.h:168
Definition: blobs.h:76
#define NULL
Definition: host.h:144
void restore_outline_tree ( TESSLINE srcline)

Definition at line 123 of file chopper.cpp.

123  {
124  TESSLINE *outline;
125 
126  for (outline = srcline; outline != NULL; outline = outline->next) {
127  outline->loop = restore_outline (outline->loop);
128  outline->start = outline->loop->pos;
129  }
130 }
EDGEPT * restore_outline(EDGEPT *start)
Definition: chopper.cpp:97
TPOINT start
Definition: blobs.h:255
TESSLINE * next
Definition: blobs.h:258
TPOINT pos
Definition: blobs.h:163
#define NULL
Definition: host.h:144
EDGEPT * loop
Definition: blobs.h:257
inT16 total_containment ( TBLOB blob1,
TBLOB blob2 
)

Definition at line 656 of file chopper.cpp.

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