interface.hpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
  6. // This file was modified by Oracle on 2013-2017.
  7. // Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  10. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  11. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  12. // Use, modification and distribution is subject to the Boost Software License,
  13. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
  16. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP
  17. #include <cstddef>
  18. #include <boost/variant/apply_visitor.hpp>
  19. #include <boost/variant/static_visitor.hpp>
  20. #include <boost/variant/variant_fwd.hpp>
  21. #include <boost/geometry/algorithms/detail/relate/interface.hpp>
  22. #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
  23. #include <boost/geometry/geometries/concepts/check.hpp>
  24. #include <boost/geometry/strategies/disjoint.hpp>
  25. namespace boost { namespace geometry
  26. {
  27. namespace resolve_strategy
  28. {
  29. struct disjoint
  30. {
  31. template <typename Geometry1, typename Geometry2, typename Strategy>
  32. static inline bool apply(Geometry1 const& geometry1,
  33. Geometry2 const& geometry2,
  34. Strategy const& strategy)
  35. {
  36. return dispatch::disjoint
  37. <
  38. Geometry1, Geometry2
  39. >::apply(geometry1, geometry2, strategy);
  40. }
  41. template <typename Geometry1, typename Geometry2>
  42. static inline bool apply(Geometry1 const& geometry1,
  43. Geometry2 const& geometry2,
  44. default_strategy)
  45. {
  46. typedef typename strategy::disjoint::services::default_strategy
  47. <
  48. Geometry1, Geometry2
  49. >::type strategy_type;
  50. return dispatch::disjoint
  51. <
  52. Geometry1, Geometry2
  53. >::apply(geometry1, geometry2, strategy_type());
  54. }
  55. };
  56. } // namespace resolve_strategy
  57. namespace resolve_variant {
  58. template <typename Geometry1, typename Geometry2>
  59. struct disjoint
  60. {
  61. template <typename Strategy>
  62. static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
  63. {
  64. concepts::check_concepts_and_equal_dimensions
  65. <
  66. Geometry1 const,
  67. Geometry2 const
  68. >();
  69. return resolve_strategy::disjoint::apply(geometry1, geometry2, strategy);
  70. }
  71. };
  72. template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
  73. struct disjoint<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
  74. {
  75. template <typename Strategy>
  76. struct visitor: boost::static_visitor<bool>
  77. {
  78. Geometry2 const& m_geometry2;
  79. Strategy const& m_strategy;
  80. visitor(Geometry2 const& geometry2, Strategy const& strategy)
  81. : m_geometry2(geometry2)
  82. , m_strategy(strategy)
  83. {}
  84. template <typename Geometry1>
  85. bool operator()(Geometry1 const& geometry1) const
  86. {
  87. return disjoint<Geometry1, Geometry2>::apply(geometry1, m_geometry2, m_strategy);
  88. }
  89. };
  90. template <typename Strategy>
  91. static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
  92. Geometry2 const& geometry2,
  93. Strategy const& strategy)
  94. {
  95. return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
  96. }
  97. };
  98. template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
  99. struct disjoint<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
  100. {
  101. template <typename Strategy>
  102. struct visitor: boost::static_visitor<bool>
  103. {
  104. Geometry1 const& m_geometry1;
  105. Strategy const& m_strategy;
  106. visitor(Geometry1 const& geometry1, Strategy const& strategy)
  107. : m_geometry1(geometry1)
  108. , m_strategy(strategy)
  109. {}
  110. template <typename Geometry2>
  111. bool operator()(Geometry2 const& geometry2) const
  112. {
  113. return disjoint<Geometry1, Geometry2>::apply(m_geometry1, geometry2, m_strategy);
  114. }
  115. };
  116. template <typename Strategy>
  117. static inline bool apply(Geometry1 const& geometry1,
  118. boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
  119. Strategy const& strategy)
  120. {
  121. return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
  122. }
  123. };
  124. template
  125. <
  126. BOOST_VARIANT_ENUM_PARAMS(typename T1),
  127. BOOST_VARIANT_ENUM_PARAMS(typename T2)
  128. >
  129. struct disjoint
  130. <
  131. boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
  132. boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
  133. >
  134. {
  135. template <typename Strategy>
  136. struct visitor: boost::static_visitor<bool>
  137. {
  138. Strategy const& m_strategy;
  139. visitor(Strategy const& strategy)
  140. : m_strategy(strategy)
  141. {}
  142. template <typename Geometry1, typename Geometry2>
  143. bool operator()(Geometry1 const& geometry1,
  144. Geometry2 const& geometry2) const
  145. {
  146. return disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2, m_strategy);
  147. }
  148. };
  149. template <typename Strategy>
  150. static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
  151. boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
  152. Strategy const& strategy)
  153. {
  154. return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
  155. }
  156. };
  157. } // namespace resolve_variant
  158. /*!
  159. \brief \brief_check2{are disjoint}
  160. \ingroup disjoint
  161. \tparam Geometry1 \tparam_geometry
  162. \tparam Geometry2 \tparam_geometry
  163. \tparam Strategy \tparam_strategy{Disjoint}
  164. \param geometry1 \param_geometry
  165. \param geometry2 \param_geometry
  166. \param strategy \param_strategy{disjoint}
  167. \return \return_check2{are disjoint}
  168. \qbk{distinguish,with strategy}
  169. \qbk{[include reference/algorithms/disjoint.qbk]}
  170. */
  171. template <typename Geometry1, typename Geometry2, typename Strategy>
  172. inline bool disjoint(Geometry1 const& geometry1,
  173. Geometry2 const& geometry2,
  174. Strategy const& strategy)
  175. {
  176. return resolve_variant::disjoint
  177. <
  178. Geometry1, Geometry2
  179. >::apply(geometry1, geometry2, strategy);
  180. }
  181. /*!
  182. \brief \brief_check2{are disjoint}
  183. \ingroup disjoint
  184. \tparam Geometry1 \tparam_geometry
  185. \tparam Geometry2 \tparam_geometry
  186. \param geometry1 \param_geometry
  187. \param geometry2 \param_geometry
  188. \return \return_check2{are disjoint}
  189. \qbk{[include reference/algorithms/disjoint.qbk]}
  190. */
  191. template <typename Geometry1, typename Geometry2>
  192. inline bool disjoint(Geometry1 const& geometry1,
  193. Geometry2 const& geometry2)
  194. {
  195. return resolve_variant::disjoint
  196. <
  197. Geometry1, Geometry2
  198. >::apply(geometry1, geometry2, default_strategy());
  199. }
  200. }} // namespace boost::geometry
  201. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_INTERFACE_HPP