]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/skyline.hh
Merge branch 'master' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / include / skyline.hh
1 /*
2   skyline.hh -- declare Skyline class.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2006 Joe Neeman <joeneeman@gmail.com>
7 */
8
9 #ifndef SKYLINE_HH
10 #define SKYLINE_HH
11
12 #include <list>
13
14 #include "axis.hh"
15 #include "box.hh"
16 #include "interval.hh"
17 #include "direction.hh"
18 #include "std-vector.hh"
19 #include "smobs.hh"
20
21 struct Building
22 {
23   Interval iv_;
24   Drul_array<Real> height_;
25
26   Real y_intercept_;
27   Real slope_;
28
29   void precompute ();
30   Building (Real start, Real start_height, Real end_height, Real end);
31   Building (Box const &b, Real horizon_padding, Axis a, Direction d);
32   void print () const;
33
34   Real height (Real x) const;
35   Real intersection_x (Building const &other) const;
36   void leading_part (Real chop);
37   bool conceals_beginning (Building const &other) const;
38   bool conceals (Building const &other) const;
39   bool sane () const;
40   Building sloped_neighbour (Real horizon_padding, Direction d) const;
41 };
42
43 class Skyline
44 {
45 private:
46   list<Building> buildings_;
47   Direction sky_;
48   
49   void internal_merge_skyline (list<Building>*, list<Building>*,
50                                list<Building> *const result);
51   void internal_build_skyline (list<Building>*, list<Building> *const result);
52   bool is_legal_skyline () const;
53
54   DECLARE_SIMPLE_SMOBS(Skyline);
55 public:
56   Skyline ();
57   Skyline (Skyline const &src);
58   Skyline (Direction sky);
59   Skyline (vector<Box> const &bldgs, Real horizon_padding, Axis a, Direction sky);
60   Skyline (Box const &b, Real horizon_padding, Axis a, Direction sky);
61   vector<Offset> to_points () const;
62   void merge (Skyline const &);
63   void insert (Box const &, Real horizon_padding, Axis);
64   void print () const;
65   void raise (Real);
66   void shift (Real);
67   Real distance (Skyline const &) const;
68   Real height (Real airplane) const;
69   Real max_height () const;
70   void set_minimum_height (Real height);
71 };
72
73 class Skyline_pair
74 {
75 private:
76   Drul_array<Skyline> skylines_;
77
78   DECLARE_SIMPLE_SMOBS(Skyline_pair);
79 public:
80   Skyline_pair ();
81   Skyline_pair (vector<Box> const &boxes, Real horizon_padding, Axis a);
82   Skyline_pair (Box const &, Real horizon_padding, Axis a);
83   void raise (Real);
84   void shift (Real);
85   void insert (Box const &, Real horizon_padding, Axis);
86   void merge (Skyline_pair const &other);
87   Skyline &operator [] (Direction d);
88   Skyline const &operator [] (Direction d) const;
89 };
90
91 #endif /* SKYLINE_HH */
92