]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/skyline.cc
bump version
[lilypond.git] / lily / skyline.cc
index 9da2606edbed49bc5354ec777f7cb02a0099890e..c935660c6ed33b400cdf2b002fc0a79f886474ab 100644 (file)
@@ -59,6 +59,16 @@ Skyline::print () const
   print_buildings (buildings_);
 }
 
+void
+Skyline::print_points () const
+{
+  vector<Offset> ps (to_points (X_AXIS));
+
+  for (vsize i = 0; i < ps.size (); i++)
+    printf ("(%f,%f)%s" , ps[i][X_AXIS], ps[i][Y_AXIS],
+           (i%2)==1 ? "\n" : " ");
+}
+
 Building::Building (Real start, Real start_height, Real end_height, Real end)
 {
   if (isinf (start) || isinf (end))
@@ -174,6 +184,12 @@ void
 Skyline::internal_merge_skyline (list<Building> *s1, list<Building> *s2,
                                 list<Building> *const result)
 {
+  if (s1->empty () || s2->empty ())
+    {
+      programming_error ("tried to merge an empty skyline");
+      return;
+    }
+
   Real x = -infinity_f;
   while (!s1->empty ())
     {
@@ -332,7 +348,7 @@ Skyline::internal_build_skyline (list<Box> *boxes, Real horizon_padding, Axis ho
 Skyline::Skyline ()
 {
   sky_ = UP;
-  empty_skyline (&buildings_);  
+  empty_skyline (&buildings_);
 }
 
 Skyline::Skyline (Skyline const &src)
@@ -403,6 +419,12 @@ Skyline::insert (Box const &b, Real horizon_padding, Axis a)
   list<Building> other_bld;
   list<Building> my_bld;
 
+  /* do the same filtering as in Skyline (vector<Box> const&, etc.) */
+  Interval iv = b[a];
+  iv.widen (horizon_padding);
+  if (iv.length () <= EPS || b[other_axis (a)].is_empty ())
+    return;
+
   my_bld.splice (my_bld.begin (), buildings_);
   single_skyline (Building (b, horizon_padding, a, sky_), b[a][LEFT], horizon_padding, &other_bld);
   internal_merge_skyline (&other_bld, &my_bld, &buildings_);
@@ -485,7 +507,7 @@ Skyline::set_minimum_height (Real h)
 
 
 vector<Offset>
-Skyline::to_points (Axis a) const
+Skyline::to_points (Axis horizon_axis) const
 {
   vector<Offset> out;
 
@@ -498,9 +520,9 @@ Skyline::to_points (Axis a) const
       start = i->end_;
     }
 
-  if (a == Y_AXIS)
+  if (horizon_axis == Y_AXIS)
     for (vsize i = 0; i < out.size (); i++)
-      out[i] = Offset (out[i][Y_AXIS], out[i][X_AXIS]);
+      out[i] = out[i].swapped ();
 
   return out;
 }