Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tesseract::RowScratchRegisters Class Reference

#include <paragraphs_internal.h>

List of all members.

Public Member Functions

void Init (const RowInfo &row)
LineType GetLineType () const
LineType GetLineType (const ParagraphModel *model) const
void SetStartLine ()
void SetBodyLine ()
void AddStartLine (const ParagraphModel *model)
void AddBodyLine (const ParagraphModel *model)
void SetUnknown ()
void StartHypotheses (SetOfModels *models) const
void StrongHypotheses (SetOfModels *models) const
void NonNullHypotheses (SetOfModels *models) const
void DiscardNonMatchingHypotheses (const SetOfModels &models)
const ParagraphModelUniqueStartHypothesis () const
const ParagraphModelUniqueBodyHypothesis () const
int OffsideIndent (tesseract::ParagraphJustification just) const
int AlignsideIndent (tesseract::ParagraphJustification just) const
void AppendDebugInfo (const ParagraphTheory &theory, GenericVector< STRING > *dbg) const

Static Public Member Functions

static void AppendDebugHeaderFields (GenericVector< STRING > *header)

Public Attributes

const RowInfori_
int lmargin_
int lindent_
int rindent_
int rmargin_

Detailed Description

Definition at line 100 of file paragraphs_internal.h.


Member Function Documentation

void tesseract::RowScratchRegisters::AddBodyLine ( const ParagraphModel model)

Definition at line 601 of file paragraphs.cpp.

{
hypotheses_.push_back_new(LineHypothesis(LT_BODY, model));
int old_idx = hypotheses_.get_index(LineHypothesis(LT_BODY, NULL));
if (old_idx >= 0)
hypotheses_.remove(old_idx);
}
void tesseract::RowScratchRegisters::AddStartLine ( const ParagraphModel model)

Definition at line 594 of file paragraphs.cpp.

{
hypotheses_.push_back_new(LineHypothesis(LT_START, model));
int old_idx = hypotheses_.get_index(LineHypothesis(LT_START, NULL));
if (old_idx >= 0)
hypotheses_.remove(old_idx);
}
int tesseract::RowScratchRegisters::AlignsideIndent ( tesseract::ParagraphJustification  just) const
inline

Definition at line 155 of file paragraphs_internal.h.

{
switch (just) {
default: return lindent_ > rindent_ ? lindent_ : rindent_;
}
}
void tesseract::RowScratchRegisters::AppendDebugHeaderFields ( GenericVector< STRING > *  header)
static

Definition at line 487 of file paragraphs.cpp.

{
header->push_back("[lmarg,lind;rind,rmarg]");
header->push_back("model");
}
void tesseract::RowScratchRegisters::AppendDebugInfo ( const ParagraphTheory theory,
GenericVector< STRING > *  dbg 
) const

Definition at line 493 of file paragraphs.cpp.

{
char s[30];
snprintf(s, sizeof(s), "[%3d,%3d;%3d,%3d]",
dbg->push_back(s);
STRING model_string;
model_string += static_cast<char>(GetLineType());
model_string += ":";
int model_numbers = 0;
for (int h = 0; h < hypotheses_.size(); h++) {
if (hypotheses_[h].model == NULL)
continue;
if (model_numbers > 0)
model_string += ",";
if (StrongModel(hypotheses_[h].model)) {
model_string += StrOf(1 + theory.IndexOf(hypotheses_[h].model));
} else if (hypotheses_[h].model == kCrownLeft) {
model_string += "CrL";
} else if (hypotheses_[h].model == kCrownRight) {
model_string += "CrR";
}
model_numbers++;
}
if (model_numbers == 0)
model_string += "0";
dbg->push_back(model_string);
}
void tesseract::RowScratchRegisters::DiscardNonMatchingHypotheses ( const SetOfModels models)

Definition at line 642 of file paragraphs.cpp.

{
if (models.empty())
return;
for (int h = hypotheses_.size() - 1; h >= 0; h--) {
if (!models.contains(hypotheses_[h].model)) {
hypotheses_.remove(h);
}
}
}
LineType tesseract::RowScratchRegisters::GetLineType ( ) const

Definition at line 532 of file paragraphs.cpp.

{
if (hypotheses_.empty())
return LT_UNKNOWN;
bool has_start = false;
bool has_body = false;
for (int i = 0; i < hypotheses_.size(); i++) {
switch (hypotheses_[i].ty) {
case LT_START: has_start = true; break;
case LT_BODY: has_body = true; break;
default:
tprintf("Encountered bad value in hypothesis list: %c\n",
hypotheses_[i].ty);
break;
}
}
if (has_start && has_body)
return LT_MULTIPLE;
return has_start ? LT_START : LT_BODY;
}
LineType tesseract::RowScratchRegisters::GetLineType ( const ParagraphModel model) const

Definition at line 552 of file paragraphs.cpp.

{
if (hypotheses_.empty())
return LT_UNKNOWN;
bool has_start = false;
bool has_body = false;
for (int i = 0; i < hypotheses_.size(); i++) {
if (hypotheses_[i].model != model)
continue;
switch (hypotheses_[i].ty) {
case LT_START: has_start = true; break;
case LT_BODY: has_body = true; break;
default:
tprintf("Encountered bad value in hypothesis list: %c\n",
hypotheses_[i].ty);
break;
}
}
if (has_start && has_body)
return LT_MULTIPLE;
return has_start ? LT_START : LT_BODY;
}
void tesseract::RowScratchRegisters::Init ( const RowInfo row)

Definition at line 524 of file paragraphs.cpp.

{
ri_ = &row;
lmargin_ = 0;
lindent_ = row.pix_ldistance;
rmargin_ = 0;
rindent_ = row.pix_rdistance;
}
void tesseract::RowScratchRegisters::NonNullHypotheses ( SetOfModels models) const

Definition at line 622 of file paragraphs.cpp.

{
for (int h = 0; h < hypotheses_.size(); h++) {
if (hypotheses_[h].model != NULL)
models->push_back_new(hypotheses_[h].model);
}
}
int tesseract::RowScratchRegisters::OffsideIndent ( tesseract::ParagraphJustification  just) const
inline

Definition at line 146 of file paragraphs_internal.h.

{
switch (just) {
default: return lindent_ > rindent_ ? lindent_ : rindent_;
}
}
void tesseract::RowScratchRegisters::SetBodyLine ( )

Definition at line 584 of file paragraphs.cpp.

{
LineType current_lt = GetLineType();
if (current_lt != LT_UNKNOWN && current_lt != LT_BODY) {
tprintf("Trying to set a line to be BODY when it's already START.\n");
}
if (current_lt == LT_UNKNOWN || current_lt == LT_START) {
hypotheses_.push_back_new(LineHypothesis(LT_BODY, NULL));
}
}
void tesseract::RowScratchRegisters::SetStartLine ( )

Definition at line 574 of file paragraphs.cpp.

{
LineType current_lt = GetLineType();
if (current_lt != LT_UNKNOWN && current_lt != LT_START) {
tprintf("Trying to set a line to be START when it's already BODY.\n");
}
if (current_lt == LT_UNKNOWN || current_lt == LT_BODY) {
hypotheses_.push_back_new(LineHypothesis(LT_START, NULL));
}
}
void tesseract::RowScratchRegisters::SetUnknown ( )
inline

Definition at line 123 of file paragraphs_internal.h.

{ hypotheses_.truncate(0); }
void tesseract::RowScratchRegisters::StartHypotheses ( SetOfModels models) const

Definition at line 608 of file paragraphs.cpp.

{
for (int h = 0; h < hypotheses_.size(); h++) {
if (hypotheses_[h].ty == LT_START && StrongModel(hypotheses_[h].model))
models->push_back_new(hypotheses_[h].model);
}
}
void tesseract::RowScratchRegisters::StrongHypotheses ( SetOfModels models) const

Definition at line 615 of file paragraphs.cpp.

{
for (int h = 0; h < hypotheses_.size(); h++) {
if (StrongModel(hypotheses_[h].model))
models->push_back_new(hypotheses_[h].model);
}
}
const ParagraphModel * tesseract::RowScratchRegisters::UniqueBodyHypothesis ( ) const

Definition at line 635 of file paragraphs.cpp.

{
if (hypotheses_.size() != 1 || hypotheses_[0].ty != LT_BODY)
return NULL;
return hypotheses_[0].model;
}
const ParagraphModel * tesseract::RowScratchRegisters::UniqueStartHypothesis ( ) const

Definition at line 629 of file paragraphs.cpp.

{
if (hypotheses_.size() != 1 || hypotheses_[0].ty != LT_START)
return NULL;
return hypotheses_[0].model;
}

Member Data Documentation

int tesseract::RowScratchRegisters::lindent_

Definition at line 178 of file paragraphs_internal.h.

int tesseract::RowScratchRegisters::lmargin_

Definition at line 177 of file paragraphs_internal.h.

const RowInfo* tesseract::RowScratchRegisters::ri_

Definition at line 170 of file paragraphs_internal.h.

int tesseract::RowScratchRegisters::rindent_

Definition at line 179 of file paragraphs_internal.h.

int tesseract::RowScratchRegisters::rmargin_

Definition at line 180 of file paragraphs_internal.h.


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