]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/simple-spacer.cc
Imported Upstream version 2.19.45
[lilypond.git] / lily / simple-spacer.cc
index aef524da87579bb2ecb1e087409f0f2da04baa3f..bf64413a8a4eb28badd8d1e969d6ecd5b4601703 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1999--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1999--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   TODO:
   - add support for different stretch/shrink constants?
@@ -193,9 +193,10 @@ Simple_spacer::expand_line ()
     inv_hooke += springs_[i].inverse_stretch_strength ();
 
   if (inv_hooke == 0.0) /* avoid division by zero. If springs are infinitely stiff */
-    return 0.0;         /* anyway, then it makes no difference what the force is */
+    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,8 +220,8 @@ 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> ());
 
@@ -248,7 +249,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;
         }
 
@@ -380,7 +383,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 = unsmob_grob (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)
         {
@@ -528,28 +531,9 @@ get_line_configuration (vector<Grob *> const &columns,
   for (vsize i = 1; i + 1 < ret.cols_.size (); i++)
     {
       SCM p = ret.cols_[i]->get_property ("line-break-permission");
-      if (p == ly_symbol2scm ("force"))
+      if (scm_is_eq (p, ly_symbol2scm ("force")))
         ret.satisfies_constraints_ = false;
     }
 
   return ret;
 }
-
-#include "ly-smobs.icc"
-
-IMPLEMENT_SIMPLE_SMOBS (Simple_spacer);
-IMPLEMENT_DEFAULT_EQUAL_P (Simple_spacer);
-
-SCM
-Simple_spacer::mark_smob (SCM /* x */)
-{
-  return SCM_EOL;
-}
-
-int
-Simple_spacer::print_smob (SCM /* x */, SCM p, scm_print_state *)
-{
-  scm_puts ("#<Simple spacer>", p);
-  return 1;
-}
-