39 "Max allowed bending of chop cells");
41 "Max distance of chop pt from vertex");
59 inT16 prev_chop_coord;
62 C_OUTLINE_LIST left_coutlines;
63 C_OUTLINE_LIST right_coutlines;
65 C_BLOB_IT cblob_it = &cblobs;
67 WERD_IT word_it = &words;
69 WERD_IT rep_it = &row->rep_words;
74 BLOBNBOX_IT box_it = row->blob_list ();
76 ICOORDELT_IT cell_it = &row->char_cells;
78 #ifndef GRAPHICS_DISABLED 90 rep_left = rep_it.data ()->bounding_box ().left ();
93 xstarts[0] = box_it.data ()->bounding_box ().left ();
94 if (rep_left < xstarts[0]) {
95 xstarts[0] = rep_left;
97 if (cell_it.empty () || row->char_cells.singleton ()) {
98 tprintf (
"Row without enough char cells!\n");
99 tprintf (
"Leftmost blob is at (%d,%d)\n",
100 box_it.data ()->bounding_box ().left (),
101 box_it.data ()->bounding_box ().bottom ());
104 ASSERT_HOST (!cell_it.empty () && !row->char_cells.singleton ());
105 prev_chop_coord = cell_it.data ()->x ();
107 while (rep_left < cell_it.data ()->x ()) {
109 blanks, row->fixed_pitch, &word_it);
111 cell_it.mark_cycle_pt ();
112 if (prev_chop_coord >= cell_it.data ()->x ())
114 for (; !cell_it.cycled_list (); cell_it.forward ()) {
115 chop_coord = cell_it.data ()->x ();
116 while (!box_it.empty ()
117 && box_it.data ()->bounding_box ().left () <= chop_coord) {
118 if (box_it.data ()->bounding_box ().right () > prev_x)
119 prev_x = box_it.data ()->bounding_box ().right ();
125 while (!box_it.empty() && box_it.data()->cblob() == NULL) {
126 delete box_it.extract();
130 if (!right_coutlines.empty() && left_coutlines.empty())
135 if (!left_coutlines.empty()) {
136 cblob_it.add_after_then_move(
new C_BLOB(&left_coutlines));
138 if (rep_left < chop_coord) {
139 if (rep_left > prev_chop_coord)
140 new_blanks = (
uinT8) floor ((rep_left - prev_chop_coord)
141 / row->fixed_pitch + 0.5);
146 if (chop_coord > prev_chop_coord)
147 new_blanks = (
uinT8) floor ((chop_coord - prev_chop_coord)
148 / row->fixed_pitch + 0.5);
152 if (!cblob_it.empty()) {
153 if (blanks < 1 && word != NULL && !word->flag (
W_REP_CHAR))
155 word =
new WERD (&cblobs, blanks, NULL);
156 cblob_it.set_to_list (&cblobs);
158 word_it.add_after_then_move (word);
166 blanks += new_blanks;
167 while (rep_left < chop_coord) {
169 blanks, row->fixed_pitch, &word_it);
172 if (prev_chop_coord < chop_coord)
173 prev_chop_coord = chop_coord;
175 if (!cblob_it.empty()) {
176 word =
new WERD(&cblobs, blanks, NULL);
178 word_it.add_after_then_move (word);
183 while (!rep_it.empty ()) {
185 blanks, row->fixed_pitch, &word_it);
189 if (prev_chop_coord > prev_x)
190 prev_x = prev_chop_coord;
191 xstarts[1] = prev_x + 1;
192 real_row =
new ROW (row, (
inT16) row->kern_size, (
inT16) row->space_size);
193 word_it.set_to_list (real_row->
word_list ());
195 word_it.add_list_after (&words);
210 inT16 &prev_chop_coord,
218 if (rep_left > prev_chop_coord) {
219 new_blanks = (
uinT8) floor ((rep_left - prev_chop_coord) / pitch + 0.5);
220 blanks += new_blanks;
222 word = rep_it->extract ();
224 word_it->add_after_then_move (word);
227 if (rep_it->empty ())
230 rep_left = rep_it->data ()->bounding_box ().left ();
247 C_OUTLINE_LIST *left_coutlines,
248 C_OUTLINE_LIST *right_coutlines) {
252 real_cblob = blob->
cblob();
256 if (!right_coutlines->empty() || real_cblob != NULL)
277 C_OUTLINE_LIST *left_outlines,
278 C_OUTLINE_LIST *right_outlines
281 C_OUTLINE_LIST new_outlines;
283 C_OUTLINE_IT left_it = left_outlines;
285 C_OUTLINE_IT right_it = right_outlines;
286 C_OUTLINE_IT new_it = &new_outlines;
287 C_OUTLINE_IT blob_it;
289 if (!right_it.empty ()) {
290 while (!right_it.empty ()) {
291 old_right = right_it.extract ();
299 right_it.add_list_before (&new_outlines);
302 blob_it.set_to_list (blob->
out_list ());
303 for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();
306 &left_it, &right_it);
323 C_OUTLINE_IT *left_it,
324 C_OUTLINE_IT *right_it
328 C_OUTLINE_LIST left_ch;
329 C_OUTLINE_LIST right_ch;
330 C_OUTLINE_FRAG_LIST left_frags;
331 C_OUTLINE_FRAG_LIST right_frags;;
332 C_OUTLINE_IT left_ch_it = &left_ch;
334 C_OUTLINE_IT right_ch_it = &right_ch;
336 C_OUTLINE_IT child_it = srcline->
child ();
339 if (srcbox.
left() + srcbox.
right() <= chop_coord * 2
340 && srcbox.
right() < chop_coord + pitch_error) {
343 left_it->add_after_then_move(srcline);
344 }
else if (srcbox.
left() + srcbox.
right() > chop_coord * 2
345 && srcbox.
left () > chop_coord - pitch_error) {
348 right_it->add_before_stay_put(srcline);
352 &left_frags, &right_frags)) {
353 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
354 child_it.forward()) {
355 child = child_it.extract();
357 if (srcbox.
right() < chop_coord) {
359 left_ch_it.add_after_then_move(child);
360 }
else if (srcbox.
left() > chop_coord) {
362 right_ch_it.add_after_then_move (child);
367 &left_frags, &right_frags)) {
370 if (srcbox.
left() + srcbox.
right() <= chop_coord * 2)
371 left_ch_it.add_after_then_move(child);
373 right_ch_it.add_after_then_move(child);
384 if (srcbox.
left() + srcbox.
right() <= chop_coord * 2)
385 left_it->add_after_then_move(srcline);
387 right_it->add_before_stay_put(srcline);
405 C_OUTLINE_FRAG_LIST *left_frags,
406 C_OUTLINE_FRAG_LIST *right_frags
418 inT16 first_index = 0;
423 left_edge = pos.
x ();
426 for (stepindex = 0; stepindex < length; stepindex++) {
427 if (pos.
x () < left_edge) {
428 left_edge = pos.
x ();
429 tail_index = stepindex;
432 pos += srcline->
step (stepindex);
434 if (left_edge >= chop_coord - pitch_error)
437 startindex = tail_index;
439 head_index = tail_index;
443 tail_pos += srcline->
step (tail_index);
445 if (tail_index == length)
448 while (tail_pos.
x () != chop_coord && tail_index != startindex);
449 if (tail_index == startindex) {
467 first_index = tail_index;
468 first_pos = tail_pos;
471 while (srcline->
step (tail_index).
x () == 0) {
472 tail_pos += srcline->
step (tail_index);
474 if (tail_index == length)
477 head_index = tail_index;
479 while (srcline->
step (tail_index).
x () > 0) {
481 tail_pos += srcline->
step (tail_index);
483 if (tail_index == length)
486 while (tail_pos.
x () != chop_coord);
496 while (srcline->
step (tail_index).
x () == 0) {
497 tail_pos += srcline->
step (tail_index);
499 if (tail_index == length)
502 head_index = tail_index;
506 while (tail_index != startindex);
528 C_OUTLINE_FRAG_LIST *frags
538 stepcount = tail_index - head_index;
541 jump = tail_pos.
y () - head_pos.
y ();
544 if (jump == stepcount)
546 tail_y = tail_pos.
y ();
548 head_index, tail_index);
576 if (end_index > start_index) {
577 for (
int i = start_index; i < end_index; ++i)
586 for (; i < end_index + len; ++i)
615 C_OUTLINE_FRAG_LIST *frags
618 C_OUTLINE_FRAG_IT frag_it = frags;
620 if (!frags->empty ()) {
621 for (frag_it.mark_cycle_pt (); !frag_it.cycled_list ();
622 frag_it.forward ()) {
623 if (frag_it.data ()->ycoord > frag->
ycoord 624 || (frag_it.data ()->ycoord == frag->
ycoord 626 frag_it.add_before_then_move (frag);
631 frag_it.add_to_end (frag);
643 C_OUTLINE_FRAG_LIST *frags,
644 C_OUTLINE_LIST *children,
646 C_OUTLINE_IT *dest_it
649 C_OUTLINE_FRAG_IT frag_it = frags;
654 C_OUTLINE_IT child_it = children;
655 C_OUTLINE_IT olchild_it;
657 while (!frag_it.empty()) {
658 frag_it.move_to_first();
660 bottom_frag = frag_it.extract();
662 top_frag = frag_it.data();
663 if ((bottom_frag->
steps == 0 && top_frag->
steps == 0)
664 || (bottom_frag->
steps != 0 && top_frag->
steps != 0)) {
665 if (frag_it.data_relative(1)->ycoord == top_frag->
ycoord)
668 top_frag = frag_it.extract();
669 if (top_frag->
other_end != bottom_frag) {
674 if (outline != NULL) {
675 olchild_it.set_to_list(outline->
child());
676 for (child_it.mark_cycle_pt(); !child_it.cycled_list();
677 child_it.forward()) {
678 child = child_it.data();
679 if (*child < *outline)
680 olchild_it.add_to_end(child_it.extract());
683 dest_it->add_after_then_move(outline);
689 while (!child_it.empty ()) {
690 dest_it->add_after_then_move (child_it.extract ());
710 if (bottom->
steps == 0)
711 outline = top->
close ();
713 outline = bottom->
close ();
718 if (bottom->
steps == 0) {
750 fake_count = top->
start.
y () - bottom->
end.
y ();
751 if (fake_count < 0) {
752 fake_count = -fake_count;
759 steps =
new DIR128[stepcount];
764 delete [] bottom->
steps;
765 bottom->
steps = steps;
786 if (fake_count < 0) {
787 fake_count = -fake_count;
796 new_steps =
new DIR128[new_stepcount];
#define ELISTIZE(CLASSNAME)
static const int kMaxOutlineLength
C_OUTLINE * join_chopped_fragments(C_OUTLINE_FRAG *bottom, C_OUTLINE_FRAG *top)
EXTERN int textord_fp_chop_error
EXTERN bool textord_show_page_cuts
void set_blanks(uinT8 new_blanks)
BOOL8 fixed_chop_coutline(C_OUTLINE *srcline, inT16 chop_coord, float pitch_error, C_OUTLINE_FRAG_LIST *left_frags, C_OUTLINE_FRAG_LIST *right_frags)
void plot_row_cells(ScrollView *win, ScrollView::Color colour, TO_ROW *row, float xshift, ICOORDELT_LIST *cells)
ICOORD step(int index) const
C_OUTLINE_FRAG * other_end
C_OUTLINE_LIST * out_list()
void recalc_bounding_box()
WERD * add_repeated_word(WERD_IT *rep_it, inT16 &rep_left, inT16 &prev_chop_coord, uinT8 &blanks, float pitch, WERD_IT *word_it)
inT16 x() const
access function
const TBOX & bounding_box() const
void fixed_chop_cblob(C_BLOB *blob, inT16 chop_coord, float pitch_error, C_OUTLINE_LIST *left_outlines, C_OUTLINE_LIST *right_outlines)
void add_frag_to_list(C_OUTLINE_FRAG *frag, C_OUTLINE_FRAG_LIST *frags)
EXTERN double textord_fp_chop_snap
ROW * fixed_pitch_words(TO_ROW *row, FCOORD rotation)
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 join_segments(C_OUTLINE_FRAG *bottom, C_OUTLINE_FRAG *top)
DIR128 step_dir(int index) const
#define double_VAR(name, val, comment)
EXTERN ScrollView * to_win
void close_chopped_cfragments(C_OUTLINE_FRAG_LIST *frags, C_OUTLINE_LIST *children, float pitch_error, C_OUTLINE_IT *dest_it)
void set_flag(WERD_FLAGS mask, BOOL8 value)
C_OUTLINE_FRAG & operator=(const C_OUTLINE_FRAG &src)
void fixed_split_coutline(C_OUTLINE *srcline, inT16 chop_coord, float pitch_error, C_OUTLINE_IT *left_it, C_OUTLINE_IT *right_it)
TBOX bounding_box() const
#define INT_VAR(name, val, comment)
void save_chop_cfragment(inT16 head_index, ICOORD head_pos, inT16 tail_index, ICOORD tail_pos, C_OUTLINE *srcline, C_OUTLINE_FRAG_LIST *frags)
inT16 y() const
access_function