Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
tesseract::Shape Class Reference

`#include <shapetable.h>`

List of all members.

## Public Member Functions
| Shape ()
bool | Serialize (FILE *fp) const
bool | DeSerialize (bool swap, FILE *fp)
int | destination_index () const
void | set_destination_index (int index)
int | size () const
const UnicharAndFonts & | operator[] (int index) const
void | AddToShape (int unichar_id, int font_id)
void | AddShape (const Shape &other)
bool | ContainsUnicharAndFont (int unichar_id, int font_id) const
bool | ContainsUnichar (int unichar_id) const
bool | ContainsFont (int font_id) const
bool | IsSubsetOf (const Shape &other) const
bool | IsEqualUnichars (Shape *other)

## Detailed Description

Definition at line 62 of file shapetable.h.

## Constructor & Destructor Documentation

tesseract::Shape::Shape | ( |  | ) |
| inline

Definition at line 64 of file shapetable.h.

: destination_index_(-1) {}

## Member Function Documentation

void tesseract::Shape::AddShape | ( | const Shape & | other | ) |

Definition at line 94 of file shapetable.cpp.

{
for (int c = 0; c < other.unichars_.size(); ++c) {
for (int f = 0; f < other.unichars_[c].font_ids.size(); ++f) {
AddToShape(other.unichars_[c].unichar_id,
other.unichars_[c].font_ids[f]);
}
}
unichars_sorted_ = unichars_.size() <= 1;
}

void tesseract::Shape::AddToShape | ( | int | unichar_id,
|  | int | font_id
| ) |  |

Definition at line 75 of file shapetable.cpp.

{
for (int c = 0; c < unichars_.size(); ++c) {
if (unichars_[c].unichar_id == unichar_id) {
// Found the unichar in the shape table.
GenericVector<int>& font_list = unichars_[c].font_ids;
for (int f = 0; f < font_list.size(); ++f) {
if (font_list[f] == font_id)
return; // Font is already there.
}
font_list.push_back(font_id);
return;
}
}
// Unichar_id is not in shape, so add it to shape.
unichars_.push_back(UnicharAndFonts(unichar_id, font_id));
unichars_sorted_ = unichars_.size() <= 1;
}

bool tesseract::Shape::ContainsFont | ( | int | font_id | ) | const

Definition at line 131 of file shapetable.cpp.

{
for (int c = 0; c < unichars_.size(); ++c) {
GenericVector<int>& font_list = unichars_[c].font_ids;
for (int f = 0; f < font_list.size(); ++f) {
if (font_list[f] == font_id)
return true;
}
}
return false;
}

bool tesseract::Shape::ContainsUnichar | ( | int | unichar_id | ) | const

Definition at line 121 of file shapetable.cpp.

{
for (int c = 0; c < unichars_.size(); ++c) {
if (unichars_[c].unichar_id == unichar_id) {
return true;
}
}
return false;
}

bool tesseract::Shape::ContainsUnicharAndFont | ( | int | unichar_id,
|  | int | font_id
| ) |  | const

Definition at line 105 of file shapetable.cpp.

{
for (int c = 0; c < unichars_.size(); ++c) {
if (unichars_[c].unichar_id == unichar_id) {
// Found the unichar, so look for the font.
GenericVector<int>& font_list = unichars_[c].font_ids;
for (int f = 0; f < font_list.size(); ++f) {
if (font_list[f] == font_id)
return true;
}
return false;
}
}
return false;
}

bool tesseract::Shape::DeSerialize | ( | bool | swap,
|  | FILE * | fp
| ) |  |

Definition at line 64 of file shapetable.cpp.

{
uinT8 sorted;
if (fread(&sorted, sizeof(sorted), 1, fp) != 1)
return false;
unichars_sorted_ = sorted != 0;
if (!unichars_.DeSerializeClasses(swap, fp)) return false;
return true;
}

int tesseract::Shape::destination_index | ( |  | ) | const
| inline

Definition at line 72 of file shapetable.h.

{
return destination_index_;
}

bool tesseract::Shape::IsEqualUnichars | ( | Shape * | other | ) |

Definition at line 158 of file shapetable.cpp.

{
if (unichars_.size() != other->unichars_.size()) return false;
if (!unichars_sorted_) SortUnichars();
if (!other->unichars_sorted_) other->SortUnichars();
for (int c = 0; c < unichars_.size(); ++c) {
if (unichars_[c].unichar_id != other->unichars_[c].unichar_id)
return false;
}
return true;
}

bool tesseract::Shape::IsSubsetOf | ( | const Shape & | other | ) | const

Definition at line 143 of file shapetable.cpp.

{
for (int c = 0; c < unichars_.size(); ++c) {
int unichar_id = unichars_[c].unichar_id;
const GenericVector<int>& font_list = unichars_[c].font_ids;
for (int f = 0; f < font_list.size(); ++f) {
if (!other.ContainsUnicharAndFont(unichar_id, font_list[f]))
return false;
}
}
return true;
}

const UnicharAndFonts& tesseract::Shape::operator[] | ( | int | index | ) | const
| inline

Definition at line 83 of file shapetable.h.

{
return unichars_[index];
}

bool tesseract::Shape::Serialize | ( | FILE * | fp | ) | const

Definition at line 55 of file shapetable.cpp.

{
uinT8 sorted = unichars_sorted_;
if (fwrite(&sorted, sizeof(sorted), 1, fp) != 1)
return false;
if (!unichars_.SerializeClasses(fp)) return false;
return true;
}

void tesseract::Shape::set_destination_index | ( | int | index | ) |
| inline

Definition at line 75 of file shapetable.h.

{
destination_index_ = index;
}

int tesseract::Shape::size | ( |  | ) | const
| inline

Definition at line 78 of file shapetable.h.

{
return unichars_.size();
}

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

- /mnt/data/src/tesseract-ocr/classify/shapetable.h
- /mnt/data/src/tesseract-ocr/classify/shapetable.cpp