simplify_concept.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/core/ignore_unused.hpp>
  16. #include <boost/geometry/geometries/point.hpp>
  17. #include <boost/geometry/strategies/concepts/distance_concept.hpp>
  18. namespace boost { namespace geometry { namespace concepts
  19. {
  20. /*!
  21. \brief Checks strategy for simplify
  22. \ingroup simplify
  23. */
  24. template <typename Strategy, typename Point>
  25. struct SimplifyStrategy
  26. {
  27. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  28. private :
  29. // 1) must define distance_strategy_type,
  30. // defining point-segment distance strategy (to be checked)
  31. typedef typename Strategy::distance_strategy_type ds_type;
  32. struct checker
  33. {
  34. template <typename ApplyMethod>
  35. static void apply(ApplyMethod)
  36. {
  37. namespace ft = boost::function_types;
  38. typedef typename ft::parameter_types
  39. <
  40. ApplyMethod
  41. >::type parameter_types;
  42. typedef typename boost::mpl::if_
  43. <
  44. ft::is_member_function_pointer<ApplyMethod>,
  45. boost::mpl::int_<1>,
  46. boost::mpl::int_<0>
  47. >::type base_index;
  48. BOOST_CONCEPT_ASSERT
  49. (
  50. (concepts::PointSegmentDistanceStrategy<ds_type, Point, Point>)
  51. );
  52. Strategy *str = 0;
  53. std::vector<Point> const* v1 = 0;
  54. std::vector<Point> * v2 = 0;
  55. // 2) must implement method apply with arguments
  56. // - Range
  57. // - OutputIterator
  58. // - floating point value
  59. str->apply(*v1, std::back_inserter(*v2), 1.0);
  60. boost::ignore_unused<parameter_types, base_index>();
  61. boost::ignore_unused(str);
  62. }
  63. };
  64. public :
  65. BOOST_CONCEPT_USAGE(SimplifyStrategy)
  66. {
  67. checker::apply(&ds_type::template apply<Point, Point>);
  68. }
  69. #endif
  70. };
  71. }}} // namespace boost::geometry::concepts
  72. #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP