relate.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // Boost.Geometry
  2. // Copyright (c) 2017, 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_STRATEGIES_RELATE_HPP
  8. #define BOOST_GEOMETRY_STRATEGIES_RELATE_HPP
  9. #include <boost/mpl/assert.hpp>
  10. #include <boost/type_traits/is_same.hpp>
  11. #include <boost/geometry/core/cs.hpp>
  12. #include <boost/geometry/core/point_type.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 = boost::is_same<within_strategy_type, covered_by_strategy_type>::value;
  47. BOOST_MPL_ASSERT_MSG((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_MPL_ASSERT_MSG
  97. (
  98. false, NOT_IMPLEMENTED_FOR_THESE_TYPES
  99. , (types<Geometry1, Geometry2>)
  100. );
  101. };
  102. template <typename PointLike1, typename PointLike2>
  103. struct default_strategy<PointLike1, PointLike2, 0, 0>
  104. : detail::default_point_in_geometry_strategy<PointLike1, PointLike2>
  105. {};
  106. template <typename PointLike, typename Geometry, int TopDim2>
  107. struct default_strategy<PointLike, Geometry, 0, TopDim2>
  108. : detail::default_point_in_geometry_strategy<PointLike, Geometry>
  109. {};
  110. template <typename Geometry, typename PointLike, int TopDim1>
  111. struct default_strategy<Geometry, PointLike, TopDim1, 0>
  112. : detail::default_point_in_geometry_strategy<PointLike, Geometry>
  113. {};
  114. template <typename Geometry1, typename Geometry2>
  115. struct default_strategy<Geometry1, Geometry2, 1, 1>
  116. : detail::default_intersection_strategy<Geometry1>
  117. {};
  118. template <typename Geometry1, typename Geometry2>
  119. struct default_strategy<Geometry1, Geometry2, 1, 2>
  120. : detail::default_intersection_strategy<Geometry1>
  121. {};
  122. template <typename Geometry1, typename Geometry2>
  123. struct default_strategy<Geometry1, Geometry2, 2, 1>
  124. : detail::default_intersection_strategy<Geometry1>
  125. {};
  126. template <typename Geometry1, typename Geometry2>
  127. struct default_strategy<Geometry1, Geometry2, 2, 2>
  128. : detail::default_intersection_strategy<Geometry1>
  129. {};
  130. } // namespace services
  131. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  132. } // namespace relate
  133. } // namespace strategy
  134. }} // namespace boost::geometry
  135. #endif // BOOST_GEOMETRY_STRATEGIES_RELATE_HPP