]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/skyline.cc
Merge branch 'master' of git://git.sv.gnu.org/lilypond
[lilypond.git] / lily / skyline.cc
index e55ba3a6637024de8e0a9fb36b28e53298d2098f..e0139a68668ecc46f4a7682bed85abb8812c1786 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))
@@ -256,7 +266,7 @@ non_overlapping_skyline (list<Box> *const boxes, Real horizon_padding, Axis hori
        }
 
       if (iv[LEFT] - horizon_padding > last_end + EPS)
-       result.push_front (Building (last_end, -infinity_f, -infinity_f, iv[LEFT] - horizon_padding));
+       result.push_front (Building (last_end, -infinity_f, -infinity_f, iv[LEFT] - 2*horizon_padding));
 
       Building b (*i, horizon_padding, horizon_axis, sky);
       bool sloped_neighbours = horizon_padding > 0 && !isinf (iv.length ());
@@ -409,6 +419,13 @@ Skyline::insert (Box const &b, Real horizon_padding, Axis a)
   list<Building> other_bld;
   list<Building> my_bld;
 
+  if (isnan (b[other_axis (a)][LEFT])
+      || isnan (b[other_axis (a)][RIGHT]))
+    {
+      programming_error ("insane box for skyline");
+      return;
+    }
+
   /* do the same filtering as in Skyline (vector<Box> const&, etc.) */
   Interval iv = b[a];
   iv.widen (horizon_padding);
@@ -497,7 +514,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;
 
@@ -510,9 +527,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;
 }
@@ -520,7 +537,8 @@ Skyline::to_points (Axis a) const
 bool
 Skyline::is_empty () const
 {
-  return buildings_.empty ();
+  Building b = buildings_.front ();
+  return b.end_ == infinity_f && b.y_intercept_ == -infinity_f;
 }
 
 Skyline_pair::Skyline_pair ()