]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/gourlay-breaking.cc
release: 1.1.58
[lilypond.git] / lily / gourlay-breaking.cc
index 8fd59f00d32d66dca2ce5f779e99a4e103248ee9..284f1e83b308063b72ff938cf8c31a5ead2d1d04 100644 (file)
@@ -3,17 +3,20 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "gourlay-breaking.hh"
 #include "colhpos.hh"
 #include "spring-spacer.hh"
 #include "debug.hh"
-#include "p-col.hh"
-#include "p-score.hh"
+#include "paper-column.hh"
+#include "paper-score.hh"
 #include "paper-def.hh"
 
+#include "killing-cons.tcc"
+
+/// How often to print operator pacification marks?
 const int HAPPY_DOTS_I = 3;
 
 /**
@@ -36,14 +39,15 @@ struct Break_node {
 };
 
 /**
-  This algorithms is adapted from 
+  This algorithms is adapted from the OSU Tech report on breaking lines.
+  
  */
 
 Array<Column_x_positions>
 Gourlay_breaking::do_solve () const
 {
   Array<Break_node> optimal_paths;
-  Line_of_cols all = all_cols ();
+  Line_of_cols all = pscore_l_->col_l_arr_ ;
   Array<int> breaks = find_break_indices ();
   
   optimal_paths.set_size (breaks.size ());
@@ -61,7 +65,7 @@ Gourlay_breaking::do_solve () const
     {
       Array<int> candidates;
       Array<Column_x_positions> candidate_lines;
-      Pointer_list<Line_spacer*> spacer_p_list;
+      Cons_list<Line_spacer> spacer_p_list;
        
       /*
        start with a short line, add measures. At some point 
@@ -78,9 +82,9 @@ Gourlay_breaking::do_solve () const
            continue;
            
          Line_of_cols line = all.slice (breaks[start_idx], breaks[break_idx]+1);
-
-         line[0] = line[0]->postbreak_l ();
-         line.top () = line.top ()->prebreak_l ();
+  
+         line[0] = dynamic_cast<Paper_column*>(line[0]->find_prebroken_piece (RIGHT));
+         line.top () =  dynamic_cast<Paper_column*>(line.top ()->find_prebroken_piece (LEFT));
            
          if (!feasible (line))
            break;
@@ -90,7 +94,7 @@ Gourlay_breaking::do_solve () const
            
          approx.spacer_l_ = generate_spacing_problem (line, 
            pscore_l_->paper_l_->line_dimensions_int (optimal_paths[start_idx].line_i_));
-         spacer_p_list.bottom ().add (approx.spacer_l_);
+         spacer_p_list.append (new Killing_cons<Line_spacer> (approx.spacer_l_,0));
 
          ( (Break_algorithm*)this)->approx_stats_.add (approx.cols);
          approx.approximate_solve_line ();
@@ -149,6 +153,8 @@ Gourlay_breaking::do_solve () const
 
       if (! (break_idx % HAPPY_DOTS_I))
        *mlog << "[" << break_idx << "]" << flush;
+
+      spacer_p_list.junk ();
     }
 
   if  (break_idx % HAPPY_DOTS_I)