Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/algorithms/envelope.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Geometry (aka GGL, Generic Geometry Library) | |
2 | |
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | |
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
9 | |
10 // Use, modification and distribution is subject to the Boost Software License, | |
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
12 // http://www.boost.org/LICENSE_1_0.txt) | |
13 | |
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP | |
15 #define BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP | |
16 | |
17 #include <boost/range.hpp> | |
18 | |
19 #include <boost/numeric/conversion/cast.hpp> | |
20 | |
21 #include <boost/geometry/algorithms/assign.hpp> | |
22 #include <boost/geometry/algorithms/expand.hpp> | |
23 #include <boost/geometry/algorithms/not_implemented.hpp> | |
24 #include <boost/geometry/core/cs.hpp> | |
25 #include <boost/geometry/core/exterior_ring.hpp> | |
26 #include <boost/geometry/geometries/concepts/check.hpp> | |
27 | |
28 | |
29 namespace boost { namespace geometry | |
30 { | |
31 | |
32 #ifndef DOXYGEN_NO_DETAIL | |
33 namespace detail { namespace envelope | |
34 { | |
35 | |
36 | |
37 /// Calculate envelope of an 2D or 3D segment | |
38 struct envelope_expand_one | |
39 { | |
40 template<typename Geometry, typename Box> | |
41 static inline void apply(Geometry const& geometry, Box& mbr) | |
42 { | |
43 assign_inverse(mbr); | |
44 geometry::expand(mbr, geometry); | |
45 } | |
46 }; | |
47 | |
48 | |
49 /// Iterate through range (also used in multi*) | |
50 template<typename Range, typename Box> | |
51 inline void envelope_range_additional(Range const& range, Box& mbr) | |
52 { | |
53 typedef typename boost::range_iterator<Range const>::type iterator_type; | |
54 | |
55 for (iterator_type it = boost::begin(range); | |
56 it != boost::end(range); | |
57 ++it) | |
58 { | |
59 geometry::expand(mbr, *it); | |
60 } | |
61 } | |
62 | |
63 | |
64 | |
65 /// Generic range dispatching struct | |
66 struct envelope_range | |
67 { | |
68 /// Calculate envelope of range using a strategy | |
69 template <typename Range, typename Box> | |
70 static inline void apply(Range const& range, Box& mbr) | |
71 { | |
72 assign_inverse(mbr); | |
73 envelope_range_additional(range, mbr); | |
74 } | |
75 }; | |
76 | |
77 }} // namespace detail::envelope | |
78 #endif // DOXYGEN_NO_DETAIL | |
79 | |
80 #ifndef DOXYGEN_NO_DISPATCH | |
81 namespace dispatch | |
82 { | |
83 | |
84 | |
85 template | |
86 < | |
87 typename Geometry, | |
88 typename Tag = typename tag<Geometry>::type | |
89 > | |
90 struct envelope: not_implemented<Tag> | |
91 {}; | |
92 | |
93 | |
94 template <typename Point> | |
95 struct envelope<Point, point_tag> | |
96 : detail::envelope::envelope_expand_one | |
97 {}; | |
98 | |
99 | |
100 template <typename Box> | |
101 struct envelope<Box, box_tag> | |
102 : detail::envelope::envelope_expand_one | |
103 {}; | |
104 | |
105 | |
106 template <typename Segment> | |
107 struct envelope<Segment, segment_tag> | |
108 : detail::envelope::envelope_expand_one | |
109 {}; | |
110 | |
111 | |
112 template <typename Linestring> | |
113 struct envelope<Linestring, linestring_tag> | |
114 : detail::envelope::envelope_range | |
115 {}; | |
116 | |
117 | |
118 template <typename Ring> | |
119 struct envelope<Ring, ring_tag> | |
120 : detail::envelope::envelope_range | |
121 {}; | |
122 | |
123 | |
124 template <typename Polygon> | |
125 struct envelope<Polygon, polygon_tag> | |
126 : detail::envelope::envelope_range | |
127 { | |
128 template <typename Box> | |
129 static inline void apply(Polygon const& poly, Box& mbr) | |
130 { | |
131 // For polygon, inspecting outer ring is sufficient | |
132 detail::envelope::envelope_range::apply(exterior_ring(poly), mbr); | |
133 } | |
134 | |
135 }; | |
136 | |
137 | |
138 } // namespace dispatch | |
139 #endif | |
140 | |
141 | |
142 /*! | |
143 \brief \brief_calc{envelope} | |
144 \ingroup envelope | |
145 \details \details_calc{envelope,\det_envelope}. | |
146 \tparam Geometry \tparam_geometry | |
147 \tparam Box \tparam_box | |
148 \param geometry \param_geometry | |
149 \param mbr \param_box \param_set{envelope} | |
150 | |
151 \qbk{[include reference/algorithms/envelope.qbk]} | |
152 \qbk{ | |
153 [heading Example] | |
154 [envelope] [envelope_output] | |
155 } | |
156 */ | |
157 template<typename Geometry, typename Box> | |
158 inline void envelope(Geometry const& geometry, Box& mbr) | |
159 { | |
160 concept::check<Geometry const>(); | |
161 concept::check<Box>(); | |
162 | |
163 dispatch::envelope<Geometry>::apply(geometry, mbr); | |
164 } | |
165 | |
166 | |
167 /*! | |
168 \brief \brief_calc{envelope} | |
169 \ingroup envelope | |
170 \details \details_calc{return_envelope,\det_envelope}. \details_return{envelope} | |
171 \tparam Box \tparam_box | |
172 \tparam Geometry \tparam_geometry | |
173 \param geometry \param_geometry | |
174 \return \return_calc{envelope} | |
175 | |
176 \qbk{[include reference/algorithms/envelope.qbk]} | |
177 \qbk{ | |
178 [heading Example] | |
179 [return_envelope] [return_envelope_output] | |
180 } | |
181 */ | |
182 template<typename Box, typename Geometry> | |
183 inline Box return_envelope(Geometry const& geometry) | |
184 { | |
185 concept::check<Geometry const>(); | |
186 concept::check<Box>(); | |
187 | |
188 Box mbr; | |
189 dispatch::envelope<Geometry>::apply(geometry, mbr); | |
190 return mbr; | |
191 } | |
192 | |
193 }} // namespace boost::geometry | |
194 | |
195 #endif // BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP |