]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/gourlay-breaking.cc
* scm/drums.scm (reset-drum-kit): new function.
[lilypond.git] / lily / gourlay-breaking.cc
index c16e044049d32d920ab95c938b56ef8e0a7b755f..b4657f893ada1c0ea373e93032056f45f534500a 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include <math.h>              // rint
 #include <stdio.h>
@@ -44,8 +44,24 @@ struct Break_node {
     line_ = 0;
     demerits_ = 0;
   }
+
+  void print () const
+  {
+    printf ("prev break %d, line %d, demerits %f\n",
+           prev_break_, line_, demerits_);
+  }
 };
 
+void
+print_break_nodes (Array<Break_node> const & arr)
+{
+  for (int i =0; i < arr.size (); i++)
+    {
+      printf ( "node %d: ", i); 
+      arr[i].print ();
+    }      
+}
+
 /**
   This algorithms is adapted from the OSU Tech report on breaking lines.
 
@@ -153,7 +169,6 @@ Gourlay_breaking::do_solve () const
   if (breaks.size () % HAPPY_DOTS_I)
     progress_indication (String ("[") + to_string (breaks.size()) + "]");    
 
-
   progress_indication ("\n");
 
   Array<int> final_breaks;
@@ -169,7 +184,10 @@ Gourlay_breaking::do_solve () const
     }
 
   if (verbose_global_b)
-    printf ("Optimal demerits: %f\n", optimal_paths.top ().demerits_); 
+    {
+      progress_indication (_f ("Optimal demerits: %f",
+                              optimal_paths.top ().demerits_) + "\n");
+    }
   
   if (optimal_paths.top ().demerits_ >= infinity_f)
     warning (_ ("No feasible line breaking found"));
@@ -214,17 +232,22 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
        }
     }
 
-#if 1
   /*
-    Q: do want globally non-cramped lines, or locally equally cramped lines. 
+    Q: do we want globally non-cramped lines, or locally equally
+    cramped lines?
+
+    There used to be an example file input/test/uniform-breaking to
+    demonstrate problems with this approach. When music is gradually
+    becoming denser, the uniformity requirement makes lines go from
+    cramped to even more cramped (because going from cramped
+    3meas/line to relatively loose 2meas/line is such a big step.
+    
    */
-  Real demerit = abs (this_one.force_) + 0.1 *abs (prev.force_ - this_one.force_)
-    + break_penalties;
-#else
-  Real demerit = abs (this_one.force_) + break_penalties;
-#endif
 
-   if (!this_one.satisfies_constraints_b_)
+  Real demerit = abs (this_one.force_) +  abs (prev.force_ - this_one.force_)
+    + break_penalties;
+  
+  if (!this_one.satisfies_constraints_b_)
      {
        /*
         If it doesn't satisfy constraints, we make this one