]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/simple-spacer.cc
input/regression/bookparts.ly fails at PDF conversion stage
[lilypond.git] / lily / simple-spacer.cc
index ada16593aa7e6b1441360413f714cc58d2a1afc5..5244d33c9e6d58ba8a3da4ece88ff4467855b0bd 100644 (file)
@@ -32,6 +32,8 @@
 #include "spring.hh"
 #include "warn.hh"
 
+using std::vector;
+
 /*
   A simple spacing constraint solver. The approach:
 
@@ -125,9 +127,9 @@ Simple_spacer::add_rod (int l, int r, Real dist)
 
       return;
     }
-  force_ = max (force_, block_force);
+  force_ = std::max (force_, block_force);
   for (int i = l; i < r; i++)
-    springs_[i].set_blocking_force (max (block_force, springs_[i].blocking_force ()));
+    springs_[i].set_blocking_force (std::max (block_force, springs_[i].blocking_force ()));
 }
 
 Real
@@ -195,7 +197,8 @@ Simple_spacer::expand_line ()
   if (inv_hooke == 0.0) /* avoid division by zero. If springs are infinitely stiff */
     inv_hooke = 1e-6;   /* then report a very large stretching force */
 
-  assert (cur_len <= line_len_);
+  if (cur_len > (1 + 1e-6) * line_len_)
+    programming_error ("misuse of expand_line");
   return (line_len_ - cur_len) / inv_hooke + force_;
 }
 
@@ -219,10 +222,10 @@ Simple_spacer::compress_line ()
 
   fits_ = true;
 
-  assert (line_len_ <= cur_len);
-
+  if (line_len_ > (1 + 1e-6) * cur_len)
+    programming_error ("misuse of compress_line");
   vector<Spring> sorted_springs = springs_;
-  sort (sorted_springs.begin (), sorted_springs.end (), greater<Spring> ());
+  sort (sorted_springs.begin (), sorted_springs.end (), std::greater<Spring> ());
 
   /* inv_hooke is the total flexibility of currently-active springs */
   double inv_hooke = 0;
@@ -248,7 +251,9 @@ Simple_spacer::compress_line ()
           /*
             Paranoia check.
           */
-          assert (fabs (configuration_length (cur_force) - cur_len) < 1e-6);
+          if (fabs (configuration_length (cur_force) - cur_len) > 1e-6 * cur_len)
+            programming_error (to_string ("mis-predicted force, %.6f ~= %.6f",
+                                          cur_len, configuration_length(cur_force)));
           return cur_force;
         }
 
@@ -264,7 +269,7 @@ Simple_spacer::compress_line ()
 void
 Simple_spacer::add_spring (Spring const &sp)
 {
-  force_ = max (force_, sp.blocking_force ());
+  force_ = std::max (force_, sp.blocking_force ());
   springs_.push_back (sp);
 }
 
@@ -286,7 +291,7 @@ Simple_spacer::force_penalty (bool ragged) const
      but according to the amount of whitespace that is present after the end
      of the line. */
   if (ragged)
-    return max (0.0, line_len_ - configuration_length (0.0));
+    return std::max (0.0, line_len_ - configuration_length (0.0));
 
   /* Use a convex compression penalty. */
   Real f = force_;
@@ -380,7 +385,7 @@ get_column_description (vector<Grob *> const &cols, vsize col_index, bool line_s
   for (SCM s = Spaceable_grob::get_minimum_distances (col);
        scm_is_pair (s); s = scm_cdr (s))
     {
-      Grob *other = Grob::unsmob (scm_caar (s));
+      Grob *other = unsmob<Grob> (scm_caar (s));
       vsize j = binary_search (cols, other, Paper_column::less_than, col_index);
       if (j != VPOS)
         {