File indexing completed on 2025-09-15 08:35:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_IMPLEMENTATION_HPP
0015 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_IMPLEMENTATION_HPP
0016
0017
0018 #include <boost/geometry/core/access.hpp>
0019
0020
0021 namespace boost { namespace geometry
0022 {
0023
0024 #ifndef DOXYGEN_NO_DETAIL
0025 namespace detail { namespace intersection
0026 {
0027
0028 template <std::size_t Dimension, std::size_t DimensionCount>
0029 struct intersection_box_box
0030 {
0031 template
0032 <
0033 typename Box1, typename Box2,
0034 typename BoxOut,
0035 typename Strategy
0036 >
0037 static inline bool apply(Box1 const& box1,
0038 Box2 const& box2,
0039 BoxOut& box_out,
0040 Strategy const& strategy)
0041 {
0042 auto max1 = get<max_corner, Dimension>(box1);
0043 auto min2 = get<min_corner, Dimension>(box2);
0044
0045 if (max1 < min2)
0046 {
0047 return false;
0048 }
0049
0050 auto max2 = get<max_corner, Dimension>(box2);
0051 auto min1 = get<min_corner, Dimension>(box1);
0052
0053 if (max2 < min1)
0054 {
0055 return false;
0056 }
0057
0058
0059 set<min_corner, Dimension>(box_out, min1 < min2 ? min2 : min1);
0060 set<max_corner, Dimension>(box_out, max1 > max2 ? max2 : max1);
0061
0062 return intersection_box_box<Dimension + 1, DimensionCount>
0063 ::apply(box1, box2, box_out, strategy);
0064 }
0065 };
0066
0067 template <std::size_t DimensionCount>
0068 struct intersection_box_box<DimensionCount, DimensionCount>
0069 {
0070 template
0071 <
0072 typename Box1, typename Box2,
0073 typename BoxOut,
0074 typename Strategy
0075 >
0076 static inline bool apply(Box1 const&, Box2 const&, BoxOut&, Strategy const&)
0077 {
0078 return true;
0079 }
0080 };
0081
0082
0083 }}
0084 #endif
0085
0086 }}
0087
0088
0089 #endif