#include <rect.h>
Definition at line 33 of file rect.h.
BOX::BOX | ( | ) | [inline] |
Definition at line 36 of file rect.h.
Referenced by bounding_union(), and intersection().
00036 : //empty constructor 00037 bot_left (MAX_INT16, MAX_INT16), top_right (-MAX_INT16, -MAX_INT16) { 00038 } //null box
Constructor from 2 ICOORDS.
Definition at line 26 of file rect.cpp.
References bot_left, top_right, and ICOORD::y().
00029 { 00030 if (pt1.x () <= pt2.x ()) { 00031 if (pt1.y () <= pt2.y ()) { 00032 bot_left = pt1; 00033 top_right = pt2; 00034 } 00035 else { 00036 bot_left = ICOORD (pt1.x (), pt2.y ()); 00037 top_right = ICOORD (pt2.x (), pt1.y ()); 00038 } 00039 } 00040 else { 00041 if (pt1.y () <= pt2.y ()) { 00042 bot_left = ICOORD (pt2.x (), pt1.y ()); 00043 top_right = ICOORD (pt1.x (), pt2.y ()); 00044 } 00045 else { 00046 bot_left = pt2; 00047 top_right = pt1; 00048 } 00049 } 00050 }
BOX::BOX | ( | const FCOORD | pt | ) | [inline] |
INT32 BOX::area | ( | ) | const [inline] |
const ICOORD& BOX::botleft | ( | ) | const [inline] |
Definition at line 67 of file rect.h.
Referenced by block_list_compress(), convert_vec_block(), do_tidy_cmd(), and do_write_file().
00067 { 00068 return bot_left; 00069 }
ICOORD BOX::botright | ( | ) | const [inline] |
INT16 BOX::bottom | ( | ) | const [inline] |
Definition at line 54 of file rect.h.
Referenced by PIXROW::bad_box(), WERD::baseline_normalise_x(), blob_noise_score(), PIXROW::char_clip_image(), char_clip_word(), clean_noise_from_row(), COMMAND_WINDOW::COMMAND_WINDOW(), compute_block_pitch(), compute_line_occupation(), convert_vec_block(), OL_BUCKETS::count_children(), delete_non_dropout_rows(), display_clip_image(), dodgy_blob(), dot_of_i(), OL_BUCKETS::extract_children(), fill_buckets(), find_lesser_parts(), find_repeated_chars(), fit_lms_line(), fit_parallel_lms(), generate_imlines(), get_ydiffs(), linear_spline_baseline(), make_baseline_spline(), make_first_baseline(), make_prop_words(), make_reject(), mark_gap(), partition_coords(), plot_fp_cells(), plot_fp_cells2(), plot_row_cells(), plot_word_decisions(), pre_associate_blobs(), re_estimate_x_ht(), re_scale_and_move_bln_word(), NON_LEAF_MENU_NODE::recalc_bounding_box(), reduced_box_for_blob(), report_failed_box(), resegment_box(), restore_underlined_blobs(), scan_hpd_blocks(), segment_baseline(), separate_underlines(), show_point(), suspected_punct_blob(), test_underline(), tweak_row_baseline(), COMMAND_WINDOW::update_menu_tree(), whiteout_block(), word_deletable(), word_display(), write_cooked_text(), and write_shm_text().
Build the smallest box containing both boxes.
Definition at line 95 of file rect.cpp.
References bot_left, BOX(), ICOORD::set_x(), ICOORD::set_y(), top_right, and ICOORD::y().
00096 { 00097 ICOORD bl; //bottom left 00098 ICOORD tr; //top right 00099 00100 if (box.bot_left.x () < bot_left.x ()) 00101 bl.set_x (box.bot_left.x ()); 00102 else 00103 bl.set_x (bot_left.x ()); 00104 00105 if (box.top_right.x () > top_right.x ()) 00106 tr.set_x (box.top_right.x ()); 00107 else 00108 tr.set_x (top_right.x ()); 00109 00110 if (box.bot_left.y () < bot_left.y ()) 00111 bl.set_y (box.bot_left.y ()); 00112 else 00113 bl.set_y (bot_left.y ()); 00114 00115 if (box.top_right.y () > top_right.y ()) 00116 tr.set_y (box.top_right.y ()); 00117 else 00118 tr.set_y (top_right.y ()); 00119 return BOX (bl, tr); 00120 }
Is point within box.
Definition at line 238 of file rect.h.
References bot_left, top_right, and ICOORD::y().
Referenced by add_word(), check_debug_pt(), contains(), crude_match_blobs(), VAR_SUB_MENU::event(), STR_VAR_MENU_LEAF::event(), INT_VAR_MENU_LEAF::event(), DBL_VAR_MENU_LEAF::event(), BOOL_VAR_MENU_LEAF::event(), VARIABLE_MENU_LEAF::event(), TOGGLE_MENU_LEAF::event(), SIMPLE_MENU_LEAF::event(), RADIO_MENU::event(), NON_LEAF_MENU_NODE::event(), row_words(), and show_point().
00238 { 00239 return ((pt.x () >= bot_left.x ()) && 00240 (pt.x () <= top_right.x ()) && 00241 (pt.y () >= bot_left.y ()) && (pt.y () <= top_right.y ())); 00242 }
void BOX::de_serialise_asc | ( | FILE * | f | ) |
Convert from ASCII file.
Definition at line 209 of file rect.cpp.
References bot_left, ICOORD::de_serialise_asc(), and top_right.
Referenced by POLY_BLOCK::de_serialise_asc().
00211 { 00212 bot_left.de_serialise_asc (f); 00213 top_right.de_serialise_asc (f); 00214 }
INT16 BOX::height | ( | ) | const [inline] |
Definition at line 84 of file rect.h.
Referenced by adapt_to_good_ems(), adapt_to_good_samples(), WERD::baseline_normalise_x(), blob_noise_score(), PIXROW::char_clip_image(), char_clip_word(), clean_noise_from_row(), clean_noise_from_words(), clip_sample(), collect_characters_for_adaption(), collect_ems_for_adaption(), display_clip_image(), dot_of_i(), generate_imlines(), get_blob_coords(), major_overlap(), mark_gap(), narrow_blob(), noise_outlines(), re_estimate_x_ht(), re_scale_and_move_bln_word(), reduced_box_next(), suspect_fullstop(), suspected_punct_blob(), tesspoly_outline(), tweak_row_baseline(), vigorous_noise_removal(), wide_blob(), word_deletable(), and word_display().
00084 { //how high is it? 00085 if (!null_box ()) 00086 return top_right.y () - bot_left.y (); 00087 else 00088 return 0; 00089 }
Build the largest box contained in both boxes.
Definition at line 56 of file rect.cpp.
References bot_left, BOX(), MAX_INT16, overlap(), ICOORD::set_x(), ICOORD::set_y(), top_right, and ICOORD::y().
00057 { 00058 ICOORD bl; //bottom left 00059 ICOORD tr; //top right 00060 00061 if (overlap (box)) { 00062 if (box.bot_left.x () > bot_left.x ()) 00063 bl.set_x (box.bot_left.x ()); 00064 else 00065 bl.set_x (bot_left.x ()); 00066 00067 if (box.top_right.x () < top_right.x ()) 00068 tr.set_x (box.top_right.x ()); 00069 else 00070 tr.set_x (top_right.x ()); 00071 00072 if (box.bot_left.y () > bot_left.y ()) 00073 bl.set_y (box.bot_left.y ()); 00074 else 00075 bl.set_y (bot_left.y ()); 00076 00077 if (box.top_right.y () < top_right.y ()) 00078 tr.set_y (box.top_right.y ()); 00079 else 00080 tr.set_y (top_right.y ()); 00081 } 00082 else { 00083 bl.set_x (MAX_INT16); 00084 bl.set_y (MAX_INT16); 00085 tr.set_x (-MAX_INT16); 00086 tr.set_y (-MAX_INT16); 00087 } 00088 return BOX (bl, tr); 00089 }
INT16 BOX::left | ( | ) | const [inline] |
Definition at line 58 of file rect.h.
Referenced by add_word(), apply_boxes(), PIXROW::bad_box(), WERD::baseline_normalise_x(), blob_comparator(), block_space_stat(), block_spacing_stats(), c_blob_comparator(), PIXROW::char_clip_image(), char_clip_word(), check_pitch_sync(), check_pitch_sync2(), clean_noise_from_row(), compute_block_pitch(), compute_line_occupation(), compute_pitch_sd(), TO_ROW::compute_vertical_projection(), OL_BUCKETS::count_children(), count_pitch_stats(), determine_newline_type(), display_clip_image(), dot_of_i(), PIXROW::extend(), OL_BUCKETS::extract_children(), fill_buckets(), find_mean_blob_spacing(), find_repeated_chars(), find_underlined_blobs(), fit_lms_line(), fit_parallel_lms(), GAPMAP::GAPMAP(), generate_imlines(), get_ydiffs(), isolated_row_stats(), linear_spline_baseline(), make_baseline_spline(), make_first_baseline(), make_holed_baseline(), make_illegal_segment(), make_prop_words(), make_reject(), make_rep_words(), mark_gap(), old_first_xheight(), peek_at_next_gap(), plot_word_decisions(), NON_LEAF_MENU_NODE::plotx(), LEAF_MENU_NODE::plotx(), pre_associate_blobs(), print_pitch_sd(), re_scale_and_move_bln_word(), NON_LEAF_MENU_NODE::recalc_bounding_box(), ROW::recalc_bounding_box(), reduced_box_for_blob(), reduced_box_next(), report_failed_box(), resegment_box(), restore_underlined_blobs(), row_pitch_stats(), row_space_stat(), row_spacing_stats(), row_words(), row_words2(), scan_hpd_blocks(), segment_baseline(), separate_underlines(), show_point(), split_and_recog_word(), suspected_punct_blob(), test_underline(), tidy_up(), transform_to_next_perm(), tweak_row_baseline(), uniformly_spaced(), unrej_good_chs(), word_blob_quality(), word_char_quality(), word_comparator(), word_display(), write_cooked_text(), and write_shm_text().
00058 { // coord of left 00059 return bot_left.x (); 00060 }
Definition at line 269 of file rect.h.
References bot_left, height(), MAX, MIN, overlap(), top_right, width(), and ICOORD::y().
00270 { 00271 int overlap = MIN(box.top_right.x(), top_right.x()); 00272 overlap -= MAX(box.bot_left.x(), bot_left.x()); 00273 overlap += overlap; 00274 if (overlap < MIN(box.width(), width())) 00275 return false; 00276 overlap = MIN(box.top_right.y(), top_right.y()); 00277 overlap -= MAX(box.bot_left.y(), bot_left.y()); 00278 overlap += overlap; 00279 if (overlap < MIN(box.height(), height())) 00280 return false; 00281 return true; 00282 }
void BOX::move | ( | const FCOORD | vec | ) | [inline] |
Definition at line 131 of file rect.h.
References ICOORD::set_x().
00132 { // by float vector 00133 bot_left.set_x ((INT16) floor (bot_left.x () + vec.x ())); 00134 //round left 00135 bot_left.set_y ((INT16) floor (bot_left.y () + vec.y ())); 00136 //round down 00137 00138 top_right.set_x ((INT16) ceil (top_right.x () + vec.x ())); 00139 //round right 00140 top_right.set_y ((INT16) ceil (top_right.y () + vec.y ())); 00141 //round up 00142 }
void BOX::move | ( | const ICOORD | vec | ) | [inline] |
void BOX::move_bottom_edge | ( | const INT16 | y | ) | [inline] |
Definition at line 105 of file rect.h.
Referenced by block_list_compress(), char_clip_word(), and display_clip_image().
void BOX::move_left_edge | ( | const INT16 | x | ) | [inline] |
void BOX::move_right_edge | ( | const INT16 | x | ) | [inline] |
Definition at line 115 of file rect.h.
Referenced by char_clip_word(), display_clip_image(), and MENU_ROOT::recalc_bounding_box().
void BOX::move_top_edge | ( | const INT16 | y | ) | [inline] |
BOOL8 BOX::null_box | ( | ) | const [inline] |
Do two boxes overlap?
Definition at line 256 of file rect.h.
References bot_left, top_right, and ICOORD::y().
Referenced by POLY_BLOCK::contains(), find_row_of_box(), intersection(), major_overlap(), make_pseudo_word(), operator-=(), POLY_BLOCK::overlap(), process_selected_blobs(), process_selected_rows(), process_selected_rows_it(), process_selected_words(), process_selected_words_it(), re_segment_word(), resegment_box(), and row_space_stat().
00257 { 00258 return ((box.bot_left.x () <= top_right.x ()) && 00259 (box.top_right.x () >= bot_left.x ()) && 00260 (box.bot_left.y () <= top_right.y ()) && 00261 (box.top_right.y () >= bot_left.y ())); 00262 }
void BOX::plot | ( | WINDOW | fd, | |
INT16 | style, | |||
INT16 | edged, | |||
COLOUR | fill_colour, | |||
COLOUR | border_colour | |||
) | const |
Paint a box using specified settings.
Definition at line 127 of file rect.cpp.
References fill_color_index, interior_style, perimeter_color_index, and plot().
00133 { 00134 interior_style(fd, style, edged); 00135 fill_color_index(fd, fill_colour); 00136 perimeter_color_index(fd, border_colour); 00137 plot(fd); 00138 }
void BOX::plot | ( | WINDOW | fd | ) | const [inline] |
Definition at line 195 of file rect.h.
References rectangle.
Referenced by display_clip_image(), plot(), NON_LEAF_MENU_NODE::plotx(), LEAF_MENU_NODE::plotx(), re_segment_word(), reduced_box_next(), word_blank_and_set_display(), word_delete(), and word_display().
00196 { //where to paint 00197 rectangle (fd, bot_left.x (), bot_left.y (), top_right.x (), 00198 top_right.y ()); 00199 }
void BOX::print | ( | ) | [inline] |
Definition at line 189 of file rect.h.
References tprintf().
Referenced by fixspace_dbg(), WERD::print(), ROW::print(), print_boxes(), and tidy_up().
00189 { //print 00190 tprintf ("Bounding box=(%d,%d)->(%d,%d)\n", 00191 left (), bottom (), right (), top ()); 00192 }
INT16 BOX::right | ( | ) | const [inline] |
Definition at line 62 of file rect.h.
Referenced by apply_boxes(), PIXROW::bad_box(), WERD::baseline_normalise_x(), block_space_stat(), block_spacing_stats(), build_image_window(), PIXROW::char_clip_image(), check_pitch_sync(), check_pitch_sync2(), clean_noise_from_row(), compute_block_pitch(), compute_line_occupation(), compute_pitch_sd(), compute_pitch_sd2(), TO_ROW::compute_vertical_projection(), OL_BUCKETS::count_children(), count_pitch_stats(), determine_newline_type(), display_clip_image(), dot_of_i(), PIXROW::extend(), OL_BUCKETS::extract_children(), find_mean_blob_spacing(), find_repeated_chars(), find_underlined_blobs(), fit_lms_line(), fit_parallel_lms(), GAPMAP::GAPMAP(), isolated_row_stats(), linear_spline_baseline(), make_baseline_spline(), make_epaper_choice(), make_first_baseline(), make_holed_baseline(), make_illegal_segment(), make_prop_words(), make_reject(), make_rep_words(), old_first_xheight(), peek_at_next_gap(), plot_word_decisions(), NON_LEAF_MENU_NODE::plotx(), pre_associate_blobs(), print_pitch_sd(), MENU_ROOT::recalc_bounding_box(), reduced_box_for_blob(), report_failed_box(), resegment_box(), restore_underlined_blobs(), row_pitch_stats(), row_space_stat(), row_spacing_stats(), row_words(), row_words2(), scan_hpd_blocks(), segment_baseline(), separate_underlines(), show_point(), split_and_recog_word(), suspected_punct_blob(), test_underline(), transform_to_next_perm(), tweak_row_baseline(), uniformly_spaced(), word_display(), write_cooked_text(), and write_shm_text().
00062 { // coord of right 00063 return top_right.x (); 00064 }
void BOX::rotate | ( | const FCOORD | vec | ) | [inline] |
Definition at line 164 of file rect.h.
Referenced by compute_line_occupation(), deskew_block_coords(), and pre_associate_blobs().
00165 { //by vector 00166 bot_left.rotate (vec); 00167 top_right.rotate (vec); 00168 *this = BOX (bot_left, top_right); 00169 }
void BOX::scale | ( | const FCOORD | vec | ) | [inline] |
Definition at line 156 of file rect.h.
00157 { // by float vector 00158 bot_left.set_x ((INT16) floor (bot_left.x () * vec.x ())); 00159 bot_left.set_y ((INT16) floor (bot_left.y () * vec.y ())); 00160 top_right.set_x ((INT16) ceil (top_right.x () * vec.x ())); 00161 top_right.set_y ((INT16) ceil (top_right.y () * vec.y ())); 00162 }
void BOX::scale | ( | const float | f | ) | [inline] |
Definition at line 144 of file rect.h.
00145 { // by multiplier 00146 //round left 00147 bot_left.set_x ((INT16) floor (bot_left.x () * f)); 00148 //round down 00149 bot_left.set_y ((INT16) floor (bot_left.y () * f)); 00150 00151 top_right.set_x ((INT16) ceil (top_right.x () * f)); 00152 //round right 00153 top_right.set_y ((INT16) ceil (top_right.y () * f)); 00154 //round up 00155 }
void BOX::serialise_asc | ( | FILE * | f | ) |
Convert to ASCII file.
Definition at line 198 of file rect.cpp.
References bot_left, ICOORD::serialise_asc(), and top_right.
00200 { 00201 bot_left.serialise_asc (f); 00202 top_right.serialise_asc (f); 00203 }
INT16 BOX::top | ( | ) | const [inline] |
Definition at line 50 of file rect.h.
Referenced by add_word(), PIXROW::bad_box(), WERD::baseline_normalise_x(), blob_noise_score(), build_image_window(), check_pitch_sync2(), clean_noise_from_row(), compute_block_pitch(), compute_line_occupation(), compute_pitch_sd(), compute_pitch_sd2(), convert_vec_block(), OL_BUCKETS::count_children(), delete_non_dropout_rows(), display_clip_image(), do_tidy_cmd(), dodgy_blob(), dot_of_i(), est_ambigs(), OL_BUCKETS::extract_children(), POLY_BLOCK::fill(), find_repeated_chars(), improve_estimate(), make_prop_words(), make_reject(), old_first_xheight(), plot_fp_cells(), plot_fp_cells2(), plot_row_cells(), plot_word_decisions(), NON_LEAF_MENU_NODE::plotx(), LEAF_MENU_NODE::plotx(), pre_associate_blobs(), re_estimate_x_ht(), MENU_ROOT::recalc_bounding_box(), reduced_box_for_blob(), report_failed_box(), resegment_box(), restore_underlined_blobs(), scan_hpd_blocks(), separate_underlines(), show_point(), suspected_punct_blob(), test_underline(), whiteout_block(), word_deletable(), write_cooked_text(), and write_shm_text().
ICOORD BOX::topleft | ( | ) | const [inline] |
const ICOORD& BOX::topright | ( | ) | const [inline] |
Definition at line 80 of file rect.h.
Referenced by convert_vec_block(), edges_and_textord(), and read_and_textord().
00080 { 00081 return top_right; 00082 }
INT16 BOX::width | ( | ) | const [inline] |
Definition at line 91 of file rect.h.
Referenced by blob_noise_score(), block_spacing_stats(), PIXROW::char_clip_image(), clean_noise_from_row(), clean_noise_from_words(), clip_sample(), COMMAND_WINDOW::COMMAND_WINDOW(), count_pitch_stats(), display_clip_image(), dot_of_i(), generate_imlines(), major_overlap(), make_a_word_break(), narrow_blob(), noise_outlines(), pre_associate_blobs(), re_scale_and_move_bln_word(), NON_LEAF_MENU_NODE::recalc_bounding_box(), reduced_box_next(), row_words(), row_words2(), separate_underlines(), suspect_fullstop(), tesspoly_outline(), test_underline(), COMMAND_WINDOW::update_menu_tree(), wide_blob(), word_deletable(), and word_display().
00091 { //how high is it? 00092 if (!null_box ()) 00093 return top_right.x () - bot_left.x (); 00094 else 00095 return 0; 00096 }
Extend one box to include the other (In place union).
Definition at line 146 of file rect.cpp.
00148 { 00149 if (op2.bot_left.x () < op1.bot_left.x ()) 00150 op1.bot_left.set_x (op2.bot_left.x ()); 00151 00152 if (op2.top_right.x () > op1.top_right.x ()) 00153 op1.top_right.set_x (op2.top_right.x ()); 00154 00155 if (op2.bot_left.y () < op1.bot_left.y ()) 00156 op1.bot_left.set_y (op2.bot_left.y ()); 00157 00158 if (op2.top_right.y () > op1.top_right.y ()) 00159 op1.top_right.set_y (op2.top_right.y ()); 00160 00161 return op1; 00162 }
Reduce one box to intersection with the other (In place intersection).
Definition at line 169 of file rect.cpp.
00171 { 00172 if (op1.overlap (op2)) { 00173 if (op2.bot_left.x () > op1.bot_left.x ()) 00174 op1.bot_left.set_x (op2.bot_left.x ()); 00175 00176 if (op2.top_right.x () < op1.top_right.x ()) 00177 op1.top_right.set_x (op2.top_right.x ()); 00178 00179 if (op2.bot_left.y () > op1.bot_left.y ()) 00180 op1.bot_left.set_y (op2.bot_left.y ()); 00181 00182 if (op2.top_right.y () < op1.top_right.y ()) 00183 op1.top_right.set_y (op2.top_right.y ()); 00184 } 00185 else { 00186 op1.bot_left.set_x (MAX_INT16); 00187 op1.bot_left.set_y (MAX_INT16); 00188 op1.top_right.set_x (-MAX_INT16); 00189 op1.top_right.set_y (-MAX_INT16); 00190 } 00191 return op1; 00192 }
ICOORD BOX::bot_left [private] |
Definition at line 220 of file rect.h.
Referenced by bounding_union(), BOX(), contains(), de_serialise_asc(), intersection(), major_overlap(), operator+=(), operator-=(), overlap(), and serialise_asc().
ICOORD BOX::top_right [private] |
Definition at line 221 of file rect.h.
Referenced by bounding_union(), BOX(), contains(), de_serialise_asc(), intersection(), major_overlap(), operator+=(), operator-=(), overlap(), and serialise_asc().