1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. 4 5 // This file was modified by Oracle on 2015. 6 // Modifications copyright (c) 2015, Oracle and/or its affiliates. 7 8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 9 10 // Use, modification and distribution is subject to the Boost Software License, 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 12 // http://www.boost.org/LICENSE_1_0.txt) 13 14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP 15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP 16 17 18 #include <boost/geometry/core/access.hpp> 19 #include <boost/geometry/core/coordinate_type.hpp> 20 21 22 namespace boost { namespace geometry 23 { 24 25 #ifndef DOXYGEN_NO_DETAIL 26 namespace detail { namespace intersection 27 { 28 29 template <std::size_t Dimension, std::size_t DimensionCount> 30 struct intersection_box_box 31 { 32 template 33 < 34 typename Box1, typename Box2, 35 typename RobustPolicy, 36 typename BoxOut, 37 typename Strategy 38 > applyboost::geometry::detail::intersection::intersection_box_box39 static inline bool apply(Box1 const& box1, 40 Box2 const& box2, 41 RobustPolicy const& robust_policy, 42 BoxOut& box_out, 43 Strategy const& strategy) 44 { 45 typedef typename coordinate_type<BoxOut>::type ct; 46 47 ct max1 = get<max_corner, Dimension>(box1); 48 ct min2 = get<min_corner, Dimension>(box2); 49 50 if (max1 < min2) 51 { 52 return false; 53 } 54 55 ct max2 = get<max_corner, Dimension>(box2); 56 ct min1 = get<min_corner, Dimension>(box1); 57 58 if (max2 < min1) 59 { 60 return false; 61 } 62 63 // Set dimensions of output coordinate 64 set<min_corner, Dimension>(box_out, min1 < min2 ? min2 : min1); 65 set<max_corner, Dimension>(box_out, max1 > max2 ? max2 : max1); 66 67 return intersection_box_box<Dimension + 1, DimensionCount> 68 ::apply(box1, box2, robust_policy, box_out, strategy); 69 } 70 }; 71 72 template <std::size_t DimensionCount> 73 struct intersection_box_box<DimensionCount, DimensionCount> 74 { 75 template 76 < 77 typename Box1, typename Box2, 78 typename RobustPolicy, 79 typename BoxOut, 80 typename Strategy 81 > applyboost::geometry::detail::intersection::intersection_box_box82 static inline bool apply(Box1 const&, Box2 const&, 83 RobustPolicy const&, BoxOut&, Strategy const&) 84 { 85 return true; 86 } 87 }; 88 89 90 }} // namespace detail::intersection 91 #endif // DOXYGEN_NO_DETAIL 92 93 }} // namespace boost::geometry 94 95 96 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP 97