Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fixspace.h File Reference
#include "pageres.h"
#include "params.h"
#include "notdll.h"

Go to the source code of this file.

Functions

void initialise_search (WERD_RES_LIST &src_list, WERD_RES_LIST &new_list)
void transform_to_next_perm (WERD_RES_LIST &words)
void fixspace_dbg (WERD_RES *word)

Function Documentation

void fixspace_dbg ( WERD_RES word)

Definition at line 879 of file fixspace.cpp.

{
TBOX box = word->word->bounding_box();
BOOL8 show_map_detail = FALSE;
inT16 i;
box.print();
tprintf(" \"%s\" ", word->best_choice->unichar_string().string());
tprintf("Blob count: %d (word); %d/%d (rebuild word)\n",
word->word->cblob_list()->length(),
word->box_word->length());
tprintf("\n");
if (show_map_detail) {
tprintf("\"%s\"\n", word->best_choice->unichar_string().string());
for (i = 0; word->best_choice->unichar_string()[i] != '\0'; i++) {
tprintf("**** \"%c\" ****\n", word->best_choice->unichar_string()[i]);
}
}
tprintf("Tess Accepted: %s\n", word->tess_accepted ? "TRUE" : "FALSE");
tprintf("Done flag: %s\n\n", word->done ? "TRUE" : "FALSE");
}
void initialise_search ( WERD_RES_LIST &  src_list,
WERD_RES_LIST &  new_list 
)

Definition at line 178 of file fixspace.cpp.

{
WERD_RES_IT src_it(&src_list);
WERD_RES_IT new_it(&new_list);
WERD_RES *src_wd;
WERD_RES *new_wd;
for (src_it.mark_cycle_pt(); !src_it.cycled_list(); src_it.forward()) {
src_wd = src_it.data();
if (!src_wd->combination) {
new_wd = new WERD_RES(*src_wd);
new_wd->combination = FALSE;
new_wd->part_of_combo = FALSE;
new_it.add_after_then_move(new_wd);
}
}
}
void transform_to_next_perm ( WERD_RES_LIST &  words)

Definition at line 373 of file fixspace.cpp.

{
WERD_RES_IT word_it(&words);
WERD_RES_IT prev_word_it(&words);
WERD_RES *word;
WERD_RES *prev_word;
WERD_RES *combo;
WERD *copy_word;
inT16 prev_right = -MAX_INT16;
TBOX box;
inT16 gap;
inT16 min_gap = MAX_INT16;
for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
word = word_it.data();
if (!word->part_of_combo) {
box = word->word->bounding_box();
if (prev_right > -MAX_INT16) {
gap = box.left() - prev_right;
if (gap < min_gap)
min_gap = gap;
}
prev_right = box.right();
}
}
if (min_gap < MAX_INT16) {
prev_right = -MAX_INT16; // back to start
word_it.set_to_list(&words);
// Note: we can't use cycle_pt due to inserted combos at start of list.
for (; (prev_right == -MAX_INT16) || !word_it.at_first();
word_it.forward()) {
word = word_it.data();
if (!word->part_of_combo) {
box = word->word->bounding_box();
if (prev_right > -MAX_INT16) {
gap = box.left() - prev_right;
if (gap <= min_gap) {
prev_word = prev_word_it.data();
if (prev_word->combination) {
combo = prev_word;
} else {
/* Make a new combination and insert before
* the first word being joined. */
copy_word = new WERD;
*copy_word = *(prev_word->word);
// deep copy
combo = new WERD_RES(copy_word);
combo->combination = TRUE;
combo->x_height = prev_word->x_height;
prev_word->part_of_combo = TRUE;
prev_word_it.add_before_then_move(combo);
}
combo->word->set_flag(W_EOL, word->word->flag(W_EOL));
if (word->combination) {
combo->word->join_on(word->word);
// Move blobs to combo
// old combo no longer needed
delete word_it.extract();
} else {
// Copy current wd to combo
combo->copy_on(word);
}
combo->done = FALSE;
combo->ClearResults();
} else {
prev_word_it = word_it; // catch up
}
}
prev_right = box.right();
}
}
} else {
words.clear(); // signal termination
}
}