Chris@16
|
1 /*
|
Chris@16
|
2 Copyright 2008 Intel Corporation
|
Chris@16
|
3
|
Chris@16
|
4 Use, modification and distribution are subject to the Boost Software License,
|
Chris@16
|
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 http://www.boost.org/LICENSE_1_0.txt).
|
Chris@16
|
7 */
|
Chris@16
|
8 #ifndef BOOST_POLYGON_POLYGON_45_SET_CONCEPT_HPP
|
Chris@16
|
9 #define BOOST_POLYGON_POLYGON_45_SET_CONCEPT_HPP
|
Chris@16
|
10 #include "polygon_45_set_data.hpp"
|
Chris@16
|
11 #include "polygon_45_set_traits.hpp"
|
Chris@16
|
12 #include "detail/polygon_45_touch.hpp"
|
Chris@16
|
13 namespace boost { namespace polygon{
|
Chris@16
|
14
|
Chris@16
|
15 template <typename T, typename T2>
|
Chris@16
|
16 struct is_either_polygon_45_set_type {
|
Chris@16
|
17 typedef typename gtl_or<typename is_polygon_45_set_type<T>::type, typename is_polygon_45_set_type<T2>::type >::type type;
|
Chris@16
|
18 };
|
Chris@16
|
19
|
Chris@16
|
20 template <typename T>
|
Chris@16
|
21 struct is_polygon_45_or_90_set_type {
|
Chris@16
|
22 typedef typename gtl_or<typename is_polygon_45_set_type<T>::type, typename is_polygon_90_set_type<T>::type >::type type;
|
Chris@16
|
23 };
|
Chris@16
|
24
|
Chris@16
|
25 template <typename polygon_set_type>
|
Chris@16
|
26 typename enable_if< typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
27 typename polygon_45_set_traits<polygon_set_type>::iterator_type>::type
|
Chris@16
|
28 begin_45_set_data(const polygon_set_type& polygon_set) {
|
Chris@16
|
29 return polygon_45_set_traits<polygon_set_type>::begin(polygon_set);
|
Chris@16
|
30 }
|
Chris@16
|
31
|
Chris@16
|
32 template <typename polygon_set_type>
|
Chris@16
|
33 typename enable_if< typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
34 typename polygon_45_set_traits<polygon_set_type>::iterator_type>::type
|
Chris@16
|
35 end_45_set_data(const polygon_set_type& polygon_set) {
|
Chris@16
|
36 return polygon_45_set_traits<polygon_set_type>::end(polygon_set);
|
Chris@16
|
37 }
|
Chris@16
|
38
|
Chris@16
|
39 template <typename polygon_set_type>
|
Chris@16
|
40 typename enable_if< typename gtl_if<typename is_polygon_45_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
41 bool>::type
|
Chris@16
|
42 clean(const polygon_set_type& polygon_set) {
|
Chris@16
|
43 return polygon_45_set_traits<polygon_set_type>::clean(polygon_set);
|
Chris@16
|
44 }
|
Chris@16
|
45
|
Chris@16
|
46 //assign
|
Chris@16
|
47 template <typename polygon_set_type_1, typename polygon_set_type_2>
|
Chris@16
|
48 typename enable_if< typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type_1>::type>::type,
|
Chris@16
|
49 typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type>::type,
|
Chris@16
|
50 polygon_set_type_1>::type &
|
Chris@16
|
51 assign(polygon_set_type_1& lvalue, const polygon_set_type_2& rvalue) {
|
Chris@16
|
52 polygon_45_set_mutable_traits<polygon_set_type_1>::set(lvalue, begin_45_set_data(rvalue), end_45_set_data(rvalue));
|
Chris@16
|
53 return lvalue;
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56 //get trapezoids
|
Chris@16
|
57 template <typename output_container_type, typename polygon_set_type>
|
Chris@16
|
58 typename enable_if< typename gtl_if<typename is_polygon_45_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
59 void>::type
|
Chris@16
|
60 get_trapezoids(output_container_type& output, const polygon_set_type& polygon_set) {
|
Chris@16
|
61 clean(polygon_set);
|
Chris@16
|
62 polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type>::coordinate_type> ps;
|
Chris@16
|
63 assign(ps, polygon_set);
|
Chris@16
|
64 ps.get_trapezoids(output);
|
Chris@16
|
65 }
|
Chris@16
|
66
|
Chris@16
|
67 //get trapezoids
|
Chris@16
|
68 template <typename output_container_type, typename polygon_set_type>
|
Chris@16
|
69 typename enable_if< typename gtl_if<typename is_polygon_45_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
70 void>::type
|
Chris@16
|
71 get_trapezoids(output_container_type& output, const polygon_set_type& polygon_set, orientation_2d slicing_orientation) {
|
Chris@16
|
72 clean(polygon_set);
|
Chris@16
|
73 polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type>::coordinate_type> ps;
|
Chris@16
|
74 assign(ps, polygon_set);
|
Chris@16
|
75 ps.get_trapezoids(output, slicing_orientation);
|
Chris@16
|
76 }
|
Chris@16
|
77
|
Chris@16
|
78 //equivalence
|
Chris@16
|
79 template <typename polygon_set_type_1, typename polygon_set_type_2>
|
Chris@16
|
80 typename enable_if< typename gtl_and_3<typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_1>::type>::type,
|
Chris@16
|
81 typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type,
|
Chris@16
|
82 typename gtl_if<typename is_either_polygon_45_set_type<polygon_set_type_1,
|
Chris@16
|
83 polygon_set_type_2>::type>::type>::type,
|
Chris@16
|
84 bool>::type
|
Chris@16
|
85 equivalence(const polygon_set_type_1& lvalue,
|
Chris@16
|
86 const polygon_set_type_2& rvalue) {
|
Chris@16
|
87 polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type_1>::coordinate_type> ps1;
|
Chris@16
|
88 assign(ps1, lvalue);
|
Chris@16
|
89 polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type_2>::coordinate_type> ps2;
|
Chris@16
|
90 assign(ps2, rvalue);
|
Chris@16
|
91 return ps1 == ps2;
|
Chris@16
|
92 }
|
Chris@16
|
93
|
Chris@16
|
94 //clear
|
Chris@16
|
95 template <typename polygon_set_type>
|
Chris@16
|
96 typename enable_if< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
97 void>::type
|
Chris@16
|
98 clear(polygon_set_type& polygon_set) {
|
Chris@16
|
99 polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type>::coordinate_type> ps;
|
Chris@16
|
100 assign(polygon_set, ps);
|
Chris@16
|
101 }
|
Chris@16
|
102
|
Chris@16
|
103 //empty
|
Chris@16
|
104 template <typename polygon_set_type>
|
Chris@16
|
105 typename enable_if< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
106 bool>::type
|
Chris@16
|
107 empty(const polygon_set_type& polygon_set) {
|
Chris@16
|
108 if(clean(polygon_set)) return begin_45_set_data(polygon_set) == end_45_set_data(polygon_set);
|
Chris@16
|
109 polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type>::coordinate_type> ps;
|
Chris@16
|
110 assign(ps, polygon_set);
|
Chris@16
|
111 ps.clean();
|
Chris@16
|
112 return ps.empty();
|
Chris@16
|
113 }
|
Chris@16
|
114
|
Chris@16
|
115 //extents
|
Chris@16
|
116 template <typename polygon_set_type, typename rectangle_type>
|
Chris@16
|
117 typename enable_if<
|
Chris@16
|
118 typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
119 typename is_mutable_rectangle_concept<typename geometry_concept<rectangle_type>::type>::type>::type,
|
Chris@16
|
120 bool>::type
|
Chris@16
|
121 extents(rectangle_type& extents_rectangle,
|
Chris@16
|
122 const polygon_set_type& polygon_set) {
|
Chris@16
|
123 clean(polygon_set);
|
Chris@16
|
124 polygon_45_set_data<typename polygon_45_set_traits<polygon_set_type>::coordinate_type> ps;
|
Chris@16
|
125 assign(ps, polygon_set);
|
Chris@16
|
126 return ps.extents(extents_rectangle);
|
Chris@16
|
127 }
|
Chris@16
|
128
|
Chris@16
|
129 //area
|
Chris@16
|
130 template <typename polygon_set_type>
|
Chris@16
|
131 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
132 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::area_type>::type
|
Chris@16
|
133 area(const polygon_set_type& polygon_set) {
|
Chris@16
|
134 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
135 typedef polygon_45_with_holes_data<Unit> p_type;
|
Chris@16
|
136 typedef typename coordinate_traits<Unit>::area_type area_type;
|
Chris@16
|
137 std::vector<p_type> polys;
|
Chris@16
|
138 assign(polys, polygon_set);
|
Chris@16
|
139 area_type retval = (area_type)0;
|
Chris@16
|
140 for(std::size_t i = 0; i < polys.size(); ++i) {
|
Chris@16
|
141 retval += area(polys[i]);
|
Chris@16
|
142 }
|
Chris@16
|
143 return retval;
|
Chris@16
|
144 }
|
Chris@16
|
145
|
Chris@16
|
146 //interact
|
Chris@16
|
147 template <typename polygon_set_type_1, typename polygon_set_type_2>
|
Chris@16
|
148 typename enable_if <
|
Chris@16
|
149 typename gtl_and< typename gtl_if<typename is_mutable_polygon_45_set_type<polygon_set_type_1>::type>::type,
|
Chris@16
|
150 typename gtl_if<typename is_polygon_45_or_90_set_type<polygon_set_type_2>::type>::type >::type,
|
Chris@16
|
151 polygon_set_type_1>::type&
|
Chris@16
|
152 interact(polygon_set_type_1& polygon_set_1, const polygon_set_type_2& polygon_set_2) {
|
Chris@16
|
153 typedef typename polygon_45_set_traits<polygon_set_type_1>::coordinate_type Unit;
|
Chris@16
|
154 std::vector<polygon_45_data<Unit> > polys;
|
Chris@16
|
155 assign(polys, polygon_set_1);
|
Chris@16
|
156 std::vector<std::set<int> > graph(polys.size()+1, std::set<int>());
|
Chris@16
|
157 connectivity_extraction_45<Unit> ce;
|
Chris@16
|
158 ce.insert(polygon_set_2);
|
Chris@16
|
159 for(std::size_t i = 0; i < polys.size(); ++i){
|
Chris@16
|
160 ce.insert(polys[i]);
|
Chris@16
|
161 }
|
Chris@16
|
162 ce.extract(graph);
|
Chris@16
|
163 clear(polygon_set_1);
|
Chris@16
|
164 polygon_45_set_data<Unit> ps;
|
Chris@16
|
165 for(std::set<int>::iterator itr = graph[0].begin(); itr != graph[0].end(); ++itr){
|
Chris@16
|
166 ps.insert(polys[(*itr)-1]);
|
Chris@16
|
167 }
|
Chris@16
|
168 assign(polygon_set_1, ps);
|
Chris@16
|
169 return polygon_set_1;
|
Chris@16
|
170 }
|
Chris@16
|
171
|
Chris@16
|
172 // //self_intersect
|
Chris@16
|
173 // template <typename polygon_set_type>
|
Chris@16
|
174 // typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type>::type,
|
Chris@16
|
175 // polygon_set_type>::type &
|
Chris@16
|
176 // self_intersect(polygon_set_type& polygon_set) {
|
Chris@16
|
177 // typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
178 // //TODO
|
Chris@16
|
179 // }
|
Chris@16
|
180
|
Chris@16
|
181 template <typename polygon_set_type, typename coord_type>
|
Chris@16
|
182 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
183 polygon_set_type>::type &
|
Chris@16
|
184 resize(polygon_set_type& polygon_set, coord_type resizing,
|
Chris@16
|
185 RoundingOption rounding = CLOSEST, CornerOption corner = INTERSECTION) {
|
Chris@16
|
186 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
187 clean(polygon_set);
|
Chris@16
|
188 polygon_45_set_data<Unit> ps;
|
Chris@16
|
189 assign(ps, polygon_set);
|
Chris@16
|
190 ps.resize(resizing, rounding, corner);
|
Chris@16
|
191 assign(polygon_set, ps);
|
Chris@16
|
192 return polygon_set;
|
Chris@16
|
193 }
|
Chris@16
|
194
|
Chris@16
|
195 template <typename polygon_set_type>
|
Chris@16
|
196 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
197 polygon_set_type>::type &
|
Chris@16
|
198 bloat(polygon_set_type& polygon_set,
|
Chris@16
|
199 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
|
Chris@16
|
200 return resize(polygon_set, static_cast<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>(bloating));
|
Chris@16
|
201 }
|
Chris@16
|
202
|
Chris@16
|
203 template <typename polygon_set_type>
|
Chris@16
|
204 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
205 polygon_set_type>::type &
|
Chris@16
|
206 shrink(polygon_set_type& polygon_set,
|
Chris@16
|
207 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type shrinking) {
|
Chris@16
|
208 return resize(polygon_set, -(typename polygon_45_set_traits<polygon_set_type>::coordinate_type)shrinking);
|
Chris@16
|
209 }
|
Chris@16
|
210
|
Chris@16
|
211 template <typename polygon_set_type>
|
Chris@16
|
212 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
213 polygon_set_type>::type &
|
Chris@16
|
214 grow_and(polygon_set_type& polygon_set,
|
Chris@16
|
215 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type bloating) {
|
Chris@16
|
216 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
217 std::vector<polygon_45_data<Unit> > polys;
|
Chris@16
|
218 assign(polys, polygon_set);
|
Chris@16
|
219 clear(polygon_set);
|
Chris@16
|
220 polygon_45_set_data<Unit> ps;
|
Chris@16
|
221 for(std::size_t i = 0; i < polys.size(); ++i) {
|
Chris@16
|
222 polygon_45_set_data<Unit> tmpPs;
|
Chris@16
|
223 tmpPs.insert(polys[i]);
|
Chris@16
|
224 bloat(tmpPs, bloating);
|
Chris@16
|
225 tmpPs.clean(); //apply implicit OR on tmp polygon set
|
Chris@16
|
226 ps.insert(tmpPs);
|
Chris@16
|
227 }
|
Chris@16
|
228 ps.self_intersect();
|
Chris@16
|
229 assign(polygon_set, ps);
|
Chris@16
|
230 return polygon_set;
|
Chris@16
|
231 }
|
Chris@16
|
232
|
Chris@16
|
233 template <typename polygon_set_type>
|
Chris@16
|
234 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
235 polygon_set_type>::type &
|
Chris@16
|
236 scale_up(polygon_set_type& polygon_set,
|
Chris@16
|
237 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type factor) {
|
Chris@16
|
238 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
239 clean(polygon_set);
|
Chris@16
|
240 polygon_45_set_data<Unit> ps;
|
Chris@16
|
241 assign(ps, polygon_set);
|
Chris@16
|
242 ps.scale_up(factor);
|
Chris@16
|
243 assign(polygon_set, ps);
|
Chris@16
|
244 return polygon_set;
|
Chris@16
|
245 }
|
Chris@16
|
246
|
Chris@16
|
247 template <typename polygon_set_type>
|
Chris@16
|
248 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
249 polygon_set_type>::type &
|
Chris@16
|
250 scale_down(polygon_set_type& polygon_set,
|
Chris@16
|
251 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type factor) {
|
Chris@16
|
252 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
253 clean(polygon_set);
|
Chris@16
|
254 polygon_45_set_data<Unit> ps;
|
Chris@16
|
255 assign(ps, polygon_set);
|
Chris@16
|
256 ps.scale_down(factor);
|
Chris@16
|
257 assign(polygon_set, ps);
|
Chris@16
|
258 return polygon_set;
|
Chris@16
|
259 }
|
Chris@16
|
260
|
Chris@16
|
261 template <typename polygon_set_type>
|
Chris@16
|
262 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
263 polygon_set_type>::type &
|
Chris@16
|
264 scale(polygon_set_type& polygon_set, double factor) {
|
Chris@16
|
265 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
266 clean(polygon_set);
|
Chris@16
|
267 polygon_45_set_data<Unit> ps;
|
Chris@16
|
268 assign(ps, polygon_set);
|
Chris@16
|
269 ps.scale(factor);
|
Chris@16
|
270 assign(polygon_set, ps);
|
Chris@16
|
271 return polygon_set;
|
Chris@16
|
272 }
|
Chris@16
|
273
|
Chris@16
|
274 //self_intersect
|
Chris@16
|
275 template <typename polygon_set_type>
|
Chris@16
|
276 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
277 polygon_set_type>::type &
|
Chris@16
|
278 self_intersect(polygon_set_type& polygon_set) {
|
Chris@16
|
279 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
280 polygon_45_set_data<Unit> ps;
|
Chris@16
|
281 assign(ps, polygon_set);
|
Chris@16
|
282 ps.self_intersect();
|
Chris@16
|
283 assign(polygon_set, ps);
|
Chris@16
|
284 return polygon_set;
|
Chris@16
|
285 }
|
Chris@16
|
286
|
Chris@16
|
287 //self_xor
|
Chris@16
|
288 template <typename polygon_set_type>
|
Chris@16
|
289 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
290 polygon_set_type>::type &
|
Chris@16
|
291 self_xor(polygon_set_type& polygon_set) {
|
Chris@16
|
292 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
293 polygon_45_set_data<Unit> ps;
|
Chris@16
|
294 assign(ps, polygon_set);
|
Chris@16
|
295 ps.self_xor();
|
Chris@16
|
296 assign(polygon_set, ps);
|
Chris@16
|
297 return polygon_set;
|
Chris@16
|
298 }
|
Chris@16
|
299
|
Chris@16
|
300 //transform
|
Chris@16
|
301 template <typename polygon_set_type, typename transformation_type>
|
Chris@16
|
302 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
303 polygon_set_type>::type &
|
Chris@16
|
304 transform(polygon_set_type& polygon_set,
|
Chris@16
|
305 const transformation_type& transformation) {
|
Chris@16
|
306 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
307 clean(polygon_set);
|
Chris@16
|
308 polygon_45_set_data<Unit> ps;
|
Chris@16
|
309 assign(ps, polygon_set);
|
Chris@16
|
310 ps.transform(transformation);
|
Chris@16
|
311 assign(polygon_set, ps);
|
Chris@16
|
312 return polygon_set;
|
Chris@16
|
313 }
|
Chris@16
|
314
|
Chris@16
|
315 //keep
|
Chris@16
|
316 template <typename polygon_set_type>
|
Chris@16
|
317 typename enable_if< typename is_mutable_polygon_45_set_type<polygon_set_type>::type,
|
Chris@16
|
318 polygon_set_type>::type &
|
Chris@16
|
319 keep(polygon_set_type& polygon_set,
|
Chris@16
|
320 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::area_type min_area,
|
Chris@16
|
321 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::area_type max_area,
|
Chris@16
|
322 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type min_width,
|
Chris@16
|
323 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type max_width,
|
Chris@16
|
324 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type min_height,
|
Chris@16
|
325 typename coordinate_traits<typename polygon_45_set_traits<polygon_set_type>::coordinate_type>::unsigned_area_type max_height) {
|
Chris@16
|
326 typedef typename polygon_45_set_traits<polygon_set_type>::coordinate_type Unit;
|
Chris@16
|
327 typedef typename coordinate_traits<Unit>::unsigned_area_type uat;
|
Chris@16
|
328 std::list<polygon_45_data<Unit> > polys;
|
Chris@16
|
329 assign(polys, polygon_set);
|
Chris@16
|
330 typename std::list<polygon_45_data<Unit> >::iterator itr_nxt;
|
Chris@16
|
331 for(typename std::list<polygon_45_data<Unit> >::iterator itr = polys.begin(); itr != polys.end(); itr = itr_nxt){
|
Chris@16
|
332 itr_nxt = itr;
|
Chris@16
|
333 ++itr_nxt;
|
Chris@16
|
334 rectangle_data<Unit> bbox;
|
Chris@16
|
335 extents(bbox, *itr);
|
Chris@16
|
336 uat pwidth = delta(bbox, HORIZONTAL);
|
Chris@16
|
337 if(pwidth > min_width && pwidth <= max_width){
|
Chris@16
|
338 uat pheight = delta(bbox, VERTICAL);
|
Chris@16
|
339 if(pheight > min_height && pheight <= max_height){
|
Chris@16
|
340 typename coordinate_traits<Unit>::area_type parea = area(*itr);
|
Chris@16
|
341 if(parea <= max_area && parea >= min_area) {
|
Chris@16
|
342 continue;
|
Chris@16
|
343 }
|
Chris@16
|
344 }
|
Chris@16
|
345 }
|
Chris@16
|
346 polys.erase(itr);
|
Chris@16
|
347 }
|
Chris@16
|
348 assign(polygon_set, polys);
|
Chris@16
|
349 return polygon_set;
|
Chris@16
|
350 }
|
Chris@16
|
351
|
Chris@16
|
352 template <typename T>
|
Chris@16
|
353 struct view_of<polygon_90_set_concept, T> {
|
Chris@16
|
354 typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
|
Chris@16
|
355 T* tp;
|
Chris@16
|
356 std::vector<polygon_90_with_holes_data<coordinate_type> > polys;
|
Chris@16
|
357 view_of(T& obj) : tp(&obj), polys() {
|
Chris@16
|
358 std::vector<polygon_with_holes_data<coordinate_type> > gpolys;
|
Chris@16
|
359 assign(gpolys, obj);
|
Chris@16
|
360 for(typename std::vector<polygon_with_holes_data<coordinate_type> >::iterator itr = gpolys.begin();
|
Chris@16
|
361 itr != gpolys.end(); ++itr) {
|
Chris@16
|
362 polys.push_back(polygon_90_with_holes_data<coordinate_type>());
|
Chris@16
|
363 assign(polys.back(), view_as<polygon_90_with_holes_concept>(*itr));
|
Chris@16
|
364 }
|
Chris@16
|
365 }
|
Chris@16
|
366 view_of(const T& obj) : tp(), polys() {
|
Chris@16
|
367 std::vector<polygon_with_holes_data<coordinate_type> > gpolys;
|
Chris@16
|
368 assign(gpolys, obj);
|
Chris@16
|
369 for(typename std::vector<polygon_with_holes_data<coordinate_type> >::iterator itr = gpolys.begin();
|
Chris@16
|
370 itr != gpolys.end(); ++itr) {
|
Chris@16
|
371 polys.push_back(polygon_90_with_holes_data<coordinate_type>());
|
Chris@16
|
372 assign(polys.back(), view_as<polygon_90_with_holes_concept>(*itr));
|
Chris@16
|
373 }
|
Chris@16
|
374 }
|
Chris@16
|
375
|
Chris@16
|
376 typedef typename std::vector<polygon_90_with_holes_data<coordinate_type> >::const_iterator iterator_type;
|
Chris@16
|
377 typedef view_of operator_arg_type;
|
Chris@16
|
378
|
Chris@16
|
379 inline iterator_type begin() const {
|
Chris@16
|
380 return polys.begin();
|
Chris@16
|
381 }
|
Chris@16
|
382
|
Chris@16
|
383 inline iterator_type end() const {
|
Chris@16
|
384 return polys.end();
|
Chris@16
|
385 }
|
Chris@16
|
386
|
Chris@16
|
387 inline orientation_2d orient() const { return HORIZONTAL; }
|
Chris@16
|
388
|
Chris@16
|
389 inline bool clean() const { return false; }
|
Chris@16
|
390
|
Chris@16
|
391 inline bool sorted() const { return false; }
|
Chris@16
|
392
|
Chris@16
|
393 inline T& get() { return *tp; }
|
Chris@16
|
394
|
Chris@16
|
395 };
|
Chris@16
|
396
|
Chris@16
|
397 template <typename T>
|
Chris@16
|
398 struct polygon_90_set_traits<view_of<polygon_90_set_concept, T> > {
|
Chris@16
|
399 typedef typename view_of<polygon_90_set_concept, T>::coordinate_type coordinate_type;
|
Chris@16
|
400 typedef typename view_of<polygon_90_set_concept, T>::iterator_type iterator_type;
|
Chris@16
|
401 typedef view_of<polygon_90_set_concept, T> operator_arg_type;
|
Chris@16
|
402
|
Chris@16
|
403 static inline iterator_type begin(const view_of<polygon_90_set_concept, T>& polygon_set) {
|
Chris@16
|
404 return polygon_set.begin();
|
Chris@16
|
405 }
|
Chris@16
|
406
|
Chris@16
|
407 static inline iterator_type end(const view_of<polygon_90_set_concept, T>& polygon_set) {
|
Chris@16
|
408 return polygon_set.end();
|
Chris@16
|
409 }
|
Chris@16
|
410
|
Chris@16
|
411 static inline orientation_2d orient(const view_of<polygon_90_set_concept, T>& polygon_set) {
|
Chris@16
|
412 return polygon_set.orient(); }
|
Chris@16
|
413
|
Chris@16
|
414 static inline bool clean(const view_of<polygon_90_set_concept, T>& polygon_set) {
|
Chris@16
|
415 return polygon_set.clean(); }
|
Chris@16
|
416
|
Chris@16
|
417 static inline bool sorted(const view_of<polygon_90_set_concept, T>& polygon_set) {
|
Chris@16
|
418 return polygon_set.sorted(); }
|
Chris@16
|
419
|
Chris@16
|
420 };
|
Chris@16
|
421
|
Chris@16
|
422 template <typename T>
|
Chris@16
|
423 struct geometry_concept<view_of<polygon_90_set_concept, T> > {
|
Chris@16
|
424 typedef polygon_90_set_concept type;
|
Chris@16
|
425 };
|
Chris@16
|
426
|
Chris@16
|
427 template <typename T>
|
Chris@16
|
428 struct get_coordinate_type<view_of<polygon_90_set_concept, T>, polygon_90_set_concept> {
|
Chris@16
|
429 typedef typename view_of<polygon_90_set_concept, T>::coordinate_type type;
|
Chris@16
|
430 };
|
Chris@16
|
431 template <typename T>
|
Chris@16
|
432 struct get_iterator_type_2<view_of<polygon_90_set_concept, T>, polygon_90_set_concept> {
|
Chris@16
|
433 typedef typename view_of<polygon_90_set_concept, T>::iterator_type type;
|
Chris@16
|
434 static type begin(const view_of<polygon_90_set_concept, T>& t) { return t.begin(); }
|
Chris@16
|
435 static type end(const view_of<polygon_90_set_concept, T>& t) { return t.end(); }
|
Chris@16
|
436 };
|
Chris@16
|
437
|
Chris@16
|
438 }
|
Chris@16
|
439 }
|
Chris@16
|
440 #include "detail/polygon_45_set_view.hpp"
|
Chris@16
|
441 #endif
|