]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/buffer/buffer_box.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / buffer / buffer_box.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
11
12 #include <cstddef>
13
14 #include <boost/geometry/core/coordinate_dimension.hpp>
15 #include <boost/geometry/core/coordinate_type.hpp>
16 #include <boost/geometry/core/access.hpp>
17
18
19 namespace boost { namespace geometry
20 {
21
22 #ifndef DOXYGEN_NO_DETAIL
23 namespace detail { namespace buffer
24 {
25
26 template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t D, std::size_t N>
27 struct box_loop
28 {
29 typedef typename coordinate_type<BoxOut>::type coordinate_type;
30
31 static inline void apply(BoxIn const& box_in, T const& distance, BoxOut& box_out)
32 {
33 coordinate_type d = distance;
34 set<C, D>(box_out, get<C, D>(box_in) + d);
35 box_loop<BoxIn, BoxOut, T, C, D + 1, N>::apply(box_in, distance, box_out);
36 }
37 };
38
39 template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t N>
40 struct box_loop<BoxIn, BoxOut, T, C, N, N>
41 {
42 static inline void apply(BoxIn const&, T const&, BoxOut&) {}
43 };
44
45 // Extends a box with the same amount in all directions
46 template<typename BoxIn, typename BoxOut, typename T>
47 inline void buffer_box(BoxIn const& box_in, T const& distance, BoxOut& box_out)
48 {
49 assert_dimension_equal<BoxIn, BoxOut>();
50
51 static const std::size_t N = dimension<BoxIn>::value;
52
53 box_loop<BoxIn, BoxOut, T, min_corner, 0, N>::apply(box_in, -distance, box_out);
54 box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, distance, box_out);
55 }
56
57 }} // namespace detail::buffer
58 #endif // DOXYGEN_NO_DETAIL
59
60 }} // namespace boost::geometry
61
62 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP