X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fskyline.cc;h=6e64a2c96b6983ba4fac58ebb05026536c058c1e;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=e55ba3a6637024de8e0a9fb36b28e53298d2098f;hpb=644cd97fc602c18b7e0aafdc027cb8454d62560c;p=lilypond.git diff --git a/lily/skyline.cc b/lily/skyline.cc index e55ba3a663..6e64a2c96b 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -2,7 +2,7 @@ source file of the GNU LilyPond music typesetter - (c) 2006--2007 Joe Neeman + (c) 2006--2008 Joe Neeman */ #include "skyline.hh" @@ -59,6 +59,16 @@ Skyline::print () const print_buildings (buildings_); } +void +Skyline::print_points () const +{ + vector 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 *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 other_bld; list 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 const&, etc.) */ Interval iv = b[a]; iv.widen (horizon_padding); @@ -497,7 +514,7 @@ Skyline::set_minimum_height (Real h) vector -Skyline::to_points (Axis a) const +Skyline::to_points (Axis horizon_axis) const { vector 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,70 +537,10 @@ Skyline::to_points (Axis a) const bool Skyline::is_empty () const { - return buildings_.empty (); -} - -Skyline_pair::Skyline_pair () - : skylines_ (Skyline (DOWN), Skyline (UP)) -{ -} - -Skyline_pair::Skyline_pair (vector const &boxes, Real padding, Axis a) - : skylines_ (Skyline (boxes, padding, a, DOWN), Skyline (boxes, padding, a, UP)) -{ -} - -Skyline_pair::Skyline_pair (Box const &b, Real padding, Axis a) - : skylines_ (Skyline (b, padding, a, DOWN), Skyline (b, padding, a, UP)) -{ -} - -void -Skyline_pair::raise (Real r) -{ - skylines_[UP].raise (r); - skylines_[DOWN].raise (r); -} - -void -Skyline_pair::shift (Real r) -{ - skylines_[UP].shift (r); - skylines_[DOWN].shift (r); -} - -void -Skyline_pair::insert (Box const &b, Real padding, Axis a) -{ - skylines_[UP].insert (b, padding, a); - skylines_[DOWN].insert (b, padding, a); -} - -void -Skyline_pair::merge (Skyline_pair const &other) -{ - skylines_[UP].merge (other[UP]); - skylines_[DOWN].merge (other[DOWN]); -} - -bool -Skyline_pair::is_empty () const -{ - return skylines_[UP].is_empty () - && skylines_[DOWN].is_empty (); + Building b = buildings_.front (); + return b.end_ == infinity_f && b.y_intercept_ == -infinity_f; } -Skyline& -Skyline_pair::operator [] (Direction d) -{ - return skylines_[d]; -} - -Skyline const& -Skyline_pair::operator [] (Direction d) const -{ - return skylines_[d]; -} /****************************************************************/ @@ -592,10 +549,6 @@ IMPLEMENT_SIMPLE_SMOBS (Skyline); IMPLEMENT_TYPE_P (Skyline, "ly:skyline?"); IMPLEMENT_DEFAULT_EQUAL_P (Skyline); -IMPLEMENT_SIMPLE_SMOBS (Skyline_pair); -IMPLEMENT_TYPE_P (Skyline_pair, "ly:skyline-pair?"); -IMPLEMENT_DEFAULT_EQUAL_P (Skyline_pair); - SCM Skyline::mark_smob (SCM) { @@ -613,19 +566,3 @@ Skyline::print_smob (SCM s, SCM port, scm_print_state *) return 1; } - -SCM -Skyline_pair::mark_smob (SCM) -{ - return SCM_EOL; -} - -int -Skyline_pair::print_smob (SCM s, SCM port, scm_print_state *) -{ - Skyline_pair *r = (Skyline_pair *) SCM_CELL_WORD_1 (s); - (void) r; - - scm_puts ("#", port); - return 1; -}