Tesseract  3.02
tesseract::TabConstraint Class Reference

#include <tabvector.h>

Inheritance diagram for tesseract::TabConstraint:
ELIST_LINK

List of all members.

Public Member Functions

 TabConstraint ()

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.

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

Member Function Documentation

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

Definition at line 120 of file tabvector.cpp.

                                                                    {
  int y_min = -MAX_INT32;
  int y_max = MAX_INT32;
  GetConstraints(constraints, &y_min, &y_max);
  int y = (y_min + y_max) / 2;
  TabConstraint_IT it(constraints);
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    TabConstraint* constraint = it.data();
    TabVector* v = constraint->vector_;
    if (constraint->is_top_) {
      v->SetYEnd(y);
      v->set_top_constraints(NULL);
    } else {
      v->SetYStart(y);
      v->set_bottom_constraints(NULL);
    }
  }
  delete constraints;
}
bool tesseract::TabConstraint::CompatibleConstraints ( TabConstraint_LIST *  list1,
TabConstraint_LIST *  list2 
) [static]

Definition at line 79 of file tabvector.cpp.

                                                                     {
  if (list1 == list2)
    return false;
  int y_min = -MAX_INT32;
  int y_max = MAX_INT32;
  if (textord_debug_tabfind > 3)
    tprintf("Testing constraint compatibility\n");
  GetConstraints(list1, &y_min, &y_max);
  GetConstraints(list2, &y_min, &y_max);
  if (textord_debug_tabfind > 3)
    tprintf("Resulting range = [%d,%d]\n", y_min, y_max);
  return y_max >= y_min;
}
void tesseract::TabConstraint::CreateConstraint ( TabVector vector,
bool  is_top 
) [static]

Definition at line 67 of file tabvector.cpp.

                                                                   {
  TabConstraint* constraint = new TabConstraint(vector, is_top);
  TabConstraint_LIST* constraints = new TabConstraint_LIST;
  TabConstraint_IT it(constraints);
  it.add_to_end(constraint);
  if (is_top)
    vector->set_top_constraints(constraints);
  else
    vector->set_bottom_constraints(constraints);
}
void tesseract::TabConstraint::MergeConstraints ( TabConstraint_LIST *  list1,
TabConstraint_LIST *  list2 
) [static]

Definition at line 96 of file tabvector.cpp.

                                                                {
  if (list1 == list2)
    return;
  TabConstraint_IT it(list2);
  if (textord_debug_tabfind > 3)
    tprintf("Merging constraints\n");
  // The vectors of all constraints on list2 are now going to be on list1.
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    TabConstraint* constraint = it.data();
    if (textord_debug_tabfind> 3)
      constraint->vector_->Print("Merge");
    if (constraint->is_top_)
      constraint->vector_->set_top_constraints(list1);
    else
      constraint->vector_->set_bottom_constraints(list1);
  }
  it = list1;
  it.add_list_before(list2);
  delete list2;
}

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