1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands.
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)
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
14 #include <boost/geometry/core/coordinate_dimension.hpp>
15 #include <boost/geometry/core/coordinate_type.hpp>
16 #include <boost/geometry/core/access.hpp>
19 namespace boost { namespace geometry
22 #ifndef DOXYGEN_NO_DETAIL
23 namespace detail { namespace buffer
26 template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t D, std::size_t N>
29 typedef typename coordinate_type<BoxOut>::type coordinate_type;
31 static inline void apply(BoxIn const& box_in, T const& distance, BoxOut& box_out)
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);
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>
42 static inline void apply(BoxIn const&, T const&, BoxOut&) {}
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)
49 assert_dimension_equal<BoxIn, BoxOut>();
51 static const std::size_t N = dimension<BoxIn>::value;
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);
57 }} // namespace detail::buffer
58 #endif // DOXYGEN_NO_DETAIL
60 }} // namespace boost::geometry
62 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP