]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/skyline.cc
*** empty log message ***
[lilypond.git] / lily / skyline.cc
index 718200c01297d1d1f935e8fd4729190ffda36e30..1d7782008dae7df5f0ccbd28184cafa569ff323b 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "skyline.hh" 
 
-
 /*
   A skyline is a shape of the form:
 
@@ -32,7 +31,7 @@
   skyline[...].width_ forms a partition of the real interval, where
   the segments are adjacent, and ascending. Hence we have
   
-  skyline.top().width_[RIGHT] = inf
+  skyline.top ().width_[RIGHT] = inf
   skyline[0].width_[LEFT] = -inf
   
  */
@@ -43,7 +42,7 @@ const Real EPS = 1e-12;
 /*
   TODO: avoid unnecessary fragmentation.
 
-  This is O(n^2), searching and insertion.  Could be O(n log n) with
+  This is O (n^2), searching and insertion.  Could be O (n log n) with
   binsearch.
 */
 void
@@ -59,29 +58,29 @@ insert_extent_into_skyline (Array<Skyline_entry> *line, Box b, Axis line_axis,
   /*
     Intersect each segment of LINE with EXTENT, and if non-empty, insert relevant segments. 
    */
-  for (int i = line->size(); i--;)
+  for (int i = line->size (); i--;)
     {
-      Interval w = line->elem(i).width_;
+      Interval w = line->elem (i).width_;
       w.intersect (extent);
 
       if (extent[LEFT] >= w[RIGHT])
        break;
       
-      Real my_height = line->elem(i).height_;
+      Real my_height = line->elem (i).height_;
 
       if (!w.is_empty () &&
-         w.length() > EPS
+         w.length () > EPS
          && d* (my_height - stick_out) < 0)
        {
-         Interval e1 (line->elem(i).width_[LEFT], extent[LEFT]);
-         Interval e3 (extent[RIGHT], line->elem(i).width_[RIGHT]);
+         Interval e1 (line->elem (i).width_[LEFT], extent[LEFT]);
+         Interval e3 (extent[RIGHT], line->elem (i).width_[RIGHT]);
 
-         if (!e3.is_empty () && e3.length() > EPS)
+         if (!e3.is_empty () && e3.length () > EPS)
            line->insert (Skyline_entry (e3, my_height), i+1);
 
-         line->elem_ref(i).height_ = stick_out;
-         line->elem_ref(i).width_ = w;
-         if (!e1.is_empty () && e1.length() > EPS)
+         line->elem_ref (i).height_ = stick_out;
+         line->elem_ref (i).width_ = w;
+         if (!e1.is_empty () && e1.length () > EPS)
            line->insert (Skyline_entry (e1, my_height), i );
        }
 
@@ -94,7 +93,7 @@ merge_skyline (Array<Skyline_entry> * a1,
               Array<Skyline_entry> const  & a2,
               Direction dir)
 {
-  for (int i = 0; i < a2.size(); i++)
+  for (int i = 0; i < a2.size (); i++)
     {
       Box b;
       b[X_AXIS] = a2[i].width_;
@@ -112,8 +111,8 @@ empty_skyline (Direction d)
   Array<Skyline_entry> skyline;
 
   Interval i;
-  i.set_empty();
-  i.swap();
+  i.set_empty ();
+  i.swap ();
   Skyline_entry e;
   e.width_ = i;
   e.height_ = -d * infinity_f; 
@@ -125,16 +124,16 @@ Array<Skyline_entry>
 extents_to_skyline (Array<Box> const &extents, Axis a, Direction d)
 {
 
-  Array<Skyline_entry> skyline = empty_skyline(d);
+  Array<Skyline_entry> skyline = empty_skyline (d);
 
   /*
-    This makes a cubic algorithm (array  insertion is O(n),
-    searching the array dumbly is O(n), and for n items, we get O(n^3).)
+    This makes a cubic algorithm (array  insertion is O (n),
+    searching the array dumbly is O (n), and for n items, we get O (n^3).)
 
     We could do a lot better (n log (n), using a balanced tree) but
     that seems overkill for now.
    */
-  for (int j = extents.size(); j--; )
+  for (int j = extents.size (); j--; )
     insert_extent_into_skyline (&skyline, extents[j], a, d);
 
   return skyline;
@@ -146,21 +145,21 @@ extents_to_skyline (Array<Box> const &extents, Axis a, Direction d)
   minimum distance that can be achieved between baselines. "Clouds" is
   a skyline pointing down.
 
-  This is an O(n) algorithm.
+  This is an O (n) algorithm.
  */
 Real
 skyline_meshing_distance (Array<Skyline_entry> const &buildings,
                          Array<Skyline_entry> const &clouds)
 {
   int i = buildings.size () -1;
-  int j  = clouds.size() -1;
+  int j  = clouds.size () -1;
 
   Real distance = - infinity_f;
   
   while (i > 0 || j > 0)
     {
       Interval w = buildings[i].width_;
-      w.intersect(clouds[j].width_);
+      w.intersect (clouds[j].width_);
       
       if (!w.is_empty ())
        distance = distance >? (buildings[i].height_ - clouds[j].height_);
@@ -178,7 +177,7 @@ skyline_meshing_distance (Array<Skyline_entry> const &buildings,
   return distance;
 }
 
-Skyline_entry::Skyline_entry()
+Skyline_entry::Skyline_entry ()
 {
   height_ = 0.0;
 }