Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:49:46

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // Use, modification and distribution is subject to the Boost Software License,
0006 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
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 // Extends a box with the same amount in all directions
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 }} // namespace detail::buffer
0058 #endif // DOXYGEN_NO_DETAIL
0059 
0060 }} // namespace boost::geometry
0061 
0062 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFER_BOX_HPP