point_box.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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-2021.
  7. // Modifications copyright (c) 2013-2021, 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_BOX_HPP
  16. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP
  17. #include <cstddef>
  18. #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
  19. #include <boost/geometry/core/access.hpp>
  20. #include <boost/geometry/core/coordinate_dimension.hpp>
  21. #include <boost/geometry/core/tags.hpp>
  22. #include <boost/geometry/strategies/detail.hpp>
  23. namespace boost { namespace geometry
  24. {
  25. #ifndef DOXYGEN_NO_DETAIL
  26. namespace detail { namespace disjoint
  27. {
  28. /*!
  29. \brief Internal utility function to detect if point/box are disjoint
  30. */
  31. template
  32. <
  33. typename Point, typename Box, typename Strategy,
  34. std::enable_if_t<strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
  35. >
  36. inline bool disjoint_point_box(Point const& point, Box const& box,
  37. Strategy const& strategy)
  38. {
  39. typedef decltype(strategy.covered_by(point, box)) strategy_type;
  40. // ! covered_by(point, box)
  41. return ! strategy_type::apply(point, box);
  42. }
  43. template
  44. <
  45. typename Point, typename Box, typename Strategy,
  46. std::enable_if_t<! strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
  47. >
  48. inline bool disjoint_point_box(Point const& point, Box const& box,
  49. Strategy const& )
  50. {
  51. // ! covered_by(point, box)
  52. return ! Strategy::apply(point, box);
  53. }
  54. }} // namespace detail::disjoint
  55. #endif // DOXYGEN_NO_DETAIL
  56. #ifndef DOXYGEN_NO_DISPATCH
  57. namespace dispatch
  58. {
  59. template <typename Point, typename Box, std::size_t DimensionCount>
  60. struct disjoint<Point, Box, DimensionCount, point_tag, box_tag, false>
  61. {
  62. template <typename Strategy>
  63. static inline bool apply(Point const& point, Box const& box,
  64. Strategy const& strategy)
  65. {
  66. typedef decltype(strategy.covered_by(point, box)) strategy_type;
  67. // ! covered_by(point, box)
  68. return ! strategy_type::apply(point, box);
  69. }
  70. };
  71. } // namespace dispatch
  72. #endif // DOXYGEN_NO_DISPATCH
  73. }} // namespace boost::geometry
  74. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_BOX_HPP