tesseract 4.1.1
Loading...
Searching...
No Matches
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 1225 of file paragraphs.cpp.

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

◆ DiscardUnusedModels()

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

Definition at line 1236 of file paragraphs.cpp.

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

◆ Fits()

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

Definition at line 1250 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 RowsFitModel(rows, start, end, model))
1256 return model;
1257 }
1258 return nullptr;
1259}
@ JUSTIFICATION_CENTER
Definition: publictypes.h:254
bool RowsFitModel(const GenericVector< RowScratchRegisters > *rows, int start, int end, const ParagraphModel *model)
tesseract::ParagraphJustification justification() const
Definition: ocrpara.h:164

◆ IndexOf()

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

Definition at line 1269 of file paragraphs.cpp.

1269 {
1270 for (int i = 0; i < models_->size(); i++) {
1271 if ((*models_)[i] == model)
1272 return i;
1273 }
1274 return -1;
1275}

◆ 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 1261 of file paragraphs.cpp.

1261 {
1262 for (int m = 0; m < models_->size(); m++) {
1263 const ParagraphModel *model = (*models_)[m];
1264 if (model->justification() != JUSTIFICATION_CENTER)
1265 models->push_back_new(model);
1266 }
1267}

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