]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/skyline.hh
Merge remote branch 'origin/master' into release/unstable
[lilypond.git] / lily / include / skyline.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2006--2014 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 start_;
36   Real end_;
37   Real y_intercept_;
38   Real slope_;
39
40   void precompute (Real start, Real start_height, Real end_height, Real end);
41   Building (Real start, Real start_height, Real end_height, Real end);
42   Building (Box const &b, Axis a, Direction d);
43   void print () const;
44
45   Real height (Real x) const;
46   Real intersection_x (Building const &other) const;
47   void leading_part (Real chop);
48   bool conceals (Building const &other, Real x) const;
49   Real shift_to_intersect (Real x, Real y) const;
50 };
51
52 class Skyline : public Simple_smob<Skyline>
53 {
54 public:
55   static const char type_p_name_[];
56 private:
57   list<Building> buildings_;
58   Direction sky_;
59
60   void internal_merge_skyline (list<Building> *, list<Building> *,
61                                list<Building> *result) const;
62   list<Building> internal_build_skyline (list<Building> *) const;
63   Real internal_distance (Skyline const &, Real horizon_padding, Real *touch_point) const;
64   Real internal_distance (Skyline const &, Real *touch_point) const;
65   void normalize ();
66
67
68 public:
69   Skyline ();
70   Skyline (Direction sky);
71   Skyline (vector<Box> const &bldgs, Axis a, Direction sky);
72   Skyline (vector<Drul_array<Offset> > const &bldgs, Axis a, Direction sky);
73   Skyline (vector<Skyline_pair> const &skypairs, Direction sky);
74   Skyline (Box const &b, Axis a, Direction sky);
75
76   vector<Offset> to_points (Axis) const;
77   void deholify ();
78   void merge (Skyline const &);
79   void insert (Box const &, Axis);
80   void print () const;
81   void print_points () const;
82   void raise (Real);
83   void shift (Real);
84   Real distance (Skyline const &, Real horizon_padding = 0) const;
85   Real touching_point (Skyline const &, Real horizon_padding = 0) const;
86   Real shift_to_avoid (Skyline const &other, Real, Direction d, Real horizon_padding = 0);
87   Real raise_to_avoid (Skyline const &other, Real, Direction d, Real horizon_padding = 0);
88   Drul_array<Real> shifts_to_avoid_intersection (Skyline const &, Real horizon_padding = 0) const;
89   Interval raises_to_avoid_intersection (Skyline const &, Real horizon_padding = 0) const;
90   Real height (Real airplane) const;
91   Real max_height () const;
92   Real max_height_position () const;
93   Real left () const;
94   Real right () const;
95   Direction direction () const;
96   void set_minimum_height (Real height);
97   void clear ();
98   bool is_empty () const;
99   Skyline padded (Real horizon_padding) const;
100
101   DECLARE_SCHEME_CALLBACK (get_touching_point, (SCM, SCM, SCM));
102   DECLARE_SCHEME_CALLBACK (get_distance, (SCM, SCM, SCM));
103   DECLARE_SCHEME_CALLBACK (get_max_height, (SCM));
104   DECLARE_SCHEME_CALLBACK (get_max_height_position, (SCM));
105   DECLARE_SCHEME_CALLBACK (get_height, (SCM, SCM));
106 };
107
108 extern bool debug_skylines;
109
110 #endif /* SKYLINE_HH */