diff --git a/src/ccmain/adaptions.cpp b/src/ccmain/adaptions.cpp index fe31fbbf32..2afa105230 100644 --- a/src/ccmain/adaptions.cpp +++ b/src/ccmain/adaptions.cpp @@ -95,7 +95,7 @@ BOOL8 Tesseract::word_adaptable( //should we adapt? return FALSE; } - if (flags.bit (CHECK_ONE_ELL_CONFLICT) && one_ell_conflict (word, FALSE)) { + if (flags.bit (CHECK_ONE_ELL_CONFLICT) && one_ell_conflict (word, false)) { if (tessedit_adaption_debug) tprintf("word has ell conflict\n"); return FALSE; } diff --git a/src/ccmain/control.cpp b/src/ccmain/control.cpp index fd7c7eca29..41aeee12b6 100644 --- a/src/ccmain/control.cpp +++ b/src/ccmain/control.cpp @@ -674,7 +674,7 @@ void Tesseract::rejection_passes(PAGE_RES* page_res, (stats_.doc_good_char_quality / static_cast(stats_.good_char_count)) : 0.0); } - BOOL8 good_quality_doc = + bool good_quality_doc = ((page_res->rej_count / static_cast(page_res->char_count)) <= quality_rej_pc) && (stats_.doc_blob_quality / static_cast(page_res->char_count) >= @@ -1792,20 +1792,20 @@ ACCEPTABLE_WERD_TYPE Tesseract::acceptable_word_string( return word_type; } -BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) { - BOOL8 show_map_detail = FALSE; +bool Tesseract::check_debug_pt(WERD_RES* word, int location) { + bool show_map_detail = false; int16_t i; if (!test_pt) - return FALSE; + return false; tessedit_rejection_debug.set_value (FALSE); debug_x_ht_level.set_value(0); - if (word->word->bounding_box ().contains (FCOORD (test_pt_x, test_pt_y))) { + if (word->word->bounding_box().contains(FCOORD (test_pt_x, test_pt_y))) { if (location < 0) - return TRUE; // For breakpoint use - tessedit_rejection_debug.set_value (TRUE); + return true; // For breakpoint use + tessedit_rejection_debug.set_value(TRUE); debug_x_ht_level.set_value(2); tprintf ("\n\nTESTWD::"); switch (location) { @@ -1827,7 +1827,7 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) { break; case 50: tprintf ("classify_word_pass2 - END"); - show_map_detail = TRUE; + show_map_detail = true; break; case 60: tprintf ("fixspace"); @@ -1849,7 +1849,7 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) { break; case 120: tprintf ("Write results pass"); - show_map_detail = TRUE; + show_map_detail = true; break; } if (word->best_choice != nullptr) { @@ -1868,9 +1868,9 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) { } tprintf ("Tess Accepted: %s\n", word->tess_accepted ? "TRUE" : "FALSE"); tprintf ("Done flag: %s\n\n", word->done ? "TRUE" : "FALSE"); - return TRUE; + return true; } else { - return FALSE; + return false; } } diff --git a/src/ccmain/fixspace.cpp b/src/ccmain/fixspace.cpp index f3470a7de9..a06a403440 100644 --- a/src/ccmain/fixspace.cpp +++ b/src/ccmain/fixspace.cpp @@ -55,7 +55,7 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor, WERD_RES *word_res; WERD_RES_LIST fuzzy_space_words; int16_t new_length; - BOOL8 prevent_null_wd_fixsp; // DON'T process blobless wds + bool prevent_null_wd_fixsp; // DON'T process blobless wds int32_t word_index; // current word block_res_it.set_to_list(&page_res->block_res_list); @@ -108,13 +108,13 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor, if (check_debug_pt(word_res, 60)) debug_fix_space_level.set_value(10); if (word_res->word->cblob_list()->empty()) - prevent_null_wd_fixsp = TRUE; + prevent_null_wd_fixsp = true; word_res = word_res_it_to.forward(); } if (check_debug_pt(word_res, 60)) debug_fix_space_level.set_value(10); if (word_res->word->cblob_list()->empty()) - prevent_null_wd_fixsp = TRUE; + prevent_null_wd_fixsp = true; if (prevent_null_wd_fixsp) { word_res_it_from = word_res_it_to; } else { @@ -148,7 +148,7 @@ void Tesseract::fix_fuzzy_space_list(WERD_RES_LIST &best_perm, int16_t best_score; WERD_RES_LIST current_perm; int16_t current_score; - BOOL8 improved = FALSE; + bool improved = false; best_score = eval_word_spacing(best_perm); // default score dump_words(best_perm, best_score, 1, improved); @@ -164,7 +164,7 @@ void Tesseract::fix_fuzzy_space_list(WERD_RES_LIST &best_perm, best_perm.clear(); best_perm.deep_copy(¤t_perm, &WERD_RES::deep_copy); best_score = current_score; - improved = TRUE; + improved = true; } if (current_score < PERFECT_WERDS) transform_to_next_perm(current_perm); @@ -246,15 +246,15 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { int16_t offset; WERD_RES *word; // current word int16_t prev_word_score = 0; - BOOL8 prev_word_done = FALSE; - BOOL8 prev_char_1 = FALSE; // prev ch a "1/I/l"? - BOOL8 prev_char_digit = FALSE; // prev ch 2..9 or 0 - BOOL8 current_char_1 = FALSE; - BOOL8 current_word_ok_so_far; + bool prev_word_done = false; + bool prev_char_1 = false; // prev ch a "1/I/l"? + bool prev_char_digit = false; // prev ch 2..9 or 0 + bool current_char_1 = false; + bool current_word_ok_so_far; STRING punct_chars = "!\"`',.:;"; - BOOL8 prev_char_punct = FALSE; - BOOL8 current_char_punct = FALSE; - BOOL8 word_done = FALSE; + bool prev_char_punct = false; + bool current_char_punct = false; + bool word_done = false; do { word = word_res_it.data(); @@ -265,9 +265,9 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { if (prev_word_done) done_word_count++; prev_word_score = 0; - prev_char_1 = FALSE; - prev_char_digit = FALSE; - prev_word_done = FALSE; + prev_char_1 = false; + prev_char_digit = false; + prev_word_done = false; } else { /* Can we add the prev word score and potentially count this word? @@ -275,7 +275,7 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { AND it didn't end in a digit when the first char of this word is a 1 */ word_len = word->reject_map.length(); - current_word_ok_so_far = FALSE; + current_word_ok_so_far = false; if (!((prev_char_1 && digit_or_numeric_punct(word, 0)) || (prev_char_digit && ( (word_done && @@ -290,16 +290,16 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { } if (current_word_ok_so_far) { - prev_word_done = TRUE; + prev_word_done = true; prev_word_score = word_len; } else { - prev_word_done = FALSE; + prev_word_done = false; prev_word_score = 0; } /* Add 1 to total score for every joined 1 regardless of context and rejtn */ - for (i = 0, prev_char_1 = FALSE; i < word_len; i++) { + for (i = 0, prev_char_1 = false; i < word_len; i++) { current_char_1 = word->best_choice->unichar_string()[i] == '1'; if (prev_char_1 || (current_char_1 && (i > 0))) total_score++; @@ -309,7 +309,7 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { /* Add 1 to total score for every joined punctuation regardless of context and rejtn */ if (tessedit_prefer_joined_punct) { - for (i = 0, offset = 0, prev_char_punct = FALSE; i < word_len; + for (i = 0, offset = 0, prev_char_punct = false; i < word_len; offset += word->best_choice->unichar_lengths()[i++]) { current_char_punct = punct_chars.contains(word->best_choice->unichar_string()[offset]); @@ -340,7 +340,7 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { return total_score; } -BOOL8 Tesseract::digit_or_numeric_punct(WERD_RES *word, int char_position) { +bool Tesseract::digit_or_numeric_punct(WERD_RES *word, int char_position) { int i; int offset; @@ -447,7 +447,7 @@ void transform_to_next_perm(WERD_RES_LIST &words) { namespace tesseract { void Tesseract::dump_words(WERD_RES_LIST &perm, int16_t score, - int16_t mode, BOOL8 improved) { + int16_t mode, bool improved) { WERD_RES_IT word_res_it(&perm); if (debug_fix_space_level > 0) { @@ -500,9 +500,9 @@ void Tesseract::dump_words(WERD_RES_LIST &perm, int16_t score, } } -BOOL8 Tesseract::fixspace_thinks_word_done(WERD_RES *word) { +bool Tesseract::fixspace_thinks_word_done(WERD_RES *word) { if (word->done) - return TRUE; + return true; /* Use all the standard pass 2 conditions for mode 5 in set_done() in @@ -518,9 +518,9 @@ BOOL8 Tesseract::fixspace_thinks_word_done(WERD_RES *word) { (word->best_choice->permuter() == FREQ_DAWG_PERM) || (word->best_choice->permuter() == USER_DAWG_PERM) || (word->best_choice->permuter() == NUMBER_PERM))) { - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -574,7 +574,7 @@ void Tesseract::fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, WERD_RES_IT current_perm_it(¤t_perm); WERD_RES *old_word_res; int16_t current_score; - BOOL8 improved = FALSE; + bool improved = false; best_score = fp_eval_word_spacing(best_perm); // default score @@ -597,7 +597,7 @@ void Tesseract::fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, best_perm.clear(); best_perm.deep_copy(¤t_perm, &WERD_RES::deep_copy); best_score = current_score; - improved = TRUE; + improved = true; } if (current_score < PERFECT_WERDS) { break_noisiest_blob_word(current_perm); @@ -794,7 +794,7 @@ float Tesseract::blob_noise_score(TBLOB *blob) { void fixspace_dbg(WERD_RES *word) { TBOX box = word->word->bounding_box(); - BOOL8 show_map_detail = FALSE; + bool show_map_detail = false; int16_t i; box.print(); diff --git a/src/ccmain/output.cpp b/src/ccmain/output.cpp index b9023325b5..a2ec651488 100644 --- a/src/ccmain/output.cpp +++ b/src/ccmain/output.cpp @@ -65,7 +65,7 @@ void Tesseract::output_pass( //Tess output pass //send to api PAGE_RES_IT &page_res_it, const TBOX *target_word_box) { BLOCK_RES *block_of_last_word; - BOOL8 force_eol; //During output + bool force_eol; //During output BLOCK *nextblock; //block of next word WERD *nextword; //next word @@ -123,13 +123,13 @@ void Tesseract::output_pass( //Tess output pass //send to api * inset list - a list of bounding boxes of reject insets - indexed by the * reject strings in the epchoice text. *************************************************************************/ -void Tesseract::write_results(PAGE_RES_IT &page_res_it, +void Tesseract::write_results(PAGE_RES_IT& page_res_it, char newline_type, // type of newline - BOOL8 force_eol) { // override tilde crunch? + bool force_eol) { // override tilde crunch? WERD_RES *word = page_res_it.word(); const UNICHARSET &uchset = *word->uch_set; int i; - BOOL8 need_reject = FALSE; + bool need_reject = false; UNICHAR_ID space = uchset.unichar_to_id(" "); if ((word->unlv_crunch_mode != CR_NONE || @@ -147,7 +147,7 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it, !word->word->flag (W_FUZZY_SP)) { stats_.last_char_was_tilde = false; } - need_reject = TRUE; + need_reject = true; } if ((need_reject && !stats_.last_char_was_tilde) || (force_eol && stats_.write_results_empty_block)) { diff --git a/src/ccmain/pgedit.cpp b/src/ccmain/pgedit.cpp index 0025324efe..87843f2639 100644 --- a/src/ccmain/pgedit.cpp +++ b/src/ccmain/pgedit.cpp @@ -390,12 +390,12 @@ void pgeditor_show_point( // display coords */ namespace tesseract { -BOOL8 Tesseract::process_cmd_win_event( // UI command semantics - int32_t cmd_event, // which menu item? - char *new_value // any prompt data - ) { +bool Tesseract::process_cmd_win_event( // UI command semantics + int32_t cmd_event, // which menu item? + char* new_value // any prompt data +) { char msg[160]; - BOOL8 exit = FALSE; + bool exit = false; color_mode = CM_RAINBOW; @@ -535,7 +535,7 @@ BOOL8 Tesseract::process_cmd_win_event( // UI command semantics do_re_display(&tesseract::Tesseract::word_display); break; case QUIT_CMD_EVENT: - exit = TRUE; + exit = true; ScrollView::Exit(); break; @@ -759,7 +759,7 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) { WERD* word = word_res->word; TBOX word_bb; // word bounding box int word_height; // ht of word BB - BOOL8 displayed_something = FALSE; + bool displayed_something = false; float shift; // from bot left C_BLOB_IT c_it; // cblob iterator @@ -833,13 +833,13 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) { c_it.set_to_list(word->cblob_list()); for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward()) c_it.data()->bounding_box().plot(image_win); - displayed_something = TRUE; + displayed_something = true; } // display edge steps if (word->display_flag(DF_EDGE_STEP)) { // edgesteps available word->plot(image_win); // rainbow colors - displayed_something = TRUE; + displayed_something = true; } // display poly approx @@ -848,7 +848,7 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) { TWERD* tword = TWERD::PolygonalCopy(poly_allow_detailed_fx, word); tword->plot(image_win); delete tword; - displayed_something = TRUE; + displayed_something = true; } // Display correct text and blamer information. @@ -898,7 +898,7 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) { blame.string()); } - displayed_something = TRUE; + displayed_something = true; } if (!displayed_something) // display BBox anyway diff --git a/src/ccmain/reject.cpp b/src/ccmain/reject.cpp index 1e34e75796..9359652815 100644 --- a/src/ccmain/reject.cpp +++ b/src/ccmain/reject.cpp @@ -57,7 +57,7 @@ void Tesseract::set_done(WERD_RES *word, int16_t pass) { word->best_choice->permuter() == FREQ_DAWG_PERM || word->best_choice->permuter() == USER_DAWG_PERM; if (word->done && (pass == 1) && (!word_from_dict || word_is_ambig) && - one_ell_conflict(word, FALSE)) { + one_ell_conflict(word, false)) { if (tessedit_rejection_debug) tprintf("one_ell_conflict detected\n"); word->done = FALSE; } @@ -104,7 +104,7 @@ void Tesseract::make_reject_map(WERD_RES *word, ROW *row, int16_t pass) { if (kBlnXHeight / word->denorm.y_scale() <= min_sane_x_ht_pixels) { word->reject_map.rej_word_small_xht(); } else { - one_ell_conflict(word, TRUE); + one_ell_conflict(word, true); /* Originally the code here just used the done flag. Now I have duplicated and unpacked the conditions for setting the done flag so that each @@ -284,7 +284,7 @@ void Tesseract::reject_edge_blobs(WERD_RES *word) { * Identify words where there is a potential I/l/1 error. * - A bundle of contextual heuristics! **********************************************************************/ -BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { +bool Tesseract::one_ell_conflict(WERD_RES* word_res, bool update_map) { const char *word; const char *lengths; int16_t word_len; //its length @@ -292,30 +292,30 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { int16_t first_alphanum_offset_; int16_t i; int16_t offset; - BOOL8 non_conflict_set_char; //non conf set a/n? - BOOL8 conflict = FALSE; - BOOL8 allow_1s; + bool non_conflict_set_char; //non conf set a/n? + bool conflict = false; + bool allow_1s; ACCEPTABLE_WERD_TYPE word_type; - BOOL8 dict_perm_type; - BOOL8 dict_word_ok; + bool dict_perm_type; + bool dict_word_ok; int dict_word_type; word = word_res->best_choice->unichar_string().string (); lengths = word_res->best_choice->unichar_lengths().string(); - word_len = strlen (lengths); + word_len = strlen(lengths); /* If there are no occurrences of the conflict set characters then the word is OK. */ - if (strpbrk (word, conflict_set_I_l_1.string ()) == nullptr) - return FALSE; + if (strpbrk(word, conflict_set_I_l_1.string ()) == nullptr) + return false; /* There is a conflict if there are NO other (confirmed) alphanumerics apart from those in the conflict set. */ - for (i = 0, offset = 0, non_conflict_set_char = FALSE; + for (i = 0, offset = 0, non_conflict_set_char = false; (i < word_len) && !non_conflict_set_char; offset += lengths[i++]) non_conflict_set_char = (word_res->uch_set->get_isalpha(word + offset, lengths[i]) || @@ -324,7 +324,7 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { if (!non_conflict_set_char) { if (update_map) reject_I_1_L(word_res); - return TRUE; + return true; } /* @@ -355,11 +355,11 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { if (update_map) word_res->reject_map[first_alphanum_index_]. setrej_1Il_conflict(); - return TRUE; + return true; } else { word_res->best_choice->unichar_string()[first_alphanum_offset_] = 'I'; - return FALSE; + return false; } } @@ -371,14 +371,14 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { if (update_map) word_res->reject_map[first_alphanum_index_]. setrej_1Il_conflict(); - return TRUE; + return true; } else { word_res->best_choice->unichar_string()[first_alphanum_offset_] = 'l'; - return FALSE; + return false; } } - return FALSE; + return false; } /* @@ -398,7 +398,7 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { word[first_alphanum_offset_] == 'l') { word_res->best_choice->unichar_string()[first_alphanum_offset_] = 'I'; if (safe_dict_word(word_res) > 0) - return FALSE; + return false; else word_res->best_choice->unichar_string()[first_alphanum_offset_] = 'l'; } @@ -406,7 +406,7 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { word[first_alphanum_offset_] == 'I') { word_res->best_choice->unichar_string()[first_alphanum_offset_] = 'l'; if (safe_dict_word(word_res) > 0) - return FALSE; + return false; else word_res->best_choice->unichar_string()[first_alphanum_offset_] = 'I'; } @@ -421,14 +421,14 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { (word_res->best_choice->permuter () == NUMBER_PERM); int16_t offset; - conflict = FALSE; + conflict = false; for (i = 0, offset = 0; word[offset] != '\0'; offset += word_res->best_choice->unichar_lengths()[i++]) { if ((!allow_1s || (word[offset] != '1')) && STRING (conflict_set_I_l_1).contains (word[offset])) { if (update_map) word_res->reject_map[i].setrej_1Il_conflict (); - conflict = TRUE; + conflict = true; } } return conflict; @@ -445,18 +445,18 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { if (update_map) word_res->reject_map[first_alphanum_index_]. setrej_1Il_conflict (); - return TRUE; + return true; } else - return FALSE; + return false; } else if (word_type == AC_UPPER_CASE) { - return FALSE; + return false; } else { if (update_map) reject_I_1_L(word_res); - return TRUE; + return true; } } @@ -524,13 +524,13 @@ void Tesseract::dont_allow_1Il(WERD_RES *word) { int word_len = word->reject_map.length(); const char *s = word->best_choice->unichar_string().string(); const char *lengths = word->best_choice->unichar_lengths().string(); - BOOL8 accepted_1Il = FALSE; + bool accepted_1Il = false; for (i = 0, offset = 0; i < word_len; offset += word->best_choice->unichar_lengths()[i++]) { if (word->reject_map[i].accepted()) { if (STRING(conflict_set_I_l_1).contains(s[offset])) { - accepted_1Il = TRUE; + accepted_1Il = true; } else { if (word->uch_set->get_isalpha(s + offset, lengths[i]) || word->uch_set->get_isdigit(s + offset, lengths[i])) @@ -574,29 +574,29 @@ void Tesseract::reject_mostly_rejects(WERD_RES *word) { } -BOOL8 Tesseract::repeated_nonalphanum_wd(WERD_RES *word, ROW *row) { +bool Tesseract::repeated_nonalphanum_wd(WERD_RES* word, ROW* row) { int16_t char_quality; int16_t accepted_char_quality; if (word->best_choice->unichar_lengths().length() <= 1) - return FALSE; + return false; if (!STRING(ok_repeated_ch_non_alphanum_wds). contains(word->best_choice->unichar_string()[0])) - return FALSE; + return false; UNICHAR_ID uch_id = word->best_choice->unichar_id(0); for (int i = 1; i < word->best_choice->length(); ++i) { - if (word->best_choice->unichar_id(i) != uch_id) return FALSE; + if (word->best_choice->unichar_id(i) != uch_id) return false; } word_char_quality(word, row, &char_quality, &accepted_char_quality); if ((word->best_choice->unichar_lengths().length () == char_quality) && (char_quality == accepted_char_quality)) - return TRUE; + return true; else - return FALSE; + return false; } int16_t Tesseract::safe_dict_word(const WERD_RES *werd_res) { @@ -777,11 +777,11 @@ void Tesseract::flip_0O(WERD_RES *word_res) { } } -BOOL8 Tesseract::non_O_upper(const UNICHARSET& ch_set, UNICHAR_ID unichar_id) { +bool Tesseract::non_O_upper(const UNICHARSET& ch_set, UNICHAR_ID unichar_id) { return ch_set.get_isupper(unichar_id) && !ch_set.eq(unichar_id, "O"); } -BOOL8 Tesseract::non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id) { +bool Tesseract::non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id) { return ch_set.get_isdigit(unichar_id) && !ch_set.eq(unichar_id, "0"); } } // namespace tesseract diff --git a/src/ccmain/reject.h b/src/ccmain/reject.h index cffb262cbe..a4ccd49639 100644 --- a/src/ccmain/reject.h +++ b/src/ccmain/reject.h @@ -26,9 +26,9 @@ void reject_blanks(WERD_RES *word); void reject_poor_matches(WERD_RES *word); float compute_reject_threshold(WERD_CHOICE* word); -BOOL8 word_contains_non_1_digit(const char *word, const char *word_lengths); +bool word_contains_non_1_digit(const char* word, const char* word_lengths); void dont_allow_1Il(WERD_RES *word); void flip_hyphens(WERD_RES *word); void flip_0O(WERD_RES *word); -BOOL8 non_0_digit(const char* str, int length); +bool non_0_digit(const char* str, int length); #endif diff --git a/src/ccmain/tesseractclass.h b/src/ccmain/tesseractclass.h index 2eb14f6444..583e0ffffc 100644 --- a/src/ccmain/tesseractclass.h +++ b/src/ccmain/tesseractclass.h @@ -459,7 +459,7 @@ class Tesseract : public Wordrec { void set_word_fonts(WERD_RES *word); void font_recognition_pass(PAGE_RES* page_res); void dictionary_correction_pass(PAGE_RES* page_res); - BOOL8 check_debug_pt(WERD_RES *word, int location); + bool check_debug_pt(WERD_RES* word, int location); //// superscript.cpp //////////////////////////////////////////////////// bool SubAndSuperscriptFix(WERD_RES *word_res); @@ -491,10 +491,10 @@ class Tesseract : public Wordrec { //// output.h ////////////////////////////////////////////////////////// void output_pass(PAGE_RES_IT &page_res_it, const TBOX *target_word_box); - void write_results(PAGE_RES_IT &page_res_it, // full info + void write_results(PAGE_RES_IT& page_res_it, // full info char newline_type, // type of newline - BOOL8 force_eol // override tilde crunch? - ); + bool force_eol // override tilde crunch? + ); void set_unlv_suspects(WERD_RES *word); UNICHAR_ID get_rep_char(WERD_RES *word); // what char is repeated? BOOL8 acceptable_number_string(const char *s, @@ -571,10 +571,10 @@ class Tesseract : public Wordrec { #endif // GRAPHICS_DISABLED void process_image_event( // action in image win const SVEvent &event); - BOOL8 process_cmd_win_event( // UI command semantics - int32_t cmd_event, // which menu item? - char *new_value // any prompt data - ); + bool process_cmd_win_event( // UI command semantics + int32_t cmd_event, // which menu item? + char* new_value // any prompt data + ); void debug_word(PAGE_RES* page_res, const TBOX &selection_box); void do_re_display( BOOL8 (tesseract::Tesseract::*word_painter)(PAGE_RES_IT* pr_it)); @@ -589,7 +589,7 @@ class Tesseract : public Wordrec { //// reject.h ////////////////////////////////////////////////////////// // make rej map for word void make_reject_map(WERD_RES *word, ROW *row, int16_t pass); - BOOL8 one_ell_conflict(WERD_RES *word_res, BOOL8 update_map); + bool one_ell_conflict(WERD_RES* word_res, bool update_map); int16_t first_alphanum_index(const char *word, const char *word_lengths); int16_t first_alphanum_offset(const char *word, @@ -602,9 +602,9 @@ class Tesseract : public Wordrec { int16_t count_alphanums( //how many alphanums WERD_RES *word); void flip_0O(WERD_RES *word); - BOOL8 non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id); - BOOL8 non_O_upper(const UNICHARSET& ch_set, UNICHAR_ID unichar_id); - BOOL8 repeated_nonalphanum_wd(WERD_RES *word, ROW *row); + bool non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id); + bool non_O_upper(const UNICHARSET& ch_set, UNICHAR_ID unichar_id); + bool repeated_nonalphanum_wd(WERD_RES* word, ROW* row); void nn_match_word( //Match a word WERD_RES *word, ROW *row); @@ -634,7 +634,7 @@ class Tesseract : public Wordrec { WERD_RES *word2, BlamerBundle *orig_bb) const; //// fixspace.cpp /////////////////////////////////////////////////////// - BOOL8 digit_or_numeric_punct(WERD_RES *word, int char_position); + bool digit_or_numeric_punct(WERD_RES *word, int char_position); int16_t eval_word_spacing(WERD_RES_LIST &word_res_list); void match_current_words(WERD_RES_LIST &words, ROW *row, BLOCK* block); int16_t fp_eval_word_spacing(WERD_RES_LIST &word_res_list); @@ -646,8 +646,8 @@ class Tesseract : public Wordrec { int32_t word_count, //count of words in doc PAGE_RES *page_res); void dump_words(WERD_RES_LIST &perm, int16_t score, - int16_t mode, BOOL8 improved); - BOOL8 fixspace_thinks_word_done(WERD_RES *word); + int16_t mode, bool improved); + bool fixspace_thinks_word_done(WERD_RES *word); int16_t worst_noise_blob(WERD_RES *word_res, float *worst_noise_score); float blob_noise_score(TBLOB *blob); void break_noisiest_blob_word(WERD_RES_LIST &words); @@ -661,9 +661,9 @@ class Tesseract : public Wordrec { PAGE_RES_IT &page_res_it); void doc_and_block_rejection( //reject big chunks PAGE_RES_IT &page_res_it, - BOOL8 good_quality_doc); + bool good_quality_doc); void quality_based_rejection(PAGE_RES_IT &page_res_it, - BOOL8 good_quality_doc); + bool good_quality_doc); void convert_bad_unlv_chs(WERD_RES *word_res); void tilde_delete(PAGE_RES_IT &page_res_it); int16_t word_blob_quality(WERD_RES *word, ROW *row); diff --git a/src/ccstruct/coutln.cpp b/src/ccstruct/coutln.cpp index fc2b005fc2..6680b3be3d 100644 --- a/src/ccstruct/coutln.cpp +++ b/src/ccstruct/coutln.cpp @@ -339,12 +339,12 @@ int32_t C_OUTLINE::outer_area() const { */ int32_t C_OUTLINE::count_transitions(int32_t threshold) { - BOOL8 first_was_max_x; //what was first - BOOL8 first_was_max_y; - BOOL8 looking_for_max_x; //what is next - BOOL8 looking_for_min_x; - BOOL8 looking_for_max_y; //what is next - BOOL8 looking_for_min_y; + bool first_was_max_x; //what was first + bool first_was_max_y; + bool looking_for_max_x; //what is next + bool looking_for_min_x; + bool looking_for_max_y; //what is next + bool looking_for_min_y; int stepindex; //current step int32_t total_steps; //steps to do //current limits @@ -354,77 +354,77 @@ int32_t C_OUTLINE::count_transitions(int32_t threshold) { ICOORD pos; //position of point ICOORD next_step; //step to next pix - pos = start_pos (); - total_steps = pathlength (); + pos = start_pos(); + total_steps = pathlength(); total = 0; - max_x = min_x = pos.x (); - max_y = min_y = pos.y (); - looking_for_max_x = TRUE; - looking_for_min_x = TRUE; - looking_for_max_y = TRUE; - looking_for_min_y = TRUE; - first_was_max_x = FALSE; - first_was_max_y = FALSE; - initial_x = pos.x (); - initial_y = pos.y (); //stop uninit warning + max_x = min_x = pos.x(); + max_y = min_y = pos.y(); + looking_for_max_x = true; + looking_for_min_x = true; + looking_for_max_y = true; + looking_for_min_y = true; + first_was_max_x = false; + first_was_max_y = false; + initial_x = pos.x(); + initial_y = pos.y(); //stop uninit warning for (stepindex = 0; stepindex < total_steps; stepindex++) { //all intersected - next_step = step (stepindex); + next_step = step(stepindex); pos += next_step; - if (next_step.x () < 0) { - if (looking_for_max_x && pos.x () < min_x) - min_x = pos.x (); - if (looking_for_min_x && max_x - pos.x () > threshold) { + if (next_step.x() < 0) { + if (looking_for_max_x && pos.x() < min_x) + min_x = pos.x(); + if (looking_for_min_x && max_x - pos.x() > threshold) { if (looking_for_max_x) { initial_x = max_x; - first_was_max_x = FALSE; + first_was_max_x = false; } total++; - looking_for_max_x = TRUE; - looking_for_min_x = FALSE; - min_x = pos.x (); //reset min + looking_for_max_x = true; + looking_for_min_x = false; + min_x = pos.x(); //reset min } } - else if (next_step.x () > 0) { - if (looking_for_min_x && pos.x () > max_x) - max_x = pos.x (); - if (looking_for_max_x && pos.x () - min_x > threshold) { + else if (next_step.x() > 0) { + if (looking_for_min_x && pos.x() > max_x) + max_x = pos.x(); + if (looking_for_max_x && pos.x() - min_x > threshold) { if (looking_for_min_x) { initial_x = min_x; //remember first min - first_was_max_x = TRUE; + first_was_max_x = true; } total++; - looking_for_max_x = FALSE; - looking_for_min_x = TRUE; - max_x = pos.x (); + looking_for_max_x = false; + looking_for_min_x = true; + max_x = pos.x(); } } - else if (next_step.y () < 0) { - if (looking_for_max_y && pos.y () < min_y) - min_y = pos.y (); - if (looking_for_min_y && max_y - pos.y () > threshold) { + else if (next_step.y() < 0) { + if (looking_for_max_y && pos.y() < min_y) + min_y = pos.y(); + if (looking_for_min_y && max_y - pos.y() > threshold) { if (looking_for_max_y) { initial_y = max_y; //remember first max - first_was_max_y = FALSE; + first_was_max_y = false; } total++; - looking_for_max_y = TRUE; - looking_for_min_y = FALSE; - min_y = pos.y (); //reset min + looking_for_max_y = true; + looking_for_min_y = false; + min_y = pos.y(); //reset min } } else { - if (looking_for_min_y && pos.y () > max_y) - max_y = pos.y (); - if (looking_for_max_y && pos.y () - min_y > threshold) { + if (looking_for_min_y && pos.y() > max_y) + max_y = pos.y(); + if (looking_for_max_y && pos.y() - min_y > threshold) { if (looking_for_min_y) { initial_y = min_y; //remember first min - first_was_max_y = TRUE; + first_was_max_y = true; } total++; - looking_for_max_y = FALSE; - looking_for_min_y = TRUE; - max_y = pos.y (); + looking_for_max_y = false; + looking_for_min_y = true; + max_y = pos.y(); } } @@ -464,14 +464,14 @@ int32_t C_OUTLINE::count_transitions(int32_t threshold) { * @param other other outline */ -BOOL8 +bool C_OUTLINE::operator<(const C_OUTLINE& other) const { int16_t count = 0; //winding count ICOORD pos; //position of point int32_t stepindex; //index to cstep if (!box.overlap (other.box)) - return FALSE; //can't be contained + return false; //can't be contained if (stepcount == 0) return other.box.contains(this->box); diff --git a/src/ccstruct/coutln.h b/src/ccstruct/coutln.h index d831b6463d..a5cf273006 100644 --- a/src/ccstruct/coutln.h +++ b/src/ccstruct/coutln.h @@ -95,12 +95,12 @@ class DLLSYM C_OUTLINE:public ELIST_LINK { BOOL8 flag( //test flag C_OUTLINE_FLAGS mask) const { //flag to test - return flags.bit (mask); + return flags.bit(mask); } void set_flag( //set flag value C_OUTLINE_FLAGS mask, //flag to test BOOL8 value) { //value to set - flags.set_bit (mask, value); + flags.set_bit(mask, value); } C_OUTLINE_LIST *child() { //get child list @@ -200,9 +200,9 @@ class DLLSYM C_OUTLINE:public ELIST_LINK { int32_t count_transitions( //count maxima int32_t threshold); //size threshold - BOOL8 operator< ( //containment test + bool operator< ( //containment test const C_OUTLINE & other) const; - BOOL8 operator> ( //containment test + bool operator> ( //containment test C_OUTLINE & other) const { return other < *this; //use the < to do it diff --git a/src/ccstruct/pdblock.cpp b/src/ccstruct/pdblock.cpp index b952758143..ad9db418fe 100644 --- a/src/ccstruct/pdblock.cpp +++ b/src/ccstruct/pdblock.cpp @@ -70,12 +70,12 @@ void PDBLK::set_sides( //set vertex lists ICOORDELT_IT left_it = &leftside; ICOORDELT_IT right_it = &rightside; - leftside.clear (); - left_it.move_to_first (); - left_it.add_list_before (left); - rightside.clear (); - right_it.move_to_first (); - right_it.add_list_before (right); + leftside.clear(); + left_it.move_to_first(); + left_it.add_list_before(left); + rightside.clear(); + right_it.move_to_first(); + right_it.add_list_before(right); } /********************************************************************** @@ -84,21 +84,21 @@ void PDBLK::set_sides( //set vertex lists * Return TRUE if the given point is within the block. **********************************************************************/ -BOOL8 PDBLK::contains( //test containment - ICOORD pt //point to test - ) { +bool PDBLK::contains( //test containment + ICOORD pt //point to test +) { BLOCK_RECT_IT it = this; //rectangle iterator ICOORD bleft, tright; //corners of rectangle - for (it.start_block (); !it.cycled_rects (); it.forward ()) { + for (it.start_block(); !it.cycled_rects(); it.forward()) { //get rectangle it.bounding_box (bleft, tright); //inside rect - if (pt.x () >= bleft.x () && pt.x () <= tright.x () - && pt.y () >= bleft.y () && pt.y () <= tright.y ()) - return TRUE; //is inside + if (pt.x() >= bleft.x() && pt.x() <= tright.x() + && pt.y() >= bleft.y() && pt.y() <= tright.y()) + return true; //is inside } - return FALSE; //not inside + return false; //not inside } diff --git a/src/ccstruct/pdblock.h b/src/ccstruct/pdblock.h index 1b9c5b40f0..86b1601d0c 100644 --- a/src/ccstruct/pdblock.h +++ b/src/ccstruct/pdblock.h @@ -69,7 +69,7 @@ class PDBLK { void set_index(int value) { index_ = value; } /// is pt inside block - BOOL8 contains(ICOORD pt); + bool contains(ICOORD pt); /// reposition block void move(const ICOORD vec); // by vector @@ -118,8 +118,8 @@ class DLLSYM BLOCK_RECT_IT //rectangle iterator void forward(); ///test end - BOOL8 cycled_rects() { - return left_it.cycled_list () && right_it.cycled_list (); + bool cycled_rects() { + return left_it.cycled_list() && right_it.cycled_list(); } ///current rectangle diff --git a/src/ccstruct/points.h b/src/ccstruct/points.h index 6d546b78cd..23a72ddf2a 100644 --- a/src/ccstruct/points.h +++ b/src/ccstruct/points.h @@ -99,11 +99,11 @@ class ICOORD } ///test equality - BOOL8 operator== (const ICOORD & other) const { + bool operator== (const ICOORD & other) const { return xcoord == other.xcoord && ycoord == other.ycoord; } ///test inequality - BOOL8 operator!= (const ICOORD & other) const { + bool operator!= (const ICOORD & other) const { return xcoord != other.xcoord || ycoord != other.ycoord; } ///rotate 90 deg anti @@ -273,11 +273,11 @@ class DLLSYM FCOORD bool normalise(); ///test equality - BOOL8 operator== (const FCOORD & other) { + bool operator== (const FCOORD & other) { return xcoord == other.xcoord && ycoord == other.ycoord; } ///test inequality - BOOL8 operator!= (const FCOORD & other) { + bool operator!= (const FCOORD & other) { return xcoord != other.xcoord || ycoord != other.ycoord; } ///rotate 90 deg anti diff --git a/src/ccstruct/quspline.cpp b/src/ccstruct/quspline.cpp index 51338846de..20e7db9f1b 100644 --- a/src/ccstruct/quspline.cpp +++ b/src/ccstruct/quspline.cpp @@ -277,22 +277,15 @@ void QSPLINE::move( // reposition spline * than the bounds of this. **********************************************************************/ -BOOL8 QSPLINE::overlap( //test overlap - QSPLINE *spline2, //2 cannot be smaller - double fraction //by more than this - ) { - int leftlimit; /*common left limit */ - int rightlimit; /*common right limit */ - - leftlimit = xcoords[1]; - rightlimit = xcoords[segments - 1]; +bool QSPLINE::overlap( //test overlap + QSPLINE* spline2, //2 cannot be smaller + double fraction //by more than this +) { + int leftlimit = xcoords[1]; /*common left limit */ + int rightlimit = xcoords[segments - 1]; /*common right limit */ /*or too non-overlap */ - if (spline2->segments < 3 || spline2->xcoords[1] > leftlimit + fraction * (rightlimit - leftlimit) - || spline2->xcoords[spline2->segments - 1] < rightlimit - - fraction * (rightlimit - leftlimit)) - return FALSE; - else - return TRUE; + return !(spline2->segments < 3 || spline2->xcoords[1] > leftlimit + fraction * (rightlimit - leftlimit) || + spline2->xcoords[spline2->segments - 1] < rightlimit - fraction * (rightlimit - leftlimit)); } diff --git a/src/ccstruct/quspline.h b/src/ccstruct/quspline.h index 8c008645d1..b2d71c4360 100644 --- a/src/ccstruct/quspline.h +++ b/src/ccstruct/quspline.h @@ -67,9 +67,9 @@ class QSPLINE void move( // reposition spline ICOORD vec); // by vector - BOOL8 overlap( //test overlap - QSPLINE *spline2, //2 cannot be smaller - double fraction); //by more than this + bool overlap( //test overlap + QSPLINE* spline2, //2 cannot be smaller + double fraction); //by more than this void extrapolate( //linear extrapolation double gradient, //gradient to use int left, //new left edge diff --git a/src/ccstruct/rejctmap.cpp b/src/ccstruct/rejctmap.cpp index ec76782e98..b2d8f805e6 100644 --- a/src/ccstruct/rejctmap.cpp +++ b/src/ccstruct/rejctmap.cpp @@ -21,7 +21,7 @@ #include "rejctmap.h" #include "params.h" -BOOL8 REJ::perm_rejected() { //Is char perm reject? +bool REJ::perm_rejected() { //Is char perm reject? return (flag (R_TESS_FAILURE) || flag (R_SMALL_XHT) || flag (R_EDGE_CHAR) || @@ -32,47 +32,47 @@ BOOL8 REJ::perm_rejected() { //Is char perm reject? } -BOOL8 REJ::rej_before_nn_accept() { +bool REJ::rej_before_nn_accept() { return flag (R_POOR_MATCH) || flag (R_NOT_TESS_ACCEPTED) || flag (R_CONTAINS_BLANKS) || flag (R_BAD_PERMUTER); } -BOOL8 REJ::rej_between_nn_and_mm() { +bool REJ::rej_between_nn_and_mm() { return flag (R_HYPHEN) || flag (R_DUBIOUS) || flag (R_NO_ALPHANUMS) || flag (R_MOSTLY_REJ) || flag (R_XHT_FIXUP); } -BOOL8 REJ::rej_between_mm_and_quality_accept() { +bool REJ::rej_between_mm_and_quality_accept() { return flag (R_BAD_QUALITY); } -BOOL8 REJ::rej_between_quality_and_minimal_rej_accept() { +bool REJ::rej_between_quality_and_minimal_rej_accept() { return flag (R_DOC_REJ) || flag (R_BLOCK_REJ) || flag (R_ROW_REJ) || flag (R_UNLV_REJ); } -BOOL8 REJ::rej_before_mm_accept() { +bool REJ::rej_before_mm_accept() { return rej_between_nn_and_mm () || (rej_before_nn_accept () && !flag (R_NN_ACCEPT) && !flag (R_HYPHEN_ACCEPT)); } -BOOL8 REJ::rej_before_quality_accept() { +bool REJ::rej_before_quality_accept() { return rej_between_mm_and_quality_accept () || (!flag (R_MM_ACCEPT) && rej_before_mm_accept ()); } -BOOL8 REJ::rejected() { //Is char rejected? +bool REJ::rejected() { //Is char rejected? if (flag (R_MINIMAL_REJ_ACCEPT)) - return FALSE; + return false; else return (perm_rejected () || rej_between_quality_and_minimal_rej_accept () || @@ -80,7 +80,7 @@ BOOL8 REJ::rejected() { //Is char rejected? } -BOOL8 REJ::accept_if_good_quality() { //potential rej? +bool REJ::accept_if_good_quality() { //potential rej? return (rejected () && !perm_rejected () && flag (R_BAD_PERMUTER) && diff --git a/src/ccstruct/rejctmap.h b/src/ccstruct/rejctmap.h index c724cd518c..bb2590d7de 100644 --- a/src/ccstruct/rejctmap.h +++ b/src/ccstruct/rejctmap.h @@ -108,12 +108,12 @@ class REJ flags2.turn_on_bit (rej_flag - 16); } - BOOL8 rej_before_nn_accept(); - BOOL8 rej_between_nn_and_mm(); - BOOL8 rej_between_mm_and_quality_accept(); - BOOL8 rej_between_quality_and_minimal_rej_accept(); - BOOL8 rej_before_mm_accept(); - BOOL8 rej_before_quality_accept(); + bool rej_before_nn_accept(); + bool rej_between_nn_and_mm(); + bool rej_between_mm_and_quality_accept(); + bool rej_between_quality_and_minimal_rej_accept(); + bool rej_before_mm_accept(); + bool rej_before_quality_accept(); public: REJ() { //constructor @@ -132,7 +132,7 @@ class REJ return *this; } - BOOL8 flag(REJ_FLAGS rej_flag) { + bool flag(REJ_FLAGS rej_flag) { if (rej_flag < 16) return flags1.bit (rej_flag); else @@ -150,16 +150,16 @@ class REJ return MAP_ACCEPT; } - BOOL8 perm_rejected(); //Is char perm reject? + bool perm_rejected(); //Is char perm reject? - BOOL8 rejected(); //Is char rejected? + bool rejected(); //Is char rejected? BOOL8 accepted() { //Is char accepted? return !rejected (); } //potential rej? - BOOL8 accept_if_good_quality(); + bool accept_if_good_quality(); BOOL8 recoverable() { return (rejected () && !perm_rejected ()); diff --git a/src/ccstruct/werd.cpp b/src/ccstruct/werd.cpp index 6e992ffedd..f0a35071c9 100644 --- a/src/ccstruct/werd.cpp +++ b/src/ccstruct/werd.cpp @@ -76,8 +76,8 @@ WERD::WERD(C_BLOB_LIST *blob_list, uint8_t blank_count, const char *text) if (start_it.empty()) return; for (start_it.mark_cycle_pt(); !start_it.cycled_list(); start_it.forward()) { - BOOL8 reject_blob = FALSE; - BOOL8 blob_inverted; + bool reject_blob = false; + bool blob_inverted; c_outline_it.set_to_list(start_it.data()->out_list()); blob_inverted = c_outline_it.data()->flag(COUT_INVERSE); diff --git a/src/ccstruct/werd.h b/src/ccstruct/werd.h index b299a996e9..a44bc861a1 100644 --- a/src/ccstruct/werd.h +++ b/src/ccstruct/werd.h @@ -126,7 +126,7 @@ class WERD : public ELIST2_LINK { void set_text(const char *new_text) { correct = new_text; } BOOL8 flag(WERD_FLAGS mask) const { return flags.bit(mask); } - void set_flag(WERD_FLAGS mask, BOOL8 value) { flags.set_bit(mask, value); } + void set_flag(WERD_FLAGS mask, bool value) { flags.set_bit(mask, value); } BOOL8 display_flag(uint8_t flag) const { return disp_flags.bit(flag); } void set_display_flag(uint8_t flag, BOOL8 value) { diff --git a/src/ccutil/bits16.h b/src/ccutil/bits16.h index dbd600b125..74eb551b26 100644 --- a/src/ccutil/bits16.h +++ b/src/ccutil/bits16.h @@ -46,15 +46,15 @@ class DLLSYM BITS16 } void set_bit( // flip specified bit - uint8_t bit_num, // bit to flip 0..7 - BOOL8 value) { // value to flip to + uint8_t bit_num, // bit to flip 0..7 + bool value) { // value to flip to if (value) val = val | 01 << bit_num; else val = val & ~(01 << bit_num); } - BOOL8 bit( // access bit + bool bit( // access bit uint8_t bit_num) const { // bit to access return (val >> bit_num) & 01; } diff --git a/src/ccutil/strngs.cpp b/src/ccutil/strngs.cpp index c5591b1cb1..045ff3ed6b 100644 --- a/src/ccutil/strngs.cpp +++ b/src/ccutil/strngs.cpp @@ -186,7 +186,7 @@ bool STRING::SkipDeSerialize(tesseract::TFile* fp) { return fp->FRead(nullptr, 1, len) == len; } -BOOL8 STRING::contains(const char c) const { +bool STRING::contains(const char c) const { return (c != '\0') && (strchr (GetCStr(), c) != nullptr); } @@ -302,7 +302,7 @@ void STRING::split(const char c, GenericVector *splited) { } } -BOOL8 STRING::operator==(const STRING& str) const { +bool STRING::operator==(const STRING& str) const { FixHeader(); str.FixHeader(); const STRING_HEADER* str_header = str.GetHeader(); @@ -314,7 +314,7 @@ BOOL8 STRING::operator==(const STRING& str) const { && (memcmp(GetCStr(), str.GetCStr(), this_used) == 0); } -BOOL8 STRING::operator!=(const STRING& str) const { +bool STRING::operator!=(const STRING& str) const { FixHeader(); str.FixHeader(); const STRING_HEADER* str_header = str.GetHeader(); @@ -326,7 +326,7 @@ BOOL8 STRING::operator!=(const STRING& str) const { || (memcmp(GetCStr(), str.GetCStr(), this_used) != 0); } -BOOL8 STRING::operator!=(const char* cstr) const { +bool STRING::operator!=(const char* cstr) const { FixHeader(); const STRING_HEADER* this_header = GetHeader(); diff --git a/src/ccutil/strngs.h b/src/ccutil/strngs.h index 0a3aacd245..abc993485c 100644 --- a/src/ccutil/strngs.h +++ b/src/ccutil/strngs.h @@ -64,7 +64,7 @@ class TESS_API STRING // As DeSerialize, but only seeks past the data - hence a static method. static bool SkipDeSerialize(tesseract::TFile* fp); - BOOL8 contains(const char c) const; + bool contains(const char c) const; int32_t length() const; int32_t size() const { return length(); } // Workaround to avoid g++ -Wsign-compare warnings. @@ -92,9 +92,9 @@ class TESS_API STRING void split(const char c, GenericVector *splited); void truncate_at(int32_t index); - BOOL8 operator== (const STRING & string) const; - BOOL8 operator!= (const STRING & string) const; - BOOL8 operator!= (const char *string) const; + bool operator== (const STRING & string) const; + bool operator!= (const STRING & string) const; + bool operator!= (const char *string) const; STRING & operator= (const char *string); STRING & operator= (const STRING & string); diff --git a/src/classify/classify.h b/src/classify/classify.h index 167a0caae1..9c8cf64e2b 100644 --- a/src/classify/classify.h +++ b/src/classify/classify.h @@ -109,7 +109,7 @@ class Classify : public CCStruct { ADAPT_TEMPLATES ReadAdaptedTemplates(TFile* File); /* normmatch.cpp ************************************************************/ FLOAT32 ComputeNormMatch(CLASS_ID ClassId, - const FEATURE_STRUCT& feature, BOOL8 DebugMatch); + const FEATURE_STRUCT& feature, bool DebugMatch); void FreeNormProtos(); NORM_PROTOS* ReadNormProtos(TFile* fp); /* protos.cpp ***************************************************************/ diff --git a/src/classify/cluster.cpp b/src/classify/cluster.cpp index 52953e6e71..b76316adc6 100644 --- a/src/classify/cluster.cpp +++ b/src/classify/cluster.cpp @@ -308,8 +308,8 @@ PROTOTYPE *NewMixedProto(int16_t N, CLUSTER *Cluster, STATISTICS *Statistics); PROTOTYPE *NewSimpleProto(int16_t N, CLUSTER *Cluster); -BOOL8 Independent (PARAM_DESC ParamDesc[], -int16_t N, FLOAT32 * CoVariance, FLOAT32 Independence); +bool Independent(PARAM_DESC* ParamDesc, + int16_t N, FLOAT32* CoVariance, FLOAT32 Independence); BUCKETS *GetBuckets(CLUSTERER* clusterer, DISTRIBUTION Distribution, @@ -347,7 +347,7 @@ uint16_t UniformBucket(PARAM_DESC *ParamDesc, FLOAT32 Mean, FLOAT32 StdDev); -BOOL8 DistributionOK(BUCKETS *Buckets); +bool DistributionOK(BUCKETS* Buckets); void FreeStatistics(STATISTICS *Statistics); @@ -378,9 +378,9 @@ FLOAT64 Solve(SOLVEFUNC Function, FLOAT64 ChiArea(CHISTRUCT *ChiParams, FLOAT64 x); -BOOL8 MultipleCharSamples(CLUSTERER *Clusterer, - CLUSTER *Cluster, - FLOAT32 MaxIllegal); +bool MultipleCharSamples(CLUSTERER* Clusterer, + CLUSTER* Cluster, + FLOAT32 MaxIllegal); double InvertMatrix(const float* input, int size, float* inv); @@ -1637,9 +1637,9 @@ PROTOTYPE *NewSimpleProto(int16_t N, CLUSTER *Cluster) { * @note Exceptions: None * @note History: 6/4/89, DSJ, Created. */ -BOOL8 -Independent (PARAM_DESC ParamDesc[], -int16_t N, FLOAT32 * CoVariance, FLOAT32 Independence) { +bool +Independent(PARAM_DESC* ParamDesc, + int16_t N, FLOAT32* CoVariance, FLOAT32 Independence) { int i, j; FLOAT32 *VARii; // points to ith on-diagonal element FLOAT32 *VARjj; // points to jth on-diagonal element @@ -1662,10 +1662,10 @@ int16_t N, FLOAT32 * CoVariance, FLOAT32 Independence) { CorrelationCoeff = sqrt (sqrt (*CoVariance * *CoVariance / (*VARii * *VARjj))); if (CorrelationCoeff > Independence) - return (FALSE); + return false; } } - return (TRUE); + return true; } // Independent /** @@ -1746,7 +1746,7 @@ BUCKETS *MakeBuckets(DISTRIBUTION Distribution, FLOAT64 LastProbDensity; FLOAT64 ProbDensity; uint16_t CurrentBucket; - BOOL8 Symmetrical; + bool Symmetrical; // allocate memory needed for data structure Buckets = static_cast(Emalloc(sizeof(BUCKETS))); @@ -1766,7 +1766,7 @@ BUCKETS *MakeBuckets(DISTRIBUTION Distribution, } // all currently defined distributions are symmetrical - Symmetrical = TRUE; + Symmetrical = true; Buckets->ChiSquared = ComputeChiSquared( DegreesOfFreedom(Distribution, Buckets->NumberOfBuckets), Confidence); @@ -2122,7 +2122,7 @@ uint16_t UniformBucket(PARAM_DESC *ParamDesc, * @note Exceptions: None * @note History: 6/5/89, DSJ, Created. */ -BOOL8 DistributionOK(BUCKETS *Buckets) { +bool DistributionOK(BUCKETS* Buckets) { FLOAT32 FrequencyDifference; FLOAT32 TotalDifference; int i; @@ -2137,9 +2137,9 @@ BOOL8 DistributionOK(BUCKETS *Buckets) { // test to see if the difference is more than expected if (TotalDifference > Buckets->ChiSquared) - return FALSE; + return false; else - return TRUE; + return true; } // DistributionOK /** @@ -2461,9 +2461,9 @@ FLOAT64 ChiArea(CHISTRUCT *ChiParams, FLOAT64 x) { * 2/22/90, DSJ, Added MaxIllegal control rather than always * splitting illegal clusters. */ -BOOL8 -MultipleCharSamples (CLUSTERER * Clusterer, -CLUSTER * Cluster, FLOAT32 MaxIllegal) +bool +MultipleCharSamples(CLUSTERER* Clusterer, + CLUSTER* Cluster, FLOAT32 MaxIllegal) #define ILLEGAL_CHAR 2 { static BOOL8 *CharFlags = nullptr; @@ -2505,11 +2505,11 @@ CLUSTER * Cluster, FLOAT32 MaxIllegal) PercentIllegal = (FLOAT32) NumIllegalInCluster / NumCharInCluster; if (PercentIllegal > MaxIllegal) { destroy(SearchState); - return (TRUE); + return true; } } } - return (FALSE); + return false; } // MultipleCharSamples diff --git a/src/classify/clusttool.cpp b/src/classify/clusttool.cpp index 99a40e927a..093a5c6fca 100644 --- a/src/classify/clusttool.cpp +++ b/src/classify/clusttool.cpp @@ -375,9 +375,9 @@ void WriteProtoStyle(FILE *File, PROTOSTYLE ProtoStyle) { * @note History: 6/12/89, DSJ, Created. */ -void WriteProtoList(FILE *File, uint16_t N, PARAM_DESC ParamDesc[], - LIST ProtoList, BOOL8 WriteSigProtos, - BOOL8 WriteInsigProtos) { +void WriteProtoList(FILE* File, uint16_t N, PARAM_DESC* ParamDesc, + LIST ProtoList, bool WriteSigProtos, + bool WriteInsigProtos) { PROTOTYPE *Proto; /* write file header */ diff --git a/src/classify/clusttool.h b/src/classify/clusttool.h index 76f6b7197c..ff0ad6edd5 100644 --- a/src/classify/clusttool.h +++ b/src/classify/clusttool.h @@ -44,9 +44,9 @@ void WriteNFloats (FILE * File, uint16_t N, FLOAT32 Array[]); void WriteProtoStyle(FILE *File, PROTOSTYLE ProtoStyle); -void WriteProtoList(FILE *File, uint16_t N, PARAM_DESC ParamDesc[], - LIST ProtoList, BOOL8 WriteSigProtos, - BOOL8 WriteInsigProtos); +void WriteProtoList(FILE* File, uint16_t N, PARAM_DESC* ParamDesc, + LIST ProtoList, bool WriteSigProtos, + bool WriteInsigProtos); //--------------Global Data Definitions and Declarations--------------------- // define errors that can be trapped diff --git a/src/classify/float2int.cpp b/src/classify/float2int.cpp index 2e913d3b8b..2af74d710b 100644 --- a/src/classify/float2int.cpp +++ b/src/classify/float2int.cpp @@ -71,7 +71,7 @@ void Classify::ComputeIntCharNormArray(const FEATURE_STRUCT& norm_feature, for (int i = 0; i < unicharset.size(); i++) { if (i < PreTrainedTemplates->NumClasses) { int norm_adjust = static_cast(INT_CHAR_NORM_RANGE * - ComputeNormMatch(i, norm_feature, FALSE)); + ComputeNormMatch(i, norm_feature, false)); char_norm_array[i] = ClipToRange(norm_adjust, 0, MAX_INT_CHAR_NORM); } else { // Classes with no templates (eg. ambigs & ligatures) default diff --git a/src/classify/intproto.cpp b/src/classify/intproto.cpp index 19650a1b40..d5df3fd307 100644 --- a/src/classify/intproto.cpp +++ b/src/classify/intproto.cpp @@ -136,7 +136,7 @@ void DoFill(FILL_SPEC *FillSpec, uint32_t ClassCount, uint32_t WordIndex); -BOOL8 FillerDone(TABLE_FILLER *Filler); +bool FillerDone(TABLE_FILLER* Filler); void FillPPCircularBits(uint32_t ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR], @@ -1221,15 +1221,12 @@ void DoFill(FILL_SPEC *FillSpec, * @note Exceptions: none * @note History: Tue Feb 19 10:08:05 1991, DSJ, Created. */ -BOOL8 FillerDone(TABLE_FILLER *Filler) { +bool FillerDone(TABLE_FILLER* Filler) { FILL_SWITCH *Next; Next = &(Filler->Switch[Filler->NextSwitch]); - if (Filler->X > Next->X && Next->Type == LastSwitch) - return (TRUE); - else - return (FALSE); + return Filler->X > Next->X && Next->Type == LastSwitch; } /* FillerDone */ diff --git a/src/classify/normmatch.cpp b/src/classify/normmatch.cpp index 7245fbc3d4..0e60ee37c2 100644 --- a/src/classify/normmatch.cpp +++ b/src/classify/normmatch.cpp @@ -87,7 +87,7 @@ namespace tesseract { */ FLOAT32 Classify::ComputeNormMatch(CLASS_ID ClassId, const FEATURE_STRUCT& feature, - BOOL8 DebugMatch) { + bool DebugMatch) { LIST Protos; FLOAT32 BestMatch; FLOAT32 Match; diff --git a/src/classify/ocrfeatures.cpp b/src/classify/ocrfeatures.cpp index d0329ed2ec..c837b5ecd2 100644 --- a/src/classify/ocrfeatures.cpp +++ b/src/classify/ocrfeatures.cpp @@ -40,14 +40,14 @@ * @return TRUE if feature added to set, FALSE if set is already full. * @note History: Tue May 22 17:22:23 1990, DSJ, Created. */ -BOOL8 AddFeature(FEATURE_SET FeatureSet, FEATURE Feature) { +bool AddFeature(FEATURE_SET FeatureSet, FEATURE Feature) { if (FeatureSet->NumFeatures >= FeatureSet->MaxNumFeatures) { FreeFeature(Feature); - return FALSE; + return false; } FeatureSet->Features[FeatureSet->NumFeatures++] = Feature; - return TRUE; + return true; } /* AddFeature */ /** diff --git a/src/classify/ocrfeatures.h b/src/classify/ocrfeatures.h index c368fb62b5..f2808217c2 100644 --- a/src/classify/ocrfeatures.h +++ b/src/classify/ocrfeatures.h @@ -104,7 +104,7 @@ const FEATURE_DESC_STRUCT Name = { \ /*---------------------------------------------------------------------- Generic routines that work for all feature types ----------------------------------------------------------------------*/ -BOOL8 AddFeature(FEATURE_SET FeatureSet, FEATURE Feature); +bool AddFeature(FEATURE_SET FeatureSet, FEATURE Feature); void FreeFeature(FEATURE Feature); diff --git a/src/textord/blkocc.cpp b/src/textord/blkocc.cpp index 446d9f8d88..7178540887 100644 --- a/src/textord/blkocc.cpp +++ b/src/textord/blkocc.cpp @@ -50,12 +50,12 @@ static void horizontal_coutline_projection(C_OUTLINE *outline, * Return TRUE if it is. */ -BOOL8 test_underline( //look for underlines - BOOL8 testing_on, //< drawing blob - C_BLOB *blob, //< blob to test - int16_t baseline, //< coords of baseline - int16_t xheight //< height of line - ) { +bool test_underline( //look for underlines + bool testing_on, //< drawing blob + C_BLOB* blob, //< blob to test + int16_t baseline, //< coords of baseline + int16_t xheight //< height of line +) { int16_t occ; int16_t blob_width; //width of blob TBOX blob_box; //bounding box @@ -106,11 +106,10 @@ BOOL8 test_underline( //look for underlines } if (desc_occ > x_occ + x_occ && desc_occ > blob_width * textord_underline_threshold) - return TRUE; //real underline - if (asc_occ > x_occ + x_occ - && asc_occ > blob_width * textord_underline_threshold) - return TRUE; //overline - return FALSE; //neither + return true; //real underline + return asc_occ > x_occ + x_occ && + asc_occ > blob_width * textord_underline_threshold; //overline + //neither } diff --git a/src/textord/blkocc.h b/src/textord/blkocc.h index 73c179e3ac..13fea883d2 100644 --- a/src/textord/blkocc.h +++ b/src/textord/blkocc.h @@ -66,7 +66,7 @@ class REGION_OCC:public ELIST_LINK ELISTIZEH (REGION_OCC) #define RANGE_IN_BAND( band_max, band_min, range_max, range_min ) \ -( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? TRUE : FALSE +( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? true : false /************************************************************************ Adapted from the following procedure so that it can be used in the bands class in an include file... @@ -85,7 +85,7 @@ int16_t range_min] } ***********************************************************************/ #define RANGE_OVERLAPS_BAND( band_max, band_min, range_max, range_min ) \ -( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? TRUE : FALSE +( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? true : false /************************************************************************ Adapted from the following procedure so that it can be used in the bands class in an include file... @@ -151,33 +151,24 @@ class BAND min_min = new_min_min; } - BOOL8 in_minimal( //in minimal limits? - float y) { //y value - if ((y >= max_min) && (y < min_max)) - return TRUE; - else - return FALSE; + bool in_minimal( //in minimal limits? + float y) { //y value + return (y >= max_min) && (y < min_max); } - BOOL8 in_nominal( //in nominal limits? - float y) { //y value - if ((y >= min) && (y < max)) - return TRUE; - else - return FALSE; + bool in_nominal( //in nominal limits? + float y) { //y value + return (y >= min) && (y < max); } - BOOL8 in_maximal( //in maximal limits? - float y) { //y value - if ((y >= min_min) && (y < max_max)) - return TRUE; - else - return FALSE; + bool in_maximal( //in maximal limits? + float y) { //y value + return (y >= min_min) && (y < max_max); } //overlaps min limits? - BOOL8 range_overlaps_minimal(float y1, //one range limit - float y2) { //other range limit + bool range_overlaps_minimal(float y1, //one range limit + float y2) { //other range limit if (y1 > y2) return RANGE_OVERLAPS_BAND (min_max, max_min, y1, y2); else @@ -185,8 +176,8 @@ class BAND } //overlaps nom limits? - BOOL8 range_overlaps_nominal(float y1, //one range limit - float y2) { //other range limit + bool range_overlaps_nominal(float y1, //one range limit + float y2) { //other range limit if (y1 > y2) return RANGE_OVERLAPS_BAND (max, min, y1, y2); else @@ -194,35 +185,35 @@ class BAND } //overlaps max limits? - BOOL8 range_overlaps_maximal(float y1, //one range limit - float y2) { //other range limit + bool range_overlaps_maximal(float y1, //one range limit + float y2) { //other range limit if (y1 > y2) return RANGE_OVERLAPS_BAND (max_max, min_min, y1, y2); else return RANGE_OVERLAPS_BAND (max_max, min_min, y2, y1); } - BOOL8 range_in_minimal( //within min limits? - float y1, //one range limit - float y2) { //other range limit + bool range_in_minimal( //within min limits? + float y1, //one range limit + float y2) { //other range limit if (y1 > y2) return RANGE_IN_BAND (min_max, max_min, y1, y2); else return RANGE_IN_BAND (min_max, max_min, y2, y1); } - BOOL8 range_in_nominal( //within nom limits? - float y1, //one range limit - float y2) { //other range limit + bool range_in_nominal( //within nom limits? + float y1, //one range limit + float y2) { //other range limit if (y1 > y2) return RANGE_IN_BAND (max, min, y1, y2); else return RANGE_IN_BAND (max, min, y2, y1); } - BOOL8 range_in_maximal( //within max limits? - float y1, //one range limit - float y2) { //other range limit + bool range_in_maximal( //within max limits? + float y1, //one range limit + float y2) { //other range limit if (y1 > y2) return RANGE_IN_BAND (max_max, min_min, y1, y2); else @@ -252,11 +243,11 @@ extern INT_VAR_H (blockocc_band_count, 4, "Number of bands used"); extern double_VAR_H (textord_underline_threshold, 0.9, "Fraction of width occupied"); -BOOL8 test_underline( //look for underlines - BOOL8 testing_on, //drawing blob - C_BLOB *blob, //blob to test - int16_t baseline, //coords of baseline - int16_t xheight //height of line - ); +bool test_underline( //look for underlines + bool testing_on, //drawing blob + C_BLOB* blob, //blob to test + int16_t baseline, //coords of baseline + int16_t xheight //height of line +); #endif diff --git a/src/textord/edgblob.cpp b/src/textord/edgblob.cpp index 7213970110..57bb56f89d 100644 --- a/src/textord/edgblob.cpp +++ b/src/textord/edgblob.cpp @@ -184,7 +184,7 @@ int32_t OL_BUCKETS::count_children( // recursive count C_OUTLINE *outline, // parent outline int32_t max_count // max output ) { - BOOL8 parent_box; // could it be boxy + bool parent_box; // could it be boxy int16_t xmin, xmax; // coord limits int16_t ymin, ymax; int16_t xindex, yindex; // current bucket @@ -207,7 +207,7 @@ int32_t OL_BUCKETS::count_children( // recursive count grandchild_count = 0; parent_area = 0; max_parent_area = 0; - parent_box = TRUE; + parent_box = true; for (yindex = ymin; yindex <= ymax; yindex++) { for (xindex = xmin; xindex <= xmax; xindex++) { child_it.set_to_list(&buckets[yindex * bxdim + xindex]); @@ -239,7 +239,7 @@ int32_t OL_BUCKETS::count_children( // recursive count parent_area = -parent_area; max_parent_area = outline->bounding_box().area() * edges_boxarea; if (parent_area < max_parent_area) - parent_box = FALSE; + parent_box = false; } if (parent_box && (!edges_children_fix || @@ -249,7 +249,7 @@ int32_t OL_BUCKETS::count_children( // recursive count child_area = -child_area; if (edges_children_fix) { if (parent_area - child_area < max_parent_area) { - parent_box = FALSE; + parent_box = false; continue; } if (grandchild_count > 0) { @@ -399,7 +399,7 @@ void empty_buckets( // find blobs BLOCK *block, // block to scan OL_BUCKETS *buckets // output buckets ) { - BOOL8 good_blob; // healthy blob + bool good_blob; // healthy blob C_OUTLINE_LIST outlines; // outlines in block // iterator C_OUTLINE_IT out_it = &outlines; @@ -437,11 +437,11 @@ void empty_buckets( // find blobs * illegal and return FALSE. */ -BOOL8 capture_children( // find children - OL_BUCKETS *buckets, // bucket sort clanss - C_BLOB_IT *reject_it, // dead grandchildren - C_OUTLINE_IT *blob_it // output outlines - ) { +bool capture_children( // find children + OL_BUCKETS* buckets, // bucket sort clanss + C_BLOB_IT* reject_it, // dead grandchildren + C_OUTLINE_IT* blob_it // output outlines +) { C_OUTLINE *outline; // master outline int32_t child_count; // no of children @@ -454,9 +454,9 @@ BOOL8 capture_children( // find children child_count = buckets->count_children(outline, edges_children_count_limit); if (child_count > edges_children_count_limit) - return FALSE; + return false; if (child_count > 0) buckets->extract_children(outline, blob_it); - return TRUE; + return true; } diff --git a/src/textord/edgblob.h b/src/textord/edgblob.h index d7537f5496..b85505c13e 100644 --- a/src/textord/edgblob.h +++ b/src/textord/edgblob.h @@ -87,9 +87,9 @@ void empty_buckets( //find blobs BLOCK *block, //block to scan OL_BUCKETS *buckets //output buckets ); -BOOL8 capture_children( //find children - OL_BUCKETS *buckets, //bucket sort clanss - C_BLOB_IT *reject_it, //dead grandchildren - C_OUTLINE_IT *blob_it //output outlines - ); +bool capture_children( //find children + OL_BUCKETS* buckets, //bucket sort clanss + C_BLOB_IT* reject_it, //dead grandchildren + C_OUTLINE_IT* blob_it //output outlines +); #endif diff --git a/src/textord/fpchop.cpp b/src/textord/fpchop.cpp index 90a311ff6e..25999f43aa 100644 --- a/src/textord/fpchop.cpp +++ b/src/textord/fpchop.cpp @@ -52,7 +52,7 @@ ROW *fixed_pitch_words( //find lines TO_ROW *row, //row to do FCOORD rotation //for drawing ) { - BOOL8 bol; //start of line + bool bol; //start of line uint8_t blanks; //in front of word uint8_t new_blanks; //blanks in empty cell int16_t chop_coord; //chop boundary @@ -82,7 +82,7 @@ ROW *fixed_pitch_words( //find lines #endif prev_x = -INT16_MAX; - bol = TRUE; + bol = true; blanks = 0; if (rep_it.empty ()) rep_left = INT16_MAX; @@ -158,7 +158,7 @@ ROW *fixed_pitch_words( //find lines word_it.add_after_then_move (word); if (bol) { word->set_flag (W_BOL, TRUE); - bol = FALSE; + bol = false; } blanks = new_blanks; } @@ -398,14 +398,14 @@ void fixed_split_coutline( //chop the outline * If the coutline lies too heavily to one side to chop, FALSE is returned. **********************************************************************/ -BOOL8 fixed_chop_coutline( //chop the outline - C_OUTLINE *srcline, //source outline - int16_t chop_coord, //place to chop - float pitch_error, //allowed deviation - C_OUTLINE_FRAG_LIST *left_frags, //left half of chop - C_OUTLINE_FRAG_LIST *right_frags //right half of chop - ) { - BOOL8 first_frag; //fragment +bool fixed_chop_coutline( //chop the outline + C_OUTLINE* srcline, //source outline + int16_t chop_coord, //place to chop + float pitch_error, //allowed deviation + C_OUTLINE_FRAG_LIST* left_frags, //left half of chop + C_OUTLINE_FRAG_LIST* right_frags //right half of chop +) { + bool first_frag; //fragment int16_t left_edge; //of outline int16_t startindex; //in first fragment int32_t length; //of outline @@ -432,10 +432,10 @@ BOOL8 fixed_chop_coutline( //chop the outline pos += srcline->step (stepindex); } if (left_edge >= chop_coord - pitch_error) - return FALSE; //not worth it + return false; //not worth it startindex = tail_index; - first_frag = TRUE; + first_frag = true; head_index = tail_index; head_pos = tail_pos; do { @@ -448,7 +448,7 @@ BOOL8 fixed_chop_coutline( //chop the outline while (tail_pos.x () != chop_coord && tail_index != startindex); if (tail_index == startindex) { if (first_frag) - return FALSE; //doesn't cross line + return false; //doesn't cross line else break; } @@ -466,7 +466,7 @@ BOOL8 fixed_chop_coutline( //chop the outline else { first_index = tail_index; first_pos = tail_pos; - first_frag = FALSE; + first_frag = false; } while (srcline->step (tail_index).x () == 0) { tail_pos += srcline->step (tail_index); @@ -510,7 +510,7 @@ BOOL8 fixed_chop_coutline( //chop the outline first_pos, srcline, left_frags); - return TRUE; //did some chopping + return true; //did some chopping } /********************************************************************** diff --git a/src/textord/fpchop.h b/src/textord/fpchop.h index 5c9802d1a9..6f7c488552 100644 --- a/src/textord/fpchop.h +++ b/src/textord/fpchop.h @@ -95,13 +95,13 @@ void fixed_split_coutline( //chop the outline C_OUTLINE_IT *left_it, //left half of chop C_OUTLINE_IT *right_it //right half of chop ); -BOOL8 fixed_chop_coutline( //chop the outline - C_OUTLINE *srcline, //source outline - int16_t chop_coord, //place to chop - float pitch_error, //allowed deviation - C_OUTLINE_FRAG_LIST *left_frags, //left half of chop - C_OUTLINE_FRAG_LIST *right_frags //right half of chop - ); +bool fixed_chop_coutline( //chop the outline + C_OUTLINE* srcline, //source outline + int16_t chop_coord, //place to chop + float pitch_error, //allowed deviation + C_OUTLINE_FRAG_LIST* left_frags, //left half of chop + C_OUTLINE_FRAG_LIST* right_frags //right half of chop +); void save_chop_cfragment( //chop the outline int16_t head_index, //head of fragment ICOORD head_pos, //head of fragment diff --git a/src/textord/gap_map.cpp b/src/textord/gap_map.cpp index 44a385b6af..3ad51ec621 100644 --- a/src/textord/gap_map.cpp +++ b/src/textord/gap_map.cpp @@ -157,17 +157,17 @@ GAPMAP::GAPMAP( //Constructor * block have a wide gap? *************************************************************************/ -BOOL8 GAPMAP::table_gap( //Is gap a table? - int16_t left, //From here - int16_t right //To here - ) { +bool GAPMAP::table_gap( //Is gap a table? + int16_t left, //From here + int16_t right //To here +) { int16_t min_quantum; int16_t max_quantum; int16_t i; - BOOL8 tab_found = FALSE; + bool tab_found = false; if (!any_tabs) - return FALSE; + return false; min_quantum = (left - min_left) / bucket_size; max_quantum = (right - min_left) / bucket_size; @@ -178,6 +178,6 @@ BOOL8 GAPMAP::table_gap( //Is gap a table? if (max_quantum > map_max) max_quantum = map_max; for (i = min_quantum; (!tab_found && (i <= max_quantum)); i++) if (map[i] > total_rows / 2) - tab_found = TRUE; + tab_found = true; return tab_found; } diff --git a/src/textord/gap_map.h b/src/textord/gap_map.h index 3eea27c401..b0e173270a 100644 --- a/src/textord/gap_map.h +++ b/src/textord/gap_map.h @@ -23,9 +23,9 @@ class GAPMAP free_mem(map); } - BOOL8 table_gap( //Is gap a table? - int16_t left, //From here - int16_t right); //To here + bool table_gap( //Is gap a table? + int16_t left, //From here + int16_t right); //To here private: int16_t total_rows; //in block diff --git a/src/textord/makerow.cpp b/src/textord/makerow.cpp index 5753345d0e..86366a5553 100644 --- a/src/textord/makerow.cpp +++ b/src/textord/makerow.cpp @@ -227,11 +227,11 @@ float make_rows(ICOORD page_tr, TO_BLOCK_LIST *port_blocks) { * Arrange the good blobs into rows of text. */ void make_initial_textrows( //find lines - ICOORD page_tr, - TO_BLOCK *block, //block to do - FCOORD rotation, //for drawing - BOOL8 testing_on //correct orientation - ) { + ICOORD page_tr, + TO_BLOCK* block, //block to do + FCOORD rotation, //for drawing + bool testing_on //correct orientation +) { TO_ROW_IT row_it = block->get_rows (); #ifndef GRAPHICS_DISABLED @@ -523,13 +523,13 @@ void vigorous_noise_removal(TO_BLOCK* block) { * Remove overlapping rows and fit all the blobs to what's left. */ void cleanup_rows_making( //find lines - ICOORD page_tr, //top right - TO_BLOCK *block, //block to do - float gradient, //gradient to fit - FCOORD rotation, //for drawing - int32_t block_edge, //edge of block - BOOL8 testing_on //correct orientation - ) { + ICOORD page_tr, //top right + TO_BLOCK* block, //block to do + float gradient, //gradient to fit + FCOORD rotation, //for drawing + int32_t block_edge, //edge of block + bool testing_on //correct orientation +) { //iterators BLOBNBOX_IT blob_it = &block->blobs; TO_ROW_IT row_it = block->get_rows (); @@ -545,12 +545,12 @@ void cleanup_rows_making( //find lines gradient, rotation, block_edge, - textord_show_parallel_rows &&testing_on); + textord_show_parallel_rows && testing_on); delete_non_dropout_rows(block, gradient, rotation, block_edge, - textord_show_parallel_rows &&testing_on); + textord_show_parallel_rows && testing_on); expand_rows(page_tr, block, gradient, rotation, block_edge, testing_on); blob_it.set_to_list (&block->blobs); row_it.set_to_list (block->get_rows ()); @@ -576,12 +576,12 @@ void cleanup_rows_making( //find lines * Compute the linespacing and offset. */ void delete_non_dropout_rows( //find lines - TO_BLOCK *block, //block to do - float gradient, //global skew - FCOORD rotation, //deskew vector - int32_t block_edge, //left edge - BOOL8 testing_on //correct orientation - ) { + TO_BLOCK* block, //block to do + float gradient, //global skew + FCOORD rotation, //deskew vector + int32_t block_edge, //left edge + bool testing_on //correct orientation +) { TBOX block_box; //deskewed block int32_t *deltas; //change in occupation int32_t *occupation; //of pixel coords @@ -663,14 +663,14 @@ void delete_non_dropout_rows( //find lines * Delete this row if it has a neighbour with better dropout characteristics. * TRUE is returned if the row should be deleted. */ -BOOL8 find_best_dropout_row( //find neighbours - TO_ROW *row, //row to test - int32_t distance, //dropout dist - float dist_limit, //threshold distance - int32_t line_index, //index of row - TO_ROW_IT *row_it, //current position - BOOL8 testing_on //correct orientation - ) { +bool find_best_dropout_row( //find neighbours + TO_ROW* row, //row to test + int32_t distance, //dropout dist + float dist_limit, //threshold distance + int32_t line_index, //index of row + TO_ROW_IT* row_it, //current position + bool testing_on //correct orientation +) { int32_t next_index; // of neighbouring row int32_t row_offset; //from current row int32_t abs_dist; //absolute distance @@ -692,7 +692,7 @@ BOOL8 find_best_dropout_row( //find neighbours if (testing_on) { tprintf (" too far - deleting\n"); } - return TRUE; + return true; } if ((distance < 0 && !row_it->at_last ()) || (distance >= 0 && !row_it->at_first ())) { @@ -711,7 +711,7 @@ BOOL8 find_best_dropout_row( //find neighbours line_index + distance - next_index, next_row->intercept ()); } - return TRUE; //other is nearer + return true; //other is nearer } else if (next_index == line_index || next_index == line_index + distance + distance) { @@ -722,7 +722,7 @@ BOOL8 find_best_dropout_row( //find neighbours row->believability (), next_row->believability ()); } - return TRUE; //other is more believable + return true; //other is more believable } } row_offset += row_inc; @@ -733,7 +733,7 @@ BOOL8 find_best_dropout_row( //find neighbours if (testing_on) tprintf (" keeping\n"); } - return FALSE; + return false; } @@ -961,14 +961,14 @@ void compute_dropout_distances( //project blobs * then do so. */ void expand_rows( //find lines - ICOORD page_tr, //top right - TO_BLOCK *block, //block to do - float gradient, //gradient to fit - FCOORD rotation, //for drawing - int32_t block_edge, //edge of block - BOOL8 testing_on //correct orientation - ) { - BOOL8 swallowed_row; //eaten a neighbour + ICOORD page_tr, //top right + TO_BLOCK* block, //block to do + float gradient, //gradient to fit + FCOORD rotation, //for drawing + int32_t block_edge, //edge of block + bool testing_on //correct orientation +) { + bool swallowed_row; //eaten a neighbour float y_max, y_min; //new row limits float y_bottom, y_top; //allowed limits TO_ROW *test_row; //next row @@ -988,9 +988,9 @@ void expand_rows( //find lines if (textord_new_initial_xheight) { if (block->get_rows ()->length () == 0) return; - compute_row_stats(block, textord_show_expanded_rows &&testing_on); + compute_row_stats(block, textord_show_expanded_rows && testing_on); } - assign_blobs_to_rows (block, &gradient, 4, TRUE, FALSE, FALSE); + assign_blobs_to_rows (block, &gradient, 4, true, false, false); //get real membership if (block->get_rows ()->length () == 0) return; @@ -998,9 +998,9 @@ void expand_rows( //find lines gradient, rotation, block_edge, - textord_show_expanded_rows &&testing_on); + textord_show_expanded_rows && testing_on); if (!textord_new_initial_xheight) - compute_row_stats(block, textord_show_expanded_rows &&testing_on); + compute_row_stats(block, textord_show_expanded_rows && testing_on); row_it.move_to_last (); do { row = row_it.data (); @@ -1016,9 +1016,9 @@ void expand_rows( //find lines tprintf("Expanding bottom of row at %f from %f to %f\n", row->intercept(), y_min, y_bottom); //expandable - swallowed_row = TRUE; + swallowed_row = true; while (swallowed_row && !row_it.at_last ()) { - swallowed_row = FALSE; + swallowed_row = false; //get next one test_row = row_it.data_relative (1); //overlaps space @@ -1040,7 +1040,7 @@ void expand_rows( //find lines //swallow complete row delete row_it.extract (); row_it.backward (); - swallowed_row = TRUE; + swallowed_row = true; } else if (test_row->max_y () < y_min) { //shorter limit @@ -1063,9 +1063,9 @@ void expand_rows( //find lines if (textord_show_expanded_rows && testing_on) tprintf("Expanding top of row at %f from %f to %f\n", row->intercept(), y_max, y_top); - swallowed_row = TRUE; + swallowed_row = true; while (swallowed_row && !row_it.at_first ()) { - swallowed_row = FALSE; + swallowed_row = false; //get one above test_row = row_it.data_relative (-1); if (test_row->min_y () < y_top) { @@ -1086,7 +1086,7 @@ void expand_rows( //find lines //swallow complete row delete row_it.extract (); row_it.forward (); - swallowed_row = TRUE; + swallowed_row = true; } else if (test_row->min_y () < y_max) { //shorter limit @@ -1155,9 +1155,9 @@ void adjust_row_limits( //tidy limits * Compute the linespacing and offset. */ void compute_row_stats( //find lines - TO_BLOCK *block, //block to do - BOOL8 testing_on //correct orientation - ) { + TO_BLOCK* block, //block to do + bool testing_on //correct orientation +) { int32_t row_index; //of median TO_ROW *row; //current row TO_ROW *prev_row; //previous row @@ -1787,10 +1787,10 @@ static int CountOverlaps(const TBOX& box, int min_height, * Test wide objects for being potential underlines. If they are then * put them in a separate list in the block. */ -void separate_underlines(TO_BLOCK *block, // block to do +void separate_underlines(TO_BLOCK* block, // block to do float gradient, // skew angle FCOORD rotation, // inverse landscape - BOOL8 testing_on) { // correct orientation + bool testing_on) { // correct orientation BLOBNBOX *blob; // current blob C_BLOB *rotated_blob; // rotated blob TO_ROW *row; // current row @@ -1861,11 +1861,11 @@ void separate_underlines(TO_BLOCK *block, // block to do * Associate overlapping blobs and fake chop wide blobs. */ void pre_associate_blobs( //make rough chars - ICOORD page_tr, //top right - TO_BLOCK *block, //block to do - FCOORD rotation, //inverse landscape - BOOL8 testing_on //correct orientation - ) { + ICOORD page_tr, //top right + TO_BLOCK* block, //block to do + FCOORD rotation, //inverse landscape + bool testing_on //correct orientation +) { #ifndef GRAPHICS_DISABLED ScrollView::Color colour; //of boxes #endif @@ -1947,12 +1947,12 @@ void pre_associate_blobs( //make rough chars * Re-fit the rows in the block to the given gradient. */ void fit_parallel_rows( //find lines - TO_BLOCK *block, //block to do - float gradient, //gradient to fit - FCOORD rotation, //for drawing - int32_t block_edge, //edge of block - BOOL8 testing_on //correct orientation - ) { + TO_BLOCK* block, //block to do + float gradient, //gradient to fit + FCOORD rotation, //for drawing + int32_t block_edge, //edge of block + bool testing_on //correct orientation +) { #ifndef GRAPHICS_DISABLED ScrollView::Color colour; //of row #endif @@ -2018,9 +2018,9 @@ void fit_parallel_lms(float gradient, TO_ROW *row) { * Re-fit the rows in the block to the given gradient. */ namespace tesseract { -void Textord::make_spline_rows(TO_BLOCK *block, // block to do +void Textord::make_spline_rows(TO_BLOCK* block, // block to do float gradient, // gradient to fit - BOOL8 testing_on) { + bool testing_on) { #ifndef GRAPHICS_DISABLED ScrollView::Color colour; //of row #endif @@ -2103,14 +2103,14 @@ void make_baseline_spline(TO_ROW *row, //row to fit * quadratic fitted to them. * Return TRUE if enough blobs were far enough away to need a quadratic. */ -BOOL8 -segment_baseline ( //split baseline -TO_ROW * row, //row to fit -TO_BLOCK * block, //block it came from -int32_t & segments, //no fo segments -int32_t xstarts[] //coords of segments +bool +segment_baseline( //split baseline + TO_ROW* row, //row to fit + TO_BLOCK* block, //block it came from + int32_t& segments, //no fo segments + int32_t* xstarts //coords of segments ) { - BOOL8 needs_curve; //needs curved line + bool needs_curve; //needs curved line int blobcount; //no of blobs int blobindex; //current blob int last_state; //above, on , below @@ -2124,7 +2124,7 @@ int32_t xstarts[] //coords of segments BLOBNBOX_IT new_it = blob_it; //front end SORTED_FLOATS yshifts; //shifts from baseline - needs_curve = FALSE; + needs_curve = false; box = box_next_pre_chopped (&blob_it); xstarts[0] = box.left (); segments = 1; @@ -2137,7 +2137,7 @@ int32_t xstarts[] //coords of segments blob_it.move_to_last (); box = blob_it.data ()->bounding_box (); xstarts[1] = box.right (); - return FALSE; + return false; } last_state = 0; new_it.mark_cycle_pt (); @@ -2149,7 +2149,7 @@ int32_t xstarts[] //coords of segments yshifts.add (yshift, blobindex); if (new_it.cycled_list ()) { xstarts[1] = new_box.right (); - return FALSE; + return false; } } for (blobcount = 0; blobcount < textord_spline_medianwin / 2; blobcount++) @@ -2165,7 +2165,7 @@ int32_t xstarts[] //coords of segments else state = 0; if (state != 0) - needs_curve = TRUE; + needs_curve = true; // tprintf("State=%d, prev=%d, shift=%g\n", // state,last_state,yshift); if (state != last_state && blobcount > textord_spline_minblobs) { @@ -2295,13 +2295,13 @@ int32_t xstarts[] //coords of segments * If a block skew is given, use that, else attempt to track it. */ void assign_blobs_to_rows( //find lines - TO_BLOCK *block, //block to do - float *gradient, //block skew - int pass, //identification - BOOL8 reject_misses, //chuck big ones out - BOOL8 make_new_rows, //add rows for unmatched - BOOL8 drawing_skew //draw smoothed skew - ) { + TO_BLOCK* block, //block to do + float* gradient, //block skew + int pass, //identification + bool reject_misses, //chuck big ones out + bool make_new_rows, //add rows for unmatched + bool drawing_skew //draw smoothed skew +) { OVERLAP_STATE overlap_result; //what to do with it float ycoord; //current y float top, bottom; //of blob @@ -2495,13 +2495,13 @@ void assign_blobs_to_rows( //find lines * Return the row which most overlaps the blob. */ OVERLAP_STATE most_overlapping_row( //find best row - TO_ROW_IT *row_it, //iterator - TO_ROW *&best_row, //output row - float top, //top of blob - float bottom, //bottom of blob - float rowsize, //max row size - BOOL8 testing_blob //test stuff - ) { + TO_ROW_IT* row_it, //iterator + TO_ROW*& best_row, //output row + float top, //top of blob + float bottom, //bottom of blob + float rowsize, //max row size + bool testing_blob //test stuff +) { OVERLAP_STATE result; //result of tests float overlap; //of blob & row float bestover; //nearest row diff --git a/src/textord/makerow.h b/src/textord/makerow.h index 5de8c9db04..10e623c02e 100644 --- a/src/textord/makerow.h +++ b/src/textord/makerow.h @@ -138,35 +138,35 @@ float make_single_row(ICOORD page_tr, bool allow_sub_blobs, TO_BLOCK* block, float make_rows(ICOORD page_tr, // top right TO_BLOCK_LIST *port_blocks); void make_initial_textrows(ICOORD page_tr, - TO_BLOCK *block, // block to do + TO_BLOCK* block, // block to do FCOORD rotation, // for drawing - BOOL8 testing_on); // correct orientation + bool testing_on); // correct orientation void fit_lms_line(TO_ROW *row); void compute_page_skew(TO_BLOCK_LIST *blocks, // list of blocks float &page_m, // average gradient float &page_err); // average error void vigorous_noise_removal(TO_BLOCK* block); void cleanup_rows_making(ICOORD page_tr, // top right - TO_BLOCK *block, // block to do + TO_BLOCK* block, // block to do float gradient, // gradient to fit FCOORD rotation, // for drawing int32_t block_edge, // edge of block - BOOL8 testing_on); // correct orientation + bool testing_on); // correct orientation void delete_non_dropout_rows( //find lines - TO_BLOCK *block, //block to do - float gradient, //global skew - FCOORD rotation, //deskew vector - int32_t block_edge, //left edge - BOOL8 testing_on //correct orientation - ); -BOOL8 find_best_dropout_row( //find neighbours - TO_ROW *row, //row to test - int32_t distance, //dropout dist - float dist_limit, //threshold distance - int32_t line_index, //index of row - TO_ROW_IT *row_it, //current position - BOOL8 testing_on //correct orientation - ); + TO_BLOCK* block, //block to do + float gradient, //global skew + FCOORD rotation, //deskew vector + int32_t block_edge, //left edge + bool testing_on //correct orientation +); +bool find_best_dropout_row( //find neighbours + TO_ROW* row, //row to test + int32_t distance, //dropout dist + float dist_limit, //threshold distance + int32_t line_index, //index of row + TO_ROW_IT* row_it, //current position + bool testing_on //correct orientation +); TBOX deskew_block_coords( //block box TO_BLOCK *block, //block to do float gradient //global skew @@ -192,20 +192,20 @@ void compute_dropout_distances( //project blobs int32_t line_count //array sizes ); void expand_rows( //find lines - ICOORD page_tr, //top right - TO_BLOCK *block, //block to do - float gradient, //gradient to fit - FCOORD rotation, //for drawing - int32_t block_edge, //edge of block - BOOL8 testing_on //correct orientation - ); + ICOORD page_tr, //top right + TO_BLOCK* block, //block to do + float gradient, //gradient to fit + FCOORD rotation, //for drawing + int32_t block_edge, //edge of block + bool testing_on //correct orientation +); void adjust_row_limits( //tidy limits TO_BLOCK *block //block to do ); void compute_row_stats( //find lines - TO_BLOCK *block, //block to do - BOOL8 testing_on //correct orientation - ); + TO_BLOCK* block, //block to do + bool testing_on //correct orientation +); float median_block_xheight( //find lines TO_BLOCK *block, //block to do float gradient //global skew @@ -228,28 +228,28 @@ void correct_row_xheight(TO_ROW *row, // row to fix float xheight, // average values float ascrise, float descdrop); -void separate_underlines(TO_BLOCK *block, // block to do +void separate_underlines(TO_BLOCK* block, // block to do float gradient, // skew angle FCOORD rotation, // inverse landscape - BOOL8 testing_on); // correct orientation -void pre_associate_blobs( ICOORD page_tr, // top right - TO_BLOCK *block, // block to do + bool testing_on); // correct orientation +void pre_associate_blobs(ICOORD page_tr, // top right + TO_BLOCK* block, // block to do FCOORD rotation, // inverse landscape - BOOL8 testing_on); // correct orientation -void fit_parallel_rows(TO_BLOCK *block, // block to do + bool testing_on); // correct orientation +void fit_parallel_rows(TO_BLOCK* block, // block to do float gradient, // gradient to fit FCOORD rotation, // for drawing int32_t block_edge, // edge of block - BOOL8 testing_on); // correct orientation + bool testing_on); // correct orientation void fit_parallel_lms(float gradient, // forced gradient TO_ROW *row); // row to fit void make_baseline_spline(TO_ROW *row, // row to fit TO_BLOCK *block); // block it came from -BOOL8 segment_baseline ( //split baseline -TO_ROW * row, //row to fit -TO_BLOCK * block, //block it came from -int32_t & segments, //no fo segments -int32_t xstarts[] //coords of segments +bool segment_baseline( //split baseline + TO_ROW* row, //row to fit + TO_BLOCK* block, //block it came from + int32_t& segments, //no fo segments + int32_t* xstarts //coords of segments ); double *linear_spline_baseline ( //split baseline TO_ROW * row, //row to fit @@ -258,21 +258,21 @@ int32_t & segments, //no fo segments int32_t xstarts[] //coords of segments ); void assign_blobs_to_rows( //find lines - TO_BLOCK *block, //block to do - float *gradient, //block skew - int pass, //identification - BOOL8 reject_misses, //chuck big ones out - BOOL8 make_new_rows, //add rows for unmatched - BOOL8 drawing_skew //draw smoothed skew - ); + TO_BLOCK* block, //block to do + float* gradient, //block skew + int pass, //identification + bool reject_misses, //chuck big ones out + bool make_new_rows, //add rows for unmatched + bool drawing_skew //draw smoothed skew +); //find best row -OVERLAP_STATE most_overlapping_row(TO_ROW_IT *row_it, //iterator - TO_ROW *&best_row, //output row +OVERLAP_STATE most_overlapping_row(TO_ROW_IT* row_it, //iterator + TO_ROW*& best_row, //output row float top, //top of blob float bottom, //bottom of blob float rowsize, //max row size - BOOL8 testing_blob //test stuff - ); + bool testing_blob //test stuff + ); int blob_x_order( //sort function const void *item1, //items to compare const void *item2); diff --git a/src/textord/oldbasel.cpp b/src/textord/oldbasel.cpp index d5e35bb2eb..89a3e65b4c 100644 --- a/src/textord/oldbasel.cpp +++ b/src/textord/oldbasel.cpp @@ -82,8 +82,8 @@ namespace tesseract { * Top level function to make baselines the old way. **********************************************************************/ -void Textord::make_old_baselines(TO_BLOCK *block, // block to do - BOOL8 testing_on, // correct orientation +void Textord::make_old_baselines(TO_BLOCK* block, // block to do + bool testing_on, // correct orientation float gradient) { QSPLINE *prev_baseline; // baseline of previous row TO_ROW *row; // current row @@ -332,7 +332,7 @@ void Textord::find_textlines(TO_BLOCK *block, // block row is in int degree, // required approximation QSPLINE *spline) { // starting spline int partcount; /*no of partitions of */ - BOOL8 holed_line = FALSE; //lost too many blobs + bool holed_line = false; //lost too many blobs int bestpart; /*biggest partition */ char *partids; /*partition no of each blob */ int partsizes[MAXPARTS]; /*no in each partition */ @@ -441,12 +441,12 @@ void Textord::find_textlines(TO_BLOCK *block, // block row is in **********************************************************************/ int get_blob_coords( //get boxes - TO_ROW *row, //row to use - int32_t lineheight, //block level - TBOX *blobcoords, //ouput boxes - BOOL8 &holed_line, //lost a lot of blobs - int &outcount //no of real blobs - ) { + TO_ROW* row, //row to use + int32_t lineheight, //block level + TBOX* blobcoords, //ouput boxes + bool& holed_line, //lost a lot of blobs + int& outcount //no of real blobs +) { //blobs BLOBNBOX_IT blob_it = row->blob_list (); int blobindex; /*no along text line */ @@ -800,8 +800,8 @@ int partsizes[], /*no in each partition */ int biggestpart, //major partition float jumplimit /*allowed delta change */ ) { - BOOL8 found_one; //found a bestpart blob - BOOL8 close_one; //found was close enough + bool found_one; //found a bestpart blob + bool close_one; //found was close enough int blobindex; /*no along text line */ int prevpart; //previous iteration int runlength; //no in this part @@ -833,14 +833,14 @@ float jumplimit /*allowed delta change */ c = stats.get_c (); if (textord_oldbl_debug) tprintf ("Fitted line y=%g x + %g\n", m, c); - found_one = FALSE; - close_one = FALSE; + found_one = false; + close_one = false; for (test_blob = 1; !found_one && (startx - test_blob >= 0 || blobindex + test_blob <= blobcount); test_blob++) { if (startx - test_blob >= 0 && partids[startx - test_blob] == biggestpart) { - found_one = TRUE; + found_one = true; coord = FCOORD ((blobcoords[startx - test_blob].left () + blobcoords[startx - test_blob].right ()) / @@ -853,11 +853,11 @@ float jumplimit /*allowed delta change */ ("Diff of common blob to suspect part=%g at (%g,%g)\n", diff, coord.x (), coord.y ()); if (diff < jumplimit && -diff < jumplimit) - close_one = TRUE; + close_one = true; } if (blobindex + test_blob <= blobcount && partids[blobindex + test_blob - 1] == biggestpart) { - found_one = TRUE; + found_one = true; coord = FCOORD ((blobcoords[blobindex + test_blob - 1]. left () + blobcoords[blobindex + test_blob - @@ -870,7 +870,7 @@ float jumplimit /*allowed delta change */ ("Diff of common blob to suspect part=%g at (%g,%g)\n", diff, coord.x (), coord.y ()); if (diff < jumplimit && -diff < jumplimit) - close_one = TRUE; + close_one = true; } } if (close_one) { @@ -1183,22 +1183,22 @@ int xstarts[] //result * Return TRUE if any were done. **********************************************************************/ -BOOL8 -split_stepped_spline ( //make xstarts -QSPLINE * baseline, //current shot -float jumplimit, //max step fuction -int xcoords[], /*points to work on */ -int xstarts[], //result -int &segments //no of segments +bool +split_stepped_spline( //make xstarts + QSPLINE* baseline, //current shot + float jumplimit, //max step fuction + int* xcoords, /*points to work on */ + int* xstarts, //result + int& segments //no of segments ) { - BOOL8 doneany; //return value + bool doneany; //return value int segment; /*partition no */ int startindex, centreindex, endindex; float leftcoord, rightcoord; int leftindex, rightindex; float step; //spline step - doneany = FALSE; + doneany = false; startindex = 0; for (segment = 1; segment < segments - 1; segment++) { step = baseline->step ((xstarts[segment - 1] + xstarts[segment]) / 2.0, @@ -1266,7 +1266,7 @@ int &segments //no of segments xcoords[leftindex]) / 2, (xcoords[rightindex - 1] + xcoords[rightindex]) / 2, segments); - doneany = TRUE; + doneany = true; } else if (textord_debug_baselines) { tprintf diff --git a/src/textord/oldbasel.h b/src/textord/oldbasel.h index eff28bb87a..74117777eb 100644 --- a/src/textord/oldbasel.h +++ b/src/textord/oldbasel.h @@ -42,12 +42,12 @@ extern double_VAR_H (oldbl_dot_error_size, 1.26, "Max aspect ratio of a dot"); extern double_VAR_H (textord_oldbl_jumplimit, 0.15, "X fraction for new partition"); int get_blob_coords( //get boxes - TO_ROW *row, //row to use - int32_t lineheight, //block level - TBOX *blobcoords, //ouput boxes - BOOL8 &holed_line, //lost a lot of blobs - int &outcount //no of real blobs - ); + TO_ROW* row, //row to use + int32_t lineheight, //block level + TBOX* blobcoords, //ouput boxes + bool& holed_line, //lost a lot of blobs + int& outcount //no of real blobs +); void make_first_baseline ( //initial approximation TBOX blobcoords[], /*blob bounding boxes */ int blobcount, /*no of blobcoords */ @@ -113,12 +113,12 @@ int ycoords[], /*points to work on */ int degree, int pointcount, /*no of points */ int xstarts[] //result ); -BOOL8 split_stepped_spline ( //make xstarts -QSPLINE * baseline, //current shot -float jumplimit, //max step fuction -int xcoords[], /*points to work on */ -int xstarts[], //result -int &segments //no of segments +bool split_stepped_spline( //make xstarts + QSPLINE* baseline, //current shot + float jumplimit, //max step fuction + int* xcoords, /*points to work on */ + int* xstarts, //result + int& segments //no of segments ); void insert_spline_point ( //get descenders int xstarts[], //starts to shuffle diff --git a/src/textord/textord.h b/src/textord/textord.h index 8ce3ab7fc3..5938112d8c 100644 --- a/src/textord/textord.h +++ b/src/textord/textord.h @@ -109,7 +109,7 @@ class Textord { ); // tordmain.cpp /////////////////////////////////////////// void find_components(Pix* pix, BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks); - void filter_blobs(ICOORD page_tr, TO_BLOCK_LIST *blocks, BOOL8 testing_on); + void filter_blobs(ICOORD page_tr, TO_BLOCK_LIST* blocks, bool testing_on); private: // For underlying memory management and other utilities. @@ -135,13 +135,13 @@ class Textord { const FCOORD& rotation, float gradient, // global skew int block_line_size); - void make_spline_rows(TO_BLOCK *block, // block to do + void make_spline_rows(TO_BLOCK* block, // block to do float gradient, // gradient to fit - BOOL8 testing_on); + bool testing_on); private: //// oldbasel.cpp //////////////////////////////////////// - void make_old_baselines(TO_BLOCK *block, // block to do - BOOL8 testing_on, // correct orientation + void make_old_baselines(TO_BLOCK* block, // block to do + bool testing_on, // correct orientation float gradient); void correlate_lines(TO_BLOCK *block, float gradient); void correlate_neighbours(TO_BLOCK *block, // block rows are in. @@ -156,14 +156,14 @@ class Textord { QSPLINE *spline); // starting spline // tospace.cpp /////////////////////////////////////////// //DEBUG USE ONLY - void block_spacing_stats(TO_BLOCK *block, - GAPMAP *gapmap, - BOOL8 &old_text_ord_proportional, - //resulting estimate - int16_t &block_space_gap_width, - //resulting estimate - int16_t &block_non_space_gap_width - ); + void block_spacing_stats(TO_BLOCK* block, + GAPMAP* gapmap, + bool& old_text_ord_proportional, + //resulting estimate + int16_t& block_space_gap_width, + //resulting estimate + int16_t& block_non_space_gap_width + ); void row_spacing_stats(TO_ROW *row, GAPMAP *gapmap, int16_t block_idx, @@ -181,30 +181,30 @@ class Textord { //estimate for block int16_t block_non_space_gap_width ); - BOOL8 isolated_row_stats(TO_ROW *row, - GAPMAP *gapmap, - STATS *all_gap_stats, - BOOL8 suspected_table, - int16_t block_idx, - int16_t row_idx); + bool isolated_row_stats(TO_ROW* row, + GAPMAP* gapmap, + STATS* all_gap_stats, + bool suspected_table, + int16_t block_idx, + int16_t row_idx); int16_t stats_count_under(STATS *stats, int16_t threshold); void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats); - BOOL8 make_a_word_break(TO_ROW *row, // row being made - TBOX blob_box, // for next_blob // how many blanks? - int16_t prev_gap, - TBOX prev_blob_box, - int16_t real_current_gap, - int16_t within_xht_current_gap, - TBOX next_blob_box, - int16_t next_gap, - uint8_t &blanks, - BOOL8 &fuzzy_sp, - BOOL8 &fuzzy_non, - BOOL8& prev_gap_was_a_space, - BOOL8& break_at_next_gap); - BOOL8 narrow_blob(TO_ROW *row, TBOX blob_box); - BOOL8 wide_blob(TO_ROW *row, TBOX blob_box); - BOOL8 suspected_punct_blob(TO_ROW *row, TBOX box); + bool make_a_word_break(TO_ROW* row, // row being made + TBOX blob_box, // for next_blob // how many blanks? + int16_t prev_gap, + TBOX prev_blob_box, + int16_t real_current_gap, + int16_t within_xht_current_gap, + TBOX next_blob_box, + int16_t next_gap, + uint8_t& blanks, + bool& fuzzy_sp, + bool& fuzzy_non, + bool& prev_gap_was_a_space, + bool& break_at_next_gap); + bool narrow_blob(TO_ROW* row, TBOX blob_box); + bool wide_blob(TO_ROW* row, TBOX blob_box); + bool suspected_punct_blob(TO_ROW* row, TBOX box); void peek_at_next_gap(TO_ROW *row, BLOBNBOX_IT box_it, TBOX &next_blob_box, @@ -218,11 +218,11 @@ class Textord { int16_t next_blob_width, int16_t next_gap); float find_mean_blob_spacing(WERD *word); - BOOL8 ignore_big_gap(TO_ROW *row, - int32_t row_length, - GAPMAP *gapmap, - int16_t left, - int16_t right); + bool ignore_big_gap(TO_ROW* row, + int32_t row_length, + GAPMAP* gapmap, + int16_t left, + int16_t right); //get bounding box TBOX reduced_box_next(TO_ROW *row, //current row BLOBNBOX_IT *it //iterator to blobds @@ -239,7 +239,7 @@ class Textord { // WERDs contain a fake blob. void cleanup_nontext_block(BLOCK* block); void cleanup_blocks(bool clean_noise, BLOCK_LIST *blocks); - BOOL8 clean_noise_from_row(ROW *row); + bool clean_noise_from_row(ROW* row); void clean_noise_from_words(ROW *row); // Remove outlines that are a tiny fraction in either width or height // of the word height. diff --git a/src/textord/topitch.cpp b/src/textord/topitch.cpp index df4db4cfd5..6a3449ab10 100644 --- a/src/textord/topitch.cpp +++ b/src/textord/topitch.cpp @@ -71,10 +71,10 @@ EXTERN double_VAR (textord_balance_factor, 1.0, **********************************************************************/ void compute_fixed_pitch(ICOORD page_tr, // top right - TO_BLOCK_LIST *port_blocks, // input list + TO_BLOCK_LIST* port_blocks, // input list float gradient, // page skew FCOORD rotation, // for drawing - BOOL8 testing_on) { // correct orientation + bool testing_on) { // correct orientation TO_BLOCK_IT block_it; //iterator TO_BLOCK *block; //current block; TO_ROW *row; //current row @@ -304,10 +304,10 @@ void fix_row_pitch(TO_ROW *bad_row, // row to fix * Decide whether each block is fixed pitch individually. **********************************************************************/ -void compute_block_pitch(TO_BLOCK *block, // input list +void compute_block_pitch(TO_BLOCK* block, // input list FCOORD rotation, // for drawing int32_t block_index, // block number - BOOL8 testing_on) { // correct orientation + bool testing_on) { // correct orientation TBOX block_box; //bounding box block_box = block->block->pdblk.bounding_box (); @@ -336,7 +336,7 @@ void compute_block_pitch(TO_BLOCK *block, // input list #endif compute_rows_pitch(block, block_index, - textord_debug_pitch_test &&testing_on); + textord_debug_pitch_test && testing_on); } } @@ -347,11 +347,11 @@ void compute_block_pitch(TO_BLOCK *block, // input list * Decide whether each row is fixed pitch individually. **********************************************************************/ -BOOL8 compute_rows_pitch( //find line stats - TO_BLOCK *block, //block to do - int32_t block_index, //block number - BOOL8 testing_on //correct orientation - ) { +bool compute_rows_pitch( //find line stats + TO_BLOCK* block, //block to do + int32_t block_index, //block number + bool testing_on //correct orientation +) { int32_t maxwidth; //of spaces TO_ROW *row; //current row int32_t row_index; //row number. @@ -381,7 +381,7 @@ BOOL8 compute_rows_pitch( //find line stats } row_index++; } - return FALSE; + return false; } @@ -391,11 +391,11 @@ BOOL8 compute_rows_pitch( //find line stats * Attempt to call the entire document fixed pitch. **********************************************************************/ -BOOL8 try_doc_fixed( //determine pitch - ICOORD page_tr, //top right - TO_BLOCK_LIST *port_blocks, //input list - float gradient //page skew - ) { +bool try_doc_fixed( //determine pitch + ICOORD page_tr, //top right + TO_BLOCK_LIST* port_blocks, //input list + float gradient //page skew +) { int16_t master_x; //uniform shifts int16_t pitch; //median pitch. int x; //profile coord @@ -426,7 +426,7 @@ BOOL8 try_doc_fixed( //determine pitch if (block_it.empty () // || block_it.data()==block_it.data_relative(1) || !textord_blockndoc_fixed) - return FALSE; + return false; shift_factor = gradient / (gradient * gradient + 1); // row iterator TO_ROW_IT row_it(block_it.data ()->get_rows()); @@ -462,7 +462,7 @@ BOOL8 try_doc_fixed( //determine pitch } } if (pitches.get_total () == 0) - return FALSE; + return false; projection.set_range (projection_left, projection_right); for (block_it.mark_cycle_pt (); !block_it.cycled_list (); @@ -521,7 +521,7 @@ BOOL8 try_doc_fixed( //determine pitch } #endif row->char_cells.clear (); - return FALSE; + return false; } @@ -531,11 +531,11 @@ BOOL8 try_doc_fixed( //determine pitch * Try to call the entire block fixed. **********************************************************************/ -BOOL8 try_block_fixed( //find line stats - TO_BLOCK *block, //block to do - int32_t block_index //block number - ) { - return FALSE; +bool try_block_fixed( //find line stats + TO_BLOCK* block, //block to do + int32_t block_index //block number +) { + return false; } @@ -545,11 +545,11 @@ BOOL8 try_block_fixed( //find line stats * Decide whether each row is fixed pitch individually. **********************************************************************/ -BOOL8 try_rows_fixed( //find line stats - TO_BLOCK *block, //block to do - int32_t block_index, //block number - BOOL8 testing_on //correct orientation - ) { +bool try_rows_fixed( //find line stats + TO_BLOCK* block, //block to do + int32_t block_index, //block number + bool testing_on //correct orientation +) { TO_ROW *row; //current row int32_t row_index; //row number. int32_t def_fixed = 0; //counters @@ -603,7 +603,7 @@ BOOL8 try_rows_fixed( //find line stats block->pitch_decision = PITCH_MAYBE_PROP; else block->pitch_decision = PITCH_DUNNO; - return FALSE; + return false; } @@ -697,11 +697,11 @@ void count_block_votes( //find line stats * Decide whether each row is fixed pitch individually. **********************************************************************/ -BOOL8 row_pitch_stats( //find line stats - TO_ROW *row, //current row - int32_t maxwidth, //of spaces - BOOL8 testing_on //correct orientation - ) { +bool row_pitch_stats( //find line stats + TO_ROW* row, //current row + int32_t maxwidth, //of spaces + bool testing_on //correct orientation +) { BLOBNBOX *blob; //current blob int gap_index; //current gap int32_t prev_x; //end of prev blob @@ -735,7 +735,7 @@ BOOL8 row_pitch_stats( //find line stats } } if (gap_stats.get_total () == 0) { - return FALSE; + return false; } cluster_count = 0; lower = row->xheight * words_initial_lower; @@ -749,7 +749,7 @@ BOOL8 row_pitch_stats( //find line stats } while (cluster_count > prev_count && cluster_count < BLOCK_STATS_CLUSTERS); if (cluster_count < 1) { - return FALSE; + return false; } for (gap_index = 0; gap_index < cluster_count; gap_index++) gaps[gap_index] = cluster_stats[gap_index + 1].ile (0.5); @@ -818,7 +818,7 @@ BOOL8 row_pitch_stats( //find line stats ("Initial estimates:pr_nonsp=%g, pr_space=%g, fp_nonsp=%g, fp_space=%g\n", row->pr_nonsp, row->pr_space, row->fp_nonsp, row->fp_space); } - return TRUE; //computed some stats + return true; //computed some stats } @@ -830,16 +830,16 @@ BOOL8 row_pitch_stats( //find line stats * The larger threshold is the word gap threshold. **********************************************************************/ -BOOL8 find_row_pitch( //find lines - TO_ROW *row, //row to do - int32_t maxwidth, //max permitted space - int32_t dm_gap, //ignorable gaps - TO_BLOCK *block, //block of row - int32_t block_index, //block_number - int32_t row_index, //number of row - BOOL8 testing_on //correct orientation - ) { - BOOL8 used_dm_model; //looks lik dot matrix +bool find_row_pitch( //find lines + TO_ROW* row, //row to do + int32_t maxwidth, //max permitted space + int32_t dm_gap, //ignorable gaps + TO_BLOCK* block, //block of row + int32_t block_index, //block_number + int32_t row_index, //number of row + bool testing_on //correct orientation +) { + bool used_dm_model; //looks lik dot matrix float min_space; //estimate threshold float non_space; //gap size float gap_iqr; //interquartile range @@ -911,7 +911,7 @@ BOOL8 find_row_pitch( //find lines row->pitch_decision = PITCH_DUNNO; if (textord_debug_pitch_metric) tprintf ("\n"); - return FALSE; //insufficient data + return false; //insufficient data } if (pitch_iqr * dm_gap_iqr <= dm_pitch_iqr * gap_iqr) { if (testing_on) @@ -921,7 +921,7 @@ BOOL8 find_row_pitch( //find lines gap_iqr = gap_stats.ile (0.75) - gap_stats.ile (0.25); pitch_iqr = pitch_stats.ile (0.75) - pitch_stats.ile (0.25); pitch = pitch_stats.ile (0.5); - used_dm_model = FALSE; + used_dm_model = false; } else { if (testing_on) @@ -931,7 +931,7 @@ BOOL8 find_row_pitch( //find lines gap_iqr = dm_gap_iqr; pitch_iqr = dm_pitch_iqr; pitch = dm_pitch; - used_dm_model = TRUE; + used_dm_model = true; } if (textord_debug_pitch_metric) { tprintf ("rev_p_iqr=%g:rev_g_iqr=%g:pitch=%g:", @@ -958,7 +958,7 @@ BOOL8 find_row_pitch( //find lines row->space_size = row->fixed_pitch; row->space_threshold = (row->max_nonspace + row->min_space) / 2; row->used_dm_model = used_dm_model; - return TRUE; + return true; } @@ -970,10 +970,10 @@ BOOL8 find_row_pitch( //find lines * The larger threshold is the word gap threshold. **********************************************************************/ -BOOL8 fixed_pitch_row(TO_ROW *row, // row to do - BLOCK* block, - int32_t block_index // block_number - ) { +bool fixed_pitch_row(TO_ROW* row, // row to do + BLOCK* block, + int32_t block_index // block_number +) { const char *res_string; // pitch result int16_t mid_cuts; // no of cheap cuts float non_space; // gap size @@ -1041,7 +1041,7 @@ BOOL8 fixed_pitch_row(TO_ROW *row, // row to do tprintf (":sd/p=%g:occ=%g:init_res=%s\n", pitch_sd / row->fixed_pitch, sp_sd, res_string); } - return TRUE; + return true; } @@ -1054,17 +1054,17 @@ BOOL8 fixed_pitch_row(TO_ROW *row, // row to do * The return value indicates whether there were any decent values to use. **********************************************************************/ -BOOL8 count_pitch_stats( //find lines - TO_ROW *row, //row to do - STATS *gap_stats, //blob gaps - STATS *pitch_stats, //centre-centre stats - float initial_pitch, //guess at pitch - float min_space, //estimate space size - BOOL8 ignore_outsize, //discard big objects - BOOL8 split_outsize, //split big objects - int32_t dm_gap //ignorable gaps - ) { - BOOL8 prev_valid; //not word broken +bool count_pitch_stats( //find lines + TO_ROW* row, //row to do + STATS* gap_stats, //blob gaps + STATS* pitch_stats, //centre-centre stats + float initial_pitch, //guess at pitch + float min_space, //estimate space size + bool ignore_outsize, //discard big objects + bool split_outsize, //split big objects + int32_t dm_gap //ignorable gaps +) { + bool prev_valid; //not word broken BLOBNBOX *blob; //current blob //blobs BLOBNBOX_IT blob_it = row->blob_list (); @@ -1080,8 +1080,8 @@ BOOL8 count_pitch_stats( //find lines gap_stats->clear (); pitch_stats->clear (); if (blob_it.empty ()) - return FALSE; - prev_valid = FALSE; + return false; + prev_valid = false; prev_centre = 0; prev_right = 0; // stop compiler warning joined_box = blob_it.data ()->bounding_box (); @@ -1143,17 +1143,17 @@ BOOL8 count_pitch_stats( //find lines **********************************************************************/ float tune_row_pitch( //find fp cells - TO_ROW *row, //row to do - STATS *projection, //vertical projection - int16_t projection_left, //edge of projection - int16_t projection_right, //edge of projection - float space_size, //size of blank - float &initial_pitch, //guess at pitch - float &best_sp_sd, //space sd - int16_t &best_mid_cuts, //no of cheap cuts - ICOORDELT_LIST *best_cells, //row cells - BOOL8 testing_on //inidividual words - ) { + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge of projection + int16_t projection_right, //edge of projection + float space_size, //size of blank + float& initial_pitch, //guess at pitch + float& best_sp_sd, //space sd + int16_t& best_mid_cuts, //no of cheap cuts + ICOORDELT_LIST* best_cells, //row cells + bool testing_on //inidividual words +) { int pitch_delta; //offset pitch int16_t mid_cuts; //cheap cuts float pitch_sd; //current sd @@ -1255,17 +1255,17 @@ float tune_row_pitch( //find fp cells **********************************************************************/ float tune_row_pitch2( //find fp cells - TO_ROW *row, //row to do - STATS *projection, //vertical projection - int16_t projection_left, //edge of projection - int16_t projection_right, //edge of projection - float space_size, //size of blank - float &initial_pitch, //guess at pitch - float &best_sp_sd, //space sd - int16_t &best_mid_cuts, //no of cheap cuts - ICOORDELT_LIST *best_cells, //row cells - BOOL8 testing_on //inidividual words - ) { + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge of projection + int16_t projection_right, //edge of projection + float space_size, //size of blank + float& initial_pitch, //guess at pitch + float& best_sp_sd, //space sd + int16_t& best_mid_cuts, //no of cheap cuts + ICOORDELT_LIST* best_cells, //row cells + bool testing_on //inidividual words +) { int pitch_delta; //offset pitch int16_t pixel; //pixel coord int16_t best_pixel; //pixel coord @@ -1370,19 +1370,19 @@ float tune_row_pitch2( //find fp cells **********************************************************************/ float compute_pitch_sd( //find fp cells - TO_ROW *row, //row to do - STATS *projection, //vertical projection - int16_t projection_left, //edge - int16_t projection_right, //edge - float space_size, //size of blank - float initial_pitch, //guess at pitch - float &sp_sd, //space sd - int16_t &mid_cuts, //no of free cuts - ICOORDELT_LIST *row_cells, //list of chop pts - BOOL8 testing_on, //inidividual words - int16_t start, //start of good range - int16_t end //end of good range - ) { + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge + int16_t projection_right, //edge + float space_size, //size of blank + float initial_pitch, //guess at pitch + float& sp_sd, //space sd + int16_t& mid_cuts, //no of free cuts + ICOORDELT_LIST* row_cells, //list of chop pts + bool testing_on, //inidividual words + int16_t start, //start of good range + int16_t end //end of good range +) { int16_t occupation; //no of cells in word. //blobs BLOBNBOX_IT blob_it = row->blob_list (); @@ -1533,18 +1533,18 @@ float compute_pitch_sd( //find fp cells **********************************************************************/ float compute_pitch_sd2( //find fp cells - TO_ROW *row, //row to do - STATS *projection, //vertical projection - int16_t projection_left, //edge - int16_t projection_right, //edge - float initial_pitch, //guess at pitch - int16_t &occupation, //no of occupied cells - int16_t &mid_cuts, //no of free cuts - ICOORDELT_LIST *row_cells, //list of chop pts - BOOL8 testing_on, //inidividual words - int16_t start, //start of good range - int16_t end //end of good range - ) { + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge + int16_t projection_right, //edge + float initial_pitch, //guess at pitch + int16_t& occupation, //no of occupied cells + int16_t& mid_cuts, //no of free cuts + ICOORDELT_LIST* row_cells, //list of chop pts + bool testing_on, //inidividual words + int16_t start, //start of good range + int16_t end //end of good range +) { //blobs BLOBNBOX_IT blob_it = row->blob_list (); BLOBNBOX_IT plot_it; @@ -1752,8 +1752,8 @@ void print_pitch_sd( //find fp cells * Extract marked leader blobs and put them * into words in advance of fixed pitch checking and word generation. **********************************************************************/ -void find_repeated_chars(TO_BLOCK *block, // Block to search. - BOOL8 testing_on) { // Debug mode. +void find_repeated_chars(TO_BLOCK* block, // Block to search. + bool testing_on) { // Debug mode. POLY_BLOCK* pb = block->block->pdblk.poly_block(); if (pb != nullptr && !pb->IsText()) return; // Don't find repeated chars in non-text blocks. diff --git a/src/textord/topitch.h b/src/textord/topitch.h index f6072c4102..82d70a8876 100644 --- a/src/textord/topitch.h +++ b/src/textord/topitch.h @@ -43,10 +43,10 @@ extern double_VAR_H (textord_balance_factor, 2.0, "Ding rate for unbalanced char cells"); void compute_fixed_pitch(ICOORD page_tr, // top right - TO_BLOCK_LIST *port_blocks, // input list + TO_BLOCK_LIST* port_blocks, // input list float gradient, // page skew FCOORD rotation, // for drawing - BOOL8 testing_on); // correct orientation + bool testing_on); // correct orientation void fix_row_pitch( //get some value TO_ROW *bad_row, //row to fix TO_BLOCK *bad_block, //block of bad_row @@ -54,29 +54,29 @@ void fix_row_pitch( //get some value int32_t row_target, //number of row int32_t block_target //number of block ); -void compute_block_pitch( TO_BLOCK *block, // input list +void compute_block_pitch(TO_BLOCK* block, // input list FCOORD rotation, // for drawing int32_t block_index, // block number - BOOL8 testing_on); // correct orientation -BOOL8 compute_rows_pitch( //find line stats - TO_BLOCK *block, //block to do - int32_t block_index, //block number - BOOL8 testing_on //correct orientation - ); -BOOL8 try_doc_fixed( //determine pitch - ICOORD page_tr, //top right - TO_BLOCK_LIST *port_blocks, //input list - float gradient //page skew - ); -BOOL8 try_block_fixed( //find line stats - TO_BLOCK *block, //block to do - int32_t block_index //block number - ); -BOOL8 try_rows_fixed( //find line stats - TO_BLOCK *block, //block to do - int32_t block_index, //block number - BOOL8 testing_on //correct orientation - ); + bool testing_on); // correct orientation +bool compute_rows_pitch( //find line stats + TO_BLOCK* block, //block to do + int32_t block_index, //block number + bool testing_on //correct orientation +); +bool try_doc_fixed( //determine pitch + ICOORD page_tr, //top right + TO_BLOCK_LIST* port_blocks, //input list + float gradient //page skew +); +bool try_block_fixed( //find line stats + TO_BLOCK* block, //block to do + int32_t block_index //block number +); +bool try_rows_fixed( //find line stats + TO_BLOCK* block, //block to do + int32_t block_index, //block number + bool testing_on //correct orientation +); void print_block_counts( //find line stats TO_BLOCK *block, //block to do int32_t block_index //block number @@ -90,85 +90,85 @@ void count_block_votes( //find line stats int32_t &corr_fixed, int32_t &corr_prop, int32_t &dunno); -BOOL8 row_pitch_stats( //find line stats - TO_ROW *row, //current row - int32_t maxwidth, //of spaces - BOOL8 testing_on //correct orientation - ); -BOOL8 find_row_pitch( //find lines - TO_ROW *row, //row to do - int32_t maxwidth, //max permitted space - int32_t dm_gap, //ignorable gaps - TO_BLOCK *block, //block of row - int32_t block_index, //block_number - int32_t row_index, //number of row - BOOL8 testing_on //correct orientation - ); -BOOL8 fixed_pitch_row( //find lines - TO_ROW *row, //row to do - BLOCK* block, - int32_t block_index //block_number - ); -BOOL8 count_pitch_stats( //find lines - TO_ROW *row, //row to do - STATS *gap_stats, //blob gaps - STATS *pitch_stats, //centre-centre stats - float initial_pitch, //guess at pitch - float min_space, //estimate space size - BOOL8 ignore_outsize, //discard big objects - BOOL8 split_outsize, //split big objects - int32_t dm_gap //ignorable gaps - ); +bool row_pitch_stats( //find line stats + TO_ROW* row, //current row + int32_t maxwidth, //of spaces + bool testing_on //correct orientation +); +bool find_row_pitch( //find lines + TO_ROW* row, //row to do + int32_t maxwidth, //max permitted space + int32_t dm_gap, //ignorable gaps + TO_BLOCK* block, //block of row + int32_t block_index, //block_number + int32_t row_index, //number of row + bool testing_on //correct orientation +); +bool fixed_pitch_row( //find lines + TO_ROW* row, //row to do + BLOCK* block, + int32_t block_index //block_number +); +bool count_pitch_stats( //find lines + TO_ROW* row, //row to do + STATS* gap_stats, //blob gaps + STATS* pitch_stats, //centre-centre stats + float initial_pitch, //guess at pitch + float min_space, //estimate space size + bool ignore_outsize, //discard big objects + bool split_outsize, //split big objects + int32_t dm_gap //ignorable gaps +); float tune_row_pitch( //find fp cells - TO_ROW *row, //row to do - STATS *projection, //vertical projection - int16_t projection_left, //edge of projection - int16_t projection_right, //edge of projection - float space_size, //size of blank - float &initial_pitch, //guess at pitch - float &best_sp_sd, //space sd - int16_t &best_mid_cuts, //no of cheap cuts - ICOORDELT_LIST *best_cells, //row cells - BOOL8 testing_on //inidividual words - ); + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge of projection + int16_t projection_right, //edge of projection + float space_size, //size of blank + float& initial_pitch, //guess at pitch + float& best_sp_sd, //space sd + int16_t& best_mid_cuts, //no of cheap cuts + ICOORDELT_LIST* best_cells, //row cells + bool testing_on //inidividual words +); float tune_row_pitch2( //find fp cells - TO_ROW *row, //row to do - STATS *projection, //vertical projection - int16_t projection_left, //edge of projection - int16_t projection_right, //edge of projection - float space_size, //size of blank - float &initial_pitch, //guess at pitch - float &best_sp_sd, //space sd - int16_t &best_mid_cuts, //no of cheap cuts - ICOORDELT_LIST *best_cells, //row cells - BOOL8 testing_on //inidividual words - ); -float compute_pitch_sd ( //find fp cells -TO_ROW * row, //row to do -STATS * projection, //vertical projection -int16_t projection_left, //edge -int16_t projection_right, //edge -float space_size, //size of blank -float initial_pitch, //guess at pitch -float &sp_sd, //space sd -int16_t & mid_cuts, //no of free cuts -ICOORDELT_LIST * row_cells, //list of chop pts -BOOL8 testing_on, //inidividual words -int16_t start = 0, //start of good range -int16_t end = 0 //end of good range + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge of projection + int16_t projection_right, //edge of projection + float space_size, //size of blank + float& initial_pitch, //guess at pitch + float& best_sp_sd, //space sd + int16_t& best_mid_cuts, //no of cheap cuts + ICOORDELT_LIST* best_cells, //row cells + bool testing_on //inidividual words +); +float compute_pitch_sd( //find fp cells + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge + int16_t projection_right, //edge + float space_size, //size of blank + float initial_pitch, //guess at pitch + float& sp_sd, //space sd + int16_t& mid_cuts, //no of free cuts + ICOORDELT_LIST* row_cells, //list of chop pts + bool testing_on, //inidividual words + int16_t start = 0, //start of good range + int16_t end = 0 //end of good range ); -float compute_pitch_sd2 ( //find fp cells -TO_ROW * row, //row to do -STATS * projection, //vertical projection -int16_t projection_left, //edge -int16_t projection_right, //edge -float initial_pitch, //guess at pitch -int16_t & occupation, //no of occupied cells -int16_t & mid_cuts, //no of free cuts -ICOORDELT_LIST * row_cells, //list of chop pts -BOOL8 testing_on, //inidividual words -int16_t start = 0, //start of good range -int16_t end = 0 //end of good range +float compute_pitch_sd2( //find fp cells + TO_ROW* row, //row to do + STATS* projection, //vertical projection + int16_t projection_left, //edge + int16_t projection_right, //edge + float initial_pitch, //guess at pitch + int16_t& occupation, //no of occupied cells + int16_t& mid_cuts, //no of free cuts + ICOORDELT_LIST* row_cells, //list of chop pts + bool testing_on, //inidividual words + int16_t start = 0, //start of good range + int16_t end = 0 //end of good range ); void print_pitch_sd( //find fp cells TO_ROW *row, //row to do @@ -178,8 +178,8 @@ void print_pitch_sd( //find fp cells float space_size, float initial_pitch //guess at pitch ); -void find_repeated_chars(TO_BLOCK *block, // Block to search. - BOOL8 testing_on); // Debug mode. +void find_repeated_chars(TO_BLOCK* block, // Block to search. + bool testing_on); // Debug mode. void plot_fp_word( //draw block of words TO_BLOCK *block, //block to draw float pitch, //pitch to draw with diff --git a/src/textord/tordmain.cpp b/src/textord/tordmain.cpp index 732324b020..7fd428a38c 100644 --- a/src/textord/tordmain.cpp +++ b/src/textord/tordmain.cpp @@ -234,8 +234,8 @@ void Textord::find_components(Pix* pix, BLOCK_LIST *blocks, **********************************************************************/ void Textord::filter_blobs(ICOORD page_tr, // top right - TO_BLOCK_LIST *blocks, // output list - BOOL8 testing_on) { // for plotting + TO_BLOCK_LIST* blocks, // output list + bool testing_on) { // for plotting TO_BLOCK_IT block_it = blocks; // destination iterator TO_BLOCK *block; // created block @@ -458,10 +458,10 @@ void Textord::cleanup_blocks(bool clean_noise, BLOCK_LIST* blocks) { * Move blobs of words from rows of garbage into the reject blobs list. **********************************************************************/ -BOOL8 Textord::clean_noise_from_row( //remove empties - ROW *row //row to clean - ) { - BOOL8 testing_on; +bool Textord::clean_noise_from_row( //remove empties + ROW* row //row to clean +) { + bool testing_on; TBOX blob_box; //bounding box C_BLOB *blob; //current blob C_OUTLINE *outline; //current outline @@ -477,12 +477,9 @@ BOOL8 Textord::clean_noise_from_row( //remove empties C_BLOB_IT blob_it; //blob iterator C_OUTLINE_IT out_it; //outline iterator - if (textord_test_y > row->base_line (textord_test_x) - && textord_show_blobs - && textord_test_y < row->base_line (textord_test_x) + row->x_height ()) - testing_on = TRUE; - else - testing_on = FALSE; + testing_on = textord_test_y > row->base_line (textord_test_x) + && textord_show_blobs + && textord_test_y < row->base_line (textord_test_x) + row->x_height (); dot_count = 0; norm_count = 0; super_norm_count = 0; diff --git a/src/textord/tospace.cpp b/src/textord/tospace.cpp index 3dae5ca4b7..cb266f8820 100644 --- a/src/textord/tospace.cpp +++ b/src/textord/tospace.cpp @@ -54,7 +54,7 @@ void Textord::to_spacing( int16_t block_space_gap_width; //estimated width of non space gaps for whole block int16_t block_non_space_gap_width; - BOOL8 old_text_ord_proportional;//old fixed/prop result + bool old_text_ord_proportional;//old fixed/prop result GAPMAP *gapmap = nullptr; //map of big vert gaps in blk block_it.set_to_list (blocks); @@ -119,12 +119,12 @@ void Textord::to_spacing( *************************************************************************/ void Textord::block_spacing_stats( - TO_BLOCK *block, - GAPMAP *gapmap, - BOOL8 &old_text_ord_proportional, - int16_t &block_space_gap_width, // resulting estimate - int16_t &block_non_space_gap_width // resulting estimate - ) { + TO_BLOCK* block, + GAPMAP* gapmap, + bool& old_text_ord_proportional, + int16_t& block_space_gap_width, // resulting estimate + int16_t& block_non_space_gap_width // resulting estimate +) { TO_ROW *row; // current row BLOBNBOX_IT blob_it; // iterator @@ -195,7 +195,7 @@ void Textord::block_spacing_stats( block_non_space_gap_width = minwidth; block_space_gap_width = -1; //No est. space width //DEBUG - old_text_ord_proportional = TRUE; + old_text_ord_proportional = true; } else { /* For debug only ..... */ @@ -312,9 +312,9 @@ void Textord::row_spacing_stats( int16_t max = 0; int16_t index; int16_t large_gap_count = 0; - BOOL8 suspected_table; + bool suspected_table; int32_t max_max_nonspace; //upper bound - BOOL8 good_block_space_estimate = block_space_gap_width > 0; + bool good_block_space_estimate = block_space_gap_width > 0; int32_t end_of_row; int32_t row_length = 0; float sane_space; @@ -676,12 +676,12 @@ void Textord::old_to_method( * isolated_row_stats() * Set values for min_space, max_non_space based on row stats only *************************************************************************/ -BOOL8 Textord::isolated_row_stats(TO_ROW *row, - GAPMAP *gapmap, - STATS *all_gap_stats, - BOOL8 suspected_table, - int16_t block_idx, - int16_t row_idx) { +bool Textord::isolated_row_stats(TO_ROW* row, + GAPMAP* gapmap, + STATS* all_gap_stats, + bool suspected_table, + int16_t block_idx, + int16_t row_idx) { float kern_estimate; float crude_threshold_estimate; int16_t small_gaps_count; @@ -711,7 +711,7 @@ BOOL8 Textord::isolated_row_stats(TO_ROW *row, if (tosp_debug_level > 5) tprintf("B:%d R:%d -- Can't do isolated row stats.\n", block_idx, row_idx); - return FALSE; + return false; } blob_it.set_to_list (row->blob_list ()); blob_it.mark_cycle_pt (); @@ -782,14 +782,14 @@ BOOL8 Textord::isolated_row_stats(TO_ROW *row, row->kern_size = 0.0f; row->space_threshold = 0; row->space_size = 0.0f; - return FALSE; + return false; } if (tosp_debug_level > 5) tprintf ("B:%d R:%d -- Isolated row stats: %f %d %f\n", block_idx, row_idx, row->kern_size, row->space_threshold, row->space_size); - return TRUE; + return true; } int16_t Textord::stats_count_under(STATS *stats, int16_t threshold) { @@ -895,17 +895,17 @@ ROW *Textord::make_prop_words( TO_ROW *row, // row to make FCOORD rotation // for drawing ) { - BOOL8 bol; // start of line + bool bol; // start of line /* prev_ values are for start of word being built. non prev_ values are for the gap between the word being built and the next one. */ - BOOL8 prev_fuzzy_sp; // probably space - BOOL8 prev_fuzzy_non; // probably not + bool prev_fuzzy_sp; // probably space + bool prev_fuzzy_non; // probably not uint8_t prev_blanks; // in front of word - BOOL8 fuzzy_sp = false; // probably space - BOOL8 fuzzy_non = false; // probably not + bool fuzzy_sp = false; // probably space + bool fuzzy_non = false; // probably not uint8_t blanks = 0; // in front of word - BOOL8 prev_gap_was_a_space = FALSE; - BOOL8 break_at_next_gap = FALSE; + bool prev_gap_was_a_space = false; + bool break_at_next_gap = false; ROW *real_row; // output row C_OUTLINE_IT cout_it; C_BLOB_LIST cblobs; @@ -941,10 +941,10 @@ ROW *Textord::make_prop_words( box_it.set_to_list (row->blob_list ()); // new words WERD_IT word_it(&words); - bol = TRUE; + bol = true; prev_blanks = 0; - prev_fuzzy_sp = FALSE; - prev_fuzzy_non = FALSE; + prev_fuzzy_sp = false; + prev_fuzzy_non = false; if (!box_it.empty ()) { xstarts[0] = box_it.data ()->bounding_box ().left (); if (xstarts[0] > next_rep_char_word_right) { @@ -952,12 +952,12 @@ ROW *Textord::make_prop_words( word = rep_char_it.extract (); word_it.add_after_then_move (word); /* Set spaces before repeated char word */ - word->set_flag (W_BOL, TRUE); - bol = FALSE; + word->set_flag (W_BOL, true); + bol = false; word->set_blanks (0); //NO uncertainty - word->set_flag (W_FUZZY_SP, FALSE); - word->set_flag (W_FUZZY_NON, FALSE); + word->set_flag (W_FUZZY_SP, false); + word->set_flag (W_FUZZY_NON, false); xstarts[0] = word->bounding_box ().left (); /* Set spaces after repeated char word (and leave current word set) */ repetition_spacing = find_mean_blob_spacing (word); @@ -976,8 +976,8 @@ ROW *Textord::make_prop_words( box_it.data ()->bounding_box ().left (), box_it.data ()->bounding_box ().bottom (), repetition_spacing, current_gap); - prev_fuzzy_sp = FALSE; - prev_fuzzy_non = FALSE; + prev_fuzzy_sp = false; + prev_fuzzy_non = false; if (rep_char_it.empty ()) { next_rep_char_word_right = INT32_MAX; } @@ -1045,14 +1045,14 @@ ROW *Textord::make_prop_words( word_count++; word_it.add_after_then_move (word); if (bol) { - word->set_flag (W_BOL, TRUE); - bol = FALSE; + word->set_flag (W_BOL, true); + bol = false; } if (prev_fuzzy_sp) //probably space - word->set_flag (W_FUZZY_SP, TRUE); + word->set_flag (W_FUZZY_SP, true); else if (prev_fuzzy_non) - word->set_flag (W_FUZZY_NON, TRUE); + word->set_flag (W_FUZZY_NON, true); //probably not if (blob_box.left () > next_rep_char_word_right) { @@ -1080,8 +1080,8 @@ ROW *Textord::make_prop_words( repetition_spacing, current_gap, blanks); word->set_blanks (blanks); //NO uncertainty - word->set_flag (W_FUZZY_SP, FALSE); - word->set_flag (W_FUZZY_NON, FALSE); + word->set_flag (W_FUZZY_SP, false); + word->set_flag (W_FUZZY_NON, false); /* Set spaces after repeated char word (and leave current word set) */ current_gap = @@ -1111,7 +1111,7 @@ ROW *Textord::make_prop_words( if (box_it.at_first () && rep_char_it.empty ()) { //at end of line - word->set_flag (W_EOL, TRUE); + word->set_flag (W_EOL, true); xstarts[1] = prev_x; } else { @@ -1146,12 +1146,12 @@ ROW *Textord::make_prop_words( repetition_spacing, current_gap, blanks); word->set_blanks (blanks); //NO uncertainty - word->set_flag (W_FUZZY_SP, FALSE); - word->set_flag (W_FUZZY_NON, FALSE); + word->set_flag (W_FUZZY_SP, false); + word->set_flag (W_FUZZY_NON, false); prev_x = word->bounding_box ().right (); if (rep_char_it.empty ()) { //at end of line - word->set_flag (W_EOL, TRUE); + word->set_flag (W_EOL, true); xstarts[1] = prev_x; } else { @@ -1258,27 +1258,27 @@ ROW *Textord::make_blob_words( return nullptr; } -BOOL8 Textord::make_a_word_break( - TO_ROW *row, // row being made - TBOX blob_box, // for next_blob // how many blanks? - int16_t prev_gap, - TBOX prev_blob_box, - int16_t real_current_gap, - int16_t within_xht_current_gap, - TBOX next_blob_box, - int16_t next_gap, - uint8_t &blanks, - BOOL8 &fuzzy_sp, - BOOL8 &fuzzy_non, - BOOL8& prev_gap_was_a_space, - BOOL8& break_at_next_gap) { - BOOL8 space; +bool Textord::make_a_word_break( + TO_ROW* row, // row being made + TBOX blob_box, // for next_blob // how many blanks? + int16_t prev_gap, + TBOX prev_blob_box, + int16_t real_current_gap, + int16_t within_xht_current_gap, + TBOX next_blob_box, + int16_t next_gap, + uint8_t& blanks, + bool& fuzzy_sp, + bool& fuzzy_non, + bool& prev_gap_was_a_space, + bool& break_at_next_gap) { + bool space; int16_t current_gap; float fuzzy_sp_to_kn_limit; if (break_at_next_gap) { - break_at_next_gap = FALSE; - return TRUE; + break_at_next_gap = false; + return true; } /* Inhibit using the reduced gap if The kerning is large - chars are not kerned and reducing "f"s can cause @@ -1304,21 +1304,21 @@ BOOL8 Textord::make_a_word_break( if (current_gap < row->min_space) { if (current_gap > row->space_threshold) { blanks = 1; - fuzzy_sp = TRUE; - fuzzy_non = FALSE; + fuzzy_sp = true; + fuzzy_non = false; } else { blanks = 0; - fuzzy_sp = FALSE; - fuzzy_non = TRUE; + fuzzy_sp = false; + fuzzy_non = true; } } else { blanks = (uint8_t) (current_gap / row->space_size); if (blanks < 1) blanks = 1; - fuzzy_sp = FALSE; - fuzzy_non = FALSE; + fuzzy_sp = false; + fuzzy_non = false; } } return space; @@ -1326,7 +1326,7 @@ BOOL8 Textord::make_a_word_break( else { /* New exciting heuristic method */ if (prev_blob_box.null_box ()) // Beginning of row - prev_gap_was_a_space = TRUE; + prev_gap_was_a_space = true; //Default as old TO space = current_gap > row->space_threshold; @@ -1340,8 +1340,8 @@ BOOL8 Textord::make_a_word_break( if (row->space_size > 1.0f) num_blanks = IntCastRounded(current_gap / row->space_size); blanks = static_cast(ClipToRange(num_blanks, 1, UINT8_MAX)); - fuzzy_sp = FALSE; - fuzzy_non = FALSE; + fuzzy_sp = false; + fuzzy_non = false; /* If xht measure causes gap to flip one of the 3 thresholds act accordingly - despite any other heuristics - the MINIMUM action is to pass a fuzzy kern to @@ -1350,8 +1350,8 @@ BOOL8 Textord::make_a_word_break( if (tosp_use_xht_gaps && (real_current_gap <= row->max_nonspace) && (within_xht_current_gap > row->max_nonspace)) { - space = TRUE; - fuzzy_non = TRUE; + space = true; + fuzzy_non = true; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 20, prev_gap, prev_blob_box.width (), @@ -1361,11 +1361,11 @@ BOOL8 Textord::make_a_word_break( else if (tosp_use_xht_gaps && (real_current_gap <= row->space_threshold) && (within_xht_current_gap > row->space_threshold)) { - space = TRUE; + space = true; if (tosp_flip_fuzz_kn_to_sp) - fuzzy_sp = TRUE; + fuzzy_sp = true; else - fuzzy_non = TRUE; + fuzzy_non = true; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 21, prev_gap, prev_blob_box.width (), @@ -1375,7 +1375,7 @@ BOOL8 Textord::make_a_word_break( else if (tosp_use_xht_gaps && (real_current_gap < row->min_space) && (within_xht_current_gap >= row->min_space)) { - space = TRUE; + space = true; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 22, prev_gap, prev_blob_box.width (), @@ -1385,7 +1385,7 @@ BOOL8 Textord::make_a_word_break( else if (tosp_force_wordbreak_on_punct && !suspected_punct_blob(row, prev_blob_box) && suspected_punct_blob(row, blob_box)) { - break_at_next_gap = TRUE; + break_at_next_gap = true; } /* Now continue with normal heuristics */ else if ((current_gap < row->min_space) && @@ -1407,12 +1407,12 @@ BOOL8 Textord::make_a_word_break( if ((tosp_all_flips_fuzzy) || (current_gap > fuzzy_sp_to_kn_limit)) { if (tosp_flip_fuzz_sp_to_kn) - fuzzy_non = TRUE; + fuzzy_non = true; else - fuzzy_sp = TRUE; + fuzzy_sp = true; } else - space = FALSE; + space = false; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 1, prev_gap, prev_blob_box.width (), @@ -1428,12 +1428,12 @@ BOOL8 Textord::make_a_word_break( if ((tosp_all_flips_fuzzy) || (current_gap > fuzzy_sp_to_kn_limit)) { if (tosp_flip_fuzz_sp_to_kn) - fuzzy_non = TRUE; + fuzzy_non = true; else - fuzzy_sp = TRUE; + fuzzy_sp = true; } else - space = FALSE; + space = false; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 2, prev_gap, prev_blob_box.width (), @@ -1447,12 +1447,12 @@ BOOL8 Textord::make_a_word_break( if ((tosp_all_flips_fuzzy) || (current_gap > fuzzy_sp_to_kn_limit)) { if (tosp_flip_fuzz_sp_to_kn) - fuzzy_non = TRUE; + fuzzy_non = true; else - fuzzy_sp = TRUE; + fuzzy_sp = true; } else - space = FALSE; + space = false; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 3, prev_gap, prev_blob_box.width (), @@ -1466,12 +1466,12 @@ BOOL8 Textord::make_a_word_break( if ((tosp_all_flips_fuzzy) || (current_gap > fuzzy_sp_to_kn_limit)) { if (tosp_flip_fuzz_sp_to_kn) - fuzzy_non = TRUE; + fuzzy_non = true; else - fuzzy_sp = TRUE; + fuzzy_sp = true; } else - space = FALSE; + space = false; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 4, prev_gap, prev_blob_box.width (), @@ -1482,7 +1482,7 @@ BOOL8 Textord::make_a_word_break( narrow_blob (row, next_blob_box)) || ((prev_blob_box.width () > 0) && narrow_blob (row, prev_blob_box)))) { - fuzzy_sp = TRUE; + fuzzy_sp = true; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 6, prev_gap, prev_blob_box.width (), @@ -1507,7 +1507,7 @@ BOOL8 Textord::make_a_word_break( wide_blob (row, prev_blob_box) && wide_blob (row, next_blob_box)) { - space = TRUE; + space = true; /* tosp_flip_caution is an attempt to stop the default changing in cases where there is a large difference between the kern and space estimates. @@ -1516,9 +1516,9 @@ BOOL8 Textord::make_a_word_break( if ((tosp_flip_fuzz_kn_to_sp) && ((tosp_flip_caution <= 0) || (tosp_flip_caution * row->kern_size > row->space_size))) - fuzzy_sp = TRUE; + fuzzy_sp = true; else - fuzzy_non = TRUE; + fuzzy_non = true; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 7, prev_gap, prev_blob_box.width (), @@ -1533,8 +1533,8 @@ BOOL8 Textord::make_a_word_break( suspected_punct_blob(row, prev_blob_box)) && !(narrow_blob(row, next_blob_box) || suspected_punct_blob(row, next_blob_box))) { - space = TRUE; - fuzzy_non = TRUE; + space = true; + fuzzy_non = true; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 8, prev_gap, prev_blob_box.width (), @@ -1548,8 +1548,8 @@ BOOL8 Textord::make_a_word_break( (!tosp_rule_9_test_punct || (!suspected_punct_blob (row, prev_blob_box) && !suspected_punct_blob (row, next_blob_box)))) { - space = TRUE; - fuzzy_non = TRUE; + space = true; + fuzzy_non = true; #ifndef GRAPHICS_DISABLED mark_gap (blob_box, 9, prev_gap, prev_blob_box.width (), @@ -1566,16 +1566,16 @@ BOOL8 Textord::make_a_word_break( } } -BOOL8 Textord::narrow_blob(TO_ROW *row, TBOX blob_box) { - BOOL8 result; +bool Textord::narrow_blob(TO_ROW* row, TBOX blob_box) { + bool result; result = ((blob_box.width () <= tosp_narrow_fraction * row->xheight) || (((float) blob_box.width () / blob_box.height ()) <= tosp_narrow_aspect_ratio)); return result; } -BOOL8 Textord::wide_blob(TO_ROW *row, TBOX blob_box) { - BOOL8 result; +bool Textord::wide_blob(TO_ROW* row, TBOX blob_box) { + bool result; if (tosp_wide_fraction > 0) { if (tosp_wide_aspect_ratio > 0) result = ((blob_box.width () >= tosp_wide_fraction * row->xheight) && @@ -1589,8 +1589,8 @@ BOOL8 Textord::wide_blob(TO_ROW *row, TBOX blob_box) { return result; } -BOOL8 Textord::suspected_punct_blob(TO_ROW *row, TBOX box) { - BOOL8 result; +bool Textord::suspected_punct_blob(TO_ROW* row, TBOX box) { + bool result; float baseline; float blob_x_centre; /* Find baseline of centre of blob */ @@ -1730,33 +1730,33 @@ float Textord::find_mean_blob_spacing(WERD *word) { } -BOOL8 Textord::ignore_big_gap(TO_ROW *row, - int32_t row_length, - GAPMAP *gapmap, - int16_t left, - int16_t right) { +bool Textord::ignore_big_gap(TO_ROW* row, + int32_t row_length, + GAPMAP* gapmap, + int16_t left, + int16_t right) { int16_t gap = right - left + 1; if (tosp_ignore_big_gaps > 999) return FALSE; // Don't ignore if (tosp_ignore_big_gaps > 0) return (gap > tosp_ignore_big_gaps * row->xheight); if (gap > tosp_ignore_very_big_gaps * row->xheight) - return TRUE; + return true; if (tosp_ignore_big_gaps == 0) { if ((gap > 2.1 * row->xheight) && (row_length > 20 * row->xheight)) - return TRUE; + return true; if ((gap > 1.75 * row->xheight) && ((row_length > 35 * row->xheight) || gapmap->table_gap (left, right))) - return TRUE; + return true; } else { /* ONLY time gaps < 3.0 * xht are ignored is when they are part of a table */ if ((gap > gapmap_big_gaps * row->xheight) && gapmap->table_gap (left, right)) - return TRUE; + return true; } - return FALSE; + return false; } /********************************************************************** diff --git a/src/textord/wordseg.cpp b/src/textord/wordseg.cpp index 560de9100e..0daaa81b5b 100644 --- a/src/textord/wordseg.cpp +++ b/src/textord/wordseg.cpp @@ -132,10 +132,10 @@ void make_words(tesseract::Textord *textord, */ void set_row_spaces( //find space sizes - TO_BLOCK *block, //block to do - FCOORD rotation, //for drawing - BOOL8 testing_on //correct orientation - ) { + TO_BLOCK* block, //block to do + FCOORD rotation, //for drawing + bool testing_on //correct orientation +) { TO_ROW *row; //current row TO_ROW_IT row_it = block->get_rows (); @@ -176,14 +176,14 @@ void set_row_spaces( //find space sizes */ int32_t row_words( //compute space size - TO_BLOCK *block, //block it came from - TO_ROW *row, //row to operate on - int32_t maxwidth, //max expected space size - FCOORD rotation, //for drawing - BOOL8 testing_on //for debug - ) { - BOOL8 testing_row; //contains testpt - BOOL8 prev_valid; //if decent size + TO_BLOCK* block, //block it came from + TO_ROW* row, //row to operate on + int32_t maxwidth, //max expected space size + FCOORD rotation, //for drawing + bool testing_on //for debug +) { + bool testing_row; //contains testpt + bool prev_valid; //if decent size int32_t prev_x; //end of prev blob int32_t cluster_count; //no of clusters int32_t gap_index; //which cluster @@ -203,14 +203,14 @@ int32_t row_words( //compute space size (int32_t) (block->xheight * textord_wordstats_smooth_factor + 1.5); // if (testing_on) // tprintf("Row smooth factor=%d\n",smooth_factor); - prev_valid = FALSE; + prev_valid = false; prev_x = -INT32_MAX; - testing_row = FALSE; + testing_row = false; for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) { blob = blob_it.data (); blob_box = blob->bounding_box (); if (blob_box.contains (testpt)) - testing_row = TRUE; + testing_row = true; gap_stats.add (blob_box.width (), 1); } gap_stats.clear (); @@ -343,15 +343,15 @@ int32_t row_words( //compute space size */ int32_t row_words2( //compute space size - TO_BLOCK *block, //block it came from - TO_ROW *row, //row to operate on - int32_t maxwidth, //max expected space size - FCOORD rotation, //for drawing - BOOL8 testing_on //for debug - ) { - BOOL8 testing_row; //contains testpt - BOOL8 prev_valid; //if decent size - BOOL8 this_valid; //current blob big enough + TO_BLOCK* block, //block it came from + TO_ROW* row, //row to operate on + int32_t maxwidth, //max expected space size + FCOORD rotation, //for drawing + bool testing_on //for debug +) { + bool testing_row; //contains testpt + bool prev_valid; //if decent size + bool this_valid; //current blob big enough int32_t prev_x; //end of prev blob int32_t min_width; //min interesting width int32_t valid_count; //good gaps @@ -377,9 +377,9 @@ int32_t row_words2( //compute space size (int32_t) (block->xheight * textord_wordstats_smooth_factor + 1.5); // if (testing_on) // tprintf("Row smooth factor=%d\n",smooth_factor); - prev_valid = FALSE; + prev_valid = false; prev_x = -INT16_MAX; - testing_row = FALSE; + testing_row = false; //min blob size min_width = (int32_t) block->pr_space; total_count = 0; @@ -587,7 +587,7 @@ ROW *make_rep_words( //make a row WERD *make_real_word(BLOBNBOX_IT *box_it, //iterator int32_t blobcount, //no of blobs to use - BOOL8 bol, //start of line + bool bol, //start of line uint8_t blanks //no of blanks ) { C_OUTLINE_IT cout_it; @@ -621,9 +621,9 @@ WERD *make_real_word(BLOBNBOX_IT *box_it, //iterator word = new WERD(&cblobs, blanks, nullptr); if (bol) - word->set_flag(W_BOL, TRUE); + word->set_flag(W_BOL, true); if (box_it->at_first()) - word->set_flag(W_EOL, TRUE); // at end of line + word->set_flag(W_EOL, true); // at end of line return word; } diff --git a/src/textord/wordseg.h b/src/textord/wordseg.h index 042efb16f2..3acc8c9447 100644 --- a/src/textord/wordseg.h +++ b/src/textord/wordseg.h @@ -41,24 +41,24 @@ void make_words(tesseract::Textord *textord, BLOCK_LIST *blocks, // block list TO_BLOCK_LIST *port_blocks); // output list void set_row_spaces( //find space sizes - TO_BLOCK *block, //block to do - FCOORD rotation, //for drawing - BOOL8 testing_on //correct orientation - ); + TO_BLOCK* block, //block to do + FCOORD rotation, //for drawing + bool testing_on //correct orientation +); int32_t row_words( //compute space size - TO_BLOCK *block, //block it came from - TO_ROW *row, //row to operate on - int32_t maxwidth, //max expected space size - FCOORD rotation, //for drawing - BOOL8 testing_on //for debug - ); + TO_BLOCK* block, //block it came from + TO_ROW* row, //row to operate on + int32_t maxwidth, //max expected space size + FCOORD rotation, //for drawing + bool testing_on //for debug +); int32_t row_words2( //compute space size - TO_BLOCK *block, //block it came from - TO_ROW *row, //row to operate on - int32_t maxwidth, //max expected space size - FCOORD rotation, //for drawing - BOOL8 testing_on //for debug - ); + TO_BLOCK* block, //block it came from + TO_ROW* row, //row to operate on + int32_t maxwidth, //max expected space size + FCOORD rotation, //for drawing + bool testing_on //for debug +); void make_real_words( tesseract::Textord *textord, TO_BLOCK *block, //block to do @@ -69,9 +69,9 @@ ROW *make_rep_words( //make a row TO_BLOCK *block //block it lives in ); WERD *make_real_word( //make a WERD - BLOBNBOX_IT *box_it, //iterator - int32_t blobcount, //no of blobs to use - BOOL8 bol, //start of line - uint8_t blanks //no of blanks - ); + BLOBNBOX_IT* box_it, //iterator + int32_t blobcount, //no of blobs to use + bool bol, //start of line + uint8_t blanks //no of blanks +); #endif