simplify_concept.hpp 2.6 KB

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