relate.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // Boost.Geometry
  2. // Copyright (c) 2017-2020, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_GEOMETRY_STRATEGY_RELATE_HPP
  8. #define BOOST_GEOMETRY_STRATEGY_RELATE_HPP
  9. #include <type_traits>
  10. #include <boost/geometry/core/cs.hpp>
  11. #include <boost/geometry/core/point_type.hpp>
  12. #include <boost/geometry/core/static_assert.hpp>
  13. #include <boost/geometry/core/topological_dimension.hpp>
  14. #include <boost/geometry/strategies/covered_by.hpp>
  15. #include <boost/geometry/strategies/intersection.hpp>
  16. #include <boost/geometry/strategies/within.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. namespace strategy
  20. {
  21. namespace point_in_geometry
  22. {
  23. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  24. namespace services
  25. {
  26. template
  27. <
  28. typename Point,
  29. typename Geometry,
  30. typename Tag1 = typename tag<Point>::type,
  31. typename Tag2 = typename tag<Geometry>::type
  32. >
  33. struct default_strategy
  34. : strategy::within::services::default_strategy
  35. <
  36. Point,
  37. Geometry
  38. >
  39. {
  40. typedef typename default_strategy::type within_strategy_type;
  41. typedef typename strategy::covered_by::services::default_strategy
  42. <
  43. Point,
  44. Geometry
  45. >::type covered_by_strategy_type;
  46. static const bool same_strategies = std::is_same<within_strategy_type, covered_by_strategy_type>::value;
  47. BOOST_GEOMETRY_STATIC_ASSERT(same_strategies,
  48. "Default within and covered_by strategies not compatible.",
  49. within_strategy_type, covered_by_strategy_type);
  50. };
  51. template<typename Point, typename Geometry>
  52. struct default_strategy<Point, Geometry, point_tag, point_tag>
  53. : strategy::within::services::default_strategy<Point, Geometry>
  54. {};
  55. template<typename Point, typename Geometry>
  56. struct default_strategy<Point, Geometry, point_tag, multi_point_tag>
  57. : strategy::within::services::default_strategy<Point, Geometry>
  58. {};
  59. } // namespace services
  60. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  61. } // namespace point_in_geometry
  62. namespace relate
  63. {
  64. #ifndef DOXYGEN_NO_DETAIL
  65. namespace detail
  66. {
  67. template <typename Geometry>
  68. struct default_intersection_strategy
  69. : strategy::intersection::services::default_strategy
  70. <
  71. typename cs_tag<Geometry>::type
  72. >
  73. {};
  74. template <typename PointLike, typename Geometry>
  75. struct default_point_in_geometry_strategy
  76. : point_in_geometry::services::default_strategy
  77. <
  78. typename point_type<PointLike>::type,
  79. Geometry
  80. >
  81. {};
  82. } // namespace detail
  83. #endif // DOXYGEN_NO_DETAIL
  84. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  85. namespace services
  86. {
  87. template
  88. <
  89. typename Geometry1,
  90. typename Geometry2,
  91. int TopDim1 = geometry::topological_dimension<Geometry1>::value,
  92. int TopDim2 = geometry::topological_dimension<Geometry2>::value
  93. >
  94. struct default_strategy
  95. {
  96. BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
  97. "Not implemented for these types.",
  98. Geometry1, Geometry2);
  99. };
  100. template <typename PointLike1, typename PointLike2>
  101. struct default_strategy<PointLike1, PointLike2, 0, 0>
  102. : detail::default_point_in_geometry_strategy<PointLike1, PointLike2>
  103. {};
  104. template <typename PointLike, typename Geometry, int TopDim2>
  105. struct default_strategy<PointLike, Geometry, 0, TopDim2>
  106. : detail::default_point_in_geometry_strategy<PointLike, Geometry>
  107. {};
  108. template <typename Geometry, typename PointLike, int TopDim1>
  109. struct default_strategy<Geometry, PointLike, TopDim1, 0>
  110. : detail::default_point_in_geometry_strategy<PointLike, Geometry>
  111. {};
  112. template <typename Geometry1, typename Geometry2>
  113. struct default_strategy<Geometry1, Geometry2, 1, 1>
  114. : detail::default_intersection_strategy<Geometry1>
  115. {};
  116. template <typename Geometry1, typename Geometry2>
  117. struct default_strategy<Geometry1, Geometry2, 1, 2>
  118. : detail::default_intersection_strategy<Geometry1>
  119. {};
  120. template <typename Geometry1, typename Geometry2>
  121. struct default_strategy<Geometry1, Geometry2, 2, 1>
  122. : detail::default_intersection_strategy<Geometry1>
  123. {};
  124. template <typename Geometry1, typename Geometry2>
  125. struct default_strategy<Geometry1, Geometry2, 2, 2>
  126. : detail::default_intersection_strategy<Geometry1>
  127. {};
  128. } // namespace services
  129. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  130. } // namespace relate
  131. } // namespace strategy
  132. }} // namespace boost::geometry
  133. #endif // BOOST_GEOMETRY_STRATEGY_RELATE_HPP