tesseract  4.0.0-1-g2a2b
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 71 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 117 of file tabvector.cpp.

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

◆ CompatibleConstraints()

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

Definition at line 76 of file tabvector.cpp.

77  {
78  if (list1 == list2)
79  return false;
80  int y_min = -INT32_MAX;
81  int y_max = INT32_MAX;
82  if (textord_debug_tabfind > 3)
83  tprintf("Testing constraint compatibility\n");
84  GetConstraints(list1, &y_min, &y_max);
85  GetConstraints(list2, &y_min, &y_max);
86  if (textord_debug_tabfind > 3)
87  tprintf("Resulting range = [%d,%d]\n", y_min, y_max);
88  return y_max >= y_min;
89 }
int textord_debug_tabfind
Definition: alignedblob.cpp:28
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37

◆ CreateConstraint()

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

Definition at line 64 of file tabvector.cpp.

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

◆ MergeConstraints()

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

Definition at line 93 of file tabvector.cpp.

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

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