From f818a60416d32dcced3d17d971c5fa959d4cecdc Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 25 Mar 2007 14:42:41 -0300 Subject: [PATCH] Add Skyline::print_points(), Offset::swapped() --- flower/include/offset.hh | 1 + flower/offset.cc | 6 ++++++ lily/include/skyline.hh | 8 ++++++-- lily/skyline.cc | 16 +++++++++++++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/flower/include/offset.hh b/flower/include/offset.hh index a3093c98ef..80053a51b6 100644 --- a/flower/include/offset.hh +++ b/flower/include/offset.hh @@ -97,6 +97,7 @@ public: return *this; } Offset direction () const; + Offset swapped () const; Real arg () const; Real angle_degrees () const; diff --git a/flower/offset.cc b/flower/offset.cc index 8fc956c65e..294f69e6f8 100644 --- a/flower/offset.cc +++ b/flower/offset.cc @@ -105,3 +105,9 @@ Offset::direction () const d /= length (); return d; } + +Offset +Offset::swapped () const +{ + return Offset (coordinate_a_[Y_AXIS], coordinate_a_[X_AXIS]); +} diff --git a/lily/include/skyline.hh b/lily/include/skyline.hh index 31747b1d43..5dadbacaf7 100644 --- a/lily/include/skyline.hh +++ b/lily/include/skyline.hh @@ -9,8 +9,7 @@ #ifndef SKYLINE_HH #define SKYLINE_HH -#include - +#include "lily-proto.hh" #include "axis.hh" #include "box.hh" #include "interval.hh" @@ -18,6 +17,8 @@ #include "std-vector.hh" #include "smobs.hh" +#include + struct Building { Real end_; @@ -47,16 +48,19 @@ private: list internal_build_skyline (list*, Real, Axis, Direction); DECLARE_SIMPLE_SMOBS(Skyline); + public: Skyline (); Skyline (Skyline const &src); Skyline (Direction sky); Skyline (vector const &bldgs, Real horizon_padding, Axis a, Direction sky); Skyline (Box const &b, Real horizon_padding, Axis a, Direction sky); + vector to_points (Axis) const; void merge (Skyline const &); void insert (Box const &, Real horizon_padding, Axis); void print () const; + void print_points () const; void raise (Real); void shift (Real); Real distance (Skyline const &) const; diff --git a/lily/skyline.cc b/lily/skyline.cc index e55ba3a663..c935660c6e 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -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)) @@ -497,7 +507,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 +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; } -- 2.39.2