From: fred Date: Mon, 28 Oct 1996 23:38:40 +0000 (+0000) Subject: lilypond-0.0.5 X-Git-Tag: release/1.5.59~7015 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c16ba662bb3304ce49c956deba3137ca787c7ae7;p=lilypond.git lilypond-0.0.5 --- diff --git a/break.cc b/break.cc index e705c546cf..b8dc1827bc 100644 --- a/break.cc +++ b/break.cc @@ -13,7 +13,7 @@ svec PScore::solve_line(svec curline) const { Spacing_problem sp; - mtor << "line of " << curline.sz() << " cols\n"; + sp.add_column(curline[0], true, 0.0); for (int i=1; i< curline.sz()-1; i++) sp.add_column(curline[i]); @@ -36,8 +36,8 @@ PScore::problem_OK() const PCursor start(cols); PCursor end (((PScore*)this)->cols.bottom()); - assert(start->breakable); - assert(end->breakable); + assert(start->breakable()); + assert(end->breakable()); } struct Col_configuration { @@ -54,10 +54,16 @@ struct Col_configuration { energy = config.last(); config.pop(); } + void print() const { +#ifndef NPRINT + mtor << "energy : " << energy << '\n'; + mtor << "line of " << config.sz() << " cols\n"; +#endif + } }; /// wordwrap type algorithm -/* el stupido. This should be optimised: +/* el stupido. This should be done more accurately: It would be nice to have a Dynamic Programming type of algorithm similar to TeX's @@ -77,8 +83,9 @@ PScore::calc_breaking() Col_configuration minimum; Col_configuration current; - // do another line - current.add(breakpoints[i]->postbreak ); + // do another line + PCol *post = breakpoints[i]->postbreak; + current.add( post); curcol++; // skip the breakable. i++; @@ -92,11 +99,15 @@ PScore::calc_breaking() } current.add(breakpoints[i]->prebreak ); current.setsol(solve_line(current.line)); - mtor << "energy : " << current.energy << '\n'; + current.print(); if (current.energy < minimum.energy) { minimum = current; - } else { + } else { // we're one col too far. + i--; + while (curcol != breakpoints[i]) + curcol --; + break; }