30 #define FIRST_COLOUR ScrollView::RED //< first rainbow colour 31 #define LAST_COLOUR ScrollView::AQUAMARINE //< last rainbow colour 32 #define CHILD_COLOUR ScrollView::BROWN //< colour of children 35 "Attempted to scale an edgestep format word";
49 : blanks(blank_count),
53 C_BLOB_IT start_it = &cblobs;
54 C_BLOB_IT rej_cblob_it = &rej_cblobs;
55 C_OUTLINE_IT c_outline_it;
56 inT16 inverted_vote = 0;
57 inT16 non_inverted_vote = 0;
60 start_it.add_list_after(blob_list);
75 start_it.set_to_list(&cblobs);
78 for (start_it.mark_cycle_pt(); !start_it.cycled_list(); start_it.forward()) {
82 c_outline_it.set_to_list(start_it.data()->out_list());
84 for (c_outline_it.mark_cycle_pt();
85 !c_outline_it.cycled_list() && !reject_blob;
86 c_outline_it.forward()) {
87 reject_blob = c_outline_it.data()->flag(
COUT_INVERSE) != blob_inverted;
90 rej_cblob_it.add_after_then_move(start_it.extract());
101 start_it.set_to_list(&cblobs);
102 if (start_it.empty())
104 for (start_it.mark_cycle_pt(); !start_it.cycled_list(); start_it.forward()) {
105 c_outline_it.set_to_list(start_it.data()->out_list());
107 rej_cblob_it.add_after_then_move(start_it.extract());
122 script_id_(clone->script_id_),
123 correct(clone->correct) {
124 C_BLOB_IT start_it = blob_list;
125 C_BLOB_IT end_it = blob_list;
127 while (!end_it.at_last ())
129 ((C_BLOB_LIST *) (&cblobs))->assign_to_sublist (&start_it, &end_it);
131 blanks = clone->blanks;
138 C_BLOB_LIST temp_blobs;
139 C_BLOB_IT temp_it(&temp_blobs);
140 temp_it.add_after_then_move(blob);
141 WERD* blob_word =
new WERD(&temp_blobs,
this);
166 int bottom = box.
bottom();
169 C_BLOB_IT it(const_cast<C_BLOB_LIST*>(&rej_cblobs));
170 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
171 TBOX dot_box = it.data()->bounding_box();
172 if ((upper_dots || dot_box.
bottom() <= top) &&
173 (lower_dots || dot_box.
top() >= bottom)) {
184 C_BLOB_IT it(const_cast<C_BLOB_LIST*>(&cblobs));
185 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
186 box += it.data()->bounding_box();
199 C_BLOB_IT cblob_it(&cblobs);
201 for (cblob_it.mark_cycle_pt(); !cblob_it.cycled_list(); cblob_it.forward())
202 cblob_it.data()->move(
vec);
212 C_BLOB_IT blob_it(&cblobs);
213 C_BLOB_IT src_it(&other->cblobs);
214 C_BLOB_IT rej_cblob_it(&rej_cblobs);
215 C_BLOB_IT src_rej_it(&other->rej_cblobs);
217 while (!src_it.empty()) {
218 blob_it.add_to_end(src_it.extract());
221 while (!src_rej_it.empty()) {
222 rej_cblob_it.add_to_end(src_rej_it.extract());
223 src_rej_it.forward();
236 C_BLOB_IT c_blob_it(&cblobs);
241 c_blob_it.add_list_before(&c_blobs);
243 c_blob_it.move_to_last();
244 c_blob_it.add_list_after(&c_blobs);
246 if (!other->rej_cblobs.empty()) {
247 C_BLOB_IT rej_c_blob_it(&rej_cblobs);
248 C_BLOB_LIST new_rej_c_blobs;
252 rej_c_blob_it.add_list_before(&new_rej_c_blobs);
254 rej_c_blob_it.move_to_last();
255 rej_c_blob_it.add_list_after(&new_rej_c_blobs);
267 tprintf(
"Blanks= %d\n", blanks);
274 tprintf(
" W_NORMALIZED = %s\n",
276 tprintf(
" W_SCRIPT_HAS_XHEIGHT = %s\n",
278 tprintf(
" W_SCRIPT_IS_LATIN = %s\n",
285 tprintf(
"Rejected cblob count = %d\n", rej_cblobs.length());
286 tprintf(
"Script = %d\n", script_id_);
296 #ifndef GRAPHICS_DISABLED 298 C_BLOB_IT it = &cblobs;
299 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
300 it.data()->plot(window, colour, colour);
321 C_BLOB_IT it = &cblobs;
322 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
338 C_BLOB_IT it = &rej_cblobs;
339 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
343 #endif // GRAPHICS_DISABLED 355 new_word->blanks = blanks;
356 new_word->flags =
flags;
357 new_word->dummy = dummy;
358 new_word->correct = correct;
371 blanks = source.blanks;
372 flags = source.flags;
373 script_id_ = source.script_id_;
374 dummy = source.dummy;
375 correct = source.correct;
380 if (!rej_cblobs.empty())
413 C_BLOB_LIST* orphan_blobs) {
414 C_BLOB_LIST current_blob_list;
415 C_BLOB_IT werd_blobs_it(¤t_blob_list);
420 C_BLOB_LIST new_werd_blobs;
421 C_BLOB_IT new_blobs_it(&new_werd_blobs);
425 C_BLOB_LIST not_found_blobs;
426 C_BLOB_IT not_found_it(¬_found_blobs);
427 not_found_it.move_to_last();
429 werd_blobs_it.move_to_first();
430 for (werd_blobs_it.mark_cycle_pt(); !werd_blobs_it.cycled_list();
431 werd_blobs_it.forward()) {
432 C_BLOB* werd_blob = werd_blobs_it.extract();
438 C_BLOB_IT all_blobs_it(all_blobs);
439 for (all_blobs_it.mark_cycle_pt(); !all_blobs_it.cycled_list();
440 all_blobs_it.forward()) {
441 C_BLOB* a_blob = all_blobs_it.data();
446 tprintf(
"Bounding box couldn't be ascertained\n");
448 if (werd_blob_box.
contains(a_blob_box) ||
453 all_blobs_it.extract();
454 new_blobs_it.add_after_then_move(a_blob);
459 not_found_it.add_after_then_move(werd_blob);
467 not_found_it.move_to_first();
468 for (not_found_it.mark_cycle_pt(); !not_found_it.cycled_list();
469 not_found_it.forward()) {
470 C_BLOB* not_found = not_found_it.data();
472 C_BLOB_IT existing_blobs_it(new_blobs_it);
473 for (existing_blobs_it.mark_cycle_pt(); !existing_blobs_it.cycled_list();
474 existing_blobs_it.forward()) {
475 C_BLOB* a_blob = existing_blobs_it.data();
481 delete not_found_it.extract();
487 C_BLOB_IT orphan_blobs_it(orphan_blobs);
488 orphan_blobs_it.move_to_last();
489 orphan_blobs_it.add_list_after(¬_found_blobs);
493 WERD* new_werd = NULL;
494 if (!new_werd_blobs.empty()) {
495 new_werd =
new WERD(&new_werd_blobs,
this);
499 this_list_it.add_list_after(¬_found_blobs);
507 C_BLOB_IT blob_it(&cblobs);
508 C_BLOB_IT rej_it(&rej_cblobs);
509 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
510 C_BLOB* blob = blob_it.data();
511 C_OUTLINE_IT ol_it(blob->
out_list());
512 for (ol_it.mark_cycle_pt(); !ol_it.cycled_list(); ol_it.forward()) {
517 if (ol_size < size_threshold) {
521 rej_it.add_after_then_move(rej_blob);
524 if (blob->
out_list()->empty())
delete blob_it.extract();
531 C_BLOB_IT rej_it(&rej_cblobs);
532 for (rej_it.mark_cycle_pt(); !rej_it.empty(); rej_it.forward()) {
533 C_BLOB* blob = rej_it.extract();
534 C_OUTLINE_IT ol_it(blob->
out_list());
551 bool* make_next_word_fuzzy) {
552 bool outline_added_to_start =
false;
553 if (make_next_word_fuzzy != NULL) *make_next_word_fuzzy =
false;
554 C_BLOB_IT rej_it(&rej_cblobs);
555 for (
int i = 0; i < outlines.
size(); ++i) {
557 if (outline == NULL)
continue;
559 C_BLOB* target_blob = target_blobs[i];
561 if (target_blob == NULL) {
562 target_blob =
new C_BLOB(outline);
564 C_BLOB_IT blob_it(&cblobs);
565 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list();
567 C_BLOB* blob = blob_it.data();
569 if (blob_box.
left() > noise_box.
left()) {
572 outline_added_to_start =
true;
574 blob_it.add_before_stay_put(target_blob);
578 if (blob_it.cycled_list()) {
579 blob_it.add_to_end(target_blob);
580 if (make_next_word_fuzzy != NULL) *make_next_word_fuzzy =
true;
583 C_OUTLINE_IT ol_it(target_blob->
out_list());
584 while (i + 1 < outlines.
size() && wanted[i + 1] &&
585 target_blobs[i + 1] == NULL) {
587 ol_it.add_to_end(outlines[i]);
591 C_OUTLINE_IT ol_it(target_blob->
out_list());
592 ol_it.add_to_end(outline);
596 rej_it.add_to_end(
new C_BLOB(outline));
599 return outline_added_to_start;
void copy_on(WERD *other)
TBOX true_bounding_box() const
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
void CleanNoise(float size_threshold)
#define ELIST2IZE(CLASSNAME)
TBOX bounding_box() const
void plot(ScrollView *window, ScrollView::Color colour)
void join_on(WERD *other)
int word_comparator(const void *word1p, const void *word2p)
static ScrollView::Color NextColor(ScrollView::Color colour)
C_OUTLINE_LIST * out_list()
double y_overlap_fraction(const TBOX &box) const
const char * string() const
bool contains(const FCOORD pt) const
BOOL8 flag(WERD_FLAGS mask) const
void plot_rej_blobs(ScrollView *window)
const TBOX & bounding_box() const
void operator=(const ELIST2_LINK &)
void GetNoiseOutlines(GenericVector< C_OUTLINE *> *outlines)
static C_BLOB * deep_copy(const C_BLOB *src)
bool AddSelectedOutlines(const GenericVector< bool > &wanted, const GenericVector< C_BLOB *> &target_blobs, const GenericVector< C_OUTLINE *> &outlines, bool *make_next_word_fuzzy)
bool major_overlap(const TBOX &box) const
WERD & operator=(const WERD &source)
WERD * ConstructWerdWithNewBlobs(C_BLOB_LIST *all_blobs, C_BLOB_LIST *orphan_blobs)
void move(const ICOORD vec)
const ERRCODE CANT_SCALE_EDGESTEPS
void set_flag(WERD_FLAGS mask, BOOL8 value)
C_BLOB_LIST * cblob_list()
TBOX bounding_box() const
WERD * ConstructFromSingleBlob(bool bol, bool eol, C_BLOB *blob)