]> git.donarmstrong.com Git - lilypond.git/commitdiff
Keep more detailed track of compressed lines in page breaking.
authorJoe Neeman <joeneeman@gmail.com>
Sun, 9 Nov 2008 02:26:17 +0000 (18:26 -0800)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 9 Nov 2008 02:26:17 +0000 (18:26 -0800)
lily/include/constrained-breaking.hh
lily/include/page-breaking.hh
lily/page-breaking.cc

index 5759a12c05666f78877391c3c972a8f8464f6454..81eff5c2eac56877ca763799245d2a7f9b868572 100644 (file)
@@ -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;
   }
 };
 
index 150e09fa9aa726ffb40eee4fc8e0631faebddabc..7bf43aa0db6d1782d1da79ca47bcc633dec7679e 100644 (file)
@@ -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);
index 1ae769e82d641d79145e53491bd77795baf2d4a4..feaaa61010ca9f1a165ce4e5b9f54fa5042ab2be 100644 (file)
@@ -36,13 +36,12 @@ compress_lines (const vector<Line_details> &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<vsize> 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];
@@ -797,6 +796,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)
 {