Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TESSLINE Struct Reference

#include <blobs.h>

Public Member Functions

 TESSLINE ()
 
 TESSLINE (const TESSLINE &src)
 
 ~TESSLINE ()
 
TESSLINEoperator= (const TESSLINE &src)
 
void CopyFrom (const TESSLINE &src)
 
void Clear ()
 
void Normalize (const DENORM &denorm)
 
void Rotate (const FCOORD rotation)
 
void Move (const ICOORD vec)
 
void Scale (float factor)
 
void SetupFromPos ()
 
void ComputeBoundingBox ()
 
void MinMaxCrossProduct (const TPOINT vec, int *min_xp, int *max_xp) const
 
TBOX bounding_box () const
 
bool Contains (const TPOINT &pt)
 
void plot (ScrollView *window, ScrollView::Color color, ScrollView::Color child_color)
 
int BBArea () const
 

Static Public Member Functions

static TESSLINEBuildFromOutlineList (EDGEPT *outline)
 

Public Attributes

TPOINT topleft
 
TPOINT botright
 
TPOINT start
 
bool is_hole
 
EDGEPTloop
 
TESSLINEnext
 

Detailed Description

Definition at line 113 of file blobs.h.

Constructor & Destructor Documentation

TESSLINE::TESSLINE ( )
inline

Definition at line 114 of file blobs.h.

114 : is_hole(false), loop(NULL), next(NULL) {}
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
bool is_hole
Definition: blobs.h:169
EDGEPT * loop
Definition: blobs.h:170
TESSLINE::TESSLINE ( const TESSLINE src)
inline

Definition at line 115 of file blobs.h.

115  : loop(NULL), next(NULL) {
116  CopyFrom(src);
117  }
TESSLINE * next
Definition: blobs.h:171
#define NULL
Definition: host.h:144
void CopyFrom(const TESSLINE &src)
Definition: blobs.cpp:76
EDGEPT * loop
Definition: blobs.h:170
TESSLINE::~TESSLINE ( )
inline

Definition at line 118 of file blobs.h.

118  {
119  Clear();
120  }
void Clear()
Definition: blobs.cpp:103

Member Function Documentation

int TESSLINE::BBArea ( ) const
inline

Definition at line 162 of file blobs.h.

162  {
163  return (botright.x - topleft.x) * (topleft.y - botright.y);
164  }
TPOINT topleft
Definition: blobs.h:166
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
TPOINT botright
Definition: blobs.h:167
TBOX TESSLINE::bounding_box ( ) const

Definition at line 223 of file blobs.cpp.

223  {
224  return TBOX(topleft.x, botright.y, botright.x, topleft.y);
225 }
TPOINT topleft
Definition: blobs.h:166
Definition: rect.h:29
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
TPOINT botright
Definition: blobs.h:167
TESSLINE * TESSLINE::BuildFromOutlineList ( EDGEPT outline)
static

Definition at line 68 of file blobs.cpp.

68  {
69  TESSLINE* result = new TESSLINE;
70  result->loop = outline;
71  result->SetupFromPos();
72  return result;
73 }
TESSLINE()
Definition: blobs.h:114
void SetupFromPos()
Definition: blobs.cpp:163
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::Clear ( )

Definition at line 103 of file blobs.cpp.

103  {
104  if (loop == NULL)
105  return;
106 
107  EDGEPT* this_edge = loop;
108  do {
109  EDGEPT* next_edge = this_edge->next;
110  delete this_edge;
111  this_edge = next_edge;
112  } while (this_edge != loop);
113  loop = NULL;
114 }
EDGEPT * next
Definition: blobs.h:106
#define NULL
Definition: host.h:144
Definition: blobs.h:72
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::ComputeBoundingBox ( )

Definition at line 175 of file blobs.cpp.

175  {
176  int minx = MAX_INT32;
177  int miny = MAX_INT32;
178  int maxx = -MAX_INT32;
179  int maxy = -MAX_INT32;
180 
181  // Find boundaries.
182  start = loop->pos;
183  EDGEPT* this_edge = loop;
184  do {
185  if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) {
186  if (this_edge->pos.x < minx)
187  minx = this_edge->pos.x;
188  if (this_edge->pos.y < miny)
189  miny = this_edge->pos.y;
190  if (this_edge->pos.x > maxx)
191  maxx = this_edge->pos.x;
192  if (this_edge->pos.y > maxy)
193  maxy = this_edge->pos.y;
194  }
195  this_edge = this_edge->next;
196  } while (this_edge != loop);
197  // Reset bounds.
198  topleft.x = minx;
199  topleft.y = maxy;
200  botright.x = maxx;
201  botright.y = miny;
202 }
EDGEPT * next
Definition: blobs.h:106
TPOINT topleft
Definition: blobs.h:166
EDGEPT * prev
Definition: blobs.h:107
inT16 y
Definition: blobs.h:68
bool IsHidden() const
Definition: blobs.h:96
#define MAX_INT32
Definition: host.h:120
inT16 x
Definition: blobs.h:67
TPOINT start
Definition: blobs.h:168
Definition: blobs.h:72
TPOINT pos
Definition: blobs.h:100
TPOINT botright
Definition: blobs.h:167
EDGEPT * loop
Definition: blobs.h:170
bool TESSLINE::Contains ( const TPOINT pt)
inline

Definition at line 152 of file blobs.h.

152  {
153  return topleft.x <= pt.x && pt.x <= botright.x &&
154  botright.y <= pt.y && pt.y <= topleft.y;
155  }
TPOINT topleft
Definition: blobs.h:166
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
TPOINT botright
Definition: blobs.h:167
void TESSLINE::CopyFrom ( const TESSLINE src)

Definition at line 76 of file blobs.cpp.

76  {
77  Clear();
78  topleft = src.topleft;
79  botright = src.botright;
80  start = src.start;
81  is_hole = src.is_hole;
82  if (src.loop != NULL) {
83  EDGEPT* prevpt = NULL;
84  EDGEPT* newpt = NULL;
85  EDGEPT* srcpt = src.loop;
86  do {
87  newpt = new EDGEPT(*srcpt);
88  if (prevpt == NULL) {
89  loop = newpt;
90  } else {
91  newpt->prev = prevpt;
92  prevpt->next = newpt;
93  }
94  prevpt = newpt;
95  srcpt = srcpt->next;
96  } while (srcpt != src.loop);
97  loop->prev = newpt;
98  newpt->next = loop;
99  }
100 }
EDGEPT * next
Definition: blobs.h:106
TPOINT topleft
Definition: blobs.h:166
EDGEPT * prev
Definition: blobs.h:107
void Clear()
Definition: blobs.cpp:103
#define NULL
Definition: host.h:144
TPOINT start
Definition: blobs.h:168
Definition: blobs.h:72
bool is_hole
Definition: blobs.h:169
TPOINT botright
Definition: blobs.h:167
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::MinMaxCrossProduct ( const TPOINT  vec,
int *  min_xp,
int *  max_xp 
) const

Definition at line 209 of file blobs.cpp.

210  {
211  *min_xp = MAX_INT32;
212  *max_xp = MIN_INT32;
213  EDGEPT* this_edge = loop;
214  do {
215  if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) {
216  int product = CROSS(this_edge->pos, vec);
217  UpdateRange(product, min_xp, max_xp);
218  }
219  this_edge = this_edge->next;
220  } while (this_edge != loop);
221 }
EDGEPT * next
Definition: blobs.h:106
EDGEPT * prev
Definition: blobs.h:107
bool IsHidden() const
Definition: blobs.h:96
#define MAX_INT32
Definition: host.h:120
Definition: blobs.h:72
#define CROSS(a, b)
Definition: vecfuncs.h:54
TPOINT pos
Definition: blobs.h:100
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:74
#define MIN_INT32
Definition: host.h:128
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::Move ( const ICOORD  vec)

Definition at line 141 of file blobs.cpp.

141  {
142  EDGEPT* pt = loop;
143  do {
144  pt->pos.x += vec.x();
145  pt->pos.y += vec.y();
146  pt = pt->next;
147  } while (pt != loop);
148  SetupFromPos();
149 }
EDGEPT * next
Definition: blobs.h:106
inT16 x() const
access function
Definition: points.h:52
inT16 y() const
access_function
Definition: points.h:56
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
Definition: blobs.h:72
TPOINT pos
Definition: blobs.h:100
void SetupFromPos()
Definition: blobs.cpp:163
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::Normalize ( const DENORM denorm)

Definition at line 117 of file blobs.cpp.

117  {
118  EDGEPT* pt = loop;
119  do {
120  denorm.LocalNormTransform(pt->pos, &pt->pos);
121  pt = pt->next;
122  } while (pt != loop);
123  SetupFromPos();
124 }
EDGEPT * next
Definition: blobs.h:106
Definition: blobs.h:72
TPOINT pos
Definition: blobs.h:100
void LocalNormTransform(const TPOINT &pt, TPOINT *transformed) const
Definition: normalis.cpp:170
void SetupFromPos()
Definition: blobs.cpp:163
EDGEPT * loop
Definition: blobs.h:170
TESSLINE& TESSLINE::operator= ( const TESSLINE src)
inline

Definition at line 121 of file blobs.h.

121  {
122  CopyFrom(src);
123  return *this;
124  }
void CopyFrom(const TESSLINE &src)
Definition: blobs.cpp:76
void TESSLINE::plot ( ScrollView window,
ScrollView::Color  color,
ScrollView::Color  child_color 
)

Definition at line 228 of file blobs.cpp.

229  {
230  if (is_hole)
231  window->Pen(child_color);
232  else
233  window->Pen(color);
234  window->SetCursor(start.x, start.y);
235  EDGEPT* pt = loop;
236  do {
237  bool prev_hidden = pt->IsHidden();
238  pt = pt->next;
239  if (prev_hidden)
240  window->SetCursor(pt->pos.x, pt->pos.y);
241  else
242  window->DrawTo(pt->pos.x, pt->pos.y);
243  } while (pt != loop);
244 }
EDGEPT * next
Definition: blobs.h:106
void SetCursor(int x, int y)
Definition: scrollview.cpp:520
void Pen(Color color)
Definition: scrollview.cpp:721
inT16 y
Definition: blobs.h:68
bool IsHidden() const
Definition: blobs.h:96
inT16 x
Definition: blobs.h:67
TPOINT start
Definition: blobs.h:168
void DrawTo(int x, int y)
Definition: scrollview.cpp:526
Definition: blobs.h:72
bool is_hole
Definition: blobs.h:169
TPOINT pos
Definition: blobs.h:100
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::Rotate ( const FCOORD  rotation)

Definition at line 127 of file blobs.cpp.

127  {
128  EDGEPT* pt = loop;
129  do {
130  int tmp = static_cast<int>(floor(pt->pos.x * rot.x() -
131  pt->pos.y * rot.y() + 0.5));
132  pt->pos.y = static_cast<int>(floor(pt->pos.y * rot.x() +
133  pt->pos.x * rot.y() + 0.5));
134  pt->pos.x = tmp;
135  pt = pt->next;
136  } while (pt != loop);
137  SetupFromPos();
138 }
EDGEPT * next
Definition: blobs.h:106
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
Definition: blobs.h:72
TPOINT pos
Definition: blobs.h:100
void SetupFromPos()
Definition: blobs.cpp:163
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::Scale ( float  factor)

Definition at line 152 of file blobs.cpp.

152  {
153  EDGEPT* pt = loop;
154  do {
155  pt->pos.x = static_cast<int>(floor(pt->pos.x * factor + 0.5));
156  pt->pos.y = static_cast<int>(floor(pt->pos.y * factor + 0.5));
157  pt = pt->next;
158  } while (pt != loop);
159  SetupFromPos();
160 }
EDGEPT * next
Definition: blobs.h:106
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
Definition: blobs.h:72
TPOINT pos
Definition: blobs.h:100
void SetupFromPos()
Definition: blobs.cpp:163
EDGEPT * loop
Definition: blobs.h:170
void TESSLINE::SetupFromPos ( )

Definition at line 163 of file blobs.cpp.

163  {
164  EDGEPT* pt = loop;
165  do {
166  pt->vec.x = pt->next->pos.x - pt->pos.x;
167  pt->vec.y = pt->next->pos.y - pt->pos.y;
168  pt = pt->next;
169  } while (pt != loop);
170  start = pt->pos;
172 }
EDGEPT * next
Definition: blobs.h:106
VECTOR vec
Definition: blobs.h:101
void ComputeBoundingBox()
Definition: blobs.cpp:175
inT16 y
Definition: blobs.h:68
inT16 x
Definition: blobs.h:67
TPOINT start
Definition: blobs.h:168
Definition: blobs.h:72
TPOINT pos
Definition: blobs.h:100
EDGEPT * loop
Definition: blobs.h:170

Member Data Documentation

TPOINT TESSLINE::botright

Definition at line 167 of file blobs.h.

bool TESSLINE::is_hole

Definition at line 169 of file blobs.h.

EDGEPT* TESSLINE::loop

Definition at line 170 of file blobs.h.

TESSLINE* TESSLINE::next

Definition at line 171 of file blobs.h.

TPOINT TESSLINE::start

Definition at line 168 of file blobs.h.

TPOINT TESSLINE::topleft

Definition at line 166 of file blobs.h.


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