X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbeam-concave.cc;h=2b88e0807ac55a13af98475e17f29028188560e3;hb=c5bf34be054141c1b2ebd354630ada56db1dfc76;hp=7c38e96aa1b58bfd34acd13c783bcfecf043a2c9;hpb=516394fdf611ef44f521e2b3a49e7c340b67e672;p=lilypond.git diff --git a/lily/beam-concave.cc b/lily/beam-concave.cc index 7c38e96aa1..2b88e0807a 100644 --- a/lily/beam-concave.cc +++ b/lily/beam-concave.cc @@ -3,18 +3,18 @@ */ #include "pointer-group-interface.hh" -#include "array.hh" #include "stem.hh" #include "beam.hh" +#include "grob.hh" #include "staff-symbol-referencer.hh" #include "directional-element-interface.hh" bool -is_concave_single_notes (Array const &positions, Direction beam_dir) +is_concave_single_notes (vector const &positions, Direction beam_dir) { Interval covering; covering.add_point (positions[0]); - covering.add_point (positions.top ()); + covering.add_point (positions.back ()); bool above = false; bool below = false; @@ -23,7 +23,7 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) /* notes above and below the interval covered by 1st and last note. */ - for (int i = 1; i < positions.size () - 1; i++) + for (vsize i = 1; i < positions.size () - 1; i++) { above = above || (positions[i] > covering[UP]); below = below || (positions[i] < covering[DOWN]); @@ -34,9 +34,9 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) A note as close or closer to the beam than begin and end, but the note is reached in the opposite direction as the last-first dy */ - int dy = positions.top () - positions[0]; - int closest = max (beam_dir * positions.top (), beam_dir * positions[0]); - for (int i = 2; !concave && i < positions.size () - 1; i++) + int dy = positions.back () - positions[0]; + int closest = max (beam_dir * positions.back (), beam_dir * positions[0]); + for (vsize i = 2; !concave && i < positions.size () - 1; i++) { int inner_dy = positions[i] - positions[i - 1]; if (sign (inner_dy) != sign (dy) @@ -46,7 +46,7 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) } bool all_closer = true; - for (int i = 1; all_closer && i < positions.size () - 1; i++) + for (vsize i = 1; all_closer && i < positions.size () - 1; i++) { all_closer = all_closer && (beam_dir * positions[i] > closest); @@ -57,12 +57,12 @@ is_concave_single_notes (Array const &positions, Direction beam_dir) } Real -calc_positions_concaveness (Array const &positions, Direction beam_dir) +calc_positions_concaveness (vector const &positions, Direction beam_dir) { - Real dy = positions.top () - positions[0]; + Real dy = positions.back () - positions[0]; Real slope = dy / Real (positions.size () - 1); Real concaveness = 0.0; - for (int i = 1; i < positions.size () - 1; i++) + for (vsize i = 1; i < positions.size () - 1; i++) { Real line_y = slope * i + positions[0]; @@ -87,30 +87,30 @@ Beam::calc_concaveness (SCM smob) { Grob *me = unsmob_grob (smob); - Link_array stems + vector stems = extract_grob_array (me, "stems"); if (is_knee (me)) return scm_from_double (0.0); Direction beam_dir = CENTER; - for (int i = stems.size (); i--;) + for (vsize i = stems.size (); i--;) { - if (Stem::is_invisible (stems[i])) - stems.del (i); - else + if (Stem::is_normal_stem (stems[i])) { if (Direction dir = get_grob_direction (stems[i])) beam_dir = dir; } + else + stems.erase (stems.begin () + i); } if (stems.size () <= 2) - return SCM_UNSPECIFIED; + return scm_from_int (0); - Array close_positions; - Array far_positions; - for (int i = 0; i < stems.size (); i++) + vector close_positions; + vector far_positions; + for (vsize i = 0; i < stems.size (); i++) { /* For chords, we take the note head that is closest to the beam. @@ -122,22 +122,15 @@ Beam::calc_concaveness (SCM smob) */ Interval posns = Stem::head_positions (stems[i]); - close_positions.push ((int) rint (posns[beam_dir])); - far_positions.push ((int) rint (posns[-beam_dir])); + close_positions.push_back ((int) rint (posns[beam_dir])); + far_positions.push_back ((int) rint (posns[-beam_dir])); } Real concaveness = 0.0; if (is_concave_single_notes (far_positions, beam_dir)) { - (void) me->get_property ("least-squares-dy"); // ugh. dependency handling. - - Drul_array pos = ly_scm2interval (me->get_property ("positions")); - Real r = linear_combination (pos, 0.0); - - r /= Staff_symbol_referencer::staff_space (me); - me->set_property ("positions", ly_interval2scm (Drul_array (r, r))); - me->set_property ("least-squares-dy", scm_from_double (0)); + concaveness = 10000; } else { @@ -147,3 +140,6 @@ Beam::calc_concaveness (SCM smob) return scm_from_double (concaveness); } + + +