Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2017-2022.
0008 // Modifications copyright (c) 2017-2022 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0012 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_INTERFACE_HPP
0019 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_INTERFACE_HPP
0020 
0021 #include <boost/geometry/algorithms/clear.hpp>
0022 #include <boost/geometry/algorithms/not_implemented.hpp>
0023 #include <boost/geometry/core/visit.hpp>
0024 #include <boost/geometry/core/tag.hpp>
0025 #include <boost/geometry/geometries/adapted/boost_variant.hpp>
0026 #include <boost/geometry/geometries/concepts/check.hpp>
0027 #include <boost/geometry/strategies/buffer/services.hpp>
0028 #include <boost/geometry/util/type_traits_std.hpp>
0029 
0030 namespace boost { namespace geometry
0031 {
0032 
0033 #ifndef DOXYGEN_NO_DISPATCH
0034 namespace dispatch
0035 {
0036 
0037 template
0038 <
0039     typename Input,
0040     typename Output,
0041     typename TagIn = tag_t<Input>,
0042     typename TagOut = tag_t<Output>
0043 >
0044 struct buffer_dc : not_implemented<TagIn, TagOut>
0045 {};
0046 
0047 template
0048 <
0049     typename Input,
0050     typename Output,
0051     typename TagIn = tag_t<Input>,
0052     typename TagOut = tag_t<Output>
0053 >
0054 struct buffer_all : not_implemented<TagIn, TagOut>
0055 {};
0056 
0057 } // namespace dispatch
0058 #endif // DOXYGEN_NO_DISPATCH
0059 
0060 
0061 namespace resolve_dynamic
0062 {
0063 
0064 template
0065 <
0066     typename Input,
0067     typename TagIn = geometry::tag_t<Input>
0068 >
0069 struct buffer_dc
0070 {
0071     template <typename Output, typename Distance>
0072     static inline void apply(Input const& geometry_in,
0073                              Output& geometry_out,
0074                              Distance const& distance,
0075                              Distance const& chord_length)
0076     {
0077         dispatch::buffer_dc<Input, Output>::apply(geometry_in, geometry_out, distance, chord_length);
0078     }
0079 };
0080 
0081 template <typename Input>
0082 struct buffer_dc<Input, dynamic_geometry_tag>
0083 {
0084     template <typename Output, typename Distance>
0085     static inline void apply(Input const& geometry_in,
0086                              Output& geometry_out,
0087                              Distance const& distance,
0088                              Distance const& chord_length)
0089     {
0090         traits::visit<Input>::apply([&](auto const& g)
0091         {
0092             dispatch::buffer_dc
0093                 <
0094                     util::remove_cref_t<decltype(g)>, Output
0095                 >::apply(g, geometry_out, distance, chord_length);
0096         }, geometry_in);
0097     }
0098 };
0099 
0100 
0101 template
0102 <
0103     typename Input,
0104     typename TagIn = geometry::tag_t<Input>
0105 >
0106 struct buffer_all
0107 {
0108     template
0109     <
0110         typename Output,
0111         typename DistanceStrategy,
0112         typename SideStrategy,
0113         typename JoinStrategy,
0114         typename EndStrategy,
0115         typename PointStrategy
0116     >
0117     static inline void apply(Input const& geometry_in,
0118                              Output& geometry_out,
0119                              DistanceStrategy const& distance_strategy,
0120                              SideStrategy const& side_strategy,
0121                              JoinStrategy const& join_strategy,
0122                              EndStrategy const& end_strategy,
0123                              PointStrategy const& point_strategy)
0124     {
0125         typename strategies::buffer::services::default_strategy
0126             <
0127                 Input
0128             >::type strategies;
0129 
0130         dispatch::buffer_all
0131             <
0132                 Input, Output
0133             >::apply(geometry_in, geometry_out, distance_strategy, side_strategy,
0134                      join_strategy, end_strategy, point_strategy, strategies);
0135     }
0136 };
0137 
0138 template <typename Input>
0139 struct buffer_all<Input, dynamic_geometry_tag>
0140 {
0141     template
0142     <
0143         typename Output,
0144         typename DistanceStrategy,
0145         typename SideStrategy,
0146         typename JoinStrategy,
0147         typename EndStrategy,
0148         typename PointStrategy
0149     >
0150     static inline void apply(Input const& geometry_in,
0151                              Output& geometry_out,
0152                              DistanceStrategy const& distance_strategy,
0153                              SideStrategy const& side_strategy,
0154                              JoinStrategy const& join_strategy,
0155                              EndStrategy const& end_strategy,
0156                              PointStrategy const& point_strategy)
0157     {
0158         traits::visit<Input>::apply([&](auto const& g)
0159         {
0160             buffer_all
0161                 <
0162                     util::remove_cref_t<decltype(g)>
0163                 >::apply(g, geometry_out, distance_strategy, side_strategy,
0164                          join_strategy, end_strategy, point_strategy);
0165         }, geometry_in);
0166     }
0167 };
0168 
0169 } // namespace resolve_dynamic
0170 
0171 
0172 /*!
0173 \brief \brief_calc{buffer}
0174 \ingroup buffer
0175 \details \details_calc{buffer, \det_buffer}.
0176 \tparam Input \tparam_geometry
0177 \tparam Output \tparam_geometry
0178 \tparam Distance \tparam_numeric
0179 \param geometry_in \param_geometry
0180 \param geometry_out \param_geometry
0181 \param distance The distance to be used for the buffer
0182 \param chord_length (optional) The length of the chord's in the generated arcs around points or bends
0183 
0184 \qbk{[include reference/algorithms/buffer.qbk]}
0185  */
0186 template <typename Input, typename Output, typename Distance>
0187 inline void buffer(Input const& geometry_in, Output& geometry_out,
0188                    Distance const& distance, Distance const& chord_length = -1)
0189 {
0190     concepts::check<Input const>();
0191     concepts::check<Output>();
0192 
0193     resolve_dynamic::buffer_dc<Input>::apply(geometry_in, geometry_out, distance, chord_length);
0194 }
0195 
0196 /*!
0197 \brief \brief_calc{buffer}
0198 \ingroup buffer
0199 \details \details_calc{return_buffer, \det_buffer}. \details_return{buffer}.
0200 \tparam Input \tparam_geometry
0201 \tparam Output \tparam_geometry
0202 \tparam Distance \tparam_numeric
0203 \param geometry \param_geometry
0204 \param distance The distance to be used for the buffer
0205 \param chord_length (optional) The length of the chord's in the generated arcs
0206     around points or bends (RESERVED, NOT YET USED)
0207 \return \return_calc{buffer}
0208  */
0209 template <typename Output, typename Input, typename Distance>
0210 inline Output return_buffer(Input const& geometry, Distance const& distance,
0211                             Distance const& chord_length = -1)
0212 {
0213     concepts::check<Input const>();
0214     concepts::check<Output>();
0215 
0216     Output geometry_out;
0217 
0218     resolve_dynamic::buffer_dc<Input>::apply(geometry, geometry_out, distance, chord_length);
0219 
0220     return geometry_out;
0221 }
0222 
0223 /*!
0224 \brief \brief_calc{buffer}
0225 \ingroup buffer
0226 \details \details_calc{buffer, \det_buffer}.
0227 \tparam GeometryIn \tparam_geometry
0228 \tparam GeometryOut \tparam_geometry{GeometryOut}
0229 \tparam DistanceStrategy A strategy defining distance (or radius)
0230 \tparam SideStrategy A strategy defining creation along sides
0231 \tparam JoinStrategy A strategy defining creation around convex corners
0232 \tparam EndStrategy A strategy defining creation at linestring ends
0233 \tparam PointStrategy A strategy defining creation around points
0234 \param geometry_in \param_geometry
0235 \param geometry_out output geometry, e.g. multi polygon,
0236        will contain a buffered version of the input geometry
0237 \param distance_strategy The distance strategy to be used
0238 \param side_strategy The side strategy to be used
0239 \param join_strategy The join strategy to be used
0240 \param end_strategy The end strategy to be used
0241 \param point_strategy The point strategy to be used
0242 
0243 \qbk{distinguish,with strategies}
0244 \qbk{[include reference/algorithms/buffer_with_strategies.qbk]}
0245  */
0246 template
0247 <
0248     typename GeometryIn,
0249     typename GeometryOut,
0250     typename DistanceStrategy,
0251     typename SideStrategy,
0252     typename JoinStrategy,
0253     typename EndStrategy,
0254     typename PointStrategy
0255 >
0256 inline void buffer(GeometryIn const& geometry_in,
0257                    GeometryOut& geometry_out,
0258                    DistanceStrategy const& distance_strategy,
0259                    SideStrategy const& side_strategy,
0260                    JoinStrategy const& join_strategy,
0261                    EndStrategy const& end_strategy,
0262                    PointStrategy const& point_strategy)
0263 {
0264     concepts::check<GeometryIn const>();
0265     concepts::check<GeometryOut>();
0266 
0267     geometry::clear(geometry_out);
0268 
0269     resolve_dynamic::buffer_all
0270         <
0271             GeometryIn, GeometryOut
0272         >::apply(geometry_in, geometry_out, distance_strategy, side_strategy,
0273                  join_strategy, end_strategy, point_strategy);
0274 }
0275 
0276 
0277 }} // namespace boost::geometry
0278 
0279 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_INTERFACE_HPP