19#ifndef TESSERACT_TEXTORD_TABVECTOR_H_
20#define TESSERACT_TEXTORD_TABVECTOR_H_
75 static void CreateConstraint(
TabVector *vector,
bool is_top);
78 static bool CompatibleConstraints(TabConstraint_LIST *list1, TabConstraint_LIST *list2);
82 static void MergeConstraints(TabConstraint_LIST *list1, TabConstraint_LIST *list2);
86 static void ApplyConstraints(TabConstraint_LIST *constraints);
92 static void GetConstraints(TabConstraint_LIST *constraints,
int *y_min,
int *y_max);
121 int extended_end_y, BLOBNBOX_CLIST *good_points,
int *vertical_x,
145 return extended_ymax_;
148 return extended_ymin_;
157 top_constraints_ = constraints;
160 bottom_constraints_ = constraints;
172 return intersects_other_lines_;
175 intersects_other_lines_ =
value;
182 int height = endpt_.
y() - startpt_.
y();
184 return (
y - startpt_.
y()) * (endpt_.
x() - startpt_.
x()) / height + startpt_.
x();
192 return std::min(other.endpt_.
y(), endpt_.
y()) - std::max(other.startpt_.
y(), startpt_.
y());
196 return std::min(top_y,
static_cast<int>(endpt_.
y())) -
197 std::max(bottom_y,
static_cast<int>(startpt_.
y()));
201 return std::min(top_y, extended_ymax_) - std::max(bottom_y, extended_ymin_);
228 return sort_key_ < other.sort_key_;
233 return partners_.empty();
238 return boxes_.length();
243 boxes_.shallow_clear();
248 int x = startpt_.
y();
249 startpt_.
set_y(startpt_.
x());
258 startpt_.
set_x(-startpt_.
x());
259 endpt_.
set_x(-endpt_.
x());
260 sort_key_ = -sort_key_;
276 return pt * vertical;
281 if (vertical.
y() != 0) {
282 return (vertical.
x() *
y +
sort_key) / vertical.
y();
292 return tv1->sort_key_ - tv2->sort_key_;
343 void Print(
const char *prefix);
346 void Debug(
const char *prefix);
367 bool Fit(
ICOORD vertical,
bool force_parallel);
394 int extended_ymin_ = 0;
396 int extended_ymax_ = 0;
400 int percent_score_ = 0;
404 bool needs_refit_ =
false;
406 bool needs_evaluation_ =
false;
408 bool intersects_other_lines_ =
false;
412 BLOBNBOX_CLIST boxes_;
414 TabVector_CLIST partners_;
417 TabConstraint_LIST *top_constraints_ =
nullptr;
418 TabConstraint_LIST *bottom_constraints_ =
nullptr;
#define ELISTIZEH(CLASSNAME)
#define CLISTIZEH(CLASSNAME)
#define ELIST2IZEH(CLASSNAME)
double textord_tabvector_vertical_gap_fraction
double_VAR_H(classify_min_slope)
double textord_tabvector_vertical_box_ratio
void set_x(TDimension xin)
rewrite function
TDimension y() const
access_function
void set_y(TDimension yin)
rewrite function
TDimension x() const
access function
void set_bottom_constraints(TabConstraint_LIST *constraints)
static int SortKey(const ICOORD &vertical, int x, int y)
const ICOORD & endpt() const
void Rotate(const FCOORD &rotation)
void set_startpt(const ICOORD &start)
void AddPartner(TabVector *partner)
void set_endpt(const ICOORD &end)
static void MergeSimilarTabVectors(const ICOORD &vertical, TabVector_LIST *vectors, BlobGrid *grid)
int ExtendedOverlap(int top_y, int bottom_y) const
int extended_ymin() const
void set_intersects_other_lines(bool value)
bool IsAPartner(const TabVector *other)
bool intersects_other_lines() const
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)
TabVector_CLIST * partners()
TabVector * VerticalTextlinePartner()
static int XAtY(const ICOORD &vertical, int sort_key, int y)
void Evaluate(const ICOORD &vertical, TabFind *finder)
int extended_ymax() const
void SetupPartnerConstraints()
void set_top_constraints(TabConstraint_LIST *constraints)
bool Fit(ICOORD vertical, bool force_parallel)
void SetYStart(int start_y)
void Print(const char *prefix)
void FitAndEvaluateIfNeeded(const ICOORD &vertical, TabFind *finder)
const ICOORD & startpt() const
void Display(ScrollView *tab_win)
int VOverlap(const TabVector &other) const
TabVector * ShallowCopy() const
void MergeWith(const ICOORD &vertical, TabVector *other)
bool IsLeftOf(const TabVector &other) const
int VOverlap(int top_y, int bottom_y) const
static int SortVectorsByKey(const void *v1, const void *v2)
void Debug(const char *prefix)
TabVector * GetSinglePartner()
void ExtendToBox(BLOBNBOX *blob)
bool SimilarTo(const ICOORD &vertical, const TabVector &other, BlobGrid *grid) const