tesseract
3.03
|
#include <blobs.h>
Public Member Functions | |
TESSLINE () | |
TESSLINE (const TESSLINE &src) | |
~TESSLINE () | |
TESSLINE & | operator= (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) |
EDGEPT * | FindBestStartPt () const |
int | BBArea () const |
Static Public Member Functions | |
static TESSLINE * | BuildFromOutlineList (EDGEPT *outline) |
Public Attributes | |
TPOINT | topleft |
TPOINT | botright |
TPOINT | start |
bool | is_hole |
EDGEPT * | loop |
TESSLINE * | next |
TESSLINE::TESSLINE | ( | ) | [inline] |
TESSLINE::TESSLINE | ( | const TESSLINE & | src | ) | [inline] |
TESSLINE::~TESSLINE | ( | ) | [inline] |
int TESSLINE::BBArea | ( | ) | const [inline] |
TBOX TESSLINE::bounding_box | ( | ) | const |
TESSLINE * TESSLINE::BuildFromOutlineList | ( | EDGEPT * | outline | ) | [static] |
Definition at line 68 of file blobs.cpp.
{ TESSLINE* result = new TESSLINE; result->loop = outline; if (outline->src_outline != NULL) { // ASSUMPTION: This function is only ever called from ApproximateOutline // and therefore either all points have a src_outline or all do not. // Just as SetupFromPos sets the vectors from the vertices, setup the // step_count members to indicate the (positive) number of original // C_OUTLINE steps to the next vertex. EDGEPT* pt = outline; do { pt->step_count = pt->next->start_step - pt->start_step; if (pt->step_count < 0) pt->step_count += pt->src_outline->pathlength(); pt = pt->next; } while (pt != outline); } result->SetupFromPos(); return result; }
void TESSLINE::Clear | ( | ) |
void TESSLINE::ComputeBoundingBox | ( | ) |
Definition at line 189 of file blobs.cpp.
{ int minx = MAX_INT32; int miny = MAX_INT32; int maxx = -MAX_INT32; int maxy = -MAX_INT32; // Find boundaries. start = loop->pos; EDGEPT* this_edge = loop; do { if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) { if (this_edge->pos.x < minx) minx = this_edge->pos.x; if (this_edge->pos.y < miny) miny = this_edge->pos.y; if (this_edge->pos.x > maxx) maxx = this_edge->pos.x; if (this_edge->pos.y > maxy) maxy = this_edge->pos.y; } this_edge = this_edge->next; } while (this_edge != loop); // Reset bounds. topleft.x = minx; topleft.y = maxy; botright.x = maxx; botright.y = miny; }
bool TESSLINE::Contains | ( | const TPOINT & | pt | ) | [inline] |
void TESSLINE::CopyFrom | ( | const TESSLINE & | src | ) |
Definition at line 90 of file blobs.cpp.
{ Clear(); topleft = src.topleft; botright = src.botright; start = src.start; is_hole = src.is_hole; if (src.loop != NULL) { EDGEPT* prevpt = NULL; EDGEPT* newpt = NULL; EDGEPT* srcpt = src.loop; do { newpt = new EDGEPT(*srcpt); if (prevpt == NULL) { loop = newpt; } else { newpt->prev = prevpt; prevpt->next = newpt; } prevpt = newpt; srcpt = srcpt->next; } while (srcpt != src.loop); loop->prev = newpt; newpt->next = loop; } }
EDGEPT * TESSLINE::FindBestStartPt | ( | ) | const |
Definition at line 263 of file blobs.cpp.
{ EDGEPT* best_start = loop; int best_step = loop->start_step; // Iterate the polygon. EDGEPT* pt = loop; do { if (pt->IsHidden()) continue; if (pt->prev->IsHidden() || pt->prev->src_outline != pt->src_outline) return pt; // Qualifies as the best. if (pt->start_step < best_step) { best_step = pt->start_step; best_start = pt; } } while ((pt = pt->next) != loop); return best_start; }
void TESSLINE::MinMaxCrossProduct | ( | const TPOINT | vec, |
int * | min_xp, | ||
int * | max_xp | ||
) | const |
void TESSLINE::Move | ( | const ICOORD | vec | ) |
void TESSLINE::Normalize | ( | const DENORM & | denorm | ) |
Definition at line 131 of file blobs.cpp.
{ EDGEPT* pt = loop; do { denorm.LocalNormTransform(pt->pos, &pt->pos); pt = pt->next; } while (pt != loop); SetupFromPos(); }
void TESSLINE::plot | ( | ScrollView * | window, |
ScrollView::Color | color, | ||
ScrollView::Color | child_color | ||
) |
Definition at line 242 of file blobs.cpp.
{ if (is_hole) window->Pen(child_color); else window->Pen(color); window->SetCursor(start.x, start.y); EDGEPT* pt = loop; do { bool prev_hidden = pt->IsHidden(); pt = pt->next; if (prev_hidden) window->SetCursor(pt->pos.x, pt->pos.y); else window->DrawTo(pt->pos.x, pt->pos.y); } while (pt != loop); }
void TESSLINE::Rotate | ( | const FCOORD | rotation | ) |
void TESSLINE::Scale | ( | float | factor | ) |
void TESSLINE::SetupFromPos | ( | ) |
bool TESSLINE::is_hole |