disjoint_box_box.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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-2018.
  7. // Modifications copyright (c) 2013-2018, 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_STRATEGIES_CARTESIAN_DISJOINT_BOX_BOX_HPP
  16. #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISJOINT_BOX_BOX_HPP
  17. #include <cstddef>
  18. #include <boost/geometry/core/access.hpp>
  19. #include <boost/geometry/core/coordinate_dimension.hpp>
  20. #include <boost/geometry/core/tags.hpp>
  21. #include <boost/geometry/strategies/disjoint.hpp>
  22. namespace boost { namespace geometry { namespace strategy { namespace disjoint
  23. {
  24. #ifndef DOXYGEN_NO_DETAIL
  25. namespace detail
  26. {
  27. template
  28. <
  29. typename Box1, typename Box2,
  30. std::size_t Dimension = 0,
  31. std::size_t DimensionCount = dimension<Box1>::value
  32. >
  33. struct box_box
  34. {
  35. static inline bool apply(Box1 const& box1, Box2 const& box2)
  36. {
  37. if (get<max_corner, Dimension>(box1) < get<min_corner, Dimension>(box2))
  38. {
  39. return true;
  40. }
  41. if (get<min_corner, Dimension>(box1) > get<max_corner, Dimension>(box2))
  42. {
  43. return true;
  44. }
  45. return box_box
  46. <
  47. Box1, Box2,
  48. Dimension + 1, DimensionCount
  49. >::apply(box1, box2);
  50. }
  51. };
  52. template <typename Box1, typename Box2, std::size_t DimensionCount>
  53. struct box_box<Box1, Box2, DimensionCount, DimensionCount>
  54. {
  55. static inline bool apply(Box1 const& , Box2 const& )
  56. {
  57. return false;
  58. }
  59. };
  60. } // namespace detail
  61. #endif // DOXYGEN_NO_DETAIL
  62. struct cartesian_box_box
  63. {
  64. template <typename Box1, typename Box2>
  65. static inline bool apply(Box1 const& box1, Box2 const& box2)
  66. {
  67. return detail::box_box<Box1, Box2>::apply(box1, box2);
  68. }
  69. };
  70. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  71. namespace services
  72. {
  73. template <typename Box1, typename Box2, int TopDim1, int TopDim2>
  74. struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, cartesian_tag, cartesian_tag>
  75. {
  76. typedef disjoint::cartesian_box_box type;
  77. };
  78. } // namespace services
  79. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  80. }}}} // namespace boost::geometry::strategy::disjoint
  81. #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISJOINT_BOX_BOX_HPP