Chris@16: /* Chris@16: Copyright 2008 Intel Corporation Chris@16: Chris@16: Use, modification and distribution are subject to the Boost Software License, Chris@16: Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: http://www.boost.org/LICENSE_1_0.txt). Chris@16: */ Chris@16: #ifndef BOOST_POLYGON_POLYGON_SET_TRAITS_HPP Chris@16: #define BOOST_POLYGON_POLYGON_SET_TRAITS_HPP Chris@16: namespace boost { namespace polygon{ Chris@16: Chris@16: struct polygon_set_concept {}; Chris@16: Chris@16: //default definition of polygon set traits works for any model of polygon , polygon with holes or any vector or list thereof Chris@16: template Chris@16: struct polygon_set_traits { Chris@16: typedef typename get_coordinate_type::type >::type coordinate_type; Chris@16: typedef typename get_iterator_type::type iterator_type; Chris@16: typedef T operator_arg_type; Chris@16: Chris@16: static inline iterator_type begin(const T& polygon_set) { Chris@16: return get_iterator_type::begin(polygon_set); Chris@16: } Chris@16: Chris@16: static inline iterator_type end(const T& polygon_set) { Chris@16: return get_iterator_type::end(polygon_set); Chris@16: } Chris@16: Chris@16: static inline bool clean(const T& ) { return false; } Chris@16: Chris@16: static inline bool sorted(const T& ) { return false; } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct is_polygonal_concept { typedef gtl_no type; }; Chris@16: template <> Chris@16: struct is_polygonal_concept { typedef gtl_yes type; }; Chris@16: template <> Chris@16: struct is_polygonal_concept { typedef gtl_yes type; }; Chris@16: template <> Chris@16: struct is_polygonal_concept { typedef gtl_yes type; }; Chris@16: Chris@16: template Chris@16: struct is_polygon_set_type { Chris@16: typedef typename is_polygonal_concept::type>::type type; Chris@16: }; Chris@16: template Chris@16: struct is_polygon_set_type > { Chris@16: typedef typename gtl_or< Chris@16: typename is_polygonal_concept >::type>::type, Chris@16: typename is_polygonal_concept::value_type>::type>::type>::type type; Chris@16: }; Chris@16: template Chris@16: struct is_polygon_set_type > { Chris@16: typedef typename gtl_or< Chris@16: typename is_polygonal_concept >::type>::type, Chris@16: typename is_polygonal_concept::value_type>::type>::type>::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct is_mutable_polygon_set_type { Chris@16: typedef typename gtl_same_type::type>::type type; Chris@16: }; Chris@16: template Chris@16: struct is_mutable_polygon_set_type > { Chris@16: typedef typename gtl_or< Chris@16: typename gtl_same_type >::type>::type, Chris@16: typename is_polygonal_concept::value_type>::type>::type>::type type; Chris@16: }; Chris@16: template Chris@16: struct is_mutable_polygon_set_type > { Chris@16: typedef typename gtl_or< Chris@16: typename gtl_same_type >::type>::type, Chris@16: typename is_polygonal_concept::value_type>::type>::type>::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct polygon_set_mutable_traits {}; Chris@16: template Chris@16: struct polygon_set_mutable_traits > { Chris@16: template Chris@16: static inline void set(std::list& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) { Chris@16: polygon_set.clear(); Chris@16: polygon_set_data >::coordinate_type> ps; Chris@16: ps.reserve(std::distance(input_begin, input_end)); Chris@16: ps.insert(input_begin, input_end); Chris@16: ps.get(polygon_set); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct polygon_set_mutable_traits > { Chris@16: template Chris@16: static inline void set(std::vector& polygon_set, input_iterator_type input_begin, input_iterator_type input_end) { Chris@16: polygon_set.clear(); Chris@16: size_t num_ele = std::distance(input_begin, input_end); Chris@16: polygon_set.reserve(num_ele); Chris@16: polygon_set_data >::coordinate_type> ps; Chris@16: ps.reserve(num_ele); Chris@16: ps.insert(input_begin, input_end); Chris@16: ps.get(polygon_set); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct polygon_set_mutable_traits > { Chris@16: template Chris@16: static inline void set(polygon_set_data& polygon_set, Chris@16: input_iterator_type input_begin, input_iterator_type input_end) { Chris@16: polygon_set.set(input_begin, input_end); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct polygon_set_traits > { Chris@16: typedef typename polygon_set_data::coordinate_type coordinate_type; Chris@16: typedef typename polygon_set_data::iterator_type iterator_type; Chris@16: typedef typename polygon_set_data::operator_arg_type operator_arg_type; Chris@16: Chris@16: static inline iterator_type begin(const polygon_set_data& polygon_set) { Chris@16: return polygon_set.begin(); Chris@16: } Chris@16: Chris@16: static inline iterator_type end(const polygon_set_data& polygon_set) { Chris@16: return polygon_set.end(); Chris@16: } Chris@16: Chris@16: static inline bool clean(const polygon_set_data& polygon_set) { polygon_set.clean(); return true; } Chris@16: Chris@16: static inline bool sorted(const polygon_set_data& polygon_set) { polygon_set.sort(); return true; } Chris@16: Chris@16: }; Chris@16: } Chris@16: } Chris@16: #endif