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_TRAITS_HPP
|
Chris@16
|
9 #define BOOST_POLYGON_POLYGON_45_SET_TRAITS_HPP
|
Chris@16
|
10 namespace boost { namespace polygon{
|
Chris@16
|
11
|
Chris@16
|
12 //default definition of polygon 45 set traits works for any model of polygon 45, polygon 45 with holes or any vector or list thereof
|
Chris@16
|
13 template <typename T>
|
Chris@16
|
14 struct polygon_45_set_traits {
|
Chris@16
|
15 typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
|
Chris@16
|
16 typedef typename get_iterator_type<T>::type iterator_type;
|
Chris@16
|
17 typedef T operator_arg_type;
|
Chris@16
|
18
|
Chris@16
|
19 static inline iterator_type begin(const T& polygon_set) {
|
Chris@16
|
20 return get_iterator_type<T>::begin(polygon_set);
|
Chris@16
|
21 }
|
Chris@16
|
22
|
Chris@16
|
23 static inline iterator_type end(const T& polygon_set) {
|
Chris@16
|
24 return get_iterator_type<T>::end(polygon_set);
|
Chris@16
|
25 }
|
Chris@16
|
26
|
Chris@16
|
27 static inline bool clean(const T& ) { return false; }
|
Chris@16
|
28
|
Chris@16
|
29 static inline bool sorted(const T& ) { return false; }
|
Chris@16
|
30 };
|
Chris@16
|
31
|
Chris@16
|
32 template <typename T>
|
Chris@16
|
33 struct is_45_polygonal_concept { typedef gtl_no type; };
|
Chris@16
|
34 template <>
|
Chris@16
|
35 struct is_45_polygonal_concept<polygon_45_concept> { typedef gtl_yes type; };
|
Chris@16
|
36 template <>
|
Chris@16
|
37 struct is_45_polygonal_concept<polygon_45_with_holes_concept> { typedef gtl_yes type; };
|
Chris@16
|
38 template <>
|
Chris@16
|
39 struct is_45_polygonal_concept<polygon_45_set_concept> { typedef gtl_yes type; };
|
Chris@16
|
40
|
Chris@16
|
41 template <typename T>
|
Chris@16
|
42 struct is_polygon_45_set_type {
|
Chris@16
|
43 typedef typename is_45_polygonal_concept<typename geometry_concept<T>::type>::type type;
|
Chris@16
|
44 };
|
Chris@16
|
45 template <typename T>
|
Chris@16
|
46 struct is_polygon_45_set_type<std::list<T> > {
|
Chris@16
|
47 typedef typename gtl_or<
|
Chris@16
|
48 typename is_45_polygonal_concept<typename geometry_concept<std::list<T> >::type>::type,
|
Chris@16
|
49 typename is_45_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
|
Chris@16
|
50 };
|
Chris@16
|
51 template <typename T>
|
Chris@16
|
52 struct is_polygon_45_set_type<std::vector<T> > {
|
Chris@16
|
53 typedef typename gtl_or<
|
Chris@16
|
54 typename is_45_polygonal_concept<typename geometry_concept<std::vector<T> >::type>::type,
|
Chris@16
|
55 typename is_45_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
|
Chris@16
|
56 };
|
Chris@16
|
57
|
Chris@16
|
58 template <typename T>
|
Chris@16
|
59 struct is_mutable_polygon_45_set_type {
|
Chris@16
|
60 typedef typename gtl_same_type<polygon_45_set_concept, typename geometry_concept<T>::type>::type type;
|
Chris@16
|
61 };
|
Chris@16
|
62 template <typename T>
|
Chris@16
|
63 struct is_mutable_polygon_45_set_type<std::list<T> > {
|
Chris@16
|
64 typedef typename gtl_or<
|
Chris@16
|
65 typename gtl_same_type<polygon_45_set_concept, typename geometry_concept<std::list<T> >::type>::type,
|
Chris@16
|
66 typename is_45_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
|
Chris@16
|
67 };
|
Chris@16
|
68 template <typename T>
|
Chris@16
|
69 struct is_mutable_polygon_45_set_type<std::vector<T> > {
|
Chris@16
|
70 typedef typename gtl_or<
|
Chris@16
|
71 typename gtl_same_type<polygon_45_set_concept, typename geometry_concept<std::vector<T> >::type>::type,
|
Chris@16
|
72 typename is_45_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
|
Chris@16
|
73 };
|
Chris@16
|
74
|
Chris@16
|
75 template <typename T>
|
Chris@16
|
76 bool fracture_holes_45_by_concept() { return false; }
|
Chris@16
|
77 template <>
|
Chris@16
|
78 inline bool fracture_holes_45_by_concept<polygon_45_concept>() { return true; }
|
Chris@16
|
79
|
Chris@16
|
80 template <typename T, typename iT>
|
Chris@16
|
81 void get_45_polygons_T(T& t, iT begin, iT end) {
|
Chris@16
|
82 typedef typename polygon_45_set_traits<T>::coordinate_type Unit;
|
Chris@16
|
83 typedef typename geometry_concept<typename T::value_type>::type CType;
|
Chris@16
|
84 typename polygon_45_formation<Unit>::Polygon45Formation pf(fracture_holes_45_by_concept<CType>());
|
Chris@16
|
85 //std::cout << "FORMING POLYGONS\n";
|
Chris@16
|
86 pf.scan(t, begin, end);
|
Chris@16
|
87 }
|
Chris@16
|
88
|
Chris@16
|
89 template <typename T>
|
Chris@16
|
90 struct polygon_45_set_mutable_traits {};
|
Chris@16
|
91 template <typename T>
|
Chris@16
|
92 struct polygon_45_set_mutable_traits<std::list<T> > {
|
Chris@16
|
93 template <typename input_iterator_type>
|
Chris@16
|
94 static inline void set(std::list<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) {
|
Chris@16
|
95 polygon_set.clear();
|
Chris@16
|
96 polygon_45_set_data<typename polygon_45_set_traits<std::list<T> >::coordinate_type> ps;
|
Chris@16
|
97 ps.reserve(std::distance(input_begin, input_end));
|
Chris@16
|
98 ps.insert(input_begin, input_end);
|
Chris@16
|
99 ps.sort();
|
Chris@16
|
100 ps.clean();
|
Chris@16
|
101 get_45_polygons_T(polygon_set, ps.begin(), ps.end());
|
Chris@16
|
102 }
|
Chris@16
|
103 };
|
Chris@16
|
104 template <typename T>
|
Chris@16
|
105 struct polygon_45_set_mutable_traits<std::vector<T> > {
|
Chris@16
|
106 template <typename input_iterator_type>
|
Chris@16
|
107 static inline void set(std::vector<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) {
|
Chris@16
|
108 polygon_set.clear();
|
Chris@16
|
109 size_t num_ele = std::distance(input_begin, input_end);
|
Chris@16
|
110 polygon_set.reserve(num_ele);
|
Chris@16
|
111 polygon_45_set_data<typename polygon_45_set_traits<std::list<T> >::coordinate_type> ps;
|
Chris@16
|
112 ps.reserve(num_ele);
|
Chris@16
|
113 ps.insert(input_begin, input_end);
|
Chris@16
|
114 ps.sort();
|
Chris@16
|
115 ps.clean();
|
Chris@16
|
116 get_45_polygons_T(polygon_set, ps.begin(), ps.end());
|
Chris@16
|
117 }
|
Chris@16
|
118 };
|
Chris@16
|
119
|
Chris@16
|
120 template <typename T>
|
Chris@16
|
121 struct polygon_45_set_mutable_traits<polygon_45_set_data<T> > {
|
Chris@16
|
122 template <typename input_iterator_type>
|
Chris@16
|
123 static inline void set(polygon_45_set_data<T>& polygon_set,
|
Chris@16
|
124 input_iterator_type input_begin, input_iterator_type input_end) {
|
Chris@16
|
125 polygon_set.set(input_begin, input_end);
|
Chris@16
|
126 }
|
Chris@16
|
127 };
|
Chris@16
|
128 template <typename T>
|
Chris@16
|
129 struct polygon_45_set_traits<polygon_45_set_data<T> > {
|
Chris@16
|
130 typedef typename polygon_45_set_data<T>::coordinate_type coordinate_type;
|
Chris@16
|
131 typedef typename polygon_45_set_data<T>::iterator_type iterator_type;
|
Chris@16
|
132 typedef typename polygon_45_set_data<T>::operator_arg_type operator_arg_type;
|
Chris@16
|
133
|
Chris@16
|
134 static inline iterator_type begin(const polygon_45_set_data<T>& polygon_set) {
|
Chris@16
|
135 return polygon_set.begin();
|
Chris@16
|
136 }
|
Chris@16
|
137
|
Chris@16
|
138 static inline iterator_type end(const polygon_45_set_data<T>& polygon_set) {
|
Chris@16
|
139 return polygon_set.end();
|
Chris@16
|
140 }
|
Chris@16
|
141
|
Chris@16
|
142 static inline bool clean(const polygon_45_set_data<T>& polygon_set) { polygon_set.clean(); return true; }
|
Chris@16
|
143
|
Chris@16
|
144 static inline bool sorted(const polygon_45_set_data<T>& polygon_set) { polygon_set.sort(); return true; }
|
Chris@16
|
145
|
Chris@16
|
146 };
|
Chris@16
|
147 }
|
Chris@16
|
148 }
|
Chris@16
|
149 #endif
|