tesseract  4.00.00dev
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

◆ ParagraphTheory()

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

Definition at line 193 of file paragraphs_internal.h.

194  : models_(models) {}

Member Function Documentation

◆ AddModel()

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

Definition at line 1215 of file paragraphs.cpp.

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

◆ DiscardUnusedModels()

void tesseract::ParagraphTheory::DiscardUnusedModels ( const SetOfModels used_models)

Definition at line 1226 of file paragraphs.cpp.

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

◆ Fits()

const ParagraphModel * tesseract::ParagraphTheory::Fits ( const GenericVector< RowScratchRegisters > *  rows,
int  start,
int  end 
) const

Definition at line 1240 of file paragraphs.cpp.

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

◆ IndexOf()

int tesseract::ParagraphTheory::IndexOf ( const ParagraphModel model) const

Definition at line 1259 of file paragraphs.cpp.

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

◆ models() [1/2]

GenericVector<ParagraphModel *>& tesseract::ParagraphTheory::models ( )
inline

Definition at line 195 of file paragraphs_internal.h.

195 { return *models_; }

◆ models() [2/2]

const GenericVector<ParagraphModel *>& tesseract::ParagraphTheory::models ( ) const
inline

Definition at line 196 of file paragraphs_internal.h.

196 { return *models_; }

◆ NonCenteredModels()

void tesseract::ParagraphTheory::NonCenteredModels ( SetOfModels models)

Definition at line 1251 of file paragraphs.cpp.

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

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