]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/cartesian/distance_segment_box.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / strategies / cartesian / distance_segment_box.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2018-2019 Oracle and/or its affiliates.
4 // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP
12 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP
13
14 #include <boost/geometry/algorithms/detail/distance/segment_to_box.hpp>
15
16 #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
17 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
18 #include <boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp>
19 #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
20 #include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
21
22 namespace boost { namespace geometry
23 {
24
25
26 namespace strategy { namespace distance
27 {
28
29 template
30 <
31 typename CalculationType = void,
32 typename Strategy = pythagoras<CalculationType>
33 >
34 struct cartesian_segment_box
35 {
36 template <typename PointOfSegment, typename PointOfBox>
37 struct calculation_type
38 : promote_floating_point
39 <
40 typename strategy::distance::services::return_type
41 <
42 Strategy,
43 PointOfSegment,
44 PointOfBox
45 >::type
46 >
47 {};
48
49 typedef cartesian_tag cs_tag;
50
51 // point-point strategy getters
52 struct distance_pp_strategy
53 {
54 typedef Strategy type;
55 };
56
57 inline typename distance_pp_strategy::type get_distance_pp_strategy() const
58 {
59 return typename distance_pp_strategy::type();
60 }
61 // point-segment strategy getters
62 struct distance_ps_strategy
63 {
64 typedef projected_point<CalculationType, Strategy> type;
65 };
66
67 inline typename distance_ps_strategy::type get_distance_ps_strategy() const
68 {
69 return typename distance_ps_strategy::type();
70 }
71
72 struct distance_pb_strategy
73 {
74 typedef pythagoras_point_box<CalculationType> type;
75 };
76
77 inline typename distance_pb_strategy::type get_distance_pb_strategy() const
78 {
79 return typename distance_pb_strategy::type();
80 }
81
82 typedef side::side_by_triangle<CalculationType> side_strategy_type;
83
84 static inline side_strategy_type get_side_strategy()
85 {
86 return side_strategy_type();
87 }
88
89 typedef within::cartesian_point_point equals_point_point_strategy_type;
90
91 static inline equals_point_point_strategy_type get_equals_point_point_strategy()
92 {
93 return equals_point_point_strategy_type();
94 }
95
96 template <typename LessEqual, typename ReturnType,
97 typename SegmentPoint, typename BoxPoint>
98 inline ReturnType segment_below_of_box(SegmentPoint const& p0,
99 SegmentPoint const& p1,
100 BoxPoint const&,
101 BoxPoint const&,
102 BoxPoint const&,
103 BoxPoint const& bottom_right) const
104 {
105
106
107 return geometry::detail::distance::segment_to_box_2D
108 <
109 ReturnType,
110 SegmentPoint,
111 BoxPoint,
112 cartesian_segment_box<CalculationType, Strategy>
113 >::template call_above_of_box
114 <
115 typename LessEqual::other
116 >(p1, p0, bottom_right, *this);
117 }
118
119 template <typename SPoint, typename BPoint>
120 static void mirror(SPoint&,
121 SPoint&,
122 BPoint&,
123 BPoint&,
124 BPoint&,
125 BPoint&)
126 {}
127 };
128
129 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
130 namespace services
131 {
132
133 template <typename CalculationType, typename Strategy>
134 struct tag<cartesian_segment_box<CalculationType, Strategy> >
135 {
136 typedef strategy_tag_distance_segment_box type;
137 };
138
139 template <typename CalculationType, typename Strategy, typename PS, typename PB>
140 struct return_type<cartesian_segment_box<CalculationType, Strategy>, PS, PB>
141 : cartesian_segment_box<CalculationType, Strategy>::template calculation_type<PS, PB>
142 {};
143
144 template <typename CalculationType, typename Strategy>
145 struct comparable_type<cartesian_segment_box<CalculationType, Strategy> >
146 {
147 // Define a cartesian_segment_box strategy with its underlying point-point
148 // strategy being comparable
149 typedef cartesian_segment_box
150 <
151 CalculationType,
152 typename comparable_type<Strategy>::type
153 > type;
154 };
155
156
157 template <typename CalculationType, typename Strategy>
158 struct get_comparable<cartesian_segment_box<CalculationType, Strategy> >
159 {
160 typedef typename comparable_type
161 <
162 cartesian_segment_box<CalculationType, Strategy>
163 >::type comparable_type;
164 public :
165 static inline comparable_type apply(cartesian_segment_box<CalculationType, Strategy> const& )
166 {
167 return comparable_type();
168 }
169 };
170
171 template <typename CalculationType, typename Strategy, typename PS, typename PB>
172 struct result_from_distance<cartesian_segment_box<CalculationType, Strategy>, PS, PB>
173 {
174 private :
175 typedef typename return_type<
176 cartesian_segment_box
177 <
178 CalculationType,
179 Strategy
180 >,
181 PS,
182 PB
183 >::type return_type;
184 public :
185 template <typename T>
186 static inline return_type apply(cartesian_segment_box<CalculationType,
187 Strategy> const& ,
188 T const& value)
189 {
190 Strategy s;
191 return result_from_distance<Strategy, PS, PB>::apply(s, value);
192 }
193 };
194
195 template <typename Segment, typename Box>
196 struct default_strategy
197 <
198 segment_tag, box_tag, Segment, Box,
199 cartesian_tag, cartesian_tag
200 >
201 {
202 typedef cartesian_segment_box<> type;
203 };
204
205 template <typename Box, typename Segment>
206 struct default_strategy
207 <
208 box_tag, segment_tag, Box, Segment,
209 cartesian_tag, cartesian_tag
210 >
211 {
212 typedef typename default_strategy
213 <
214 segment_tag, box_tag, Segment, Box,
215 cartesian_tag, cartesian_tag
216 >::type type;
217 };
218
219 }
220 #endif
221
222 }} // namespace strategy::distance
223
224 }} // namespace boost::geometry
225 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP