Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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

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

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

Definition at line 120 of file tabvector.cpp.

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

Definition at line 79 of file tabvector.cpp.

80  {
81  if (list1 == list2)
82  return false;
83  int y_min = -MAX_INT32;
84  int y_max = MAX_INT32;
85  if (textord_debug_tabfind > 3)
86  tprintf("Testing constraint compatibility\n");
87  GetConstraints(list1, &y_min, &y_max);
88  GetConstraints(list2, &y_min, &y_max);
89  if (textord_debug_tabfind > 3)
90  tprintf("Resulting range = [%d,%d]\n", y_min, y_max);
91  return y_max >= y_min;
92 }
int textord_debug_tabfind
Definition: alignedblob.cpp:28
#define MAX_INT32
Definition: host.h:120
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:41
void tesseract::TabConstraint::CreateConstraint ( TabVector vector,
bool  is_top 
)
static

Definition at line 67 of file tabvector.cpp.

67  {
68  TabConstraint* constraint = new TabConstraint(vector, is_top);
69  TabConstraint_LIST* constraints = new TabConstraint_LIST;
70  TabConstraint_IT it(constraints);
71  it.add_to_end(constraint);
72  if (is_top)
73  vector->set_top_constraints(constraints);
74  else
75  vector->set_bottom_constraints(constraints);
76 }
void tesseract::TabConstraint::MergeConstraints ( TabConstraint_LIST *  list1,
TabConstraint_LIST *  list2 
)
static

Definition at line 96 of file tabvector.cpp.

97  {
98  if (list1 == list2)
99  return;
100  TabConstraint_IT it(list2);
101  if (textord_debug_tabfind > 3)
102  tprintf("Merging constraints\n");
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  if (constraint->is_top_)
109  constraint->vector_->set_top_constraints(list1);
110  else
111  constraint->vector_->set_bottom_constraints(list1);
112  }
113  it = list1;
114  it.add_list_before(list2);
115  delete list2;
116 }
int textord_debug_tabfind
Definition: alignedblob.cpp:28
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:41

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