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");
44 current
.energy
= INFTY
; // make sure we go back
46 current
= solve_line(current
.cols
);
50 // update minimum, or backup.
51 if (current
.energy
< minimum
.energy
) {
53 } else { // we're one col too far.
55 while (curcol
.ptr() != breakpoints
[break_idx_i
])
57 break; // do the next line.
61 // add nobreak version of breakable column
62 current
.cols
.top()=breakpoints
[break_idx_i
];
67 *mlog
<< "[" <<break_idx_i
<<"]"<<flush
;
68 breaking
.push(minimum
);
74 Word_wrap::Word_wrap(PScore
&ps
)