5 /** el stupido. This should be done more accurately:
7 It would be nice to have a Dynamic Programming type of algorithm
15 iter_top(pscore_
.cols
,curcol
);
16 Array
<Col_hpositions
> breaking
;
17 Line_of_cols
breakpoints(find_breaks());
18 assert(breakpoints
.size()>=2);
21 while ( break_idx_i
< breakpoints
.size() -1) {
22 Col_hpositions minimum
;
23 Col_hpositions current
;
26 PCol
*post
= breakpoints
[break_idx_i
]->postbreak_p_
;
28 curcol
++; // skip the breakable.
31 while (break_idx_i
< breakpoints
.size()) {
33 // add another measure.
34 while (breakpoints
[break_idx_i
] != curcol
.ptr()){
38 current
.add(breakpoints
[break_idx_i
]->prebreak_p_
);
41 if (!feasible(current
.cols
)) {
42 if (!minimum
.cols
.size())
43 error("sorry, this measure is too long, breakpoint: "
44 + String(break_idx_i
) );
45 current
.energy
= INFTY
; // make sure we go back
47 current
= solve_line(current
.cols
);
51 // update minimum, or backup.
52 if (current
.energy
< minimum
.energy
) {
54 } else { // we're one col too far.
56 while (curcol
.ptr() != breakpoints
[break_idx_i
])
58 break; // do the next line.
62 // add nobreak version of breakable column
63 current
.cols
.top()=breakpoints
[break_idx_i
];
68 *mlog
<< "[" <<break_idx_i
<<"]"<<flush
;
69 breaking
.push(minimum
);
75 Word_wrap::Word_wrap(PScore
&ps
)