comparison DEPENDENCIES/generic/include/boost/geometry/geometries/polygon.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_GEOMETRIES_POLYGON_HPP
15 #define BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP
16
17 #include <memory>
18 #include <vector>
19
20 #include <boost/concept/assert.hpp>
21
22 #include <boost/geometry/core/exterior_ring.hpp>
23 #include <boost/geometry/core/interior_rings.hpp>
24 #include <boost/geometry/core/point_type.hpp>
25 #include <boost/geometry/core/ring_type.hpp>
26 #include <boost/geometry/geometries/concepts/point_concept.hpp>
27 #include <boost/geometry/geometries/ring.hpp>
28
29 namespace boost { namespace geometry
30 {
31
32 namespace model
33 {
34
35 /*!
36 \brief The polygon contains an outer ring and zero or more inner rings.
37 \ingroup geometries
38 \tparam Point point type
39 \tparam ClockWise true for clockwise direction,
40 false for CounterClockWise direction
41 \tparam Closed true for closed polygons (last point == first point),
42 false open points
43 \tparam PointList container type for points,
44 for example std::vector, std::list, std::deque
45 \tparam RingList container type for inner rings,
46 for example std::vector, std::list, std::deque
47 \tparam PointAlloc container-allocator-type, for the points
48 \tparam RingAlloc container-allocator-type, for the rings
49 \note The container collecting the points in the rings can be different
50 from the container collecting the inner rings. They all default to vector.
51
52 \qbk{before.synopsis,
53 [heading Model of]
54 [link geometry.reference.concepts.concept_polygon Polygon Concept]
55 }
56
57
58 */
59 template
60 <
61 typename Point,
62 bool ClockWise = true,
63 bool Closed = true,
64 template<typename, typename> class PointList = std::vector,
65 template<typename, typename> class RingList = std::vector,
66 template<typename> class PointAlloc = std::allocator,
67 template<typename> class RingAlloc = std::allocator
68 >
69 class polygon
70 {
71 BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
72
73 public:
74
75 // Member types
76 typedef Point point_type;
77 typedef ring<Point, ClockWise, Closed, PointList, PointAlloc> ring_type;
78 typedef RingList<ring_type , RingAlloc<ring_type > > inner_container_type;
79
80 inline ring_type const& outer() const { return m_outer; }
81 inline inner_container_type const& inners() const { return m_inners; }
82
83 inline ring_type& outer() { return m_outer; }
84 inline inner_container_type & inners() { return m_inners; }
85
86 /// Utility method, clears outer and inner rings
87 inline void clear()
88 {
89 m_outer.clear();
90 m_inners.clear();
91 }
92
93 private:
94
95 ring_type m_outer;
96 inner_container_type m_inners;
97 };
98
99
100 } // namespace model
101
102
103 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
104 namespace traits
105 {
106
107 template
108 <
109 typename Point,
110 bool ClockWise, bool Closed,
111 template<typename, typename> class PointList,
112 template<typename, typename> class RingList,
113 template<typename> class PointAlloc,
114 template<typename> class RingAlloc
115 >
116 struct tag
117 <
118 model::polygon
119 <
120 Point, ClockWise, Closed,
121 PointList, RingList, PointAlloc, RingAlloc
122 >
123 >
124 {
125 typedef polygon_tag type;
126 };
127
128 template
129 <
130 typename Point,
131 bool ClockWise, bool Closed,
132 template<typename, typename> class PointList,
133 template<typename, typename> class RingList,
134 template<typename> class PointAlloc,
135 template<typename> class RingAlloc
136 >
137 struct ring_const_type
138 <
139 model::polygon
140 <
141 Point, ClockWise, Closed,
142 PointList, RingList, PointAlloc, RingAlloc
143 >
144 >
145 {
146 typedef typename model::polygon
147 <
148 Point, ClockWise, Closed,
149 PointList, RingList,
150 PointAlloc, RingAlloc
151 >::ring_type const& type;
152 };
153
154
155 template
156 <
157 typename Point,
158 bool ClockWise, bool Closed,
159 template<typename, typename> class PointList,
160 template<typename, typename> class RingList,
161 template<typename> class PointAlloc,
162 template<typename> class RingAlloc
163 >
164 struct ring_mutable_type
165 <
166 model::polygon
167 <
168 Point, ClockWise, Closed,
169 PointList, RingList, PointAlloc, RingAlloc
170 >
171 >
172 {
173 typedef typename model::polygon
174 <
175 Point, ClockWise, Closed,
176 PointList, RingList,
177 PointAlloc, RingAlloc
178 >::ring_type& type;
179 };
180
181 template
182 <
183 typename Point,
184 bool ClockWise, bool Closed,
185 template<typename, typename> class PointList,
186 template<typename, typename> class RingList,
187 template<typename> class PointAlloc,
188 template<typename> class RingAlloc
189 >
190 struct interior_const_type
191 <
192 model::polygon
193 <
194 Point, ClockWise, Closed,
195 PointList, RingList,
196 PointAlloc, RingAlloc
197 >
198 >
199 {
200 typedef typename model::polygon
201 <
202 Point, ClockWise, Closed,
203 PointList, RingList,
204 PointAlloc, RingAlloc
205 >::inner_container_type const& type;
206 };
207
208
209 template
210 <
211 typename Point,
212 bool ClockWise, bool Closed,
213 template<typename, typename> class PointList,
214 template<typename, typename> class RingList,
215 template<typename> class PointAlloc,
216 template<typename> class RingAlloc
217 >
218 struct interior_mutable_type
219 <
220 model::polygon
221 <
222 Point, ClockWise, Closed,
223 PointList, RingList,
224 PointAlloc, RingAlloc
225 >
226 >
227 {
228 typedef typename model::polygon
229 <
230 Point, ClockWise, Closed,
231 PointList, RingList,
232 PointAlloc, RingAlloc
233 >::inner_container_type& type;
234 };
235
236
237 template
238 <
239 typename Point,
240 bool ClockWise, bool Closed,
241 template<typename, typename> class PointList,
242 template<typename, typename> class RingList,
243 template<typename> class PointAlloc,
244 template<typename> class RingAlloc
245 >
246 struct exterior_ring
247 <
248 model::polygon
249 <
250 Point, ClockWise, Closed,
251 PointList, RingList, PointAlloc, RingAlloc
252 >
253 >
254 {
255 typedef model::polygon
256 <
257 Point, ClockWise, Closed,
258 PointList, RingList,
259 PointAlloc, RingAlloc
260 > polygon_type;
261
262 static inline typename polygon_type::ring_type& get(polygon_type& p)
263 {
264 return p.outer();
265 }
266
267 static inline typename polygon_type::ring_type const& get(
268 polygon_type const& p)
269 {
270 return p.outer();
271 }
272 };
273
274 template
275 <
276 typename Point,
277 bool ClockWise, bool Closed,
278 template<typename, typename> class PointList,
279 template<typename, typename> class RingList,
280 template<typename> class PointAlloc,
281 template<typename> class RingAlloc
282 >
283 struct interior_rings
284 <
285 model::polygon
286 <
287 Point, ClockWise, Closed,
288 PointList, RingList,
289 PointAlloc, RingAlloc
290 >
291 >
292 {
293 typedef model::polygon
294 <
295 Point, ClockWise, Closed, PointList, RingList,
296 PointAlloc, RingAlloc
297 > polygon_type;
298
299 static inline typename polygon_type::inner_container_type& get(
300 polygon_type& p)
301 {
302 return p.inners();
303 }
304
305 static inline typename polygon_type::inner_container_type const& get(
306 polygon_type const& p)
307 {
308 return p.inners();
309 }
310 };
311
312 } // namespace traits
313 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
314
315
316
317 }} // namespace boost::geometry
318
319 #endif // BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP