123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_CIRCLE_HPP
- #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_CIRCLE_HPP
- #include <cstddef>
- #include <boost/range/value_type.hpp>
- #include <boost/geometry/core/access.hpp>
- #include <boost/geometry/core/coordinate_type.hpp>
- #include <boost/geometry/strategies/buffer.hpp>
- #include <boost/geometry/util/math.hpp>
- #include <boost/geometry/util/select_most_precise.hpp>
- namespace boost { namespace geometry
- {
- namespace strategy { namespace buffer
- {
- class point_circle
- {
- public :
-
-
- explicit point_circle(std::size_t count = default_points_per_circle)
- : m_count(get_point_count_for_circle(count))
- {}
- #ifndef DOXYGEN_SHOULD_SKIP_THIS
-
- template
- <
- typename Point,
- typename OutputRange,
- typename DistanceStrategy
- >
- inline void apply(Point const& point,
- DistanceStrategy const& distance_strategy,
- OutputRange& output_range) const
- {
- typedef typename boost::range_value<OutputRange>::type output_point_type;
- typedef typename geometry::select_most_precise
- <
- typename geometry::select_most_precise
- <
- typename geometry::coordinate_type<Point>::type,
- typename geometry::coordinate_type<output_point_type>::type
- >::type,
- double
- >::type promoted_type;
- promoted_type const buffer_distance = distance_strategy.apply(point, point,
- strategy::buffer::buffer_side_left);
- promoted_type const two_pi = geometry::math::two_pi<promoted_type>();
- promoted_type const diff = two_pi / promoted_type(m_count);
- promoted_type a = 0;
- for (std::size_t i = 0; i < m_count; i++, a -= diff)
- {
- output_point_type p;
- set<0>(p, get<0>(point) + buffer_distance * cos(a));
- set<1>(p, get<1>(point) + buffer_distance * sin(a));
- output_range.push_back(p);
- }
-
- output_range.push_back(output_range.front());
- }
- #endif
- private :
- std::size_t m_count;
- };
- }}
- }}
- #endif
|