File indexing completed on 2025-09-17 08:32:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_CIRCLE_HPP
0016 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_CIRCLE_HPP
0017
0018 #include <cstddef>
0019
0020 #include <boost/range/value_type.hpp>
0021
0022 #include <boost/geometry/core/access.hpp>
0023 #include <boost/geometry/core/coordinate_type.hpp>
0024
0025 #include <boost/geometry/strategies/buffer.hpp>
0026
0027 #include <boost/geometry/util/math.hpp>
0028 #include <boost/geometry/util/select_most_precise.hpp>
0029
0030 namespace boost { namespace geometry
0031 {
0032
0033 namespace strategy { namespace buffer
0034 {
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 class point_circle
0057 {
0058 public :
0059
0060
0061 explicit point_circle(std::size_t count = default_points_per_circle)
0062 : m_count(get_point_count_for_circle(count))
0063 {}
0064
0065 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0066
0067 template
0068 <
0069 typename Point,
0070 typename OutputRange,
0071 typename DistanceStrategy
0072 >
0073 inline void apply(Point const& point,
0074 DistanceStrategy const& distance_strategy,
0075 OutputRange& output_range) const
0076 {
0077 using output_point_type = typename boost::range_value<OutputRange>::type;
0078
0079 using promoted_type = typename geometry::select_most_precise
0080 <
0081 geometry::coordinate_type_t<Point>,
0082 geometry::coordinate_type_t<output_point_type>,
0083 double
0084 >::type;
0085
0086 promoted_type const buffer_distance = distance_strategy.apply(point, point,
0087 strategy::buffer::buffer_side_left);
0088
0089 promoted_type const two_pi = geometry::math::two_pi<promoted_type>();
0090
0091 promoted_type const diff = two_pi / promoted_type(m_count);
0092 promoted_type a = 0;
0093
0094 for (std::size_t i = 0; i < m_count; i++, a -= diff)
0095 {
0096 output_point_type p;
0097 set<0>(p, get<0>(point) + buffer_distance * cos(a));
0098 set<1>(p, get<1>(point) + buffer_distance * sin(a));
0099 output_range.push_back(p);
0100 }
0101
0102
0103 output_range.push_back(output_range.front());
0104 }
0105 #endif
0106
0107 private :
0108 std::size_t m_count;
0109 };
0110
0111
0112 }}
0113
0114 }}
0115
0116 #endif