From: Joe Neeman Date: Sun, 9 Nov 2008 02:26:17 +0000 (-0800) Subject: Keep more detailed track of compressed lines in page breaking. X-Git-Tag: release/2.13.1-1~61^2~14 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4d040126cfd89587730265e549e3d28161642275;p=lilypond.git Keep more detailed track of compressed lines in page breaking. --- diff --git a/lily/include/constrained-breaking.hh b/lily/include/constrained-breaking.hh index 157411a83c..62c5813dc4 100644 --- a/lily/include/constrained-breaking.hh +++ b/lily/include/constrained-breaking.hh @@ -33,6 +33,14 @@ struct Line_details { bool title_; + /* The page-breaker deals with forbidden page breaks by "compressing" + two Line_detailses into one. The following fields are used by the + page-breaker to keep track of this. If the number of fields needed + by the page-breaker grows, it might be a good idea to create a separate + class. */ + int compressed_lines_count_; + int compressed_nontitle_lines_count_; + Line_details () { force_ = infinity_f; @@ -47,6 +55,8 @@ struct Line_details { page_penalty_ = 0; turn_penalty_ = 0; title_ = false; + compressed_lines_count_ = 0; + compressed_nontitle_lines_count_ = 0; } Line_details (Prob *pb) @@ -64,6 +74,8 @@ struct Line_details { page_penalty_ = robust_scm2double (pb->get_property ("page-break-penalty"), 0); turn_penalty_ = robust_scm2double (pb->get_property ("page-turn-penalty"), 0); title_ = to_boolean (pb->get_property ("is-title")); + compressed_lines_count_ = 0; + compressed_nontitle_lines_count_ = 0; } }; diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh index 0070a980ca..71aff9386e 100644 --- a/lily/include/page-breaking.hh +++ b/lily/include/page-breaking.hh @@ -129,11 +129,14 @@ protected: vsize current_configuration_count () const; Line_division current_configuration (vsize configuration_index) const; Page_spacing_result space_systems_on_n_pages (vsize configuration_index, - vsize n, vsize first_page_num); + vsize n, vsize first_page_num); Page_spacing_result space_systems_on_n_or_one_more_pages (vsize configuration_index, vsize n, - vsize first_page_num); + vsize first_page_num); Page_spacing_result space_systems_on_best_pages (vsize configuration_index, - vsize first_page_num); + vsize first_page_num); + Page_spacing_result space_systems_with_fixed_number_per_page (vsize configuration_index, + int systems_per_page, + vsize first_page_num); Page_spacing_result pack_systems_on_least_pages (vsize configuration_index, vsize first_page_num); vsize min_page_count (vsize configuration_index, vsize first_page_num); diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index a5fe6278d0..8228910080 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -36,13 +36,12 @@ compress_lines (const vector &orig) compressed.extent_[UP] = old.extent_[UP] + orig[i].extent_.length () + old.padding_; compressed.space_ += old.space_; compressed.inverse_hooke_ += old.inverse_hooke_; - compressed.title_ = old.title_; - /* we don't need the force_ field for the vertical spacing, - so we use force_ = n to signal that the line was compressed, - reducing the number of lines by n (and force_ = 0 otherwise). - This makes uncompression much easier. */ - compressed.force_ = old.force_ + 1; + compressed.compressed_lines_count_ = old.compressed_lines_count_ + 1; + compressed.compressed_nontitle_lines_count_ = + old.compressed_nontitle_lines_count_ + (compressed.title_ ? 0 : 1); + + compressed.title_ = compressed.title_ && old.title_; ret.back () = compressed; } else @@ -68,7 +67,7 @@ uncompress_solution (vector const &systems_per_page, { int compressed_count = 0; for (vsize j = start_sys; j < start_sys + systems_per_page[i]; j++) - compressed_count += (int)compressed[j].force_; + compressed_count += compressed[j].compressed_lines_count_; ret.push_back (systems_per_page[i] + compressed_count); start_sys += systems_per_page[i]; @@ -802,6 +801,13 @@ Page_breaking::space_systems_on_best_pages (vsize configuration, vsize first_pag return finalize_spacing_result (configuration, best); } +Page_spacing_result space_systems_with_fixed_number_per_page (vsize configuration_index, + int systems_per_page, + vsize first_page_num) +{ + return Page_spacing_result (); +} + Page_spacing_result Page_breaking::pack_systems_on_least_pages (vsize configuration, vsize first_page_num) {