simplify_concept.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  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. #ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP
  14. #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP
  15. #include <iterator>
  16. #include <type_traits>
  17. #include <vector>
  18. #include <boost/concept_check.hpp>
  19. #include <boost/core/ignore_unused.hpp>
  20. #include <boost/geometry/geometries/point.hpp>
  21. #include <boost/geometry/strategies/concepts/distance_concept.hpp>
  22. namespace boost { namespace geometry { namespace concepts
  23. {
  24. /*!
  25. \brief Checks strategy for simplify
  26. \ingroup simplify
  27. */
  28. template <typename Strategy, typename Point>
  29. struct SimplifyStrategy
  30. {
  31. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  32. private :
  33. // 1) must define distance_strategy_type,
  34. // defining point-segment distance strategy (to be checked)
  35. typedef typename Strategy::distance_strategy_type ds_type;
  36. struct checker
  37. {
  38. template <typename ApplyMethod>
  39. static void apply(ApplyMethod)
  40. {
  41. namespace ft = boost::function_types;
  42. typedef typename ft::parameter_types
  43. <
  44. ApplyMethod
  45. >::type parameter_types;
  46. typedef std::conditional_t
  47. <
  48. ft::is_member_function_pointer<ApplyMethod>::value,
  49. std::integral_constant<int, 1>,
  50. std::integral_constant<int, 0>
  51. > base_index;
  52. BOOST_CONCEPT_ASSERT
  53. (
  54. (concepts::PointSegmentDistanceStrategy<ds_type, Point, Point>)
  55. );
  56. Strategy *str = 0;
  57. std::vector<Point> const* v1 = 0;
  58. std::vector<Point> * v2 = 0;
  59. // 2) must implement method apply with arguments
  60. // - Range
  61. // - OutputIterator
  62. // - floating point value
  63. str->apply(*v1, std::back_inserter(*v2), 1.0);
  64. boost::ignore_unused<parameter_types, base_index>();
  65. boost::ignore_unused(str);
  66. }
  67. };
  68. public :
  69. BOOST_CONCEPT_USAGE(SimplifyStrategy)
  70. {
  71. checker::apply(&ds_type::template apply<Point, Point>);
  72. }
  73. #endif
  74. };
  75. }}} // namespace boost::geometry::concepts
  76. #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP