]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam-concave.cc
* lily/grob-property.cc (get_interfaces): new function.
[lilypond.git] / lily / beam-concave.cc
index 91c772a06b12fca6a5c6dcc0b0ac0aa2f338c884..f8b31f460a6d1f926daa6d68513820a0c362efa7 100644 (file)
@@ -2,13 +2,12 @@
   Determine whether a beam is concave.
 */
 
-#include <math.h>
-
-#include "group-interface.hh"
+#include "pointer-group-interface.hh"
 #include "array.hh"
 #include "stem.hh"
 #include "beam.hh"
 #include "staff-symbol-referencer.hh"
+#include "directional-element-interface.hh"
 
 bool
 is_concave_single_notes (Array<int> const &positions, Direction beam_dir)
@@ -36,7 +35,7 @@ is_concave_single_notes (Array<int> const &positions, Direction beam_dir)
     note is reached in the opposite direction as the last-first dy
   */
   int dy = positions.top () - positions[0];
-  int closest = (beam_dir * positions.top ()) >? (beam_dir * positions[0]);
+  int closest = max (beam_dir * positions.top (), beam_dir * positions[0]);
   for (int i = 2; !concave && i < positions.size () - 1; i++)
     {
       int inner_dy = positions[i] - positions[i - 1];
@@ -67,7 +66,7 @@ calc_concaveness (Array<int> const &positions, Direction beam_dir)
     {
       Real line_y = slope * i + positions[0];
 
-      concaveness += (beam_dir * (positions[i] - line_y)) >? 0.0;
+      concaveness += max (beam_dir * (positions[i] - line_y), 0.0);
     }
 
   concaveness /= positions.size ();
@@ -88,7 +87,7 @@ Beam::check_concave (SCM smob)
   Grob *me = unsmob_grob (smob);
 
   Link_array<Grob> stems
-    = extract_grob_array (me, ly_symbol2scm ("stems"));
+    = extract_grob_array (me, "stems");
 
   if (is_knee (me))
     return SCM_UNSPECIFIED;
@@ -100,7 +99,7 @@ Beam::check_concave (SCM smob)
        stems.del (i);
       else
        {
-         if (Direction dir = Stem::get_direction (stems[i]))
+         if (Direction dir = get_grob_direction (stems[i]))
            beam_dir = dir;
        }
     }
@@ -133,7 +132,7 @@ Beam::check_concave (SCM smob)
 
       r /= Staff_symbol_referencer::staff_space (me);
       me->set_property ("positions", ly_interval2scm (Drul_array<Real> (r, r)));
-      me->set_property ("least-squares-dy", scm_make_real (0));
+      me->set_property ("least-squares-dy", scm_from_double (0));
     }
   else
     {