tesseract  5.0.0
tesseract::TabConstraint Class Reference

#include <tabvector.h>

Inheritance diagram for tesseract::TabConstraint:
tesseract::ELIST_LINK

Public Member Functions

 TabConstraint ()=default
 
- Public Member Functions inherited from tesseract::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 67 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 122 of file tabvector.cpp.

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

◆ CompatibleConstraints()

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

Definition at line 76 of file tabvector.cpp.

76  {
77  if (list1 == list2) {
78  return false;
79  }
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  }
85  GetConstraints(list1, &y_min, &y_max);
86  GetConstraints(list2, &y_min, &y_max);
87  if (textord_debug_tabfind > 3) {
88  tprintf("Resulting range = [%d,%d]\n", y_min, y_max);
89  }
90  return y_max >= y_min;
91 }
void tprintf(const char *format,...)
Definition: tprintf.cpp:41
int textord_debug_tabfind
Definition: alignedblob.cpp:29

◆ 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  }
73 }

◆ MergeConstraints()

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

Definition at line 95 of file tabvector.cpp.

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

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