]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/skyline.hh
eeb655950f080459c57fb8c3968ea3577f94ebb1
[lilypond.git] / lily / include / skyline.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2006--2009 Joe Neeman <joeneeman@gmail.com>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef SKYLINE_HH
21 #define SKYLINE_HH
22
23 #include "lily-proto.hh"
24 #include "axis.hh"
25 #include "box.hh"
26 #include "interval.hh"
27 #include "direction.hh"
28 #include "std-vector.hh"
29 #include "smobs.hh"
30
31 #include <list>
32
33 struct Building
34 {
35   Real end_;
36   Real y_intercept_;
37   Real slope_;
38
39   void precompute (Real start, Real start_height, Real end_height, Real end);
40   Building (Real start, Real start_height, Real end_height, Real end);
41   Building (Box const &b, Real horizon_padding, Axis a, Direction d);
42   void print () const;
43
44   Real height (Real x) const;
45   Real intersection_x (Building const &other) const;
46   void leading_part (Real chop);
47   bool conceals (Building const &other, Real x) const;
48   Building sloped_neighbour (Real start, Real horizon_padding, Direction d) const;
49 };
50
51 class Skyline
52 {
53 private:
54   list<Building> buildings_;
55   Direction sky_;
56   
57   void internal_merge_skyline (list<Building>*, list<Building>*,
58                                list<Building> *const result);
59   list<Building> internal_build_skyline (list<Box>*, Real, Axis, Direction);
60
61   DECLARE_SIMPLE_SMOBS(Skyline);
62
63 public:
64   Skyline ();
65   Skyline (Skyline const &src);
66   Skyline (Direction sky);
67   Skyline (vector<Box> const &bldgs, Real horizon_padding, Axis a, Direction sky);
68   Skyline (Box const &b, Real horizon_padding, Axis a, Direction sky);
69   
70   vector<Offset> to_points (Axis) const;
71   void merge (Skyline const &);
72   void insert (Box const &, Real horizon_padding, Axis);
73   void print () const;
74   void print_points () const;
75   void raise (Real);
76   void shift (Real);
77   Real distance (Skyline const &) const;
78   Real height (Real airplane) const;
79   Real max_height () const;
80   void set_minimum_height (Real height);
81   void clear ();
82   bool is_empty () const;
83 };
84
85 extern bool debug_skylines;
86
87 #endif /* SKYLINE_HH */
88