File indexing completed on 2025-01-18 09:48:01
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_POLYGON_POLYGON_90_SET_TRAITS_HPP
0009 #define BOOST_POLYGON_POLYGON_90_SET_TRAITS_HPP
0010 namespace boost { namespace polygon{
0011
0012 struct polygon_90_set_concept {};
0013
0014 template <typename T, typename T2>
0015 struct traits_by_concept {};
0016 template <typename T>
0017 struct traits_by_concept<T, coordinate_concept> { typedef coordinate_traits<T> type; };
0018 template <typename T>
0019 struct traits_by_concept<T, interval_concept> { typedef interval_traits<T> type; };
0020 template <typename T>
0021 struct traits_by_concept<T, point_concept> { typedef point_traits<T> type; };
0022 template <typename T>
0023 struct traits_by_concept<T, rectangle_concept> { typedef rectangle_traits<T> type; };
0024 template <typename T>
0025 struct traits_by_concept<T, segment_concept> { typedef segment_traits<T> type; };
0026 template <typename T>
0027 struct traits_by_concept<T, polygon_90_concept> { typedef polygon_traits<T> type; };
0028 template <typename T>
0029 struct traits_by_concept<T, polygon_90_with_holes_concept> { typedef polygon_traits<T> type; };
0030 template <typename T>
0031 struct traits_by_concept<T, polygon_45_concept> { typedef polygon_traits<T> type; };
0032 template <typename T>
0033 struct traits_by_concept<T, polygon_45_with_holes_concept> { typedef polygon_traits<T> type; };
0034 template <typename T>
0035 struct traits_by_concept<T, polygon_concept> { typedef polygon_traits<T> type; };
0036 template <typename T>
0037 struct traits_by_concept<T, polygon_with_holes_concept> { typedef polygon_traits<T> type; };
0038
0039 struct polygon_45_set_concept;
0040 struct polygon_set_concept;
0041 template <typename T>
0042 struct polygon_90_set_traits;
0043 template <typename T>
0044 struct polygon_45_set_traits;
0045 template <typename T>
0046 struct polygon_set_traits;
0047 template <typename T>
0048 struct traits_by_concept<T, polygon_90_set_concept> { typedef polygon_90_set_traits<T> type; };
0049 template <typename T>
0050 struct traits_by_concept<T, polygon_45_set_concept> { typedef polygon_45_set_traits<T> type; };
0051 template <typename T>
0052 struct traits_by_concept<T, polygon_set_concept> { typedef polygon_set_traits<T> type; };
0053
0054 template <typename T, typename T2>
0055 struct get_coordinate_type {
0056 typedef typename traits_by_concept<T, T2>::type traits_type;
0057 typedef typename traits_type::coordinate_type type;
0058 };
0059
0060 template <typename T, typename T2>
0061 struct get_coordinate_type_2 {
0062 typedef typename traits_by_concept<T, T2>::type traits_type;
0063 typedef typename traits_type::coordinate_type type;
0064 };
0065 template <typename T>
0066 struct get_coordinate_type<T, undefined_concept> {
0067 typedef typename get_coordinate_type_2<typename std::iterator_traits
0068 <typename T::iterator>::value_type,
0069 typename geometry_concept<typename std::iterator_traits
0070 <typename T::iterator>::value_type>::type>::type type; };
0071
0072 template <typename T, typename T2>
0073 struct get_iterator_type_2 {
0074 typedef const T* type;
0075 static type begin(const T& t) { return &t; }
0076 static type end(const T& t) { const T* tp = &t; ++tp; return tp; }
0077 };
0078 template <typename T>
0079 struct get_iterator_type {
0080 typedef get_iterator_type_2<T, typename geometry_concept<T>::type> indirect_type;
0081 typedef typename indirect_type::type type;
0082 static type begin(const T& t) { return indirect_type::begin(t); }
0083 static type end(const T& t) { return indirect_type::end(t); }
0084 };
0085 template <typename T>
0086 struct get_iterator_type_2<T, undefined_concept> {
0087 typedef typename T::const_iterator type;
0088 static type begin(const T& t) { return t.begin(); }
0089 static type end(const T& t) { return t.end(); }
0090 };
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 template <typename T>
0136 struct polygon_90_set_traits {
0137 typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
0138 typedef get_iterator_type<T> indirection_type;
0139 typedef typename get_iterator_type<T>::type iterator_type;
0140 typedef T operator_arg_type;
0141
0142 static inline iterator_type begin(const T& polygon_set) {
0143 return indirection_type::begin(polygon_set);
0144 }
0145
0146 static inline iterator_type end(const T& polygon_set) {
0147 return indirection_type::end(polygon_set);
0148 }
0149
0150 static inline orientation_2d orient(const T&) { return HORIZONTAL; }
0151
0152 static inline bool clean(const T&) { return false; }
0153
0154 static inline bool sorted(const T&) { return false; }
0155 };
0156
0157 template <typename T>
0158 struct is_manhattan_polygonal_concept { typedef gtl_no type; };
0159 template <>
0160 struct is_manhattan_polygonal_concept<rectangle_concept> { typedef gtl_yes type; };
0161 template <>
0162 struct is_manhattan_polygonal_concept<polygon_90_concept> { typedef gtl_yes type; };
0163 template <>
0164 struct is_manhattan_polygonal_concept<polygon_90_with_holes_concept> { typedef gtl_yes type; };
0165 template <>
0166 struct is_manhattan_polygonal_concept<polygon_90_set_concept> { typedef gtl_yes type; };
0167
0168 template <typename T>
0169 struct is_polygon_90_set_type {
0170 typedef typename is_manhattan_polygonal_concept<typename geometry_concept<T>::type>::type type;
0171 };
0172 template <typename T>
0173 struct is_polygon_90_set_type<std::list<T> > {
0174 typedef typename gtl_or<
0175 typename is_manhattan_polygonal_concept<typename geometry_concept<std::list<T> >::type>::type,
0176 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
0177 };
0178 template <typename T>
0179 struct is_polygon_90_set_type<std::vector<T> > {
0180 typedef typename gtl_or<
0181 typename is_manhattan_polygonal_concept<typename geometry_concept<std::vector<T> >::type>::type,
0182 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
0183 };
0184
0185 template <typename T>
0186 struct is_mutable_polygon_90_set_type {
0187 typedef typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<T>::type>::type type;
0188 };
0189 template <typename T>
0190 struct is_mutable_polygon_90_set_type<std::list<T> > {
0191 typedef typename gtl_or<
0192 typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::list<T> >::type>::type,
0193 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
0194 };
0195 template <typename T>
0196 struct is_mutable_polygon_90_set_type<std::vector<T> > {
0197 typedef typename gtl_or<
0198 typename gtl_same_type<polygon_90_set_concept, typename geometry_concept<std::vector<T> >::type>::type,
0199 typename is_manhattan_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
0200 };
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 template <typename output_container_type, typename pst>
0253 void get_90_dispatch(output_container_type& output, const pst& ps,
0254 orientation_2d orient, rectangle_concept ) {
0255 form_rectangles(output, ps.begin(), ps.end(), orient, rectangle_concept());
0256 }
0257
0258 template <typename output_container_type, typename pst>
0259 void get_90_dispatch(output_container_type& output, const pst& ps,
0260 orientation_2d orient, polygon_90_concept tag) {
0261 get_polygons(output, ps.begin(), ps.end(), orient, true, tag);
0262 }
0263
0264 template <typename output_container_type, typename pst>
0265 void get_90_dispatch(output_container_type& output, const pst& ps,
0266 orientation_2d orient, polygon_90_with_holes_concept tag) {
0267 get_polygons(output, ps.begin(), ps.end(), orient, false, tag);
0268 }
0269
0270
0271
0272 template <typename T>
0273 struct polygon_90_set_mutable_traits {};
0274 template <typename T>
0275 struct polygon_90_set_mutable_traits<std::list<T> > {
0276 typedef typename geometry_concept<T>::type concept_type;
0277 template <typename input_iterator_type>
0278 static inline void set(std::list<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end, orientation_2d orient) {
0279 polygon_set.clear();
0280 polygon_90_set_data<typename polygon_90_set_traits<std::list<T> >::coordinate_type> ps(orient);
0281 ps.reserve(std::distance(input_begin, input_end));
0282 ps.insert(input_begin, input_end, orient);
0283 ps.clean();
0284 get_90_dispatch(polygon_set, ps, orient, concept_type());
0285 }
0286 };
0287 template <typename T>
0288 struct polygon_90_set_mutable_traits<std::vector<T> > {
0289 typedef typename geometry_concept<T>::type concept_type;
0290 template <typename input_iterator_type>
0291 static inline void set(std::vector<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end, orientation_2d orient) {
0292 polygon_set.clear();
0293 size_t num_ele = std::distance(input_begin, input_end);
0294 polygon_set.reserve(num_ele);
0295 polygon_90_set_data<typename polygon_90_set_traits<std::list<T> >::coordinate_type> ps(orient);
0296 ps.reserve(num_ele);
0297 ps.insert(input_begin, input_end, orient);
0298 ps.clean();
0299 get_90_dispatch(polygon_set, ps, orient, concept_type());
0300 }
0301 };
0302
0303 template <typename T>
0304 struct polygon_90_set_mutable_traits<polygon_90_set_data<T> > {
0305
0306 template <typename input_iterator_type>
0307 static inline void set(polygon_90_set_data<T>& polygon_set,
0308 input_iterator_type input_begin, input_iterator_type input_end,
0309 orientation_2d orient) {
0310 polygon_set.clear();
0311 polygon_set.reserve(std::distance(input_begin, input_end));
0312 polygon_set.insert(input_begin, input_end, orient);
0313 }
0314
0315 };
0316
0317 template <typename T>
0318 struct polygon_90_set_traits<polygon_90_set_data<T> > {
0319 typedef typename polygon_90_set_data<T>::coordinate_type coordinate_type;
0320 typedef typename polygon_90_set_data<T>::iterator_type iterator_type;
0321 typedef typename polygon_90_set_data<T>::operator_arg_type operator_arg_type;
0322
0323 static inline iterator_type begin(const polygon_90_set_data<T>& polygon_set) {
0324 return polygon_set.begin();
0325 }
0326
0327 static inline iterator_type end(const polygon_90_set_data<T>& polygon_set) {
0328 return polygon_set.end();
0329 }
0330
0331 static inline orientation_2d orient(const polygon_90_set_data<T>& polygon_set) { return polygon_set.orient(); }
0332
0333 static inline bool clean(const polygon_90_set_data<T>& polygon_set) { polygon_set.clean(); return true; }
0334
0335 static inline bool sorted(const polygon_90_set_data<T>& polygon_set) { polygon_set.sort(); return true; }
0336
0337 };
0338
0339 template <typename T>
0340 struct is_polygon_90_set_concept { };
0341 template <>
0342 struct is_polygon_90_set_concept<polygon_90_set_concept> { typedef gtl_yes type; };
0343 template <>
0344 struct is_polygon_90_set_concept<rectangle_concept> { typedef gtl_yes type; };
0345 template <>
0346 struct is_polygon_90_set_concept<polygon_90_concept> { typedef gtl_yes type; };
0347 template <>
0348 struct is_polygon_90_set_concept<polygon_90_with_holes_concept> { typedef gtl_yes type; };
0349
0350 template <typename T>
0351 struct is_mutable_polygon_90_set_concept { typedef gtl_no type; };
0352 template <>
0353 struct is_mutable_polygon_90_set_concept<polygon_90_set_concept> { typedef gtl_yes type; };
0354
0355 template <typename T>
0356 struct geometry_concept<polygon_90_set_data<T> > { typedef polygon_90_set_concept type; };
0357
0358
0359
0360
0361
0362
0363
0364 }
0365 }
0366 #endif