26 #define PROJECTION_MARGIN 10 //arbitrary
31 "Chop underlines & put back");
46 ICOORDELT_LIST chop_cells;
48 BLOBNBOX_LIST residual_underlines;
49 C_OUTLINE_LIST left_coutlines;
50 C_OUTLINE_LIST right_coutlines;
51 ICOORDELT_IT cell_it = &chop_cells;
54 BLOBNBOX_IT ru_it = &residual_underlines;
58 for (under_it.mark_cycle_pt (); !under_it.cycled_list ();
59 under_it.forward ()) {
60 u_line = under_it.extract ();
66 cell_it.set_to_list (&chop_cells);
67 for (cell_it.mark_cycle_pt (); !cell_it.cycled_list ();
69 chop_coord = cell_it.data ()->x ();
75 if (!left_coutlines.empty()) {
76 ru_it.add_after_then_move(
new BLOBNBOX(
new C_BLOB(&left_coutlines)));
78 chop_coord = cell_it.data ()->y ();
80 &left_coutlines, &right_coutlines);
81 if (!left_coutlines.empty()) {
85 "Error:no outlines after chopping from %d to %d from (%d,%d)->(%d,%d)\n",
86 cell_it.data ()->x (), cell_it.data ()->y (),
93 delete cell_it.extract();
95 if (!right_coutlines.empty ()) {
97 &left_coutlines, &right_coutlines);
98 if (!left_coutlines.empty())
99 ru_it.add_after_then_move(
new BLOBNBOX(
new C_BLOB(&left_coutlines)));
101 if (u_line !=
NULL) {
103 delete u_line->
cblob();
107 if (!ru_it.empty()) {
108 ru_it.move_to_first();
109 for (ru_it.mark_cycle_pt(); !ru_it.cycled_list(); ru_it.forward()) {
110 under_it.add_after_then_move(ru_it.extract());
128 TO_ROW_IT row_it = rows;
138 row = row_it.data ();
139 row_it.mark_cycle_pt ();
141 && !row_it.cycled_list ()) {
146 row = row_it.data ();
158 if (overlap > bestover) {
163 row = row_it.data ();
183 float baseline_offset,
184 ICOORDELT_LIST *chop_cells
190 ICOORDELT_IT cell_it = chop_cells;
199 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
202 &lower_proj, &middle_proj, &upper_proj);
205 for (x = blob_box.
left (); x < blob_box.
right (); x++) {
206 if (middle_proj.pile_count (x) > 0) {
208 y < blob_box.
right () && middle_proj.pile_count (y) > 0; y++);
209 blob_chop =
ICOORD (x, y);
210 cell_it.add_after_then_move (
new ICOORDELT (blob_chop));
228 float baseline_offset,
235 inT16 lower_y, upper_y;
238 C_OUTLINE_IT out_it = outline->
child ();
242 for (stepindex = 0; stepindex < length; stepindex++) {
243 step = outline->
step (stepindex);
246 (
inT16) floor (baseline->
y (pos.
x ()) + baseline_offset + 0.5);
248 (
inT16) floor (baseline->
y (pos.
x ()) + baseline_offset +
250 if (pos.
y () >= lower_y) {
251 lower_proj->
add (pos.
x (), -lower_y);
252 if (pos.
y () >= upper_y) {
253 middle_proj->
add (pos.
x (), lower_y - upper_y);
254 upper_proj->
add (pos.
x (), upper_y - pos.
y ());
257 middle_proj->
add (pos.
x (), lower_y - pos.
y ());
260 lower_proj->
add (pos.
x (), -pos.
y ());
262 else if (step.
x () < 0) {
264 (
inT16) floor (baseline->
y (pos.
x () - 1) + baseline_offset +
267 (
inT16) floor (baseline->
y (pos.
x () - 1) + baseline_offset +
269 if (pos.
y () >= lower_y) {
270 lower_proj->
add (pos.
x () - 1, lower_y);
271 if (pos.
y () >= upper_y) {
272 middle_proj->
add (pos.
x () - 1, upper_y - lower_y);
273 upper_proj->
add (pos.
x () - 1, pos.
y () - upper_y);
276 middle_proj->
add (pos.
x () - 1, pos.
y () - lower_y);
279 lower_proj->
add (pos.
x () - 1, pos.
y ());
284 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
287 lower_proj, middle_proj, upper_proj);