]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/cs_undefined/setops.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / geometry / test / cs_undefined / setops.cpp
1 // Boost.Geometry
2
3 // Copyright (c) 2019, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
10 #include "common.hpp"
11
12 #include <boost/geometry/algorithms/difference.hpp>
13 #include <boost/geometry/algorithms/intersection.hpp>
14 #include <boost/geometry/algorithms/sym_difference.hpp>
15 #include <boost/geometry/algorithms/union.hpp>
16
17 template <typename G1, typename G2, typename G3, typename S>
18 inline void set_idsu(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
19 {
20 bg::intersection(g1, g2, g3, s);
21 bg::difference(g1, g2, g3, s);
22 bg::sym_difference(g1, g2, g3, s);
23 bg::union_(g1, g2, g3, s);
24 }
25
26 template <typename G1, typename G2, typename G3, typename S>
27 inline void set_ids(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
28 {
29 bg::intersection(g1, g2, g3, s);
30 bg::difference(g1, g2, g3, s);
31 bg::sym_difference(g1, g2, g3, s);
32 }
33
34 template <typename G1, typename G2, typename G3, typename S>
35 inline void set_id(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
36 {
37 bg::intersection(g1, g2, g3, s);
38 bg::difference(g1, g2, g3, s);
39 }
40
41 template <typename G1, typename G2, typename G3, typename S>
42 inline void set_i(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
43 {
44 bg::intersection(g1, g2, g3, s);
45 }
46
47 template <typename G1, typename G2, typename G3, typename S>
48 inline void set_d(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
49 {
50 bg::difference(g1, g2, g3, s);
51 }
52
53 template <typename G1, typename G2, typename G3>
54 inline void set_idsu_pp(G1 const& g1, G2 const& g2, G3 & g3)
55 {
56 ::set_idsu(g1, g2, g3, bg::strategy::within::cartesian_point_point());
57 ::set_idsu(g1, g2, g3, bg::strategy::within::spherical_point_point());
58 }
59
60 template <typename G1, typename G2, typename G3>
61 inline void set_idsu_ps(G1 const& g1, G2 const& g2, G3 & g3)
62 {
63 typedef typename bg::point_type<G1>::type point_type;
64 ::set_idsu(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
65 ::set_idsu(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
66 ::set_idsu(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
67 }
68
69 template <typename G1, typename G2, typename G3>
70 inline void set_idsu_ss(G1 const& g1, G2 const& g2, G3 & g3)
71 {
72 ::set_idsu(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
73 ::set_idsu(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
74 ::set_idsu(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
75 }
76
77 template <typename G1, typename G2, typename G3>
78 inline void set_ids_pp(G1 const& g1, G2 const& g2, G3 & g3)
79 {
80 ::set_ids(g1, g2, g3, bg::strategy::within::cartesian_point_point());
81 ::set_ids(g1, g2, g3, bg::strategy::within::spherical_point_point());
82 }
83
84 template <typename G1, typename G2, typename G3>
85 inline void set_ids_ps(G1 const& g1, G2 const& g2, G3 & g3)
86 {
87 typedef typename bg::point_type<G1>::type point_type;
88 ::set_ids(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
89 ::set_ids(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
90 ::set_ids(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
91 }
92
93 template <typename G1, typename G2, typename G3>
94 inline void set_ids_ss(G1 const& g1, G2 const& g2, G3 & g3)
95 {
96 ::set_ids(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
97 ::set_ids(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
98 ::set_ids(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
99 }
100
101 template <typename G1, typename G2, typename G3>
102 inline void set_id_pp(G1 const& g1, G2 const& g2, G3 & g3)
103 {
104 ::set_id(g1, g2, g3, bg::strategy::within::cartesian_point_point());
105 ::set_id(g1, g2, g3, bg::strategy::within::spherical_point_point());
106 }
107
108 template <typename G1, typename G2, typename G3>
109 inline void set_id_ps(G1 const& g1, G2 const& g2, G3 & g3)
110 {
111 typedef typename bg::point_type<G1>::type point_type;
112 ::set_id(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
113 ::set_id(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
114 ::set_id(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
115 }
116
117 template <typename G1, typename G2, typename G3>
118 inline void set_id_ss(G1 const& g1, G2 const& g2, G3 & g3)
119 {
120 ::set_id(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
121 ::set_id(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
122 ::set_id(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
123 }
124
125 template <typename G1, typename G2, typename G3>
126 inline void set_i_pp(G1 const& g1, G2 const& g2, G3 & g3)
127 {
128 ::set_i(g1, g2, g3, bg::strategy::within::cartesian_point_point());
129 ::set_i(g1, g2, g3, bg::strategy::within::spherical_point_point());
130 }
131
132 template <typename G1, typename G2, typename G3>
133 inline void set_i_ps(G1 const& g1, G2 const& g2, G3 & g3)
134 {
135 typedef typename bg::point_type<G1>::type point_type;
136 ::set_i(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
137 ::set_i(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
138 ::set_i(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
139 }
140
141 template <typename G1, typename G2, typename G3>
142 inline void set_i_ss(G1 const& g1, G2 const& g2, G3 & g3)
143 {
144 ::set_i(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
145 ::set_i(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
146 ::set_i(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
147 }
148
149 template <typename G1, typename G2, typename G3>
150 inline void set_d_pp(G1 const& g1, G2 const& g2, G3 & g3)
151 {
152 ::set_d(g1, g2, g3, bg::strategy::within::cartesian_point_point());
153 ::set_d(g1, g2, g3, bg::strategy::within::spherical_point_point());
154 }
155
156 template <typename G1, typename G2, typename G3>
157 inline void set_d_ps(G1 const& g1, G2 const& g2, G3 & g3)
158 {
159 typedef typename bg::point_type<G1>::type point_type;
160 ::set_d(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
161 ::set_d(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
162 ::set_d(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
163 }
164
165 template <typename G1, typename G2, typename G3>
166 inline void set_d_ss(G1 const& g1, G2 const& g2, G3 & g3)
167 {
168 ::set_d(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
169 ::set_d(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
170 ::set_d(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
171 }
172
173 int test_main(int, char*[])
174 {
175 geom g;
176
177 // P/P->P
178 ::set_idsu_pp(g.pt, g.pt, g.mpt);
179 ::set_idsu_pp(g.pt, g.mpt, g.mpt);
180 ::set_idsu_pp(g.mpt, g.mpt, g.mpt);
181
182 // P/L->P
183 ::set_id_ps(g.pt, g.s, g.mpt);
184 ::set_id_ps(g.pt, g.ls, g.mpt);
185 ::set_id_ps(g.pt, g.mls, g.mpt);
186 ::set_id_ps(g.mpt, g.s, g.mpt);
187 ::set_id_ps(g.mpt, g.ls, g.mpt);
188 ::set_id_ps(g.mpt, g.mls, g.mpt);
189
190 // P/A->P
191 // no intersection nor difference
192 //::set_id_ps(g.pt, g.r, g.mpt);
193 //::set_id_ps(g.pt, g.po, g.mpt);
194 //::set_id_ps(g.pt, g.mpo, g.mpt);
195 //::set_id_ps(g.mpt, g.r, g.mpt);
196 //::set_id_ps(g.mpt, g.po, g.mpt);
197 //::set_id_ps(g.mpt, g.mpo, g.mpt);
198
199 // L/L->P
200 ::set_ids_ss(g.s, g.s, g.mpt);
201 //::set_i_ss(g.s, g.ls, g.mpt); // no intersection nor difference
202 //::set_i_ss(g.s, g.mls, g.mpt); // no intersection nor difference
203 //::set_i_ss(g.ls, g.s, g.mpt); // no intersection nor difference
204 ::set_ids_ss(g.ls, g.ls, g.mpt);
205 ::set_i_ss(g.ls, g.mls, g.mpt); // no difference nor sym_difference
206 //::set_i_ss(g.mls, g.s, g.mpt); // no intersection nor difference
207 ::set_i_ss(g.mls, g.ls, g.mpt); // no difference nor sym_difference
208 ::set_ids_ss(g.mls, g.mls, g.mpt);
209
210 // L/L->L
211 //::set_ids_ss(g.s, g.s, g.mls); // union not implemented, missing specialization
212 //::set_idsu_ss(g.s, g.ls, g.mls); // missing specialization
213 //::set_idsu_ss(g.s, g.mls, g.mls); // missing specialization
214 //::set_idsu_ss(g.ls, g.s, g.mls); // missing specialization
215 ::set_idsu_ss(g.ls, g.ls, g.mls);
216 ::set_idsu_ss(g.ls, g.mls, g.mls);
217 //::set_idsu_ss(g.mls, g.s, g.mls); // missing specialization
218 ::set_idsu_ss(g.mls, g.ls, g.mls);
219 ::set_idsu_ss(g.mls, g.mls, g.mls);
220
221 // S/B->L ?
222
223 // L/B->L ?
224
225 // L/A->P
226 //::set_ids_ss(g.s, g.r, g.mpt); // no intersection
227 //::set_ids_ss(g.s, g.po, g.mpt); // no intersection
228 //::set_ids_ss(g.s, g.mpo, g.mpt); // no intersection
229 ::set_ids_ss(g.ls, g.r, g.mpt);
230 ::set_ids_ss(g.ls, g.po, g.mpt);
231 ::set_ids_ss(g.ls, g.mpo, g.mpt);
232 ::set_ids_ss(g.mls, g.r, g.mpt);
233 ::set_ids_ss(g.mls, g.po, g.mpt);
234 ::set_ids_ss(g.mls, g.mpo, g.mpt);
235
236 // L/A->L
237 //::set_id_ss(g.s, g.r, g.mls); // no intersection
238 //::set_id_ss(g.s, g.po, g.mls); // no intersection
239 //::set_id_ss(g.s, g.mpo, g.mls); // no intersection
240 ::set_id_ss(g.ls, g.r, g.mls);
241 ::set_id_ss(g.ls, g.po, g.mls);
242 ::set_id_ss(g.ls, g.mpo, g.mls);
243 ::set_id_ss(g.mls, g.r, g.mls);
244 ::set_id_ss(g.mls, g.po, g.mls);
245 ::set_id_ss(g.mls, g.mpo, g.mls);
246
247 // A/A->P
248 ::set_i_ss(g.r, g.r, g.mpt);
249 ::set_i_ss(g.r, g.po, g.mpt);
250 ::set_i_ss(g.r, g.mpo, g.mpt);
251 ::set_i_ss(g.po, g.r, g.mpt);
252 ::set_i_ss(g.po, g.po, g.mpt);
253 ::set_i_ss(g.po, g.mpo, g.mpt);
254 ::set_i_ss(g.mpo, g.r, g.mpt);
255 ::set_i_ss(g.mpo, g.po, g.mpt);
256 ::set_i_ss(g.mpo, g.mpo, g.mpt);
257
258 // A/A->L
259 ::set_i_ss(g.r, g.r, g.mls);
260 ::set_i_ss(g.r, g.po, g.mls);
261 ::set_i_ss(g.r, g.mpo, g.mls);
262 ::set_i_ss(g.po, g.r, g.mls);
263 ::set_i_ss(g.po, g.po, g.mls);
264 ::set_i_ss(g.po, g.mpo, g.mls);
265 ::set_i_ss(g.mpo, g.r, g.mls);
266 ::set_i_ss(g.mpo, g.po, g.mls);
267 ::set_i_ss(g.mpo, g.mpo, g.mls);
268
269 // A/A->A
270 ::set_idsu_ss(g.r, g.r, g.mpo);
271 ::set_idsu_ss(g.r, g.po, g.mpo);
272 ::set_idsu_ss(g.r, g.mpo, g.mpo);
273 ::set_idsu_ss(g.po, g.r, g.mpo);
274 ::set_idsu_ss(g.po, g.po, g.mpo);
275 ::set_idsu_ss(g.po, g.mpo, g.mpo);
276 ::set_idsu_ss(g.mpo, g.r, g.mpo);
277 ::set_idsu_ss(g.mpo, g.po, g.mpo);
278 ::set_idsu_ss(g.mpo, g.mpo, g.mpo);
279
280 return 0;
281 }