annotate DEPENDENCIES/generic/include/boost/polygon/polygon_90_set_traits.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
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_90_SET_TRAITS_HPP
Chris@16 9 #define BOOST_POLYGON_POLYGON_90_SET_TRAITS_HPP
Chris@16 10 namespace boost { namespace polygon{
Chris@16 11
Chris@16 12 struct polygon_90_set_concept {};
Chris@16 13
Chris@16 14 template <typename T, typename T2>
Chris@16 15 struct traits_by_concept {};
Chris@16 16 template <typename T>
Chris@16 17 struct traits_by_concept<T, coordinate_concept> { typedef coordinate_traits<T> type; };
Chris@16 18 template <typename T>
Chris@16 19 struct traits_by_concept<T, interval_concept> { typedef interval_traits<T> type; };
Chris@16 20 template <typename T>
Chris@16 21 struct traits_by_concept<T, point_concept> { typedef point_traits<T> type; };
Chris@16 22 template <typename T>
Chris@16 23 struct traits_by_concept<T, rectangle_concept> { typedef rectangle_traits<T> type; };
Chris@16 24 template <typename T>
Chris@16 25 struct traits_by_concept<T, segment_concept> { typedef segment_traits<T> type; };
Chris@16 26 template <typename T>
Chris@16 27 struct traits_by_concept<T, polygon_90_concept> { typedef polygon_traits<T> type; };
Chris@16 28 template <typename T>
Chris@16 29 struct traits_by_concept<T, polygon_90_with_holes_concept> { typedef polygon_traits<T> type; };
Chris@16 30 template <typename T>
Chris@16 31 struct traits_by_concept<T, polygon_45_concept> { typedef polygon_traits<T> type; };
Chris@16 32 template <typename T>
Chris@16 33 struct traits_by_concept<T, polygon_45_with_holes_concept> { typedef polygon_traits<T> type; };
Chris@16 34 template <typename T>
Chris@16 35 struct traits_by_concept<T, polygon_concept> { typedef polygon_traits<T> type; };
Chris@16 36 template <typename T>
Chris@16 37 struct traits_by_concept<T, polygon_with_holes_concept> { typedef polygon_traits<T> type; };
Chris@16 38
Chris@16 39 struct polygon_45_set_concept;
Chris@16 40 struct polygon_set_concept;
Chris@16 41 template <typename T>
Chris@16 42 struct polygon_90_set_traits;
Chris@16 43 template <typename T>
Chris@16 44 struct polygon_45_set_traits;
Chris@16 45 template <typename T>
Chris@16 46 struct polygon_set_traits;
Chris@16 47 template <typename T>
Chris@16 48 struct traits_by_concept<T, polygon_90_set_concept> { typedef polygon_90_set_traits<T> type; };
Chris@16 49 template <typename T>
Chris@16 50 struct traits_by_concept<T, polygon_45_set_concept> { typedef polygon_45_set_traits<T> type; };
Chris@16 51 template <typename T>
Chris@16 52 struct traits_by_concept<T, polygon_set_concept> { typedef polygon_set_traits<T> type; };
Chris@16 53
Chris@16 54 template <typename T, typename T2>
Chris@16 55 struct get_coordinate_type {
Chris@16 56 typedef typename traits_by_concept<T, T2>::type traits_type;
Chris@16 57 typedef typename traits_type::coordinate_type type;
Chris@16 58 };
Chris@16 59 //want to prevent recursive template definition syntax errors, so duplicate get_coordinate_type
Chris@16 60 template <typename T, typename T2>
Chris@16 61 struct get_coordinate_type_2 {
Chris@16 62 typedef typename traits_by_concept<T, T2>::type traits_type;
Chris@16 63 typedef typename traits_type::coordinate_type type;
Chris@16 64 };
Chris@16 65 template <typename T>
Chris@16 66 struct get_coordinate_type<T, undefined_concept> {
Chris@16 67 typedef typename get_coordinate_type_2<typename std::iterator_traits
Chris@16 68 <typename T::iterator>::value_type,
Chris@16 69 typename geometry_concept<typename std::iterator_traits
Chris@16 70 <typename T::iterator>::value_type>::type>::type type; };
Chris@16 71
Chris@16 72 template <typename T, typename T2>
Chris@16 73 struct get_iterator_type_2 {
Chris@16 74 typedef const T* type;
Chris@16 75 static type begin(const T& t) { return &t; }
Chris@16 76 static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
Chris@16 77 };
Chris@16 78 template <typename T>
Chris@16 79 struct get_iterator_type {
Chris@16 80 typedef get_iterator_type_2<T, typename geometry_concept<T>::type> indirect_type;
Chris@16 81 typedef typename indirect_type::type type;
Chris@16 82 static type begin(const T& t) { return indirect_type::begin(t); }
Chris@16 83 static type end(const T& t) { return indirect_type::end(t); }
Chris@16 84 };
Chris@16 85 template <typename T>
Chris@16 86 struct get_iterator_type_2<T, undefined_concept> {
Chris@16 87 typedef typename T::const_iterator type;
Chris@16 88 static type begin(const T& t) { return t.begin(); }
Chris@16 89 static type end(const T& t) { return t.end(); }
Chris@16 90 };
Chris@16 91
Chris@16 92 // //helpers for allowing polygon 45 and containers of polygon 45 to behave interchangably in polygon_45_set_traits
Chris@16 93 // template <typename T, typename T2>
Chris@16 94 // struct get_coordinate_type_45 {};
Chris@16 95 // template <typename T, typename T2>
Chris@16 96 // struct get_coordinate_type_2_45 {};
Chris@16 97 // template <typename T>
Chris@16 98 // struct get_coordinate_type_45<T, void> {
Chris@16 99 // typedef typename get_coordinate_type_2_45< typename T::value_type, typename geometry_concept<typename T::value_type>::type >::type type; };
Chris@16 100 // template <typename T>
Chris@16 101 // struct get_coordinate_type_45<T, polygon_45_concept> { typedef typename polygon_traits<T>::coordinate_type type; };
Chris@16 102 // template <typename T>
Chris@16 103 // struct get_coordinate_type_45<T, polygon_45_with_holes_concept> { typedef typename polygon_traits<T>::coordinate_type type; };
Chris@16 104 // template <typename T>
Chris@16 105 // struct get_coordinate_type_2_45<T, polygon_45_concept> { typedef typename polygon_traits<T>::coordinate_type type; };
Chris@16 106 // template <typename T>
Chris@16 107 // struct get_coordinate_type_2_45<T, polygon_45_with_holes_concept> { typedef typename polygon_traits<T>::coordinate_type type; };
Chris@16 108 // template <typename T, typename T2>
Chris@16 109 // struct get_iterator_type_45 {};
Chris@16 110 // template <typename T>
Chris@16 111 // struct get_iterator_type_45<T, void> {
Chris@16 112 // typedef typename T::const_iterator type;
Chris@16 113 // static type begin(const T& t) { return t.begin(); }
Chris@16 114 // static type end(const T& t) { return t.end(); }
Chris@16 115 // };
Chris@16 116 // template <typename T>
Chris@16 117 // struct get_iterator_type_45<T, polygon_45_concept> {
Chris@16 118 // typedef const T* type;
Chris@16 119 // static type begin(const T& t) { return &t; }
Chris@16 120 // static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
Chris@16 121 // };
Chris@16 122 // template <typename T>
Chris@16 123 // struct get_iterator_type_45<T, polygon_45_with_holes_concept> {
Chris@16 124 // typedef const T* type;
Chris@16 125 // static type begin(const T& t) { return &t; }
Chris@16 126 // static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
Chris@16 127 // };
Chris@16 128 // template <typename T>
Chris@16 129 // struct get_iterator_type_45<T, polygon_90_set_concept> {
Chris@16 130 // typedef const T* type;
Chris@16 131 // static type begin(const T& t) { return &t; }
Chris@16 132 // static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
Chris@16 133 // };
Chris@16 134
Chris@16 135 template <typename T>
Chris@16 136 struct polygon_90_set_traits {
Chris@16 137 typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
Chris@16 138 typedef get_iterator_type<T> indirection_type;
Chris@16 139 typedef typename get_iterator_type<T>::type iterator_type;
Chris@16 140 typedef T operator_arg_type;
Chris@16 141
Chris@16 142 static inline iterator_type begin(const T& polygon_set) {
Chris@16 143 return indirection_type::begin(polygon_set);
Chris@16 144 }
Chris@16 145
Chris@16 146 static inline iterator_type end(const T& polygon_set) {
Chris@16 147 return indirection_type::end(polygon_set);
Chris@16 148 }
Chris@16 149
Chris@16 150 static inline orientation_2d orient(const T&) { return HORIZONTAL; }
Chris@16 151
Chris@16 152 static inline bool clean(const T&) { return false; }
Chris@16 153
Chris@16 154 static inline bool sorted(const T&) { return false; }
Chris@16 155 };
Chris@16 156
Chris@16 157 template <typename T>
Chris@16 158 struct is_manhattan_polygonal_concept { typedef gtl_no type; };
Chris@16 159 template <>
Chris@16 160 struct is_manhattan_polygonal_concept<rectangle_concept> { typedef gtl_yes type; };
Chris@16 161 template <>
Chris@16 162 struct is_manhattan_polygonal_concept<polygon_90_concept> { typedef gtl_yes type; };
Chris@16 163 template <>
Chris@16 164 struct is_manhattan_polygonal_concept<polygon_90_with_holes_concept> { typedef gtl_yes type; };
Chris@16 165 template <>
Chris@16 166 struct is_manhattan_polygonal_concept<polygon_90_set_concept> { typedef gtl_yes type; };
Chris@16 167
Chris@16 168 template <typename T>
Chris@16 169 struct is_polygon_90_set_type {
Chris@16 170 typedef typename is_manhattan_polygonal_concept<typename geometry_concept<T>::type>::type type;
Chris@16 171 };
Chris@16 172 template <typename T>
Chris@16 173 struct is_polygon_90_set_type<std::list<T> > {
Chris@16 174 typedef typename gtl_or<
Chris@16 175 typename is_manhattan_polygonal_concept<typename geometry_concept<std::list<T> >::type>::type,
Chris@16 176 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
Chris@16 177 };
Chris@16 178 template <typename T>
Chris@16 179 struct is_polygon_90_set_type<std::vector<T> > {
Chris@16 180 typedef typename gtl_or<
Chris@16 181 typename is_manhattan_polygonal_concept<typename geometry_concept<std::vector<T> >::type>::type,
Chris@16 182 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
Chris@16 183 };
Chris@16 184
Chris@16 185 template <typename T>
Chris@16 186 struct is_mutable_polygon_90_set_type {
Chris@16 187 typedef typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<T>::type>::type type;
Chris@16 188 };
Chris@16 189 template <typename T>
Chris@16 190 struct is_mutable_polygon_90_set_type<std::list<T> > {
Chris@16 191 typedef typename gtl_or<
Chris@16 192 typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::list<T> >::type>::type,
Chris@16 193 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
Chris@16 194 };
Chris@16 195 template <typename T>
Chris@16 196 struct is_mutable_polygon_90_set_type<std::vector<T> > {
Chris@16 197 typedef typename gtl_or<
Chris@16 198 typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::vector<T> >::type>::type,
Chris@16 199 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
Chris@16 200 };
Chris@16 201
Chris@16 202 // //specialization for rectangle, polygon_90 and polygon_90_with_holes types
Chris@16 203 // template <typename T>
Chris@16 204 // struct polygon_90_set_traits
Chris@16 205 // typedef typename geometry_concept<T>::type concept_type;
Chris@16 206 // typedef typename get_coordinate_type<T, concept_type>::type coordinate_type;
Chris@16 207 // typedef iterator_geometry_to_set<concept_type, T> iterator_type;
Chris@16 208 // typedef T operator_arg_type;
Chris@16 209
Chris@16 210 // static inline iterator_type begin(const T& polygon_set) {
Chris@16 211 // return iterator_geometry_to_set<concept_type, T>(polygon_set, LOW, HORIZONTAL);
Chris@16 212 // }
Chris@16 213
Chris@16 214 // static inline iterator_type end(const T& polygon_set) {
Chris@16 215 // return iterator_geometry_to_set<concept_type, T>(polygon_set, HIGH, HORIZONTAL);
Chris@16 216 // }
Chris@16 217
Chris@16 218 // static inline orientation_2d orient(const T& polygon_set) { return HORIZONTAL; }
Chris@16 219
Chris@16 220 // static inline bool clean(const T& polygon_set) { return false; }
Chris@16 221
Chris@16 222 // static inline bool sorted(const T& polygon_set) { return false; }
Chris@16 223
Chris@16 224 // };
Chris@16 225
Chris@16 226 // //specialization for containers of recangle, polygon_90, polygon_90_with_holes
Chris@16 227 // template <typename T>
Chris@16 228 // struct polygon_90_set_traits<T, typename is_manhattan_polygonal_concept<typename std::iterator_traits<typename T::iterator>::value_type>::type> {
Chris@16 229 // typedef typename std::iterator_traits<typename T::iterator>::value_type geometry_type;
Chris@16 230 // typedef typename geometry_concept<geometry_type>::type concept_type;
Chris@16 231 // typedef typename get_coordinate_type<geometry_type, concept_type>::type coordinate_type;
Chris@16 232 // typedef iterator_geometry_range_to_set<concept_type, typename T::const_iterator> iterator_type;
Chris@16 233 // typedef T operator_arg_type;
Chris@16 234
Chris@16 235 // static inline iterator_type begin(const T& polygon_set) {
Chris@16 236 // return iterator_type(polygon_set.begin(), HORIZONTAL);
Chris@16 237 // }
Chris@16 238
Chris@16 239 // static inline iterator_type end(const T& polygon_set) {
Chris@16 240 // return iterator_type(polygon_set.end(), HORIZONTAL);
Chris@16 241 // }
Chris@16 242
Chris@16 243 // static inline orientation_2d orient(const T& polygon_set) { return HORIZONTAL; }
Chris@16 244
Chris@16 245 // static inline bool clean(const T& polygon_set) { return false; }
Chris@16 246
Chris@16 247 // static inline bool sorted(const T& polygon_set) { return false; }
Chris@16 248
Chris@16 249 // };
Chris@16 250
Chris@16 251 //get dispatch functions
Chris@16 252 template <typename output_container_type, typename pst>
Chris@16 253 void get_90_dispatch(output_container_type& output, const pst& ps,
Chris@16 254 orientation_2d orient, rectangle_concept ) {
Chris@16 255 form_rectangles(output, ps.begin(), ps.end(), orient, rectangle_concept());
Chris@16 256 }
Chris@16 257
Chris@16 258 template <typename output_container_type, typename pst>
Chris@16 259 void get_90_dispatch(output_container_type& output, const pst& ps,
Chris@16 260 orientation_2d orient, polygon_90_concept tag) {
Chris@16 261 get_polygons(output, ps.begin(), ps.end(), orient, true, tag);
Chris@16 262 }
Chris@16 263
Chris@16 264 template <typename output_container_type, typename pst>
Chris@16 265 void get_90_dispatch(output_container_type& output, const pst& ps,
Chris@16 266 orientation_2d orient, polygon_90_with_holes_concept tag) {
Chris@16 267 get_polygons(output, ps.begin(), ps.end(), orient, false, tag);
Chris@16 268 }
Chris@16 269
Chris@16 270 //by default works with containers of rectangle, polygon or polygon with holes
Chris@16 271 //must be specialized to work with anything else
Chris@16 272 template <typename T>
Chris@16 273 struct polygon_90_set_mutable_traits {};
Chris@16 274 template <typename T>
Chris@16 275 struct polygon_90_set_mutable_traits<std::list<T> > {
Chris@16 276 typedef typename geometry_concept<T>::type concept_type;
Chris@16 277 template <typename input_iterator_type>
Chris@16 278 static inline void set(std::list<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end, orientation_2d orient) {
Chris@16 279 polygon_set.clear();
Chris@16 280 polygon_90_set_data<typename polygon_90_set_traits<std::list<T> >::coordinate_type> ps(orient);
Chris@16 281 ps.reserve(std::distance(input_begin, input_end));
Chris@16 282 ps.insert(input_begin, input_end, orient);
Chris@16 283 ps.clean();
Chris@16 284 get_90_dispatch(polygon_set, ps, orient, concept_type());
Chris@16 285 }
Chris@16 286 };
Chris@16 287 template <typename T>
Chris@16 288 struct polygon_90_set_mutable_traits<std::vector<T> > {
Chris@16 289 typedef typename geometry_concept<T>::type concept_type;
Chris@16 290 template <typename input_iterator_type>
Chris@16 291 static inline void set(std::vector<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end, orientation_2d orient) {
Chris@16 292 polygon_set.clear();
Chris@16 293 size_t num_ele = std::distance(input_begin, input_end);
Chris@16 294 polygon_set.reserve(num_ele);
Chris@16 295 polygon_90_set_data<typename polygon_90_set_traits<std::list<T> >::coordinate_type> ps(orient);
Chris@16 296 ps.reserve(num_ele);
Chris@16 297 ps.insert(input_begin, input_end, orient);
Chris@16 298 ps.clean();
Chris@16 299 get_90_dispatch(polygon_set, ps, orient, concept_type());
Chris@16 300 }
Chris@16 301 };
Chris@16 302
Chris@16 303 template <typename T>
Chris@16 304 struct polygon_90_set_mutable_traits<polygon_90_set_data<T> > {
Chris@16 305
Chris@16 306 template <typename input_iterator_type>
Chris@16 307 static inline void set(polygon_90_set_data<T>& polygon_set,
Chris@16 308 input_iterator_type input_begin, input_iterator_type input_end,
Chris@16 309 orientation_2d orient) {
Chris@16 310 polygon_set.clear();
Chris@16 311 polygon_set.reserve(std::distance(input_begin, input_end));
Chris@16 312 polygon_set.insert(input_begin, input_end, orient);
Chris@16 313 }
Chris@16 314
Chris@16 315 };
Chris@16 316
Chris@16 317 template <typename T>
Chris@16 318 struct polygon_90_set_traits<polygon_90_set_data<T> > {
Chris@16 319 typedef typename polygon_90_set_data<T>::coordinate_type coordinate_type;
Chris@16 320 typedef typename polygon_90_set_data<T>::iterator_type iterator_type;
Chris@16 321 typedef typename polygon_90_set_data<T>::operator_arg_type operator_arg_type;
Chris@16 322
Chris@16 323 static inline iterator_type begin(const polygon_90_set_data<T>& polygon_set) {
Chris@16 324 return polygon_set.begin();
Chris@16 325 }
Chris@16 326
Chris@16 327 static inline iterator_type end(const polygon_90_set_data<T>& polygon_set) {
Chris@16 328 return polygon_set.end();
Chris@16 329 }
Chris@16 330
Chris@16 331 static inline orientation_2d orient(const polygon_90_set_data<T>& polygon_set) { return polygon_set.orient(); }
Chris@16 332
Chris@16 333 static inline bool clean(const polygon_90_set_data<T>& polygon_set) { polygon_set.clean(); return true; }
Chris@16 334
Chris@16 335 static inline bool sorted(const polygon_90_set_data<T>& polygon_set) { polygon_set.sort(); return true; }
Chris@16 336
Chris@16 337 };
Chris@16 338
Chris@16 339 template <typename T>
Chris@16 340 struct is_polygon_90_set_concept { };
Chris@16 341 template <>
Chris@16 342 struct is_polygon_90_set_concept<polygon_90_set_concept> { typedef gtl_yes type; };
Chris@16 343 template <>
Chris@16 344 struct is_polygon_90_set_concept<rectangle_concept> { typedef gtl_yes type; };
Chris@16 345 template <>
Chris@16 346 struct is_polygon_90_set_concept<polygon_90_concept> { typedef gtl_yes type; };
Chris@16 347 template <>
Chris@16 348 struct is_polygon_90_set_concept<polygon_90_with_holes_concept> { typedef gtl_yes type; };
Chris@16 349
Chris@16 350 template <typename T>
Chris@16 351 struct is_mutable_polygon_90_set_concept { typedef gtl_no type; };
Chris@16 352 template <>
Chris@16 353 struct is_mutable_polygon_90_set_concept<polygon_90_set_concept> { typedef gtl_yes type; };
Chris@16 354
Chris@16 355 template <typename T>
Chris@16 356 struct geometry_concept<polygon_90_set_data<T> > { typedef polygon_90_set_concept type; };
Chris@16 357
Chris@16 358 //template <typename T>
Chris@16 359 //typename enable_if<typename is_polygon_90_set_type<T>::type, void>::type
Chris@16 360 //print_is_polygon_90_set_concept(const T& t) { std::cout << "is polygon 90 set concept\n"; }
Chris@16 361 //template <typename T>
Chris@16 362 //typename enable_if<typename is_mutable_polygon_90_set_type<T>::type, void>::type
Chris@16 363 //print_is_mutable_polygon_90_set_concept(const T& t) { std::cout << "is mutable polygon 90 set concept\n"; }
Chris@16 364 }
Chris@16 365 }
Chris@16 366 #endif