Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:06

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2015.
0006 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
0007 
0008 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0009 
0010 // Use, modification and distribution is subject to the Boost Software License,
0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0012 // http://www.boost.org/LICENSE_1_0.txt)
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 RobustPolicy,
0035         typename BoxOut,
0036         typename Strategy
0037     >
0038     static inline bool apply(Box1 const& box1,
0039             Box2 const& box2,
0040             RobustPolicy const& robust_policy,
0041             BoxOut& box_out,
0042             Strategy const& strategy)
0043     {
0044         auto max1 = get<max_corner, Dimension>(box1);
0045         auto min2 = get<min_corner, Dimension>(box2);
0046 
0047         if (max1 < min2)
0048         {
0049             return false;
0050         }
0051 
0052         auto max2 = get<max_corner, Dimension>(box2);
0053         auto min1 = get<min_corner, Dimension>(box1);
0054 
0055         if (max2 < min1)
0056         {
0057             return false;
0058         }
0059 
0060         // Set dimensions of output coordinate
0061         set<min_corner, Dimension>(box_out, min1 < min2 ? min2 : min1);
0062         set<max_corner, Dimension>(box_out, max1 > max2 ? max2 : max1);
0063 
0064         return intersection_box_box<Dimension + 1, DimensionCount>
0065                ::apply(box1, box2, robust_policy, box_out, strategy);
0066     }
0067 };
0068 
0069 template <std::size_t DimensionCount>
0070 struct intersection_box_box<DimensionCount, DimensionCount>
0071 {
0072     template
0073     <
0074         typename Box1, typename Box2,
0075         typename RobustPolicy,
0076         typename BoxOut,
0077         typename Strategy
0078     >
0079     static inline bool apply(Box1 const&, Box2 const&,
0080             RobustPolicy const&, BoxOut&, Strategy const&)
0081     {
0082         return true;
0083     }
0084 };
0085 
0086 
0087 }} // namespace detail::intersection
0088 #endif // DOXYGEN_NO_DETAIL
0089 
0090 }} // namespace boost::geometry
0091 
0092 
0093 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_IMPLEMENTATION_HPP