26 #define BLOCK_LABEL_HEIGHT 150 //char height of block id 41 :
PDBLK (xmin, ymin, xmax, ymax),
43 re_rotation_(1.0f, 0.0f),
44 classify_rotation_(1.0f, 0.0f),
46 ICOORDELT_IT left_it = &leftside;
47 ICOORDELT_IT right_it = &rightside;
50 right_to_left_ =
false;
54 cell_over_xheight_ = 2.0f;
56 left_it.set_to_list (&leftside);
57 right_it.set_to_list (&rightside);
59 left_it.add_to_end (
new ICOORDELT (xmin, ymin));
60 left_it.add_to_end (
new ICOORDELT (xmin, ymax));
61 right_it.add_to_end (
new ICOORDELT (xmax, ymin));
62 right_it.add_to_end (
new ICOORDELT (xmax, ymax));
74 return (*(
ROW **) row2)->bounding_box ().top () -
75 (*(
ROW **) row1)->bounding_box ().top ();
94 ROW_IT it(const_cast<ROW_LIST*>(&rows));
95 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
96 box += it.data()->restricted_bounding_box(upper_dots, lower_dots);
119 ROW_IT row_it(&rows);
133 #define ROW_SPACING 5 135 ROW_IT row_it(&rows);
139 ICOORDELT_IT icoordelt_it;
145 for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
146 row = row_it.data ();
153 icoordelt_it.set_to_list (&
leftside);
203 tprintf (
"Proportional= %s\n", proportional ?
"TRUE" :
"FALSE");
204 tprintf (
"Kerning= %d\n", kerning);
205 tprintf (
"Spacing= %d\n", spacing);
206 tprintf (
"Fixed_pitch=%d\n", pitch);
210 tprintf (
"Left side coords are:\n");
211 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
212 tprintf (
"(%d,%d) ", it.data ()->x (), it.data ()->y ());
214 tprintf (
"Right side coords are:\n");
216 for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
217 tprintf (
"(%d,%d) ", it.data ()->x (), it.data ()->y ());
233 proportional = source.proportional;
234 kerning = source.kerning;
235 spacing = source.spacing;
236 filename = source.filename;
239 re_rotation_ = source.re_rotation_;
240 classify_rotation_ = source.classify_rotation_;
241 skew_ = source.skew_;
255 bool LeftMargin(ICOORDELT_LIST *segments,
int x,
int *margin) {
258 if (segments->empty())
260 ICOORDELT_IT seg_it(segments);
261 for (seg_it.mark_cycle_pt(); !seg_it.cycled_list(); seg_it.forward()) {
262 int cur_margin = x - seg_it.data()->x();
263 if (cur_margin >= 0) {
265 *margin = cur_margin;
266 }
else if (cur_margin < *margin) {
267 *margin = cur_margin;
288 if (segments->empty())
290 ICOORDELT_IT seg_it(segments);
291 for (seg_it.mark_cycle_pt(); !seg_it.cycled_list(); seg_it.forward()) {
292 int cur_margin = seg_it.data()->x() + seg_it.data()->y() - x;
293 if (cur_margin >= 0) {
295 *margin = cur_margin;
296 }
else if (cur_margin < *margin) {
297 *margin = cur_margin;
348 ROW *first_row = r_it.data();
349 ROW *second_row = r_it.data_relative(1);
357 WERD_IT werd_it(r_it.data()->word_list());
358 if (!werd_it.empty()) {
359 C_BLOB_IT cblob_it(werd_it.data()->cblob_list());
360 for (cblob_it.mark_cycle_pt(); !cblob_it.cycled_list();
361 cblob_it.forward()) {
362 TBOX bbox = cblob_it.data()->bounding_box();
363 if (bbox.
bottom() <= mid_second_line) {
366 if (drop_cap_bottom > bbox.
bottom())
367 drop_cap_bottom = bbox.
bottom();
368 if (drop_cap_right < bbox.
right())
369 drop_cap_right = bbox.
right();
378 for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward()) {
379 ROW *row = r_it.data();
383 ICOORDELT_LIST *segments = lines.
get_line(left_y);
387 if (row_box.
top() >= drop_cap_bottom) {
388 int drop_cap_distance = row_box.
left() - row->
space() - drop_cap_right;
389 if (drop_cap_distance < 0)
390 drop_cap_distance = 0;
391 if (drop_cap_distance < left_margin)
392 left_margin = drop_cap_distance;
416 BLOCK_IT block_it(block_list);
417 for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
418 BLOCK* block = block_it.data();
421 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
423 ROW* row = row_it.data();
426 for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
427 WERD* werd = werd_it.data();
433 tprintf(
"Block list stats:\nBlocks = %d\nRows = %d\nWords = %d\nBlobs = %d\n",
434 num_blocks, num_rows, num_words, num_blobs);
445 C_BLOB_LIST* output_blob_list) {
446 C_BLOB_IT return_list_it(output_blob_list);
447 BLOCK_IT block_it(blocks);
448 for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
449 BLOCK* block = block_it.data();
451 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
452 ROW* row = row_it.data();
455 for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
456 WERD* werd = werd_it.data();
457 return_list_it.move_to_last();
458 return_list_it.add_list_after(werd->
cblob_list());
459 return_list_it.move_to_last();
480 C_BLOB_LIST* new_blobs,
481 C_BLOB_LIST* not_found_blobs) {
484 BLOCK_IT block_it(block_list);
485 for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
486 BLOCK* block = block_it.data();
491 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
492 ROW* row = row_it.data();
496 WERD_IT new_words_it(&new_words);
497 for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
498 WERD* werd = werd_it.extract();
504 new_words_it.add_after_then_move(new_werd);
510 new_words_it.add_after_then_move(werd);
515 werd_it.move_to_first();
516 werd_it.add_list_after(&new_words);
#define ELISTIZE(CLASSNAME)
void set_has_drop_cap(bool has)
void set_rmargin(inT16 rmargin)
void RefreshWordBlobsFromNewBlobs(BLOCK_LIST *block_list, C_BLOB_LIST *new_blobs, C_BLOB_LIST *not_found_blobs)
void rotate(FCOORD rotation)
TBOX bounding_box() const
void ExtractBlobsFromSegmentation(BLOCK_LIST *blocks, C_BLOB_LIST *output_blob_list)
void rotate(const FCOORD &rotation)
float base_line(float xpos) const
void compress()
shrink white space
void operator=(const ELIST_LINK &)
void check_pitch()
check proportional
ROW_LIST * row_list()
get rows
PDBLK & operator=(const PDBLK &source)
void set_lmargin(inT16 lmargin)
POLY_BLOCK * poly_block() const
ICOORDELT_LIST * get_line(inT16 y)
const char * string() const
void compute_row_margins()
bool LeftMargin(ICOORDELT_LIST *segments, int x, int *margin)
bool RightMargin(ICOORDELT_LIST *segments, int x, int *margin)
void move(const ICOORD vec)
const TBOX & bounding_box() const
get real box
void move_bottom_edge(const inT16 y)
void print(FILE *fp, BOOL8 dump)
dump whole table
void PrintSegmentationStats(BLOCK_LIST *block_list)
void reflect_polygon_in_y_axis()
BLOCK & operator=(const BLOCK &source)
WERD * ConstructWerdWithNewBlobs(C_BLOB_LIST *all_blobs, C_BLOB_LIST *orphan_blobs)
C_BLOB_LIST * cblob_list()
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
const ICOORD & botleft() const
void move(const ICOORD vec)
void sort_rows()
decreasing y order
C_BLOB_LIST * rej_cblob_list()
int decreasing_top_order(const void *row1, const void *row2)