1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 6 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 9 10 // Use, modification and distribution is subject to the Boost Software License, 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 12 // http://www.boost.org/LICENSE_1_0.txt) 13 14 #ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP 15 #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP 16 17 #include <vector> 18 #include <iterator> 19 20 #include <boost/concept_check.hpp> 21 #include <boost/core/ignore_unused.hpp> 22 23 #include <boost/geometry/geometries/point.hpp> 24 #include <boost/geometry/strategies/concepts/distance_concept.hpp> 25 26 27 namespace boost { namespace geometry { namespace concepts 28 { 29 30 31 /*! 32 \brief Checks strategy for simplify 33 \ingroup simplify 34 */ 35 template <typename Strategy, typename Point> 36 struct SimplifyStrategy 37 { 38 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS 39 private : 40 41 // 1) must define distance_strategy_type, 42 // defining point-segment distance strategy (to be checked) 43 typedef typename Strategy::distance_strategy_type ds_type; 44 45 46 struct checker 47 { 48 template <typename ApplyMethod> applyboost::geometry::concepts::SimplifyStrategy::checker49 static void apply(ApplyMethod) 50 { 51 namespace ft = boost::function_types; 52 typedef typename ft::parameter_types 53 < 54 ApplyMethod 55 >::type parameter_types; 56 57 typedef typename boost::mpl::if_ 58 < 59 ft::is_member_function_pointer<ApplyMethod>, 60 boost::mpl::int_<1>, 61 boost::mpl::int_<0> 62 >::type base_index; 63 64 BOOST_CONCEPT_ASSERT 65 ( 66 (concepts::PointSegmentDistanceStrategy<ds_type, Point, Point>) 67 ); 68 69 Strategy *str = 0; 70 std::vector<Point> const* v1 = 0; 71 std::vector<Point> * v2 = 0; 72 73 // 2) must implement method apply with arguments 74 // - Range 75 // - OutputIterator 76 // - floating point value 77 str->apply(*v1, std::back_inserter(*v2), 1.0); 78 79 boost::ignore_unused<parameter_types, base_index>(); 80 boost::ignore_unused(str); 81 } 82 }; 83 84 public : BOOST_CONCEPT_USAGEboost::geometry::concepts::SimplifyStrategy85 BOOST_CONCEPT_USAGE(SimplifyStrategy) 86 { 87 checker::apply(&ds_type::template apply<Point, Point>); 88 } 89 #endif 90 }; 91 92 93 94 }}} // namespace boost::geometry::concepts 95 96 #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP 97