All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tesseract::ParagraphTheory Class Reference

#include <paragraphs_internal.h>

Public Member Functions

 ParagraphTheory (GenericVector< ParagraphModel * > *models)
 
GenericVector< ParagraphModel * > & models ()
 
const GenericVector
< ParagraphModel * > & 
models () const
 
const ParagraphModelAddModel (const ParagraphModel &model)
 
void DiscardUnusedModels (const SetOfModels &used_models)
 
void NonCenteredModels (SetOfModels *models)
 
const ParagraphModelFits (const GenericVector< RowScratchRegisters > *rows, int start, int end) const
 
int IndexOf (const ParagraphModel *model) const
 

Detailed Description

Definition at line 189 of file paragraphs_internal.h.

Constructor & Destructor Documentation

tesseract::ParagraphTheory::ParagraphTheory ( GenericVector< ParagraphModel * > *  models)
inlineexplicit

Definition at line 193 of file paragraphs_internal.h.

194  : models_(models) {}

Member Function Documentation

const ParagraphModel * tesseract::ParagraphTheory::AddModel ( const ParagraphModel model)

Definition at line 1214 of file paragraphs.cpp.

1214  {
1215  for (int i = 0; i < models_->size(); i++) {
1216  if ((*models_)[i]->Comparable(model))
1217  return (*models_)[i];
1218  }
1219  ParagraphModel *m = new ParagraphModel(model);
1220  models_->push_back(m);
1221  models_we_added_.push_back_new(m);
1222  return m;
1223 }
int size() const
Definition: genericvector.h:72
int push_back(T object)
int push_back_new(T object)
void tesseract::ParagraphTheory::DiscardUnusedModels ( const SetOfModels used_models)

Definition at line 1225 of file paragraphs.cpp.

1225  {
1226  for (int i = models_->size() - 1; i >= 0; i--) {
1227  ParagraphModel *m = (*models_)[i];
1228  if (!used_models.contains(m) && models_we_added_.contains(m)) {
1229  models_->remove(i);
1230  models_we_added_.remove(models_we_added_.get_index(m));
1231  delete m;
1232  }
1233  }
1234 }
int size() const
Definition: genericvector.h:72
bool contains(T object) const
void remove(int index)
int get_index(T object) const
const ParagraphModel * tesseract::ParagraphTheory::Fits ( const GenericVector< RowScratchRegisters > *  rows,
int  start,
int  end 
) const

Definition at line 1239 of file paragraphs.cpp.

1240  {
1241  for (int m = 0; m < models_->size(); m++) {
1242  const ParagraphModel *model = (*models_)[m];
1243  if (model->justification() != JUSTIFICATION_CENTER &&
1244  RowsFitModel(rows, start, end, model))
1245  return model;
1246  }
1247  return NULL;
1248 }
int size() const
Definition: genericvector.h:72
bool RowsFitModel(const GenericVector< RowScratchRegisters > *rows, int start, int end, const ParagraphModel *model)
tesseract::ParagraphJustification justification() const
Definition: ocrpara.h:164
#define NULL
Definition: host.h:144
int tesseract::ParagraphTheory::IndexOf ( const ParagraphModel model) const

Definition at line 1258 of file paragraphs.cpp.

1258  {
1259  for (int i = 0; i < models_->size(); i++) {
1260  if ((*models_)[i] == model)
1261  return i;
1262  }
1263  return -1;
1264 }
int size() const
Definition: genericvector.h:72
GenericVector<ParagraphModel *>& tesseract::ParagraphTheory::models ( )
inline

Definition at line 195 of file paragraphs_internal.h.

195 { return *models_; }
const GenericVector<ParagraphModel *>& tesseract::ParagraphTheory::models ( ) const
inline

Definition at line 196 of file paragraphs_internal.h.

196 { return *models_; }
void tesseract::ParagraphTheory::NonCenteredModels ( SetOfModels models)

Definition at line 1250 of file paragraphs.cpp.

1250  {
1251  for (int m = 0; m < models_->size(); m++) {
1252  const ParagraphModel *model = (*models_)[m];
1253  if (model->justification() != JUSTIFICATION_CENTER)
1254  models->push_back_new(model);
1255  }
1256 }
int size() const
Definition: genericvector.h:72
GenericVector< ParagraphModel * > & models()
tesseract::ParagraphJustification justification() const
Definition: ocrpara.h:164
int push_back_new(T object)

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