20 #ifndef TESSERACT_TEXTORD_TABVECTOR_H__ 21 #define TESSERACT_TEXTORD_TABVECTOR_H__ 37 "Max fraction of mean blob width allowed for vertical gaps in vertical text");
39 "Fraction of box matches required to declare a line vertical");
78 static void CreateConstraint(
TabVector* vector,
bool is_top);
81 static bool CompatibleConstraints(TabConstraint_LIST* list1,
82 TabConstraint_LIST* list2);
86 static void MergeConstraints(TabConstraint_LIST* list1,
87 TabConstraint_LIST* list2);
91 static void ApplyConstraints(TabConstraint_LIST* constraints);
97 static void GetConstraints(TabConstraint_LIST* constraints,
98 int* y_min,
int* y_max);
128 int extended_start_y,
int extended_end_y,
129 BLOBNBOX_CLIST* good_points,
130 int* vertical_x,
int* vertical_y);
153 return extended_ymax_;
156 return extended_ymin_;
165 top_constraints_ = constraints;
168 bottom_constraints_ = constraints;
180 return intersects_other_lines_;
183 intersects_other_lines_ = value;
190 int height = endpt_.
y() - startpt_.
y();
192 return (y - startpt_.
y()) * (endpt_.
x() - startpt_.
x()) / height +
200 return MIN(other.endpt_.
y(), endpt_.
y()) -
201 MAX(other.startpt_.
y(), startpt_.
y());
205 return MIN(top_y, endpt_.
y()) -
MAX(bottom_y, startpt_.
y());
209 return MIN(top_y, extended_ymax_) -
MAX(bottom_y, extended_ymin_);
236 return sort_key_ < other.sort_key_;
241 return partners_.empty();
246 return boxes_.length();
251 boxes_.shallow_clear();
256 int x = startpt_.
y();
257 startpt_.
set_y(startpt_.
x());
266 startpt_.
set_x(-startpt_.
x());
267 endpt_.
set_x(-endpt_.
x());
268 sort_key_ = -sort_key_;
282 return pt * vertical;
287 if (vertical.
y() != 0)
288 return (vertical.
x() * y +
sort_key) / vertical.
y();
297 return tv1->sort_key_ - tv2->sort_key_;
329 TabVector_LIST* vectors,
BlobGrid* grid);
349 void Print(
const char* prefix);
352 void Debug(
const char* prefix);
373 bool Fit(
ICOORD vertical,
bool force_parallel);
413 bool needs_evaluation_;
415 bool intersects_other_lines_;
419 BLOBNBOX_CLIST boxes_;
421 TabVector_CLIST partners_;
424 TabConstraint_LIST* top_constraints_;
425 TabConstraint_LIST* bottom_constraints_;
430 #endif // TESSERACT_TEXTORD_TABVECTOR_H__ void AddPartner(TabVector *partner)
void Display(ScrollView *tab_win)
#define CLISTIZEH(CLASSNAME)
void set_intersects_other_lines(bool value)
bool intersects_other_lines() const
void set_bottom_constraints(TabConstraint_LIST *constraints)
double textord_tabvector_vertical_gap_fraction
static int SortVectorsByKey(const void *v1, const void *v2)
void MergeWith(const ICOORD &vertical, TabVector *other)
void set_top_constraints(TabConstraint_LIST *constraints)
void FitAndEvaluateIfNeeded(const ICOORD &vertical, TabFind *finder)
bool SimilarTo(const ICOORD &vertical, const TabVector &other, BlobGrid *grid) const
bool IsLeftOf(const TabVector &other) const
static int SortKey(const ICOORD &vertical, int x, int y)
void Evaluate(const ICOORD &vertical, TabFind *finder)
int ExtendedOverlap(int top_y, int bottom_y) const
void Debug(const char *prefix)
TabVector * GetSinglePartner()
int VOverlap(const TabVector &other) const
bool Fit(ICOORD vertical, bool force_parallel)
void set_startpt(const ICOORD &start)
int extended_ymin() const
void SetYStart(int start_y)
static void MergeSimilarTabVectors(const ICOORD &vertical, TabVector_LIST *vectors, BlobGrid *grid)
inT16 x() const
access function
void Rotate(const FCOORD &rotation)
void Print(const char *prefix)
#define ELIST2IZEH(CLASSNAME)
bool IsAPartner(const TabVector *other)
TabVector_CLIST * partners()
static TabVector * FitVector(TabAlignment alignment, ICOORD vertical, int extended_start_y, int extended_end_y, BLOBNBOX_CLIST *good_points, int *vertical_x, int *vertical_y)
double textord_tabvector_vertical_box_ratio
TabVector * VerticalTextlinePartner()
TabVector * ShallowCopy() const
void set_y(inT16 yin)
rewrite function
void SetupPartnerConstraints()
const ICOORD & startpt() const
void set_x(inT16 xin)
rewrite function
const ICOORD & endpt() const
int VOverlap(int top_y, int bottom_y) const
static int XAtY(const ICOORD &vertical, int sort_key, int y)
void ExtendToBox(BLOBNBOX *blob)
int extended_ymax() const
#define double_VAR_H(name, val, comment)
void set_endpt(const ICOORD &end)
inT16 y() const
access_function