annotate DEPENDENCIES/generic/include/boost/polygon/polygon_set_traits.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +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_SET_TRAITS_HPP
Chris@16 9 #define BOOST_POLYGON_POLYGON_SET_TRAITS_HPP
Chris@16 10 namespace boost { namespace polygon{
Chris@16 11
Chris@16 12 struct polygon_set_concept {};
Chris@16 13
Chris@16 14 //default definition of polygon set traits works for any model of polygon , polygon with holes or any vector or list thereof
Chris@16 15 template <typename T>
Chris@16 16 struct polygon_set_traits {
Chris@16 17 typedef typename get_coordinate_type<T, typename geometry_concept<T>::type >::type coordinate_type;
Chris@16 18 typedef typename get_iterator_type<T>::type iterator_type;
Chris@16 19 typedef T operator_arg_type;
Chris@16 20
Chris@16 21 static inline iterator_type begin(const T& polygon_set) {
Chris@16 22 return get_iterator_type<T>::begin(polygon_set);
Chris@16 23 }
Chris@16 24
Chris@16 25 static inline iterator_type end(const T& polygon_set) {
Chris@16 26 return get_iterator_type<T>::end(polygon_set);
Chris@16 27 }
Chris@16 28
Chris@16 29 static inline bool clean(const T& ) { return false; }
Chris@16 30
Chris@16 31 static inline bool sorted(const T& ) { return false; }
Chris@16 32 };
Chris@16 33
Chris@16 34 template <typename T>
Chris@16 35 struct is_polygonal_concept { typedef gtl_no type; };
Chris@16 36 template <>
Chris@16 37 struct is_polygonal_concept<polygon_concept> { typedef gtl_yes type; };
Chris@16 38 template <>
Chris@16 39 struct is_polygonal_concept<polygon_with_holes_concept> { typedef gtl_yes type; };
Chris@16 40 template <>
Chris@16 41 struct is_polygonal_concept<polygon_set_concept> { typedef gtl_yes type; };
Chris@16 42
Chris@16 43 template <typename T>
Chris@16 44 struct is_polygon_set_type {
Chris@16 45 typedef typename is_polygonal_concept<typename geometry_concept<T>::type>::type type;
Chris@16 46 };
Chris@16 47 template <typename T>
Chris@16 48 struct is_polygon_set_type<std::list<T> > {
Chris@16 49 typedef typename gtl_or<
Chris@16 50 typename is_polygonal_concept<typename geometry_concept<std::list<T> >::type>::type,
Chris@16 51 typename is_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
Chris@16 52 };
Chris@16 53 template <typename T>
Chris@16 54 struct is_polygon_set_type<std::vector<T> > {
Chris@16 55 typedef typename gtl_or<
Chris@16 56 typename is_polygonal_concept<typename geometry_concept<std::vector<T> >::type>::type,
Chris@16 57 typename is_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
Chris@16 58 };
Chris@16 59
Chris@16 60 template <typename T>
Chris@16 61 struct is_mutable_polygon_set_type {
Chris@16 62 typedef typename gtl_same_type<polygon_set_concept, typename geometry_concept<T>::type>::type type;
Chris@16 63 };
Chris@16 64 template <typename T>
Chris@16 65 struct is_mutable_polygon_set_type<std::list<T> > {
Chris@16 66 typedef typename gtl_or<
Chris@16 67 typename gtl_same_type<polygon_set_concept, typename geometry_concept<std::list<T> >::type>::type,
Chris@16 68 typename is_polygonal_concept<typename geometry_concept<typename std::list<T>::value_type>::type>::type>::type type;
Chris@16 69 };
Chris@16 70 template <typename T>
Chris@16 71 struct is_mutable_polygon_set_type<std::vector<T> > {
Chris@16 72 typedef typename gtl_or<
Chris@16 73 typename gtl_same_type<polygon_set_concept, typename geometry_concept<std::vector<T> >::type>::type,
Chris@16 74 typename is_polygonal_concept<typename geometry_concept<typename std::vector<T>::value_type>::type>::type>::type type;
Chris@16 75 };
Chris@16 76
Chris@16 77 template <typename T>
Chris@16 78 struct polygon_set_mutable_traits {};
Chris@16 79 template <typename T>
Chris@16 80 struct polygon_set_mutable_traits<std::list<T> > {
Chris@16 81 template <typename input_iterator_type>
Chris@16 82 static inline void set(std::list<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) {
Chris@16 83 polygon_set.clear();
Chris@16 84 polygon_set_data<typename polygon_set_traits<std::list<T> >::coordinate_type> ps;
Chris@16 85 ps.reserve(std::distance(input_begin, input_end));
Chris@16 86 ps.insert(input_begin, input_end);
Chris@16 87 ps.get(polygon_set);
Chris@16 88 }
Chris@16 89 };
Chris@16 90 template <typename T>
Chris@16 91 struct polygon_set_mutable_traits<std::vector<T> > {
Chris@16 92 template <typename input_iterator_type>
Chris@16 93 static inline void set(std::vector<T>& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) {
Chris@16 94 polygon_set.clear();
Chris@16 95 size_t num_ele = std::distance(input_begin, input_end);
Chris@16 96 polygon_set.reserve(num_ele);
Chris@16 97 polygon_set_data<typename polygon_set_traits<std::list<T> >::coordinate_type> ps;
Chris@16 98 ps.reserve(num_ele);
Chris@16 99 ps.insert(input_begin, input_end);
Chris@16 100 ps.get(polygon_set);
Chris@16 101 }
Chris@16 102 };
Chris@16 103
Chris@16 104 template <typename T>
Chris@16 105 struct polygon_set_mutable_traits<polygon_set_data<T> > {
Chris@16 106 template <typename input_iterator_type>
Chris@16 107 static inline void set(polygon_set_data<T>& polygon_set,
Chris@16 108 input_iterator_type input_begin, input_iterator_type input_end) {
Chris@16 109 polygon_set.set(input_begin, input_end);
Chris@16 110 }
Chris@16 111 };
Chris@16 112 template <typename T>
Chris@16 113 struct polygon_set_traits<polygon_set_data<T> > {
Chris@16 114 typedef typename polygon_set_data<T>::coordinate_type coordinate_type;
Chris@16 115 typedef typename polygon_set_data<T>::iterator_type iterator_type;
Chris@16 116 typedef typename polygon_set_data<T>::operator_arg_type operator_arg_type;
Chris@16 117
Chris@16 118 static inline iterator_type begin(const polygon_set_data<T>& polygon_set) {
Chris@16 119 return polygon_set.begin();
Chris@16 120 }
Chris@16 121
Chris@16 122 static inline iterator_type end(const polygon_set_data<T>& polygon_set) {
Chris@16 123 return polygon_set.end();
Chris@16 124 }
Chris@16 125
Chris@16 126 static inline bool clean(const polygon_set_data<T>& polygon_set) { polygon_set.clean(); return true; }
Chris@16 127
Chris@16 128 static inline bool sorted(const polygon_set_data<T>& polygon_set) { polygon_set.sort(); return true; }
Chris@16 129
Chris@16 130 };
Chris@16 131 }
Chris@16 132 }
Chris@16 133 #endif