21 #define PROJECTION_MARGIN 10 //arbitrary 26 "Chop underlines & put back");
41 ICOORDELT_LIST chop_cells;
43 BLOBNBOX_LIST residual_underlines;
44 C_OUTLINE_LIST left_coutlines;
45 C_OUTLINE_LIST right_coutlines;
46 ICOORDELT_IT cell_it = &chop_cells;
49 BLOBNBOX_IT ru_it = &residual_underlines;
53 for (under_it.mark_cycle_pt (); !under_it.cycled_list ();
54 under_it.forward ()) {
55 u_line = under_it.extract ();
63 cell_it.set_to_list (&chop_cells);
64 for (cell_it.mark_cycle_pt (); !cell_it.cycled_list ();
66 chop_coord = cell_it.data ()->x ();
72 if (!left_coutlines.empty()) {
73 ru_it.add_after_then_move(
new BLOBNBOX(
new C_BLOB(&left_coutlines)));
75 chop_coord = cell_it.data ()->y ();
77 &left_coutlines, &right_coutlines);
78 if (!left_coutlines.empty()) {
83 delete cell_it.extract();
85 if (!right_coutlines.empty ()) {
87 &left_coutlines, &right_coutlines);
88 if (!left_coutlines.empty())
89 ru_it.add_after_then_move(
new BLOBNBOX(
new C_BLOB(&left_coutlines)));
91 if (u_line !=
nullptr) {
92 delete u_line->
cblob();
97 ru_it.move_to_first();
98 for (ru_it.mark_cycle_pt(); !ru_it.cycled_list(); ru_it.forward()) {
99 under_it.add_after_then_move(ru_it.extract());
117 TO_ROW_IT row_it = rows;
124 bestover = (float) -INT32_MAX;
127 row = row_it.data ();
128 row_it.mark_cycle_pt ();
130 && !row_it.cycled_list ()) {
135 row = row_it.data ();
147 if (overlap > bestover) {
152 row = row_it.data ();
172 float baseline_offset,
173 ICOORDELT_LIST *chop_cells
179 ICOORDELT_IT cell_it = chop_cells;
188 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
191 &lower_proj, &middle_proj, &upper_proj);
194 for (x = blob_box.
left (); x < blob_box.
right (); x++) {
195 if (middle_proj.pile_count (x) > 0) {
197 y < blob_box.
right () && middle_proj.pile_count (y) > 0; y++);
198 blob_chop =
ICOORD (x, y);
199 cell_it.add_after_then_move (
new ICOORDELT (blob_chop));
217 float baseline_offset,
224 int16_t lower_y, upper_y;
227 C_OUTLINE_IT out_it = outline->
child ();
231 for (stepindex = 0; stepindex < length; stepindex++) {
232 step = outline->
step (stepindex);
235 (int16_t) floor (
baseline->y (pos.
x ()) + baseline_offset + 0.5);
237 (int16_t) floor (
baseline->y (pos.
x ()) + baseline_offset +
239 if (pos.
y () >= lower_y) {
240 lower_proj->
add (pos.
x (), -lower_y);
241 if (pos.
y () >= upper_y) {
242 middle_proj->
add (pos.
x (), lower_y - upper_y);
243 upper_proj->
add (pos.
x (), upper_y - pos.
y ());
246 middle_proj->
add (pos.
x (), lower_y - pos.
y ());
249 lower_proj->
add (pos.
x (), -pos.
y ());
251 else if (step.
x () < 0) {
253 (int16_t) floor (
baseline->y (pos.
x () - 1) + baseline_offset +
256 (int16_t) floor (
baseline->y (pos.
x () - 1) + baseline_offset +
258 if (pos.
y () >= lower_y) {
259 lower_proj->
add (pos.
x () - 1, lower_y);
260 if (pos.
y () >= upper_y) {
261 middle_proj->
add (pos.
x () - 1, upper_y - lower_y);
262 upper_proj->
add (pos.
x () - 1, pos.
y () - upper_y);
265 middle_proj->
add (pos.
x () - 1, pos.
y () - lower_y);
268 lower_proj->
add (pos.
x () - 1, pos.
y ());
273 for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
276 lower_proj, middle_proj, upper_proj);
TO_ROW * most_overlapping_row(TO_ROW_LIST *rows, BLOBNBOX *blob)
void insert_blob(BLOBNBOX *blob)
#define BOOL_VAR(name, val, comment)
void vertical_cunderline_projection(C_OUTLINE *outline, QSPLINE *baseline, float xheight, float baseline_offset, STATS *lower_proj, STATS *middle_proj, STATS *upper_proj)
#define double_VAR(name, val, comment)
int16_t y() const
access_function
void split_to_blob(BLOBNBOX *blob, int16_t chop_coord, float pitch_error, C_OUTLINE_LIST *left_coutlines, C_OUTLINE_LIST *right_coutlines)
void restore_underlined_blobs(TO_BLOCK *block)
const ICOORD & start_pos() const
EXTERN double textord_underline_offset
int16_t x() const
access function
int32_t pathlength() const
EXTERN bool textord_restore_underlines
void add(int32_t value, int32_t count)
void find_underlined_blobs(BLOBNBOX *u_line, QSPLINE *baseline, float xheight, float baseline_offset, ICOORDELT_LIST *chop_cells)
C_OUTLINE_LIST * out_list()
const TBOX & bounding_box() const
EXTERN int textord_fp_chop_error
ICOORD step(int index) const