tesseract  5.0.0-alpha-619-ge9db
tesseract::TabConstraint Class Reference

#include <tabvector.h>

Inheritance diagram for tesseract::TabConstraint:
ELIST_LINK

Public Member Functions

 TabConstraint ()=default
 
- Public Member Functions inherited from ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Static Public Member Functions

static void CreateConstraint (TabVector *vector, bool is_top)
 
static bool CompatibleConstraints (TabConstraint_LIST *list1, TabConstraint_LIST *list2)
 
static void MergeConstraints (TabConstraint_LIST *list1, TabConstraint_LIST *list2)
 
static void ApplyConstraints (TabConstraint_LIST *constraints)
 

Detailed Description

Definition at line 70 of file tabvector.h.

Constructor & Destructor Documentation

◆ TabConstraint()

tesseract::TabConstraint::TabConstraint ( )
default

Member Function Documentation

◆ ApplyConstraints()

void tesseract::TabConstraint::ApplyConstraints ( TabConstraint_LIST *  constraints)
static

Definition at line 116 of file tabvector.cpp.

116  {
117  int y_min = -INT32_MAX;
118  int y_max = INT32_MAX;
119  GetConstraints(constraints, &y_min, &y_max);
120  int y = (y_min + y_max) / 2;
121  TabConstraint_IT it(constraints);
122  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
123  TabConstraint* constraint = it.data();
124  TabVector* v = constraint->vector_;
125  if (constraint->is_top_) {
126  v->SetYEnd(y);
127  v->set_top_constraints(nullptr);
128  } else {
129  v->SetYStart(y);
130  v->set_bottom_constraints(nullptr);
131  }
132  }
133  delete constraints;
134 }

◆ CompatibleConstraints()

bool tesseract::TabConstraint::CompatibleConstraints ( TabConstraint_LIST *  list1,
TabConstraint_LIST *  list2 
)
static

Definition at line 75 of file tabvector.cpp.

76  {
77  if (list1 == list2)
78  return false;
79  int y_min = -INT32_MAX;
80  int y_max = INT32_MAX;
81  if (textord_debug_tabfind > 3)
82  tprintf("Testing constraint compatibility\n");
83  GetConstraints(list1, &y_min, &y_max);
84  GetConstraints(list2, &y_min, &y_max);
85  if (textord_debug_tabfind > 3)
86  tprintf("Resulting range = [%d,%d]\n", y_min, y_max);
87  return y_max >= y_min;
88 }

◆ CreateConstraint()

void tesseract::TabConstraint::CreateConstraint ( TabVector vector,
bool  is_top 
)
static

Definition at line 63 of file tabvector.cpp.

63  {
64  auto* constraint = new TabConstraint(vector, is_top);
65  auto* constraints = new TabConstraint_LIST;
66  TabConstraint_IT it(constraints);
67  it.add_to_end(constraint);
68  if (is_top)
69  vector->set_top_constraints(constraints);
70  else
71  vector->set_bottom_constraints(constraints);
72 }

◆ MergeConstraints()

void tesseract::TabConstraint::MergeConstraints ( TabConstraint_LIST *  list1,
TabConstraint_LIST *  list2 
)
static

Definition at line 92 of file tabvector.cpp.

93  {
94  if (list1 == list2)
95  return;
96  TabConstraint_IT it(list2);
97  if (textord_debug_tabfind > 3)
98  tprintf("Merging constraints\n");
99  // The vectors of all constraints on list2 are now going to be on list1.
100  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
101  TabConstraint* constraint = it.data();
102  if (textord_debug_tabfind> 3)
103  constraint->vector_->Print("Merge");
104  if (constraint->is_top_)
105  constraint->vector_->set_top_constraints(list1);
106  else
107  constraint->vector_->set_bottom_constraints(list1);
108  }
109  it = list1;
110  it.add_list_before(list2);
111  delete list2;
112 }

The documentation for this class was generated from the following files:
tesseract::TabConstraint::TabConstraint
TabConstraint()=default
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34
textord_debug_tabfind
int textord_debug_tabfind
Definition: alignedblob.cpp:27