|
Tesseract
3.02
|
#include <shapetable.h>
Public Member Functions | |
| Shape () | |
| bool | Serialize (FILE *fp) |
| 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) |
Definition at line 62 of file shapetable.h.
| tesseract::Shape::Shape | ( | ) | [inline] |
Definition at line 64 of file shapetable.h.
: destination_index_(-1) {}
| void tesseract::Shape::AddShape | ( | const Shape & | other | ) |
Definition at line 94 of file shapetable.cpp.
| 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.
| 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 66 of file shapetable.cpp.
{
if (fread(&unichars_sorted_, sizeof(unichars_sorted_), 1, fp) != 1)
return false;
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.
| bool tesseract::Shape::IsSubsetOf | ( | const Shape & | other | ) | const |
Definition at line 143 of file shapetable.cpp.
| 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 | ) |
Definition at line 58 of file shapetable.cpp.
{
if (fwrite(&unichars_sorted_, sizeof(unichars_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();
}