X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fskyline.cc;h=33d2823d47e0d752934558f75ea74e90e85ead41;hb=0b544cfb7332615ef809b71b57ab656741311ae1;hp=5073e69e14b3eaccb805a712e8979be7d9b8856f;hpb=2210b8053b053726ae598f31b62456df1e4db82b;p=lilypond.git diff --git a/lily/skyline.cc b/lily/skyline.cc index 5073e69e14..33d2823d47 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2006--2012 Joe Neeman + Copyright (C) 2006--2014 Joe Neeman LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -125,6 +125,12 @@ Building::precompute (Real start, Real start_height, Real end_height, Real end) assert (start_height == end_height); y_intercept_ = start_height; } + else if (fabs(slope_) > 1e6) + // too steep to be stored in slope-intercept form, given round-off error + { + slope_ = 0.0; + y_intercept_ = max(start_height, end_height); + } else y_intercept_ = start_height - slope_ * start; } @@ -169,7 +175,9 @@ Building::shift_to_intersect (Real x, Real y) const } static Real -first_intersection (Building const &b, list *const s, Real start_x) +first_intersection (Building const &b, list *s, Real start_x) +/* Return the first x >= start_x where skyline s above Building b. + * Removes buildings from s that are concealed by b. */ { while (!s->empty () && start_x < b.end_) { @@ -299,7 +307,7 @@ Skyline::internal_merge_skyline (list *s1, list *s2, last_end = x; continue; } - + // first_intersection() removes buildings from s2 if b hides them Real end = first_intersection (b, s2, x); if (s2->empty ()) { @@ -308,6 +316,8 @@ Skyline::internal_merge_skyline (list *s1, list *s2, break; } + // Should be (end > x), during ver2.19. end == x happens fairly often, + // and we do not need to keep vertical segments within a skyline. if (end >= x) { b.leading_part (end); @@ -318,6 +328,9 @@ Skyline::internal_merge_skyline (list *s1, list *s2, if (end >= s1->front ().end_) s1->pop_front (); + // Should add during ver2.19 (to avoid an endless loop + // when merging identical skylines with a vertical segment) + // if (end >= s2->front().end_) s2->pop_front(); x = end; } @@ -457,18 +470,6 @@ Skyline::Skyline () empty_skyline (&buildings_); } -Skyline::Skyline (Skyline const &src) -{ - sky_ = src.sky_; - - /* doesn't a list's copy constructor do this? -- jneem */ - for (list::const_iterator i = src.buildings_.begin (); - i != src.buildings_.end (); i++) - { - buildings_.push_back (Building ((*i))); - } -} - Skyline::Skyline (Direction sky) { sky_ = sky;