point_point.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
  6. // This file was modified by Oracle on 2013-2020.
  7. // Modifications copyright (c) 2013-2020, 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_POINT_POINT_HPP
  16. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP
  17. #include <cstddef>
  18. #include <type_traits>
  19. #include <boost/geometry/core/tags.hpp>
  20. #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
  21. #include <boost/geometry/strategies/detail.hpp>
  22. // For backward compatibility
  23. #include <boost/geometry/strategies/disjoint.hpp>
  24. #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
  25. #include <boost/geometry/strategies/spherical/point_in_point.hpp>
  26. namespace boost { namespace geometry
  27. {
  28. #ifndef DOXYGEN_NO_DETAIL
  29. namespace detail { namespace disjoint
  30. {
  31. /*!
  32. \brief Internal utility function to detect of points are disjoint
  33. \note To avoid circular references
  34. */
  35. template
  36. <
  37. typename Point1, typename Point2, typename Strategy,
  38. std::enable_if_t<strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
  39. >
  40. inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2,
  41. Strategy const& strategy)
  42. {
  43. typedef decltype(strategy.relate(point1, point2)) strategy_type;
  44. // ! within(point1, point2)
  45. return ! strategy_type::apply(point1, point2);
  46. }
  47. template
  48. <
  49. typename Point1, typename Point2, typename Strategy,
  50. std::enable_if_t<! strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
  51. >
  52. inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2,
  53. Strategy const& )
  54. {
  55. // ! within(point1, point2)
  56. return ! Strategy::apply(point1, point2);
  57. }
  58. }} // namespace detail::disjoint
  59. #endif // DOXYGEN_NO_DETAIL
  60. #ifndef DOXYGEN_NO_DISPATCH
  61. namespace dispatch
  62. {
  63. template <typename Point1, typename Point2, std::size_t DimensionCount>
  64. struct disjoint<Point1, Point2, DimensionCount, point_tag, point_tag, false>
  65. {
  66. template <typename Strategy>
  67. static inline bool apply(Point1 const& point1, Point2 const& point2,
  68. Strategy const& strategy)
  69. {
  70. typedef decltype(strategy.relate(point1, point2)) strategy_type;
  71. // ! within(point1, point2)
  72. return ! strategy_type::apply(point1, point2);
  73. }
  74. };
  75. } // namespace dispatch
  76. #endif // DOXYGEN_NO_DISPATCH
  77. }} // namespace boost::geometry
  78. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP