]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/cartesian/buffer_point_square.hpp
import new upstream nautilus stable release 14.2.8
[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 OutputRange
58 >
59 inline void add_point(Point const& point,
60 DistanceType const& distance,
61 DistanceType const& x,
62 DistanceType const& y,
63 OutputRange& output_range) const
64 {
65 typename boost::range_value<OutputRange>::type p;
66 set<0>(p, get<0>(point) + x * distance);
67 set<1>(p, get<1>(point) + y * distance);
68 output_range.push_back(p);
69 }
70
71 template
72 <
73 typename Point,
74 typename DistanceType,
75 typename OutputRange
76 >
77 inline void add_points(Point const& point,
78 DistanceType const& distance,
79 OutputRange& output_range) const
80 {
81 add_point(point, distance, -1.0, -1.0, output_range);
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
86 // Close it:
87 output_range.push_back(output_range.front());
88 }
89
90 public :
91
92 #ifndef DOXYGEN_SHOULD_SKIP_THIS
93 //! Fills output_range with a square around point using distance_strategy
94 template
95 <
96 typename Point,
97 typename DistanceStrategy,
98 typename OutputRange
99 >
100 inline void apply(Point const& point,
101 DistanceStrategy const& distance_strategy,
102 OutputRange& output_range) const
103 {
104 add_points(point, distance_strategy.apply(point, point,
105 strategy::buffer::buffer_side_left), output_range);
106 }
107 #endif // DOXYGEN_SHOULD_SKIP_THIS
108
109 };
110
111
112 }} // namespace strategy::buffer
113
114 }} // namespace boost::geometry
115
116 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP