]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/simple-spacer-scheme.cc
Fix outside-staff placement for children of System.
[lilypond.git] / lily / simple-spacer-scheme.cc
index 6c95f421244b93abe912cd9e524ef7568e4b515f..1ffe464fc28f9b8eccc4f047c0af079e2fe93d29 100644 (file)
@@ -3,12 +3,10 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include <cstdio>
-#include <cmath>
-using namespace std;
 
 #include "paper-column.hh"
 #include "spring.hh"
@@ -55,32 +53,14 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
       spacer.add_rod (l, r, distance);
     }
 
-  spacer.line_len_ = scm_to_double (length);
+  spacer.solve (scm_to_double (length), is_ragged);
 
-  if (is_ragged)
-    spacer.my_solve_natural_len ();
-  else
-    spacer.my_solve_linelen ();
+  vector<Real> posns = spacer.spring_positions ();
 
-  Array<Real> posns;
-  posns.push (0.0);
-  for (int i = 0; i < spacer.springs_.size (); i++)
-    {
-      Real l = spacer.springs_[i].length ((is_ragged) ? 0.0 : spacer.force_);
-      posns.push (posns.top () + l);
-    }
-
-  SCM force_return = SCM_BOOL_F;
-  if (!isinf (spacer.force_)
-      && (spacer.is_active () || is_ragged))
-    force_return = scm_from_double (spacer.force_);
-
-  if (is_ragged
-      && posns.top () > spacer.line_len_)
-    force_return = SCM_BOOL_F;
+  SCM force_return = spacer.fits () ? scm_from_double (spacer.force ()) : SCM_BOOL_F;
 
   SCM retval = SCM_EOL;
-  for (int i = posns.size (); i--;)
+  for (vsize i = posns.size (); i--;)
     retval = scm_cons (scm_from_double (posns[i]), retval);
 
   retval = scm_cons (force_return, retval);