File indexing completed on 2025-12-16 09:49:46
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
0010 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP
0011
0012 #include <cstddef>
0013
0014 #include <boost/geometry/core/coordinate_dimension.hpp>
0015 #include <boost/geometry/core/coordinate_type.hpp>
0016 #include <boost/geometry/core/access.hpp>
0017
0018
0019 namespace boost { namespace geometry
0020 {
0021
0022 #ifndef DOXYGEN_NO_DETAIL
0023 namespace detail { namespace buffer
0024 {
0025
0026 template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t D, std::size_t N>
0027 struct box_loop
0028 {
0029 using coordinate_type = coordinate_type_t<BoxOut>;
0030
0031 static inline void apply(BoxIn const& box_in, T const& distance, BoxOut& box_out)
0032 {
0033 coordinate_type d = distance;
0034 set<C, D>(box_out, get<C, D>(box_in) + d);
0035 box_loop<BoxIn, BoxOut, T, C, D + 1, N>::apply(box_in, distance, box_out);
0036 }
0037 };
0038
0039 template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t N>
0040 struct box_loop<BoxIn, BoxOut, T, C, N, N>
0041 {
0042 static inline void apply(BoxIn const&, T const&, BoxOut&) {}
0043 };
0044
0045
0046 template<typename BoxIn, typename BoxOut, typename T>
0047 inline void buffer_box(BoxIn const& box_in, T const& distance, BoxOut& box_out)
0048 {
0049 assert_dimension_equal<BoxIn, BoxOut>();
0050
0051 static const std::size_t N = dimension<BoxIn>::value;
0052
0053 box_loop<BoxIn, BoxOut, T, min_corner, 0, N>::apply(box_in, -distance, box_out);
0054 box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, distance, box_out);
0055 }
0056
0057 }}
0058 #endif
0059
0060 }}
0061
0062 #endif