]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/index/detail/algorithms/intersection_content.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / index / detail / algorithms / intersection_content.hpp
1 // Boost.Geometry Index
2 //
3 // boxes union/intersection area/volume
4 //
5 // Copyright (c) 2011-2017 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
13
14 #include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
15 #include <boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp>
16
17 #include <boost/geometry/index/detail/algorithms/content.hpp>
18
19 namespace boost { namespace geometry { namespace index { namespace detail {
20
21 /**
22 * \brief Compute the area of the intersection of b1 and b2
23 */
24 template <typename Box>
25 inline typename default_content_result<Box>::type intersection_content(Box const& box1, Box const& box2)
26 {
27 bool const intersects = ! geometry::detail::disjoint::box_box<Box, Box>::apply(box1, box2);
28
29 if ( intersects )
30 {
31 Box box_intersection;
32 bool const ok = geometry::detail::intersection::intersection_box_box
33 <
34 0, geometry::dimension<Box>::value
35 >::apply(box1, box2, 0, box_intersection, 0);
36 if ( ok )
37 {
38 return index::detail::content(box_intersection);
39 }
40 }
41 return 0;
42 }
43
44 }}}} // namespace boost::geometry::index::detail
45
46 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP