tesseract  4.00.00dev
tesseract::TabConstraint Class Reference

#include <tabvector.h>

Inheritance diagram for tesseract::TabConstraint:
ELIST_LINK

Public Member Functions

 TabConstraint ()
 
- 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 69 of file tabvector.h.

Constructor & Destructor Documentation

◆ TabConstraint()

tesseract::TabConstraint::TabConstraint ( )
inline

Definition at line 71 of file tabvector.h.

71  {
72  // This empty constructor is here only so that the class can be ELISTIZED.
73  // TODO(rays) change deep_copy in elst.h line 955 to take a callback copier
74  // and eliminate CLASSNAME##_copier.
75  }

Member Function Documentation

◆ ApplyConstraints()

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

Definition at line 119 of file tabvector.cpp.

119  {
120  int y_min = -MAX_INT32;
121  int y_max = MAX_INT32;
122  GetConstraints(constraints, &y_min, &y_max);
123  int y = (y_min + y_max) / 2;
124  TabConstraint_IT it(constraints);
125  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
126  TabConstraint* constraint = it.data();
127  TabVector* v = constraint->vector_;
128  if (constraint->is_top_) {
129  v->SetYEnd(y);
130  v->set_top_constraints(NULL);
131  } else {
132  v->SetYStart(y);
133  v->set_bottom_constraints(NULL);
134  }
135  }
136  delete constraints;
137 }
#define MAX_INT32
Definition: host.h:62
double v[max]

◆ CompatibleConstraints()

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

Definition at line 78 of file tabvector.cpp.

79  {
80  if (list1 == list2)
81  return false;
82  int y_min = -MAX_INT32;
83  int y_max = MAX_INT32;
84  if (textord_debug_tabfind > 3)
85  tprintf("Testing constraint compatibility\n");
86  GetConstraints(list1, &y_min, &y_max);
87  GetConstraints(list2, &y_min, &y_max);
88  if (textord_debug_tabfind > 3)
89  tprintf("Resulting range = [%d,%d]\n", y_min, y_max);
90  return y_max >= y_min;
91 }
#define MAX_INT32
Definition: host.h:62
#define tprintf(...)
Definition: tprintf.h:31
int textord_debug_tabfind
Definition: alignedblob.cpp:27

◆ CreateConstraint()

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

Definition at line 66 of file tabvector.cpp.

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

◆ MergeConstraints()

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

Definition at line 95 of file tabvector.cpp.

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

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