tesseract  4.0.0-1-g2a2b
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 192 of file paragraphs_internal.h.

Constructor & Destructor Documentation

◆ ParagraphTheory()

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

Definition at line 196 of file paragraphs_internal.h.

197  : models_(models) {}
GenericVector< ParagraphModel * > & models()

Member Function Documentation

◆ AddModel()

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

Definition at line 1227 of file paragraphs.cpp.

1227  {
1228  for (int i = 0; i < models_->size(); i++) {
1229  if ((*models_)[i]->Comparable(model))
1230  return (*models_)[i];
1231  }
1232  ParagraphModel *m = new ParagraphModel(model);
1233  models_->push_back(m);
1234  models_we_added_.push_back_new(m);
1235  return m;
1236 }
int size() const
Definition: genericvector.h:71
int push_back_new(const T &object)
int push_back(T object)

◆ DiscardUnusedModels()

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

Definition at line 1238 of file paragraphs.cpp.

1238  {
1239  for (int i = models_->size() - 1; i >= 0; i--) {
1240  ParagraphModel *m = (*models_)[i];
1241  if (!used_models.contains(m) && models_we_added_.contains(m)) {
1242  models_->remove(i);
1243  models_we_added_.remove(models_we_added_.get_index(m));
1244  delete m;
1245  }
1246  }
1247 }
int size() const
Definition: genericvector.h:71
void remove(int index)
bool contains(const T &object) const
int get_index(const T &object) const

◆ Fits()

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

Definition at line 1252 of file paragraphs.cpp.

1253  {
1254  for (int m = 0; m < models_->size(); m++) {
1255  const ParagraphModel *model = (*models_)[m];
1256  if (model->justification() != JUSTIFICATION_CENTER &&
1257  RowsFitModel(rows, start, end, model))
1258  return model;
1259  }
1260  return nullptr;
1261 }
int size() const
Definition: genericvector.h:71
tesseract::ParagraphJustification justification() const
Definition: ocrpara.h:164
bool RowsFitModel(const GenericVector< RowScratchRegisters > *rows, int start, int end, const ParagraphModel *model)

◆ IndexOf()

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

Definition at line 1271 of file paragraphs.cpp.

1271  {
1272  for (int i = 0; i < models_->size(); i++) {
1273  if ((*models_)[i] == model)
1274  return i;
1275  }
1276  return -1;
1277 }
int size() const
Definition: genericvector.h:71

◆ models() [1/2]

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

Definition at line 198 of file paragraphs_internal.h.

198 { return *models_; }

◆ models() [2/2]

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

Definition at line 199 of file paragraphs_internal.h.

199 { return *models_; }

◆ NonCenteredModels()

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

Definition at line 1263 of file paragraphs.cpp.

1263  {
1264  for (int m = 0; m < models_->size(); m++) {
1265  const ParagraphModel *model = (*models_)[m];
1266  if (model->justification() != JUSTIFICATION_CENTER)
1267  models->push_back_new(model);
1268  }
1269 }
GenericVector< ParagraphModel * > & models()
int size() const
Definition: genericvector.h:71
tesseract::ParagraphJustification justification() const
Definition: ocrpara.h:164
int push_back_new(const T &object)

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