File indexing completed on 2025-01-18 09:36:42
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 typedef typename boost::range_value<OutputRange>::type output_point_type;
0078
0079 typedef typename geometry::select_most_precise
0080 <
0081 typename geometry::select_most_precise
0082 <
0083 typename geometry::coordinate_type<Point>::type,
0084 typename geometry::coordinate_type<output_point_type>::type
0085 >::type,
0086 double
0087 >::type promoted_type;
0088
0089 promoted_type const buffer_distance = distance_strategy.apply(point, point,
0090 strategy::buffer::buffer_side_left);
0091
0092 promoted_type const two_pi = geometry::math::two_pi<promoted_type>();
0093
0094 promoted_type const diff = two_pi / promoted_type(m_count);
0095 promoted_type a = 0;
0096
0097 for (std::size_t i = 0; i < m_count; i++, a -= diff)
0098 {
0099 output_point_type p;
0100 set<0>(p, get<0>(point) + buffer_distance * cos(a));
0101 set<1>(p, get<1>(point) + buffer_distance * sin(a));
0102 output_range.push_back(p);
0103 }
0104
0105
0106 output_range.push_back(output_range.front());
0107 }
0108 #endif
0109
0110 private :
0111 std::size_t m_count;
0112 };
0113
0114
0115 }}
0116
0117 }}
0118
0119 #endif