25 #define PROJECTION_MARGIN 10 //arbitrary 30 "Chop underlines & put back");
45 ICOORDELT_LIST chop_cells;
47 BLOBNBOX_LIST residual_underlines;
48 C_OUTLINE_LIST left_coutlines;
49 C_OUTLINE_LIST right_coutlines;
50 ICOORDELT_IT cell_it = &chop_cells;
53 BLOBNBOX_IT ru_it = &residual_underlines;
57 for (under_it.mark_cycle_pt (); !under_it.cycled_list ();
58 under_it.forward ()) {
59 u_line = under_it.extract ();
67 cell_it.set_to_list (&chop_cells);
68 for (cell_it.mark_cycle_pt (); !cell_it.cycled_list ();
70 chop_coord = cell_it.data ()->x ();
76 if (!left_coutlines.empty()) {
77 ru_it.add_after_then_move(
new BLOBNBOX(
new C_BLOB(&left_coutlines)));
79 chop_coord = cell_it.data ()->y ();
81 &left_coutlines, &right_coutlines);
82 if (!left_coutlines.empty()) {
87 delete cell_it.extract();
89 if (!right_coutlines.empty ()) {
91 &left_coutlines, &right_coutlines);
92 if (!left_coutlines.empty())
93 ru_it.add_after_then_move(
new BLOBNBOX(
new C_BLOB(&left_coutlines)));
96 if (u_line->
cblob() != NULL)
97 delete u_line->
cblob();
101 if (!ru_it.empty()) {
102 ru_it.move_to_first();
103 for (ru_it.mark_cycle_pt(); !ru_it.cycled_list(); ru_it.forward()) {
104 under_it.add_after_then_move(ru_it.extract());
122 TO_ROW_IT row_it = rows;
132 row = row_it.data ();
133 row_it.mark_cycle_pt ();
135 && !row_it.cycled_list ()) {
140 row = row_it.data ();
152 if (overlap > bestover) {
157 row = row_it.data ();
177 float baseline_offset,
178 ICOORDELT_LIST *chop_cells
184 ICOORDELT_IT cell_it = chop_cells;
193 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
196 &lower_proj, &middle_proj, &upper_proj);
199 for (x = blob_box.
left (); x < blob_box.
right (); x++) {
200 if (middle_proj.pile_count (x) > 0) {
202 y < blob_box.
right () && middle_proj.pile_count (y) > 0; y++);
203 blob_chop =
ICOORD (x, y);
204 cell_it.add_after_then_move (
new ICOORDELT (blob_chop));
222 float baseline_offset,
229 inT16 lower_y, upper_y;
232 C_OUTLINE_IT out_it = outline->
child ();
236 for (stepindex = 0; stepindex < length; stepindex++) {
237 step = outline->
step (stepindex);
244 if (pos.
y () >= lower_y) {
245 lower_proj->
add (pos.
x (), -lower_y);
246 if (pos.
y () >= upper_y) {
247 middle_proj->
add (pos.
x (), lower_y - upper_y);
248 upper_proj->
add (pos.
x (), upper_y - pos.
y ());
251 middle_proj->
add (pos.
x (), lower_y - pos.
y ());
254 lower_proj->
add (pos.
x (), -pos.
y ());
256 else if (step.
x () < 0) {
263 if (pos.
y () >= lower_y) {
264 lower_proj->
add (pos.
x () - 1, lower_y);
265 if (pos.
y () >= upper_y) {
266 middle_proj->
add (pos.
x () - 1, upper_y - lower_y);
267 upper_proj->
add (pos.
x () - 1, pos.
y () - upper_y);
270 middle_proj->
add (pos.
x () - 1, pos.
y () - lower_y);
273 lower_proj->
add (pos.
x () - 1, pos.
y ());
278 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
281 lower_proj, middle_proj, upper_proj);
const TBOX & bounding_box() const
EXTERN int textord_fp_chop_error
void add(inT32 value, inT32 count)
ICOORD step(int index) const
C_OUTLINE_LIST * out_list()
void vertical_cunderline_projection(C_OUTLINE *outline, QSPLINE *baseline, float xheight, float baseline_offset, STATS *lower_proj, STATS *middle_proj, STATS *upper_proj)
inT16 x() const
access function
void insert_blob(BLOBNBOX *blob)
EXTERN double textord_underline_offset
TO_ROW * most_overlapping_row(TO_ROW_LIST *rows, BLOBNBOX *blob)
EXTERN bool textord_restore_underlines
void split_to_blob(BLOBNBOX *blob, inT16 chop_coord, float pitch_error, C_OUTLINE_LIST *left_coutlines, C_OUTLINE_LIST *right_coutlines)
const ICOORD & start_pos() const
void restore_underlined_blobs(TO_BLOCK *block)
#define double_VAR(name, val, comment)
#define BOOL_VAR(name, val, comment)
inT16 y() const
access_function
void find_underlined_blobs(BLOBNBOX *u_line, QSPLINE *baseline, float xheight, float baseline_offset, ICOORDELT_LIST *chop_cells)