]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/cartesian/buffer_point_square.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / strategies / cartesian / buffer_point_square.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2018.
6 // Modifications copyright (c) 2018, Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP
15 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP
16
17 #include <cstddef>
18
19 #include <boost/range/value_type.hpp>
20
21 #include <boost/geometry/core/access.hpp>
22 #include <boost/geometry/strategies/buffer.hpp>
23 #include <boost/geometry/util/math.hpp>
24
25 namespace boost { namespace geometry
26 {
27
28 namespace strategy { namespace buffer
29 {
30
31 /*!
32 \brief Create a squared form buffer around a point
33 \ingroup strategies
34 \details This strategy can be used as PointStrategy for the buffer algorithm.
35 It creates a square from each point, where the point lies in the center.
36 It can be applied for points and multi_points, but also for a linestring (if it is degenerate,
37 so consisting of only one point) and for polygons (if it is degenerate).
38 This strategy is only applicable for Cartesian coordinate systems.
39
40 \qbk{
41 [heading Example]
42 [buffer_point_square]
43 [heading Output]
44 [$img/strategies/buffer_point_square.png]
45 [heading See also]
46 \* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
47 \* [link geometry.reference.strategies.strategy_buffer_point_circle point_circle]
48 \* [link geometry.reference.strategies.strategy_buffer_geographic_point_circle geographic_point_circle]
49 }
50 */
51 class point_square
52 {
53 template
54 <
55 typename Point,
56 typename DistanceType,
57 typename MultiplierType,
58 typename OutputRange
59 >
60 inline void add_point(Point const& point,
61 DistanceType const& distance,
62 MultiplierType const& x,
63 MultiplierType const& y,
64 OutputRange& output_range) const
65 {
66 typename boost::range_value<OutputRange>::type p;
67 set<0>(p, get<0>(point) + x * distance);
68 set<1>(p, get<1>(point) + y * distance);
69 output_range.push_back(p);
70 }
71
72 template
73 <
74 typename Point,
75 typename DistanceType,
76 typename OutputRange
77 >
78 inline void add_points(Point const& point,
79 DistanceType const& distance,
80 OutputRange& output_range) const
81 {
82 add_point(point, distance, -1.0, -1.0, output_range);
83 add_point(point, distance, -1.0, +1.0, output_range);
84 add_point(point, distance, +1.0, +1.0, output_range);
85 add_point(point, distance, +1.0, -1.0, output_range);
86
87 // Close it:
88 output_range.push_back(output_range.front());
89 }
90
91 public :
92
93 #ifndef DOXYGEN_SHOULD_SKIP_THIS
94 //! Fills output_range with a square around point using distance_strategy
95 template
96 <
97 typename Point,
98 typename DistanceStrategy,
99 typename OutputRange
100 >
101 inline void apply(Point const& point,
102 DistanceStrategy const& distance_strategy,
103 OutputRange& output_range) const
104 {
105 add_points(point, distance_strategy.apply(point, point,
106 strategy::buffer::buffer_side_left), output_range);
107 }
108 #endif // DOXYGEN_SHOULD_SKIP_THIS
109
110 };
111
112
113 }} // namespace strategy::buffer
114
115 }} // namespace boost::geometry
116
117 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP