File indexing completed on 2025-12-16 09:49:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
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 }
0058 #endif
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 }
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
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
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
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
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
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 }}
0278
0279 #endif