]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/skyline.hh
Rework skyline algorithm for a more compact representation and less fuzzy
[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--2007 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   Real end_;
24   Real y_intercept_;
25   Real slope_;
26
27   void precompute (Real start, Real start_height, Real end_height, Real end);
28   Building (Real start, Real start_height, Real end_height, Real end);
29   Building (Box const &b, Real horizon_padding, Axis a, Direction d);
30   void print () const;
31
32   Real height (Real x) const;
33   Real intersection_x (Building const &other) const;
34   void leading_part (Real chop);
35   bool conceals (Building const &other, Real x) const;
36   Building sloped_neighbour (Real start, Real horizon_padding, Direction d) const;
37 };
38
39 class Skyline
40 {
41 private:
42   list<Building> buildings_;
43   Direction sky_;
44   
45   void internal_merge_skyline (list<Building>*, list<Building>*,
46                                list<Building> *const result);
47   list<Building> internal_build_skyline (list<Box>*, Real, Axis, Direction);
48
49   DECLARE_SIMPLE_SMOBS(Skyline);
50 public:
51   Skyline ();
52   Skyline (Skyline const &src);
53   Skyline (Direction sky);
54   Skyline (vector<Box> const &bldgs, Real horizon_padding, Axis a, Direction sky);
55   Skyline (Box const &b, Real horizon_padding, Axis a, Direction sky);
56   vector<Offset> to_points (Axis) const;
57   void merge (Skyline const &);
58   void insert (Box const &, Real horizon_padding, Axis);
59   void print () const;
60   void raise (Real);
61   void shift (Real);
62   Real distance (Skyline const &) const;
63   Real height (Real airplane) const;
64   Real max_height () const;
65   void set_minimum_height (Real height);
66   bool is_empty () const;
67 };
68
69 class Skyline_pair
70 {
71 private:
72   Drul_array<Skyline> skylines_;
73
74   DECLARE_SIMPLE_SMOBS(Skyline_pair);
75 public:
76   Skyline_pair ();
77   Skyline_pair (vector<Box> const &boxes, Real horizon_padding, Axis a);
78   Skyline_pair (Box const &, Real horizon_padding, Axis a);
79   void raise (Real);
80   void shift (Real);
81   void insert (Box const &, Real horizon_padding, Axis);
82   void merge (Skyline_pair const &other);
83   Skyline &operator [] (Direction d);
84   Skyline const &operator [] (Direction d) const;
85   bool is_empty () const;
86 };
87
88 #endif /* SKYLINE_HH */
89