]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add a page-breaking debugging flag and fix a page-turn-page-breaking bug.
authorJoe Neeman <joeneeman@gmail.com>
Mon, 26 Feb 2007 08:18:11 +0000 (19:18 +1100)
committerJoe Neeman <joeneeman@gmail.com>
Mon, 26 Feb 2007 08:18:11 +0000 (19:18 +1100)
lily/include/page-turn-page-breaking.hh
lily/page-turn-page-breaking.cc
lily/program-option-scheme.cc
scm/lily.scm

index 74ed4e84bae4be7c18ae1bbc02535af7d74891da..db675202b6f8e138b139e745561fd0b972192d36 100644 (file)
@@ -63,5 +63,6 @@ protected:
   SCM make_pages (vector<Break_node> const &breaks, SCM systems);
 
   void calc_subproblem (vsize i);
+  void print_break_node (Break_node const &b);
 };
 #endif /* PAGE_TURN_PAGE_BREAKING_HH */
index 58c66ed09d69b71c1f8c26d939c1c5b87e869130..028856229bc00cb236f1d1003427a8b30572f367 100644 (file)
@@ -53,7 +53,7 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start,
   /* If [START, END] does not contain an intermediate
      breakpoint, we may need to consider solutions that result in a bad turn.
      In this case, we won't abort if the min_page_count is too big */
-  if (start < end - 1 && min_p_count + (page_number % 2) > 2)
+  if (start < end - 1 && min_p_count + (auto_first ? 0 : (page_number % 2)) > 2)
     return Break_node ();
 
   /* if PAGE-NUMBER is odd, we are starting on a right hand page. That is, we
@@ -118,6 +118,8 @@ Page_turn_page_breaking::final_page_num (Break_node const &b)
   return end - 1 + (end % 2);
 }
 
+extern bool debug_page_breaking_scoring;
+
 void
 Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
 {
@@ -156,6 +158,9 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
 
       bool ok_page = true;
 
+      if (debug_page_breaking_scoring)
+       message (_f ("page-turn-page-breaking: breaking from %d to %d", (int) start, (int) end));
+
       /* heuristic: we've just added a breakpoint, we'll need at least as
          many systems as before */
       min_sys_count = max (min_sys_count, prev_best_system_count);
@@ -181,6 +186,9 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
 
               if (cur.demerits_ < this_start_best.demerits_)
                 {
+                 if (debug_page_breaking_scoring)
+                   print_break_node (cur);
+
                   found = true;
                   this_start_best = cur;
                   prev_best_system_count = sys_count;
@@ -274,3 +282,17 @@ Page_turn_page_breaking::make_pages (vector<Break_node> const &soln, SCM systems
                               scm_from_int (soln[0].first_page_number_));
   return Page_breaking::make_pages (lines_per_page, systems);
 }
+
+void
+Page_turn_page_breaking::print_break_node (Break_node const &node)
+{
+  int system_count = 0;
+  for (vsize i = 0; i < node.system_count_.size (); i++)
+    system_count += node.system_count_[i];
+
+  message (_f ("break starting at page %d", (int) node.first_page_number_));
+  message (_f ("\tdemerits: %f", node.demerits_));
+  message (_f ("\tsystem count: %d", system_count));
+  message (_f ("\tpage count: %d", (int) node.page_count_));
+  message (_f ("\tprevious break: %d", (int) node.prev_));
+}
index 2e92fcd45b7e23a45d7de4506dcaa918aa62b2dd..b636948fa84c8490cb556ebf559a6204fc9dafd6 100644 (file)
@@ -21,6 +21,7 @@ using namespace std;
 
 bool debug_skylines;
 bool debug_property_callbacks;
+bool debug_page_breaking_scoring;
 
 /*
   Backwards compatibility.
@@ -94,6 +95,11 @@ void internal_set_option (SCM var, SCM val)
       debug_property_callbacks = to_boolean (val);
       val = scm_from_bool (to_boolean (val));
     }
+  else if (var == ly_symbol2scm ("debug-page-breaking-scoring"))
+    {
+      debug_page_breaking_scoring = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
 }
 
 
index 5a8a74407470d6d0596ef0cec8e21ad0bfcd6cf9..4afe0fb8beec66b981e74ef61e189eaa96bc0e17 100644 (file)
@@ -35,6 +35,7 @@
     (debug-gc-assert-parsed-dead #f "for memory debugging:
 ensure that all refs to parsed objects are dead.  This is an internal option, and is switched on automatically for -ddebug-gc.") 
     (debug-lexer #f "debug the flex lexer")
+    (debug-page-breaking-scoring #f "dump scores for many different page breaking configurations")
     (debug-parser #f "debug the bison parser")
     (debug-property-callbacks #f "debug cyclic callback chains")
     (debug-skylines #f "debug skylines")