]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beaming-info.cc
*** empty log message ***
[lilypond.git] / lily / beaming-info.cc
index 4cc9390996f5b933d7b59868d8ee12014cb04fa6..fb4b934a9e09efe4e530c0a050b06df82095dd8f 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "beaming.hh"
@@ -31,7 +31,7 @@ Beaming_info_list::best_splitpoint_index (Moment &beat_length, bool subdivide) c
   int minidx = -1;
   Moment beat_pos;
 
-  for (int i = 1; i < infos_.size (); i++)
+  for (vsize i = 1; i < infos_.size (); i++)
     {
       beat_pos = infos_[i].start_mom_ / beat_length;
       int den = beat_pos.den ();
@@ -53,8 +53,8 @@ Beaming_info_list::beam_extend_count (Direction d) const
   if (infos_.size () == 1)
     return infos_[0].beams_i_drul_[d];
 
-  Beaming_info thisbeam = infos_.boundary (d, 0);
-  Beaming_info next = infos_.boundary (d, 1);
+  Beaming_info thisbeam = boundary (infos_, d, 0);
+  Beaming_info next = boundary (infos_, d, 1);
 
   return min (thisbeam.beams_i_drul_[-d], next.beams_i_drul_[d]);
 }
@@ -68,15 +68,15 @@ Beaming_info_list::beamify (Moment &beat_length, bool subdivide)
   Drul_array<Beaming_info_list> splits;
   int m = best_splitpoint_index (beat_length, subdivide);
   bool split = subdivide && (m & at_beat); m = m & ~at_beat;
-  splits[LEFT].infos_ = infos_.slice (0, m);
-  splits[RIGHT].infos_ = infos_.slice (m, infos_.size ());
+  splits[LEFT].infos_ = vector<Beaming_info> (infos_.begin (),
+                                                  infos_.begin () + m);
+  splits[RIGHT].infos_ = vector<Beaming_info> (infos_.begin () + m,
+                                                   infos_.end ());
 
   Direction d = LEFT;
 
   do
-    {
-      splits[d].beamify (beat_length, subdivide);
-    }
+    splits[d].beamify (beat_length, subdivide);
   while (flip (&d) != LEFT);
 
   int middle_beams = (split ? 1
@@ -86,16 +86,28 @@ Beaming_info_list::beamify (Moment &beat_length, bool subdivide)
   do
     {
       if (splits[d].infos_.size () != 1)
-       splits[d].infos_.boundary (-d, 0).beams_i_drul_[-d] = middle_beams;
+       boundary (splits[d].infos_, -d, 0).beams_i_drul_[-d] = middle_beams;
     }
   while (flip (&d) != LEFT);
 
   infos_ = splits[LEFT].infos_;
-  infos_.concat (splits[RIGHT].infos_);
+  infos_.insert (infos_.end (), splits[RIGHT].infos_.begin (), splits[RIGHT].infos_.end ());
+
+  clip_edges ();
 }
 
 void
 Beaming_info_list::add_stem (Moment m, int b)
 {
-  infos_.push (Beaming_info (m, b));
+  infos_.push_back (Beaming_info (m, b));
+}
+
+void
+Beaming_info_list::clip_edges ()
+{
+  if (infos_.size ())
+    {
+      infos_[0].beams_i_drul_[LEFT] = 0;
+      infos_.back ().beams_i_drul_[RIGHT] = 0;
+    }
 }