]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/break.cc
release: 0.0.76
[lilypond.git] / lily / break.cc
index 826346f4b3cf8846cb1e3a4a69581a75f6385538..fbda8d4279553612647bc2f734cfacf5ac71c254 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "break.hh"
 #include "paper-def.hh"
-#include "linespace.hh"
+#include "line-spacer.hh"
 #include "debug.hh"
 #include "scoreline.hh"
 #include "p-score.hh"
@@ -20,7 +20,7 @@ Line_of_cols
 Break_algorithm::find_breaks() const
 {
     Line_of_cols retval;
-    for (iter_top(pscore_.cols,c); c.ok(); c++) {
+    for (iter_top(pscore_l_->col_p_list_,c); c.ok(); c++) {
        if (c->breakable_b())
            retval.push(c);
     }
@@ -30,59 +30,59 @@ Break_algorithm::find_breaks() const
 
     return retval;
 }
-
-void
-Break_algorithm::generate_spacing_problem(Line_of_cols curline, Spacing_problem & sp)const
+Line_spacer*
+Break_algorithm::generate_spacing_problem(Line_of_cols curline)const
 {
-    sp.add_column(curline[0], true, 0.0);
+    Line_spacer * sp= (*get_line_spacer)();
+    sp->paper_l_ = pscore_l_->paper_l_;
+    sp->add_column(curline[0], true, 0.0);
     for (int i=1; i< curline.size()-1; i++)
-       sp.add_column(curline[i]);
+       sp->add_column(curline[i]);
 
     if ( linelength > 0)
-       sp.add_column(curline.top(), true, linelength);
+       sp->add_column(curline.top(), true, linelength);
     else
-       sp.add_column(curline.top());
+       sp->add_column(curline.top());
+    return sp;
 }
 
 Col_hpositions
 Break_algorithm::stupid_solution(Line_of_cols curline)const
 {
-    Spacing_problem sp;
-    generate_spacing_problem(curline, sp);
-   Col_hpositions colhpos;
-   colhpos.cols = curline;
-   colhpos.energy = INFTY;
-   colhpos.ugh_b_ = true;
-   colhpos.config = sp.try_initial_solution();
-   return colhpos;
+    Line_spacer *sp =generate_spacing_problem(curline);
+    Col_hpositions colhpos;
+    colhpos.cols = curline;
+    colhpos.energy = INFTY;
+    colhpos.ugh_b_ = true;
+    colhpos.config = sp->default_solution();
+    delete sp;
+    return colhpos;
 }
 
 /// construct an appropriate Spacing_problem and solve it. 
 Col_hpositions
 Break_algorithm::solve_line(Line_of_cols curline) const
 {
-   Spacing_problem sp;
-   generate_spacing_problem(curline, sp);
-
-   // misschien  moeven uit Spacing_problem? 
-   for (iter_top(pscore_.suz,i); i.ok(); i++) {
-       sp.add_ideal(i);
-   }
-   sp.prepare();
+    Line_spacer *sp = generate_spacing_problem(curline);
+    sp->prepare();
    
-   Array<Real> the_sol=sp.solve();
-   Col_hpositions col_hpos;
-   col_hpos.cols = curline;
-   col_hpos.energy = the_sol.pop();
-   col_hpos.config = the_sol;
-   col_hpos.error_col_l_arr_ = sp.error_pcol_l_arr();
-   col_hpos.OK();
-   return col_hpos;
+    Array<Real> the_sol=sp->solve();
+    Col_hpositions col_hpos;
+    col_hpos.cols = curline;
+    col_hpos.energy = the_sol.pop();
+    col_hpos.config = the_sol;
+    col_hpos.error_col_l_arr_ = sp->error_pcol_l_arr();
+    col_hpos.OK();
+    delete sp;
+   
+    return col_hpos;
 }
 
 Break_algorithm::Break_algorithm(PScore&s)
-    :pscore_(s)
 {
+    pscore_l_ = &s;
+    get_line_spacer =0;
     linelength = s.paper_l_->linewidth_f();
 }
 
@@ -101,11 +101,17 @@ Break_algorithm::feasible(Line_of_cols curline) const
 void
 Break_algorithm::problem_OK() const
 {
-    if (!pscore_.cols.size())
+    if (!pscore_l_->col_p_list_.size())
        error("Score does not have any columns");
+    OK();
+}
+
+void
+Break_algorithm::OK()const
+{
 #ifndef NDEBUG
-    iter_top(pscore_.cols,start);
-    PCursor<PCol *> end (pscore_.cols.bottom());
+    iter_top(pscore_l_->col_p_list_,start);
+    PCursor<PCol *> end (pscore_l_->col_p_list_.bottom());
     
     assert(start->breakable_b());    
     assert(end->breakable_b());
@@ -115,7 +121,6 @@ Break_algorithm::problem_OK() const
 Array<Col_hpositions>
 Break_algorithm::solve()const
 {
-
     return do_solve();
 }