2 Copyright 2008 Intel Corporation
4 Use, modification and distribution are subject to the Boost Software License,
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
8 #ifndef BOOST_POLYGON_POLYGON_45_SET_TRAITS_HPP
9 #define BOOST_POLYGON_POLYGON_45_SET_TRAITS_HPP
10 namespace boost { namespace polygon{
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
14 struct polygon_45_set_traits {
15 typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
16 typedef typename get_iterator_type<T>::type iterator_type;
17 typedef T operator_arg_type;
19 static inline iterator_type begin(const T& polygon_set) {
20 return get_iterator_type<T>::begin(polygon_set);
23 static inline iterator_type end(const T& polygon_set) {
24 return get_iterator_type<T>::end(polygon_set);
27 static inline bool clean(const T& ) { return false; }
29 static inline bool sorted(const T& ) { return false; }
33 struct is_45_polygonal_concept { typedef gtl_no type; };
35 struct is_45_polygonal_concept<polygon_45_concept> { typedef gtl_yes type; };
37 struct is_45_polygonal_concept<polygon_45_with_holes_concept> { typedef gtl_yes type; };
39 struct is_45_polygonal_concept<polygon_45_set_concept> { typedef gtl_yes type; };
42 struct is_polygon_45_set_type {
43 typedef typename is_45_polygonal_concept<typename geometry_concept<T>::type>::type type;
46 struct is_polygon_45_set_type<std::list<T> > {
47 typedef typename gtl_or<
48 typename is_45_polygonal_concept<typename geometry_concept<std::list<T> >::type>::type,
49 typename is_45_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
52 struct is_polygon_45_set_type<std::vector<T> > {
53 typedef typename gtl_or<
54 typename is_45_polygonal_concept<typename geometry_concept<std::vector<T> >::type>::type,
55 typename is_45_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
59 struct is_mutable_polygon_45_set_type {
60 typedef typename gtl_same_type<polygon_45_set_concept, typename geometry_concept<T>::type>::type type;
63 struct is_mutable_polygon_45_set_type<std::list<T> > {
64 typedef typename gtl_or<
65 typename gtl_same_type<polygon_45_set_concept, typename geometry_concept<std::list<T> >::type>::type,
66 typename is_45_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
69 struct is_mutable_polygon_45_set_type<std::vector<T> > {
70 typedef typename gtl_or<
71 typename gtl_same_type<polygon_45_set_concept, typename geometry_concept<std::vector<T> >::type>::type,
72 typename is_45_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
76 bool fracture_holes_45_by_concept() { return false; }
78 inline bool fracture_holes_45_by_concept<polygon_45_concept>() { return true; }
80 template <typename T, typename iT>
81 void get_45_polygons_T(T& t, iT begin, iT end) {
82 typedef typename polygon_45_set_traits<T>::coordinate_type Unit;
83 typedef typename geometry_concept<typename T::value_type>::type CType;
84 typename polygon_45_formation<Unit>::Polygon45Formation pf(fracture_holes_45_by_concept<CType>());
85 //std::cout << "FORMING POLYGONS\n";
86 pf.scan(t, begin, end);
90 struct polygon_45_set_mutable_traits {};
92 struct polygon_45_set_mutable_traits<std::list<T> > {
93 template <typename input_iterator_type>
94 static inline void set(std::list<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) {
96 polygon_45_set_data<typename polygon_45_set_traits<std::list<T> >::coordinate_type> ps;
97 ps.insert(input_begin, input_end);
100 get_45_polygons_T(polygon_set, ps.begin(), ps.end());
103 template <typename T>
104 struct polygon_45_set_mutable_traits<std::vector<T> > {
105 template <typename input_iterator_type>
106 static inline void set(std::vector<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) {
108 polygon_45_set_data<typename polygon_45_set_traits<std::list<T> >::coordinate_type> ps;
109 ps.insert(input_begin, input_end);
112 get_45_polygons_T(polygon_set, ps.begin(), ps.end());
116 template <typename T>
117 struct polygon_45_set_mutable_traits<polygon_45_set_data<T> > {
118 template <typename input_iterator_type>
119 static inline void set(polygon_45_set_data<T>& polygon_set,
120 input_iterator_type input_begin, input_iterator_type input_end) {
121 polygon_set.set(input_begin, input_end);
124 template <typename T>
125 struct polygon_45_set_traits<polygon_45_set_data<T> > {
126 typedef typename polygon_45_set_data<T>::coordinate_type coordinate_type;
127 typedef typename polygon_45_set_data<T>::iterator_type iterator_type;
128 typedef typename polygon_45_set_data<T>::operator_arg_type operator_arg_type;
130 static inline iterator_type begin(const polygon_45_set_data<T>& polygon_set) {
131 return polygon_set.begin();
134 static inline iterator_type end(const polygon_45_set_data<T>& polygon_set) {
135 return polygon_set.end();
138 static inline bool clean(const polygon_45_set_data<T>& polygon_set) { polygon_set.clean(); return true; }
140 static inline bool sorted(const polygon_45_set_data<T>& polygon_set) { polygon_set.sort(); return true; }