From: Joe Neeman Date: Mon, 26 Feb 2007 08:18:11 +0000 (+1100) Subject: Add a page-breaking debugging flag and fix a page-turn-page-breaking bug. X-Git-Tag: release/2.11.21-1~18^2~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0308629bff80f4f1aefc01729cf6afcbe3aaaa09;p=lilypond.git Add a page-breaking debugging flag and fix a page-turn-page-breaking bug. --- diff --git a/lily/include/page-turn-page-breaking.hh b/lily/include/page-turn-page-breaking.hh index 74ed4e84ba..db675202b6 100644 --- a/lily/include/page-turn-page-breaking.hh +++ b/lily/include/page-turn-page-breaking.hh @@ -63,5 +63,6 @@ protected: SCM make_pages (vector const &breaks, SCM systems); void calc_subproblem (vsize i); + void print_break_node (Break_node const &b); }; #endif /* PAGE_TURN_PAGE_BREAKING_HH */ diff --git a/lily/page-turn-page-breaking.cc b/lily/page-turn-page-breaking.cc index 58c66ed09d..028856229b 100644 --- a/lily/page-turn-page-breaking.cc +++ b/lily/page-turn-page-breaking.cc @@ -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 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_)); +} diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc index 2e92fcd45b..b636948fa8 100644 --- a/lily/program-option-scheme.cc +++ b/lily/program-option-scheme.cc @@ -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)); + } } diff --git a/scm/lily.scm b/scm/lily.scm index 5a8a744074..4afe0fb8be 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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")