1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2015.
6 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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)
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/core/coordinate_type.hpp>
22 namespace boost { namespace geometry
25 #ifndef DOXYGEN_NO_DETAIL
26 namespace detail { namespace intersection
29 template <std::size_t Dimension, std::size_t DimensionCount>
30 struct intersection_box_box
34 typename Box1, typename Box2,
35 typename RobustPolicy,
39 static inline bool apply(Box1 const& box1,
41 RobustPolicy const& robust_policy,
43 Strategy const& strategy)
45 typedef typename coordinate_type<BoxOut>::type ct;
47 ct max1 = get<max_corner, Dimension>(box1);
48 ct min2 = get<min_corner, Dimension>(box2);
55 ct max2 = get<max_corner, Dimension>(box2);
56 ct min1 = get<min_corner, Dimension>(box1);
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);
67 return intersection_box_box<Dimension + 1, DimensionCount>
68 ::apply(box1, box2, robust_policy, box_out, strategy);
72 template <std::size_t DimensionCount>
73 struct intersection_box_box<DimensionCount, DimensionCount>
77 typename Box1, typename Box2,
78 typename RobustPolicy,
82 static inline bool apply(Box1 const&, Box2 const&,
83 RobustPolicy const&, BoxOut&, Strategy const&)
90 }} // namespace detail::intersection
91 #endif // DOXYGEN_NO_DETAIL
93 }} // namespace boost::geometry
96 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP