All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SPLIT Struct Reference

#include <split.h>

Public Member Functions

 SPLIT ()
 
 SPLIT (EDGEPT *pt1, EDGEPT *pt2)
 
TBOX bounding_box () const
 
TBOX Box12 () const
 
TBOX Box21 () const
 
void Hide () const
 
void Reveal () const
 
bool UsesPoint (const EDGEPT *point) const
 
bool SharesPosition (const SPLIT &other) const
 
bool ContainedByBlob (const TBLOB &blob) const
 
bool ContainedByOutline (const TESSLINE &outline) const
 
float FullPriority (int xmin, int xmax, double overlap_knob, int centered_maxwidth, double center_knob, double width_change_knob) const
 
bool IsHealthy (const TBLOB &blob, int min_points, int min_area) const
 
bool IsLittleChunk (int min_points, int min_area) const
 
void Print () const
 
void Mark (ScrollView *window) const
 
void SplitOutlineList (TESSLINE *outlines) const
 
void SplitOutline () const
 
void UnsplitOutlineList (TBLOB *blob) const
 
void UnsplitOutlines () const
 

Public Attributes

EDGEPTpoint1
 
EDGEPTpoint2
 

Detailed Description

Definition at line 37 of file split.h.

Constructor & Destructor Documentation

SPLIT::SPLIT ( )
inline

Definition at line 38 of file split.h.

38 : point1(NULL), point2(NULL) {}
EDGEPT * point2
Definition: split.h:104
#define NULL
Definition: host.h:144
EDGEPT * point1
Definition: split.h:103
SPLIT::SPLIT ( EDGEPT pt1,
EDGEPT pt2 
)
inline

Definition at line 39 of file split.h.

39 : point1(pt1), point2(pt2) {}
EDGEPT * point2
Definition: split.h:104
EDGEPT * point1
Definition: split.h:103

Member Function Documentation

TBOX SPLIT::bounding_box ( ) const

Definition at line 47 of file split.cpp.

47  {
48  return TBOX(
51 }
#define MAX(x, y)
Definition: ndminx.h:24
#define MIN(x, y)
Definition: ndminx.h:28
inT16 y
Definition: blobs.h:72
EDGEPT * point2
Definition: split.h:104
inT16 x
Definition: blobs.h:71
TPOINT pos
Definition: blobs.h:163
Definition: rect.h:30
EDGEPT * point1
Definition: split.h:103
TBOX SPLIT::Box12 ( ) const
inline

Definition at line 44 of file split.h.

44 { return point1->SegmentBox(point2); }
EDGEPT * point2
Definition: split.h:104
TBOX SegmentBox(const EDGEPT *end) const
Definition: blobs.h:108
EDGEPT * point1
Definition: split.h:103
TBOX SPLIT::Box21 ( ) const
inline

Definition at line 46 of file split.h.

46 { return point2->SegmentBox(point1); }
EDGEPT * point2
Definition: split.h:104
TBOX SegmentBox(const EDGEPT *end) const
Definition: blobs.h:108
EDGEPT * point1
Definition: split.h:103
bool SPLIT::ContainedByBlob ( const TBLOB blob) const
inline

Definition at line 65 of file split.h.

65  {
66  return blob.Contains(point1->pos) && blob.Contains(point2->pos);
67  }
EDGEPT * point2
Definition: split.h:104
bool Contains(const TPOINT &pt) const
Definition: blobs.h:324
TPOINT pos
Definition: blobs.h:163
EDGEPT * point1
Definition: split.h:103
bool SPLIT::ContainedByOutline ( const TESSLINE outline) const
inline

Definition at line 69 of file split.h.

69  {
70  return outline.Contains(point1->pos) && outline.Contains(point2->pos);
71  }
EDGEPT * point2
Definition: split.h:104
TPOINT pos
Definition: blobs.h:163
bool Contains(const TPOINT &pt) const
Definition: blobs.h:234
EDGEPT * point1
Definition: split.h:103
float SPLIT::FullPriority ( int  xmin,
int  xmax,
double  overlap_knob,
int  centered_maxwidth,
double  center_knob,
double  width_change_knob 
) const

Definition at line 84 of file split.cpp.

86  {
87  TBOX box1 = Box12();
88  TBOX box2 = Box21();
89  int min_left = MIN(box1.left(), box2.left());
90  int max_right = MAX(box1.right(), box2.right());
91  if (xmin < min_left && xmax > max_right) return kBadPriority;
92 
93  float grade = 0.0f;
94  // grade_overlap.
95  int width1 = box1.width();
96  int width2 = box2.width();
97  int min_width = MIN(width1, width2);
98  int overlap = -box1.x_gap(box2);
99  if (overlap == min_width) {
100  grade += 100.0f; // Total overlap.
101  } else {
102  if (2 * overlap > min_width) overlap += 2 * overlap - min_width;
103  if (overlap > 0) grade += overlap_knob * overlap;
104  }
105  // grade_center_of_blob.
106  if (width1 <= centered_maxwidth || width2 <= centered_maxwidth) {
107  grade += MIN(kCenterGradeCap, center_knob * abs(width1 - width2));
108  }
109  // grade_width_change.
110  float width_change_grade = 20 - (max_right - min_left - MAX(width1, width2));
111  if (width_change_grade > 0.0f)
112  grade += width_change_grade * width_change_knob;
113  return grade;
114 }
#define MAX(x, y)
Definition: ndminx.h:24
const int kCenterGradeCap
Definition: split.cpp:40
#define MIN(x, y)
Definition: ndminx.h:28
TBOX Box21() const
Definition: split.h:46
inT16 right() const
Definition: rect.h:75
const double kBadPriority
Definition: split.cpp:42
inT16 left() const
Definition: rect.h:68
inT16 width() const
Definition: rect.h:111
int x_gap(const TBOX &box) const
Definition: rect.h:217
Definition: rect.h:30
TBOX Box12() const
Definition: split.h:44
void SPLIT::Hide ( ) const

Definition at line 54 of file split.cpp.

54  {
55  EDGEPT* edgept = point1;
56  do {
57  edgept->Hide();
58  edgept = edgept->next;
59  } while (!edgept->EqualPos(*point2) && edgept != point1);
60  edgept = point2;
61  do {
62  edgept->Hide();
63  edgept = edgept->next;
64  } while (!edgept->EqualPos(*point1) && edgept != point2);
65 }
EDGEPT * point2
Definition: split.h:104
EDGEPT * next
Definition: blobs.h:169
bool EqualPos(const EDGEPT &other) const
Definition: blobs.h:105
Definition: blobs.h:76
void Hide()
Definition: blobs.h:147
EDGEPT * point1
Definition: split.h:103
bool SPLIT::IsHealthy ( const TBLOB blob,
int  min_points,
int  min_area 
) const

Definition at line 118 of file split.cpp.

118  {
119  return !IsLittleChunk(min_points, min_area) &&
121 }
bool SegmentCrossesOutline(const TPOINT &pt1, const TPOINT &pt2) const
Definition: blobs.h:316
bool IsLittleChunk(int min_points, int min_area) const
Definition: split.cpp:125
EDGEPT * point2
Definition: split.h:104
TPOINT pos
Definition: blobs.h:163
EDGEPT * point1
Definition: split.h:103
bool SPLIT::IsLittleChunk ( int  min_points,
int  min_area 
) const

Definition at line 125 of file split.cpp.

125  {
126  if (point1->ShortNonCircularSegment(min_points, point2) &&
127  point1->SegmentArea(point2) < min_area) {
128  return true;
129  }
130  if (point2->ShortNonCircularSegment(min_points, point1) &&
131  point2->SegmentArea(point1) < min_area) {
132  return true;
133  }
134  return false;
135 }
bool ShortNonCircularSegment(int min_points, const EDGEPT *end) const
Definition: blobs.h:135
int SegmentArea(const EDGEPT *end) const
Definition: blobs.h:122
EDGEPT * point2
Definition: split.h:104
EDGEPT * point1
Definition: split.h:103
void SPLIT::Mark ( ScrollView window) const

Definition at line 231 of file split.cpp.

231  {
232  window->Pen(ScrollView::GREEN);
233  window->Line(point1->pos.x, point1->pos.y, point2->pos.x, point2->pos.y);
234  window->UpdateWindow();
235 }
void Pen(Color color)
Definition: scrollview.cpp:726
inT16 y
Definition: blobs.h:72
EDGEPT * point2
Definition: split.h:104
void UpdateWindow()
Definition: scrollview.cpp:710
inT16 x
Definition: blobs.h:71
TPOINT pos
Definition: blobs.h:163
void Line(int x1, int y1, int x2, int y2)
Definition: scrollview.cpp:538
EDGEPT * point1
Definition: split.h:103
void SPLIT::Print ( ) const

Definition at line 222 of file split.cpp.

222  {
223  if (this != NULL) {
224  tprintf("(%d,%d)--(%d,%d)", point1->pos.x, point1->pos.y, point2->pos.x,
225  point2->pos.y);
226  }
227 }
#define tprintf(...)
Definition: tprintf.h:31
inT16 y
Definition: blobs.h:72
EDGEPT * point2
Definition: split.h:104
inT16 x
Definition: blobs.h:71
TPOINT pos
Definition: blobs.h:163
#define NULL
Definition: host.h:144
EDGEPT * point1
Definition: split.h:103
void SPLIT::Reveal ( ) const

Definition at line 68 of file split.cpp.

68  {
69  EDGEPT* edgept = point1;
70  do {
71  edgept->Reveal();
72  edgept = edgept->next;
73  } while (!edgept->EqualPos(*point2) && edgept != point1);
74  edgept = point2;
75  do {
76  edgept->Reveal();
77  edgept = edgept->next;
78  } while (!edgept->EqualPos(*point1) && edgept != point2);
79 }
void Reveal()
Definition: blobs.h:150
EDGEPT * point2
Definition: split.h:104
EDGEPT * next
Definition: blobs.h:169
bool EqualPos(const EDGEPT &other) const
Definition: blobs.h:105
Definition: blobs.h:76
EDGEPT * point1
Definition: split.h:103
bool SPLIT::SharesPosition ( const SPLIT other) const
inline

Definition at line 60 of file split.h.

60  {
61  return point1->EqualPos(*other.point1) || point1->EqualPos(*other.point2) ||
62  point2->EqualPos(*other.point1) || point2->EqualPos(*other.point2);
63  }
EDGEPT * point2
Definition: split.h:104
bool EqualPos(const EDGEPT &other) const
Definition: blobs.h:105
EDGEPT * point1
Definition: split.h:103
void SPLIT::SplitOutline ( ) const

Definition at line 259 of file split.cpp.

259  {
260  EDGEPT* temp2 = point2->next;
261  EDGEPT* temp1 = point1->next;
262  /* Create two new points */
263  EDGEPT* new_point1 = make_edgept(point1->pos.x, point1->pos.y, temp1, point2);
264  EDGEPT* new_point2 = make_edgept(point2->pos.x, point2->pos.y, temp2, point1);
265  // point1 and 2 are now cross-over points, so they must have NULL
266  // src_outlines and give their src_outline information their new
267  // replacements.
268  new_point1->src_outline = point1->src_outline;
269  new_point1->start_step = point1->start_step;
270  new_point1->step_count = point1->step_count;
271  new_point2->src_outline = point2->src_outline;
272  new_point2->start_step = point2->start_step;
273  new_point2->step_count = point2->step_count;
275  point1->start_step = 0;
276  point1->step_count = 0;
278  point2->start_step = 0;
279  point2->step_count = 0;
280 }
int start_step
Definition: blobs.h:173
inT16 y
Definition: blobs.h:72
EDGEPT * point2
Definition: split.h:104
EDGEPT * next
Definition: blobs.h:169
inT16 x
Definition: blobs.h:71
EDGEPT * make_edgept(int x, int y, EDGEPT *next, EDGEPT *prev)
Definition: split.cpp:142
int step_count
Definition: blobs.h:174
C_OUTLINE * src_outline
Definition: blobs.h:171
TPOINT pos
Definition: blobs.h:163
Definition: blobs.h:76
#define NULL
Definition: host.h:144
EDGEPT * point1
Definition: split.h:103
void SPLIT::SplitOutlineList ( TESSLINE outlines) const

Definition at line 240 of file split.cpp.

240  {
241  SplitOutline();
242  while (outlines->next != NULL) outlines = outlines->next;
243 
244  outlines->next = new TESSLINE;
245  outlines->next->loop = point1;
246  outlines->next->ComputeBoundingBox();
247 
248  outlines = outlines->next;
249 
250  outlines->next = new TESSLINE;
251  outlines->next->loop = point2;
252  outlines->next->ComputeBoundingBox();
253 
254  outlines->next->next = NULL;
255 }
TESSLINE * next
Definition: blobs.h:258
void ComputeBoundingBox()
Definition: blobs.cpp:225
EDGEPT * point2
Definition: split.h:104
void SplitOutline() const
Definition: split.cpp:259
#define NULL
Definition: host.h:144
EDGEPT * loop
Definition: blobs.h:257
EDGEPT * point1
Definition: split.h:103
void SPLIT::UnsplitOutlineList ( TBLOB blob) const

Definition at line 284 of file split.cpp.

284  {
285  /* Modify edge points */
286  UnsplitOutlines();
287 
288  TESSLINE* outline1 = new TESSLINE;
289  outline1->next = blob->outlines;
290  blob->outlines = outline1;
291  outline1->loop = point1;
292 
293  TESSLINE* outline2 = new TESSLINE;
294  outline2->next = blob->outlines;
295  blob->outlines = outline2;
296  outline2->loop = point2;
297 }
TESSLINE * next
Definition: blobs.h:258
EDGEPT * point2
Definition: split.h:104
void UnsplitOutlines() const
Definition: split.cpp:300
TESSLINE * outlines
Definition: blobs.h:377
EDGEPT * loop
Definition: blobs.h:257
EDGEPT * point1
Definition: split.h:103
void SPLIT::UnsplitOutlines ( ) const

Definition at line 300 of file split.cpp.

300  {
301  EDGEPT* tmp1 = point1->next;
302  EDGEPT* tmp2 = point2->next;
303 
304  tmp1->next->prev = point2;
305  tmp2->next->prev = point1;
306 
307  // tmp2 is coincident with point1. point1 takes tmp2's place as tmp2 is
308  // deleted.
309  point1->next = tmp2->next;
310  point1->src_outline = tmp2->src_outline;
311  point1->start_step = tmp2->start_step;
312  point1->step_count = tmp2->step_count;
313  // Likewise point2 takes tmp1's place.
314  point2->next = tmp1->next;
315  point2->src_outline = tmp1->src_outline;
316  point2->start_step = tmp1->start_step;
317  point2->step_count = tmp1->step_count;
318 
319  delete tmp1;
320  delete tmp2;
321 
322  point1->vec.x = point1->next->pos.x - point1->pos.x;
323  point1->vec.y = point1->next->pos.y - point1->pos.y;
324 
325  point2->vec.x = point2->next->pos.x - point2->pos.x;
326  point2->vec.y = point2->next->pos.y - point2->pos.y;
327 }
int start_step
Definition: blobs.h:173
EDGEPT * prev
Definition: blobs.h:170
inT16 y
Definition: blobs.h:72
EDGEPT * point2
Definition: split.h:104
VECTOR vec
Definition: blobs.h:164
EDGEPT * next
Definition: blobs.h:169
inT16 x
Definition: blobs.h:71
int step_count
Definition: blobs.h:174
C_OUTLINE * src_outline
Definition: blobs.h:171
TPOINT pos
Definition: blobs.h:163
Definition: blobs.h:76
EDGEPT * point1
Definition: split.h:103
bool SPLIT::UsesPoint ( const EDGEPT point) const
inline

Definition at line 56 of file split.h.

56  {
57  return point1 == point || point2 == point;
58  }
EDGEPT * point2
Definition: split.h:104
EDGEPT * point1
Definition: split.h:103

Member Data Documentation

EDGEPT* SPLIT::point1

Definition at line 103 of file split.h.

EDGEPT* SPLIT::point2

Definition at line 104 of file split.h.


The documentation for this struct was generated from the following files: