]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/overlay/get_turn_info.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / overlay / get_turn_info.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
4// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
b32b8144
FG
6// This file was modified by Oracle on 2017.
7// Modifications copyright (c) 2017, Oracle and/or its affiliates.
8// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
7c673cae
FG
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#include <iostream>
15
16#include <geometry_test_common.hpp>
17
18
19#include <boost/foreach.hpp>
20
21#include <boost/geometry/algorithms/intersection.hpp>
b32b8144 22#include <boost/geometry/algorithms/make.hpp>
7c673cae
FG
23
24#include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
25#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
26#include <boost/geometry/geometries/point_xy.hpp>
27
28#if defined(TEST_WITH_SVG)
29# include <boost/geometry/io/svg/svg_mapper.hpp>
30#endif
31
32
33
34template <typename P, typename T>
35void test_with_point(std::string const& caseid,
36 T pi_x, T pi_y, T pj_x, T pj_y, T pk_x, T pk_y,
37 T qi_x, T qi_y, T qj_x, T qj_y, T qk_x, T qk_y,
38 bg::detail::overlay::method_type expected_method,
b32b8144 39 bool expected_touch_only,
7c673cae
FG
40 T ip_x, T ip_y,
41 std::string const& expected,
42 T ip_x2, T ip_y2)
43{
44 P pi = bg::make<P>(pi_x, pi_y);
45 P pj = bg::make<P>(pj_x, pj_y);
46 P pk = bg::make<P>(pk_x, pk_y);
47 P qi = bg::make<P>(qi_x, qi_y);
48 P qj = bg::make<P>(qj_x, qj_y);
49 P qk = bg::make<P>(qk_x, qk_y);
50
b32b8144
FG
51 typedef typename bg::strategy::intersection::services::default_strategy
52 <
53 typename bg::cs_tag<P>::type
54 >::type strategy_type;
55
7c673cae
FG
56 typedef typename bg::detail::no_rescale_policy rescale_policy_type;
57
58 typedef bg::detail::overlay::turn_info
59 <
60 P,
61 typename bg::segment_ratio_type<P, rescale_policy_type>::type
62 > turn_info;
63 typedef std::vector<turn_info> tp_vector;
64 turn_info model;
65 tp_vector info;
b32b8144 66 strategy_type strategy;
7c673cae
FG
67 rescale_policy_type rescale_policy;
68 bg::detail::overlay::get_turn_info
69 <
70 bg::detail::overlay::assign_null_policy
71 >::apply(pi, pj, pk, qi, qj, qk,
72 false, false, false, false, // dummy parameters
b32b8144 73 model, strategy, rescale_policy, std::back_inserter(info));
7c673cae
FG
74
75
76 if (info.size() == 0)
77 {
78 BOOST_CHECK_EQUAL(expected_method,
79 bg::detail::overlay::method_none);
80 }
81
82 std::string detected;
83 std::string method;
84 for (typename tp_vector::const_iterator it = info.begin(); it != info.end(); ++it)
85 {
86 for (int t = 0; t < 2; t++)
87 {
88 detected += bg::operation_char(it->operations[t].operation);
89 method += bg::method_char(it->method);
90 }
91 }
92
93 BOOST_CHECK_MESSAGE(detected == expected,
94 caseid
95 << (caseid.find("_") == std::string::npos ? " " : "")
96 << " method: " << method
97 << " detected: " << detected
98 << " expected: " << expected);
99
100
101 if (! info.empty())
102 {
103 BOOST_CHECK_EQUAL(info[0].method, expected_method);
b32b8144
FG
104 BOOST_CHECK_MESSAGE(info[0].touch_only == expected_touch_only,
105 caseid
106 << " detected: " << info[0].touch_only
107 << " expected: " << expected_touch_only);
7c673cae
FG
108 BOOST_CHECK_CLOSE(bg::get<0>(info[0].point), ip_x, 0.001);
109 BOOST_CHECK_CLOSE(bg::get<1>(info[0].point), ip_y, 0.001);
110
111 if (info.size() > 1)
112 {
113 BOOST_CHECK_EQUAL(info.size(), 2u);
114 BOOST_CHECK_EQUAL(info[1].method, expected_method);
115 BOOST_CHECK_CLOSE(bg::get<0>(info[1].point), ip_x2, 0.001);
116 BOOST_CHECK_CLOSE(bg::get<1>(info[1].point), ip_y2, 0.001);
117 }
118 }
119
120#if defined(TEST_WITH_SVG)
121 {
122 std::ostringstream filename;
123 filename << "get_turn_info_" << caseid
124 << "_" << string_from_type<typename bg::coordinate_type<P>::type>::name()
125 << ".svg";
126
127 std::ofstream svg(filename.str().c_str());
128
129 bg::svg_mapper<P> mapper(svg, 500, 500);
130 mapper.add(bg::make<P>(0, 0));
131 mapper.add(bg::make<P>(10, 10));
132
133 bg::model::linestring<P> p; p.push_back(pi); p.push_back(pj); p.push_back(pk);
134 bg::model::linestring<P> q; q.push_back(qi); q.push_back(qj); q.push_back(qk);
135 mapper.map(p, "opacity:0.8;stroke:rgb(0,192,0);stroke-width:3");
136 mapper.map(q, "opacity:0.8;stroke:rgb(0,0,255);stroke-width:3");
137
138 std::string style = ";font-family='Verdana';font-weight:bold";
139 std::string align = ";text-anchor:end;text-align:end";
140 int offset = 8;
141
142 mapper.text(pi, "pi", "fill:rgb(0,192,0)" + style, offset, offset);
143 mapper.text(pj, "pj", "fill:rgb(0,192,0)" + style, offset, offset);
144 mapper.text(pk, "pk", "fill:rgb(0,192,0)" + style, offset, offset);
145
146 mapper.text(qi, "qi", "fill:rgb(0,0,255)" + style + align, -offset, offset);
147 mapper.text(qj, "qj", "fill:rgb(0,0,255)" + style + align, -offset, offset);
148 mapper.text(qk, "qk", "fill:rgb(0,0,255)" + style + align, -offset, offset);
149
150
151 int factor = 1; // second info, if any, will go left by factor -1
152 int ch = '1';
153 for (typename tp_vector::const_iterator it = info.begin();
154 it != info.end();
155 ++it, factor *= -1, ch++)
156 {
157 bool at_j = it->method == bg::detail::overlay::method_crosses;
158 std::string op;
159 op += bg::operation_char(it->operations[0].operation);
160 align = ";text-anchor:middle;text-align:center";
161 mapper.text(at_j ? pj : pk, op, "fill:rgb(255,128,0)" + style + align, offset * factor, -offset);
162
163 op.clear();
164 op += bg::operation_char(it->operations[1].operation);
165 mapper.text(at_j ? qj : qk, op, "fill:rgb(255,128,0)" + style + align, offset * factor, -offset);
166
167 // Map intersection point + method
168 mapper.map(it->point, "opacity:0.8;fill:rgb(255,0,0);stroke:rgb(0,0,100);stroke-width:1");
169
170 op.clear();
171 op += bg::method_char(it->method);
b32b8144
FG
172 op += ' ';
173 op += (it->touch_only ? 'o' : '*');
7c673cae
FG
174 if (info.size() != 1)
175 {
176 op += ch;
177 op += " p:"; op += bg::operation_char(it->operations[0].operation);
178 op += " q:"; op += bg::operation_char(it->operations[1].operation);
179 }
180 mapper.text(it->point, op, "fill:rgb(255,0,0)" + style, offset, -offset);
181 }
182 }
183#endif
184
185}
186
187template <typename P, typename T>
188void test_both(std::string const& caseid,
189 T pi_x, T pi_y, T pj_x, T pj_y, T pk_x, T pk_y,
190 T qi_x, T qi_y, T qj_x, T qj_y, T qk_x, T qk_y,
191 bg::detail::overlay::method_type method
192 = bg::detail::overlay::method_none,
b32b8144 193 bool expected_touch_only = false,
7c673cae
FG
194 T ip_x = -1, T ip_y = -1,
195 std::string const& expected = "",
196 T ip_x2 = -1, T ip_y2 = -1)
197{
198 test_with_point<P, double>(caseid,
199 pi_x, pi_y, pj_x, pj_y, pk_x, pk_y,
200 qi_x, qi_y, qj_x, qj_y, qk_x, qk_y,
b32b8144 201 method, expected_touch_only, ip_x, ip_y, expected, ip_x2, ip_y2);
7c673cae
FG
202
203 std::string reversed(expected.rbegin(), expected.rend());
204
205 if (ip_x2 >= 0 && ip_y2 >= 0)
206 {
207 std::swap(ip_x, ip_x2);
208 std::swap(ip_y, ip_y2);
209 }
210
211 test_with_point<P, double>(caseid + "_r",
212 qi_x, qi_y, qj_x, qj_y, qk_x, qk_y, // q
213 pi_x, pi_y, pj_x, pj_y, pk_x, pk_y, // p
b32b8144 214 method, expected_touch_only, ip_x, ip_y, reversed, ip_x2, ip_y2);
7c673cae
FG
215}
216
217
218template <typename P>
219void test_all()
220{
221 using namespace bg::detail::overlay;
222
223 // See powerpoint "doc/testcases/get_turn_info.ppt"
224
225
226 // ------------------------------------------------------------------------
227 // "Real" intersections ("i"), or, crossing
228 // ------------------------------------------------------------------------
229 test_both<P, double>("il1",
230 5, 1, 5, 6, 7, 8, // p
231 3, 3, 7, 5, 8, 3, // q
b32b8144 232 method_crosses, false, 5, 4, "ui");
7c673cae
FG
233
234 test_both<P, double>("il2",
235 5, 1, 5, 6, 7, 8, // p
236 3, 5, 7, 5, 3, 3, // q
b32b8144 237 method_crosses, false, 5, 5, "ui");
7c673cae
FG
238
239 test_both<P, double>("il3",
240 5, 1, 5, 6, 7, 8, // p
241 3, 3, 7, 5, 3, 5, // q
b32b8144 242 method_crosses, false, 5, 4, "ui");
7c673cae
FG
243
244 test_both<P, double>("il4",
245 5, 1, 5, 6, 7, 8, // p
246 3, 3, 7, 5, 4, 8, // q
b32b8144 247 method_crosses, false, 5, 4, "ui");
7c673cae
FG
248
249 test_both<P, double>("ir1",
250 5, 1, 5, 6, 7, 8, // p
251 7, 5, 3, 3, 2, 5, // q
b32b8144 252 method_crosses, false, 5, 4, "iu");
7c673cae
FG
253
254
255 // ------------------------------------------------------------------------
256 // TOUCH INTERIOR or touch in the middle ("m")
257 // ------------------------------------------------------------------------
258 test_both<P, double>("ml1",
259 5, 1, 5, 6, 7, 8, // p
260 3, 3, 5, 4, 7, 3, // q
b32b8144 261 method_touch_interior, false, 5, 4, "ui");
7c673cae
FG
262
263 test_both<P, double>("ml2",
264 5, 1, 5, 6, 7, 8, // p
265 3, 3, 5, 4, 3, 6, // q
b32b8144 266 method_touch_interior, true, 5, 4, "iu");
7c673cae
FG
267
268 test_both<P, double>("ml3",
269 5, 1, 5, 6, 7, 8, // p
270 3, 6, 5, 4, 3, 3, // q
b32b8144 271 method_touch_interior, true, 5, 4, "uu");
7c673cae
FG
272
273 test_both<P, double>("mr1",
274 5, 1, 5, 6, 7, 8, // p
275 7, 3, 5, 4, 3, 3, // q
b32b8144 276 method_touch_interior, false, 5, 4, "iu");
7c673cae
FG
277
278 test_both<P, double>("mr2",
279 5, 1, 5, 6, 7, 8, // p
280 7, 3, 5, 4, 7, 6, // q
b32b8144 281 method_touch_interior, true, 5, 4, "ui");
7c673cae
FG
282
283 test_both<P, double>("mr3",
284 5, 1, 5, 6, 7, 8, // p
285 7, 6, 5, 4, 7, 3, // q
b32b8144 286 method_touch_interior, true, 5, 4, "ii");
7c673cae
FG
287
288 test_both<P, double>("mcl",
289 5, 1, 5, 6, 7, 8, // p
290 3, 2, 5, 3, 5, 5, // q
b32b8144 291 method_touch_interior, false, 5, 3, "cc");
7c673cae
FG
292
293 test_both<P, double>("mcr",
294 5, 1, 5, 6, 7, 8, // p
295 7, 2, 5, 3, 5, 5, // q
b32b8144 296 method_touch_interior, false, 5, 3, "cc");
7c673cae
FG
297
298 test_both<P, double>("mclo",
299 5, 1, 5, 6, 7, 8, // p
300 3, 4, 5, 5, 5, 3, // q
b32b8144 301 method_touch_interior, false, 5, 5, "ux");
7c673cae
FG
302
303 test_both<P, double>("mcro",
304 5, 1, 5, 6, 7, 8, // p
305 7, 4, 5, 5, 5, 3, // q
b32b8144 306 method_touch_interior, false, 5, 5, "ix");
7c673cae
FG
307
308 // ------------------------------------------------------------------------
309 // COLLINEAR
310 // ------------------------------------------------------------------------
311 test_both<P, double>("cll1",
312 5, 1, 5, 6, 3, 8, // p
313 5, 5, 5, 7, 3, 8, // q
b32b8144 314 method_collinear, false, 5, 6, "ui");
7c673cae
FG
315 test_both<P, double>("cll2",
316 5, 1, 5, 6, 3, 8, // p
317 5, 3, 5, 5, 3, 6, // q
b32b8144 318 method_collinear, false, 5, 5, "iu");
7c673cae
FG
319 test_both<P, double>("clr1",
320 5, 1, 5, 6, 3, 8, // p
321 5, 5, 5, 7, 6, 8, // q
b32b8144 322 method_collinear, false, 5, 6, "ui");
7c673cae
FG
323 test_both<P, double>("clr2",
324 5, 1, 5, 6, 3, 8, // p
325 5, 3, 5, 5, 6, 6, // q
b32b8144 326 method_collinear, false, 5, 5, "ui");
7c673cae
FG
327
328 test_both<P, double>("crl1",
329 5, 1, 5, 6, 7, 8, // p
330 5, 5, 5, 7, 3, 8, // q
b32b8144 331 method_collinear, false, 5, 6, "iu");
7c673cae
FG
332 test_both<P, double>("crl2",
333 5, 1, 5, 6, 7, 8, // p
334 5, 3, 5, 5, 3, 6, // q
b32b8144 335 method_collinear, false, 5, 5, "iu");
7c673cae
FG
336 test_both<P, double>("crr1",
337 5, 1, 5, 6, 7, 8, // p
338 5, 5, 5, 7, 6, 8, // q
b32b8144 339 method_collinear, false, 5, 6, "iu");
7c673cae
FG
340 test_both<P, double>("crr2",
341 5, 1, 5, 6, 7, 8, // p
342 5, 3, 5, 5, 6, 6, // q
b32b8144 343 method_collinear, false, 5, 5, "ui");
7c673cae
FG
344
345 // The next two cases are changed (BSG 2013-09-24), they contain turn info (#buffer_rt_g)
346 // In new approach they are changed back (BSG 2013-10-20)
347 test_both<P, double>("ccx1",
348 5, 1, 5, 6, 5, 8, // p
349 5, 5, 5, 7, 3, 8, // q
b32b8144 350 method_collinear, false, 5, 6, "cc"); // "iu");
7c673cae
FG
351 test_both<P, double>("cxc1",
352 5, 1, 5, 6, 7, 8, // p
353 5, 3, 5, 5, 5, 7, // q
b32b8144 354 method_collinear, false, 5, 5, "cc"); // "iu");
7c673cae
FG
355
356 // Bug in case #54 of "overlay_cases.hpp"
357 test_both<P, double>("c_bug1",
358 5, 0, 2, 0, 2, 2, // p
359 4, 0, 1, 0, 1, 2, // q
b32b8144 360 method_collinear, false, 2, 0, "iu");
7c673cae
FG
361
362
363 // ------------------------------------------------------------------------
364 // COLLINEAR OPPOSITE
365 // ------------------------------------------------------------------------
366
367 test_both<P, double>("clo1",
368 5, 2, 5, 6, 3, 8, // p
369 5, 7, 5, 5, 3, 3, // q
b32b8144 370 method_collinear, false, 5, 6, "ixxu", 5, 5);
7c673cae
FG
371 test_both<P, double>("clo2",
372 5, 2, 5, 6, 3, 8, // p
373 5, 7, 5, 5, 5, 2, // q
b32b8144 374 method_collinear, false, 5, 6, "ix");
7c673cae
FG
375 // actually "xxix", xx is skipped everywhere
376 test_both<P, double>("clo3",
377 5, 2, 5, 6, 3, 8, // p
378 5, 7, 5, 5, 7, 3, // q
b32b8144 379 method_collinear, false, 5, 6, "ixxi", 5, 5);
7c673cae
FG
380
381 test_both<P, double>("cco1",
382 5, 2, 5, 6, 5, 8, // p
383 5, 7, 5, 5, 3, 3, // q
b32b8144 384 method_collinear, false, 5, 5, "xu"); // "xuxx"
7c673cae
FG
385 test_both<P, double>("cco2",
386 5, 2, 5, 6, 5, 8, // p
387 5, 7, 5, 5, 5, 2); // q "xxxx"
388 test_both<P, double>("cco3",
389 5, 2, 5, 6, 5, 8, // p
390 5, 7, 5, 5, 7, 3, // q
b32b8144 391 method_collinear, false, 5, 5, "xi"); // "xixx"
7c673cae
FG
392
393
394 test_both<P, double>("cro1",
395 5, 2, 5, 6, 7, 8, // p
396 5, 7, 5, 5, 3, 3, // q
b32b8144 397 method_collinear, false, 5, 6, "uxxu", 5, 5);
7c673cae
FG
398 test_both<P, double>("cro2",
399 5, 2, 5, 6, 7, 8, // p
400 5, 7, 5, 5, 5, 2, // q
b32b8144 401 method_collinear, false, 5, 6, "ux"); // "xxux"
7c673cae
FG
402 test_both<P, double>("cro3",
403 5, 2, 5, 6, 7, 8, // p
404 5, 7, 5, 5, 7, 3, // q
b32b8144 405 method_collinear, false, 5, 6, "uxxi", 5, 5);
7c673cae
FG
406
407 test_both<P, double>("cxo1",
408 5, 2, 5, 6, 3, 8, // p
409 5, 5, 5, 3, 3, 1, // q
b32b8144 410 method_collinear, false, 5, 3, "xu");
7c673cae
FG
411 test_both<P, double>("cxo2",
412 5, 2, 5, 6, 3, 8, // p
413 5, 5, 5, 3, 5, 0); // q "xx"
414 test_both<P, double>("cxo3",
415 5, 2, 5, 6, 3, 8, // p
416 5, 5, 5, 3, 7, 1, // q
b32b8144 417 method_collinear, false, 5, 3, "xi");
7c673cae
FG
418
419 test_both<P, double>("cxo4",
420 5, 2, 5, 6, 3, 8, // p
421 5, 7, 5, 1, 3, 0, // q
b32b8144 422 method_collinear, false, 5, 6, "ix");
7c673cae
FG
423 test_both<P, double>("cxo5",
424 5, 2, 5, 6, 5, 8, // p
425 5, 7, 5, 1, 3, 0); // q "xx"
426 test_both<P, double>("cxo6",
427 5, 2, 5, 6, 7, 8, // p
428 5, 7, 5, 1, 3, 0, // q
b32b8144 429 method_collinear, false, 5, 6, "ux");
7c673cae
FG
430
431
432 // Verify
433 test_both<P, double>("cvo1",
434 5, 3, 5, 7, 7, 9, // p
435 5, 5, 5, 3, 3, 1 // q
436 );
437 test_both<P, double>("cvo2",
438 5, 3, 5, 7, 7, 9, // p
439 5, 4, 5, 2, 3, 0 // q
440 );
441
442
443 // ------------------------------------------------------------------------
444 // TOUCH - both same
445 // ------------------------------------------------------------------------
446 // Both left, Q turns right
447 test_both<P, double>("blr1",
448 5, 1, 5, 6, 4, 4, // p
449 3, 7, 5, 6, 3, 5, // q
b32b8144 450 method_touch, true, 5, 6, "ui");
7c673cae
FG
451 test_both<P, double>("blr2",
452 5, 1, 5, 6, 1, 4, // p
453 3, 7, 5, 6, 3, 5, // q
b32b8144 454 method_touch, false, 5, 6, "cc");
7c673cae
FG
455 test_both<P, double>("blr3",
456 5, 1, 5, 6, 3, 6, // p
457 3, 7, 5, 6, 3, 5, // q
b32b8144 458 method_touch, false, 5, 6, "iu");
7c673cae
FG
459 test_both<P, double>("blr4",
460 5, 1, 5, 6, 1, 8, // p
461 3, 7, 5, 6, 3, 5, // q
b32b8144 462 method_touch, false, 5, 6, "xu");
7c673cae
FG
463 test_both<P, double>("blr5",
464 5, 1, 5, 6, 4, 8, // p
465 3, 7, 5, 6, 3, 5, // q
b32b8144 466 method_touch, true, 5, 6, "uu");
7c673cae
FG
467 test_both<P, double>("blr6",
468 5, 1, 5, 6, 6, 4, // p
469 3, 7, 5, 6, 3, 5, // q
b32b8144 470 method_touch, true, 5, 6, "uu");
7c673cae
FG
471
472 test_both<P, double>("blr7",
473 5, 1, 5, 6, 3, 6, // p
474 3, 7, 5, 6, 5, 3, // q
b32b8144 475 method_touch, false, 5, 6, "ix");
7c673cae
FG
476 test_both<P, double>("blr8",
477 5, 1, 5, 6, 3, 6, // p
478 3, 6, 5, 6, 5, 3, // q
b32b8144 479 method_touch, false, 5, 6, "xx");
7c673cae
FG
480 test_both<P, double>("blr9",
481 5, 1, 5, 6, 3, 6, // p
482 3, 5, 5, 6, 5, 3, // q
b32b8144 483 method_touch, false, 5, 6, "ux");
7c673cae
FG
484
485 // Variants
486 test_both<P, double>("blr7-a",
487 5, 1, 5, 6, 3, 6, // p
488 5, 8, 5, 6, 5, 3, // q
b32b8144 489 method_touch, false, 5, 6, "ix");
7c673cae
FG
490 test_both<P, double>("blr7-b", // in fact NOT "both-left"
491 5, 1, 5, 6, 3, 6, // p
492 6, 8, 5, 6, 5, 3, // q
b32b8144 493 method_touch, false, 5, 6, "ix");
7c673cae
FG
494
495 // To check if "collinear-check" on other side
496 // does not apply to this side
497 test_both<P, double>("blr6-c1",
498 5, 1, 5, 6, 7, 5, // p
499 3, 7, 5, 6, 3, 5, // q
b32b8144 500 method_touch, true, 5, 6, "uu");
7c673cae
FG
501 test_both<P, double>("blr6-c2",
502 5, 1, 5, 6, 7, 7, // p
503 3, 7, 5, 6, 3, 5, // q
b32b8144 504 method_touch, true, 5, 6, "uu");
7c673cae
FG
505
506
507
508 // Both right, Q turns right
509 test_both<P, double>("brr1",
510 5, 1, 5, 6, 6, 4, // p
511 7, 5, 5, 6, 7, 7, // q
b32b8144 512 method_touch, true, 5, 6, "uu");
7c673cae
FG
513 test_both<P, double>("brr2",
514 5, 1, 5, 6, 9, 4, // p
515 7, 5, 5, 6, 7, 7, // q
b32b8144 516 method_touch, false, 5, 6, "xu");
7c673cae
FG
517 test_both<P, double>("brr3",
518 5, 1, 5, 6, 7, 6, // p
519 7, 5, 5, 6, 7, 7, // q
b32b8144 520 method_touch, false, 5, 6, "iu");
7c673cae
FG
521 test_both<P, double>("brr4",
522 5, 1, 5, 6, 9, 8, // p
523 7, 5, 5, 6, 7, 7, // q
b32b8144 524 method_touch, false, 5, 6, "cc");
7c673cae
FG
525 test_both<P, double>("brr5",
526 5, 1, 5, 6, 6, 8, // p
527 7, 5, 5, 6, 7, 7, // q
b32b8144 528 method_touch, true, 5, 6, "ui");
7c673cae
FG
529 test_both<P, double>("brr6",
530 5, 1, 5, 6, 4, 4, // p
531 7, 5, 5, 6, 7, 7, // q
b32b8144 532 method_touch, true, 5, 6, "ui");
7c673cae
FG
533
534 // Both right, Q turns left
535 test_both<P, double>("brl1",
536 5, 1, 5, 6, 6, 4, // p
537 7, 7, 5, 6, 7, 5, // q
b32b8144 538 method_touch, true, 5, 6, "iu");
7c673cae
FG
539 test_both<P, double>("brl2",
540 5, 1, 5, 6, 9, 4, // p
541 7, 7, 5, 6, 7, 5, // q
b32b8144 542 method_touch, false, 5, 6, "cc");
7c673cae
FG
543 test_both<P, double>("brl3",
544 5, 1, 5, 6, 7, 6, // p
545 7, 7, 5, 6, 7, 5, // q
b32b8144 546 method_touch, false, 5, 6, "ui");
7c673cae
FG
547 test_both<P, double>("brl4",
548 5, 1, 5, 6, 9, 8, // p
549 7, 7, 5, 6, 7, 5, // q
b32b8144 550 method_touch, false, 5, 6, "xi");
7c673cae
FG
551 test_both<P, double>("brl5",
552 5, 1, 5, 6, 6, 8, // p
553 7, 7, 5, 6, 7, 5, // q
b32b8144 554 method_touch, true, 5, 6, "ii");
7c673cae
FG
555 test_both<P, double>("brl6",
556 5, 1, 5, 6, 4, 4, // p
557 7, 7, 5, 6, 7, 5, // q
b32b8144 558 method_touch, true, 5, 6, "ii");
7c673cae
FG
559 test_both<P, double>("brl7",
560 5, 1, 5, 6, 7, 6, // p
561 7, 7, 5, 6, 5, 3, // q
b32b8144 562 method_touch, false, 5, 6, "ux");
7c673cae
FG
563 test_both<P, double>("brl8",
564 5, 1, 5, 6, 7, 6, // p
565 7, 6, 5, 6, 5, 3, // q
b32b8144 566 method_touch, false, 5, 6, "xx");
7c673cae
FG
567 test_both<P, double>("brl9",
568 5, 1, 5, 6, 7, 6, // p
569 7, 5, 5, 6, 5, 3, // q
b32b8144 570 method_touch, false, 5, 6, "ix");
7c673cae
FG
571
572 // Variants
573 test_both<P, double>("brl7-a",
574 5, 1, 5, 6, 7, 6, // p
575 5, 8, 5, 6, 5, 3, // q
b32b8144 576 method_touch, false, 5, 6, "ux");
7c673cae
FG
577 test_both<P, double>("brl7-b", // in fact NOT "both right"
578 5, 1, 5, 6, 7, 6, // p
579 4, 8, 5, 6, 5, 3, // q
b32b8144 580 method_touch, false, 5, 6, "ux");
7c673cae
FG
581
582
583
584 // Both left, Q turns left
585 test_both<P, double>("bll1",
586 5, 1, 5, 6, 4, 4, // p
587 3, 5, 5, 6, 3, 7, // q
b32b8144 588 method_touch, true, 5, 6, "ii");
7c673cae
FG
589 test_both<P, double>("bll2",
590 5, 1, 5, 6, 1, 4, // p
591 3, 5, 5, 6, 3, 7, // q
b32b8144 592 method_touch, false, 5, 6, "xi");
7c673cae
FG
593 test_both<P, double>("bll3",
594 5, 1, 5, 6, 3, 6, // p
595 3, 5, 5, 6, 3, 7, // q
b32b8144 596 method_touch, false, 5, 6, "ui");
7c673cae
FG
597 test_both<P, double>("bll4",
598 5, 1, 5, 6, 1, 8, // p
599 3, 5, 5, 6, 3, 7, // q
b32b8144 600 method_touch, false, 5, 6, "cc");
7c673cae
FG
601 test_both<P, double>("bll5",
602 5, 1, 5, 6, 4, 8, // p
603 3, 5, 5, 6, 3, 7, // q
b32b8144 604 method_touch, true, 5, 6, "iu");
7c673cae
FG
605 test_both<P, double>("bll6",
606 5, 1, 5, 6, 6, 4, // p
607 3, 5, 5, 6, 3, 7, // q
b32b8144 608 method_touch, true, 5, 6, "iu");
7c673cae
FG
609
610 // TOUCH - COLLINEAR + one side
611 // Collinear/left, Q turns right
612 test_both<P, double>("t-clr1",
613 5, 1, 5, 6, 4, 4, // p
614 5, 8, 5, 6, 3, 5, // q
b32b8144 615 method_touch, true, 5, 6, "ui");
7c673cae
FG
616 test_both<P, double>("t-clr2",
617 5, 1, 5, 6, 1, 4, // p
618 5, 8, 5, 6, 3, 5, // q
b32b8144 619 method_touch, false, 5, 6, "cc");
7c673cae
FG
620 test_both<P, double>("t-clr3",
621 5, 1, 5, 6, 3, 6, // p
622 5, 8, 5, 6, 3, 5, // q
b32b8144 623 method_touch, false, 5, 6, "iu");
7c673cae
FG
624 test_both<P, double>("t-clr4",
625 5, 1, 5, 6, 5, 8, // p
626 5, 8, 5, 6, 3, 5, // q
b32b8144 627 method_touch, false, 5, 6, "xu");
7c673cae
FG
628 // 5 n.a.
629 test_both<P, double>("t-clr6",
630 5, 1, 5, 6, 6, 4, // p
631 5, 8, 5, 6, 3, 5, // q
b32b8144 632 method_touch, true, 5, 6, "uu");
7c673cae
FG
633
634 // Collinear/right, Q turns right
635 test_both<P, double>("t-crr1",
636 5, 1, 5, 6, 6, 4, // p
637 7, 5, 5, 6, 5, 8, // q
b32b8144 638 method_touch, true, 5, 6, "uu");
7c673cae
FG
639 test_both<P, double>("t-crr2",
640 5, 1, 5, 6, 9, 4, // p
641 7, 5, 5, 6, 5, 8, // q
b32b8144 642 method_touch, false, 5, 6, "xu");
7c673cae
FG
643 test_both<P, double>("t-crr3",
644 5, 1, 5, 6, 7, 6, // p
645 7, 5, 5, 6, 5, 8, // q
b32b8144 646 method_touch, false, 5, 6, "iu");
7c673cae
FG
647 test_both<P, double>("t-crr4",
648 5, 1, 5, 6, 5, 9, // p
649 7, 5, 5, 6, 5, 8, // q
b32b8144 650 method_touch, false, 5, 6, "cc");
7c673cae
FG
651 // 5 n.a.
652 test_both<P, double>("t-crr6",
653 5, 1, 5, 6, 4, 4, // p
654 7, 5, 5, 6, 5, 8, // q
b32b8144 655 method_touch, true, 5, 6, "ui");
7c673cae
FG
656
657 // Collinear/right, Q turns left
658 test_both<P, double>("t-crl1",
659 5, 1, 5, 6, 6, 4, // p
660 5, 7, 5, 6, 7, 5, // q
b32b8144 661 method_touch, true, 5, 6, "iu");
7c673cae
FG
662 test_both<P, double>("t-crl2",
663 5, 1, 5, 6, 9, 4, // p
664 5, 7, 5, 6, 7, 5, // q
b32b8144 665 method_touch, false, 5, 6, "cc");
7c673cae
FG
666 test_both<P, double>("t-crl3",
667 5, 1, 5, 6, 7, 6, // p
668 5, 7, 5, 6, 7, 5, // q
b32b8144 669 method_touch, false, 5, 6, "ui");
7c673cae
FG
670 test_both<P, double>("t-crl4",
671 5, 1, 5, 6, 5, 8, // p
672 5, 7, 5, 6, 7, 5, // q
b32b8144 673 method_touch, false, 5, 6, "xi");
7c673cae
FG
674 // 5 n.a.
675 test_both<P, double>("t-crl6",
676 5, 1, 5, 6, 4, 4, // p
677 5, 7, 5, 6, 7, 5, // q
b32b8144 678 method_touch, true, 5, 6, "ii");
7c673cae
FG
679
680 // Collinear/left, Q turns left
681 test_both<P, double>("t-cll1",
682 5, 1, 5, 6, 4, 4, // p
683 3, 5, 5, 6, 5, 8, // q
b32b8144 684 method_touch, true, 5, 6, "ii");
7c673cae
FG
685 test_both<P, double>("t-cll2",
686 5, 1, 5, 6, 1, 4, // p
687 3, 5, 5, 6, 5, 8, // q
b32b8144 688 method_touch, false, 5, 6, "xi");
7c673cae
FG
689 test_both<P, double>("t-cll3",
690 5, 1, 5, 6, 3, 6, // p
691 3, 5, 5, 6, 5, 8, // q
b32b8144 692 method_touch, false, 5, 6, "ui");
7c673cae
FG
693 test_both<P, double>("t-cll4",
694 5, 1, 5, 6, 5, 9, // p
695 3, 5, 5, 6, 5, 8, // q
b32b8144 696 method_touch, false, 5, 6, "cc");
7c673cae
FG
697 // 5 n.a.
698 test_both<P, double>("t-cll6",
699 5, 1, 5, 6, 6, 4, // p
700 3, 5, 5, 6, 5, 8, // q
b32b8144 701 method_touch, true, 5, 6, "iu");
7c673cae
FG
702
703 // Left to right
704 test_both<P, double>("lr1",
705 5, 1, 5, 6, 3, 3, // p
706 1, 5, 5, 6, 9, 5, // q
b32b8144 707 method_touch, true, 5, 6, "ii");
7c673cae
FG
708 test_both<P, double>("lr2",
709 5, 1, 5, 6, 1, 5, // p
710 1, 5, 5, 6, 9, 5, // q
b32b8144 711 method_touch, false, 5, 6, "xi");
7c673cae
FG
712 test_both<P, double>("lr3",
713 5, 1, 5, 6, 4, 8, // p
714 1, 5, 5, 6, 9, 5, // q
b32b8144 715 method_touch, false, 5, 6, "ui");
7c673cae
FG
716 test_both<P, double>("lr4",
717 5, 1, 5, 6, 9, 5, // p
718 1, 5, 5, 6, 9, 5, // q
b32b8144 719 method_touch, false, 5, 6, "cc");
7c673cae
FG
720 test_both<P, double>("lr5",
721 5, 1, 5, 6, 7, 3, // p
722 1, 5, 5, 6, 9, 5, // q
b32b8144 723 method_touch, true, 5, 6, "iu");
7c673cae
FG
724 // otherwise case more thoroughly
725 test_both<P, double>("lr3a",
726 5, 1, 5, 6, 1, 6, // p
727 1, 5, 5, 6, 9, 5, // q
b32b8144 728 method_touch, false, 5, 6, "ui");
7c673cae
FG
729 test_both<P, double>("lr3b",
730 5, 1, 5, 6, 5, 10, // p
731 1, 5, 5, 6, 9, 5, // q
b32b8144 732 method_touch, false, 5, 6, "ui");
7c673cae
FG
733 test_both<P, double>("lr3c",
734 5, 1, 5, 6, 8, 9, // p
735 1, 5, 5, 6, 9, 5, // q
b32b8144 736 method_touch, false, 5, 6, "ui");
7c673cae
FG
737 test_both<P, double>("lr3d",
738 5, 1, 5, 6, 9, 7, // p
739 1, 5, 5, 6, 9, 5, // q
b32b8144 740 method_touch, false, 5, 6, "ui");
7c673cae
FG
741 test_both<P, double>("lr3e",
742 5, 1, 5, 6, 9, 6, // p
743 1, 5, 5, 6, 9, 5, // q
b32b8144 744 method_touch, false, 5, 6, "ui");
7c673cae
FG
745
746 // Right to left
747 test_both<P, double>("rl1",
748 5, 1, 5, 6, 3, 3, // p
749 9, 5, 5, 6, 1, 5, // q
b32b8144 750 method_touch, true, 5, 6, "ui");
7c673cae
FG
751 test_both<P, double>("rl2",
752 5, 1, 5, 6, 1, 5, // p
753 9, 5, 5, 6, 1, 5, // q
b32b8144 754 method_touch, false, 5, 6, "cc");
7c673cae
FG
755 test_both<P, double>("rl3",
756 5, 1, 5, 6, 4, 8, // p
757 9, 5, 5, 6, 1, 5, // q
b32b8144 758 method_touch, false, 5, 6, "iu");
7c673cae
FG
759 test_both<P, double>("rl4",
760 5, 1, 5, 6, 9, 5, // p
761 9, 5, 5, 6, 1, 5, // q
b32b8144 762 method_touch, false, 5, 6, "xu");
7c673cae
FG
763 test_both<P, double>("rl5",
764 5, 1, 5, 6, 7, 3, // p
765 9, 5, 5, 6, 1, 5, // q
b32b8144 766 method_touch, true, 5, 6, "uu");
7c673cae
FG
767
768 // Equal (p1/q1 are equal)
769 test_both<P, double>("ebl1",
770 5, 1, 5, 6, 3, 4, // p
771 5, 1, 5, 6, 3, 8, // q
b32b8144 772 method_equal, false, 5, 6, "ui");
7c673cae
FG
773 test_both<P, double>("ebl2",
774 5, 1, 5, 6, 3, 8, // p
775 5, 1, 5, 6, 3, 4, // q
b32b8144 776 method_equal, false, 5, 6, "iu");
7c673cae
FG
777 test_both<P, double>("ebl3",
778 5, 1, 5, 6, 3, 8, // p
779 5, 1, 5, 6, 3, 8, // q
b32b8144 780 method_equal, false, 5, 6, "cc");
7c673cae
FG
781
782 test_both<P, double>("ebl3-c1",
783 5, 1, 5, 6, 10, 1, // p
784 5, 1, 5, 6, 3, 8, // q
b32b8144 785 method_equal, false, 5, 6, "iu");
7c673cae
FG
786
787 test_both<P, double>("ebr1",
788 5, 1, 5, 6, 7, 4, // p
789 5, 1, 5, 6, 7, 8, // q
b32b8144 790 method_equal, false, 5, 6, "iu");
7c673cae
FG
791 test_both<P, double>("ebr2",
792 5, 1, 5, 6, 7, 8, // p
793 5, 1, 5, 6, 7, 4, // q
b32b8144 794 method_equal, false, 5, 6, "ui");
7c673cae
FG
795 test_both<P, double>("ebr3",
796 5, 1, 5, 6, 7, 8, // p
797 5, 1, 5, 6, 7, 8, // q
b32b8144 798 method_equal, false, 5, 6, "cc");
7c673cae
FG
799
800 test_both<P, double>("ebr3-c1",
801 5, 1, 5, 6, 0, 1, // p
802 5, 1, 5, 6, 7, 8, // q
b32b8144 803 method_equal, false, 5, 6, "ui");
7c673cae
FG
804
805 test_both<P, double>("elr1",
806 5, 1, 5, 6, 7, 8, // p
807 5, 1, 5, 6, 3, 8, // q
b32b8144 808 method_equal, false, 5, 6, "iu");
7c673cae
FG
809 test_both<P, double>("elr2",
810 5, 1, 5, 6, 3, 8, // p
811 5, 1, 5, 6, 7, 8, // q
b32b8144 812 method_equal, false, 5, 6, "ui");
7c673cae
FG
813 test_both<P, double>("ec1",
814 5, 1, 5, 6, 5, 8, // p
815 5, 1, 5, 6, 5, 8, // q
b32b8144 816 method_equal, false, 5, 6, "cc");
7c673cae
FG
817 test_both<P, double>("ec2",
818 5, 1, 5, 6, 5, 8, // p
819 5, 1, 5, 6, 5, 7, // q
b32b8144 820 method_equal, false, 5, 6, "cc");
7c673cae
FG
821
822 test_both<P, double>("snl-1",
823 0, 3, 2, 3, 4, 3, // p
824 4, 3, 2, 3, 0, 3, // q
b32b8144 825 method_touch, false, 2, 3, "xx");
7c673cae
FG
826
827 // BSG 2012-05-26 to be decided what's the problem here and what it tests...
828 // Anyway, test results are not filled out.
829 //test_both<P, double>("issue_buffer_mill",
830 // 5.1983614873206241 , 6.7259025813913107 , 5.0499999999999998 , 6.4291796067500622 , 5.1983614873206241 , 6.7259025813913107, // p
831 // 5.0499999999999998 , 6.4291796067500622 , 5.0499999999999998 , 6.4291796067500622 , 5.1983614873206241 , 6.7259025813913107, // q
b32b8144 832 // method_collinear, false, 2, 0, "tt");
7c673cae
FG
833
834}
835
836
837/***
838#include <boost/geometry/geometries/adapted/c_array.hpp>
839BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
840
841template <typename G>
842void test2(G const& geometry)
843{
844 typedef typename bg::point_type<G>::type P;
845 typedef typename bg::tag<G>::type T;
846 typedef typename bg::tag<P>::type PT;
847 std::cout << typeid(G).name() << std::endl;
848 std::cout << typeid(T).name() << std::endl;
849 std::cout << typeid(P).name() << std::endl;
850 std::cout << typeid(PT).name() << std::endl;
851
852
853 std::cout << bg::length(geometry) << std::endl;
854
855 typedef bg::model::point<float, 3, bg::cs::cartesian> P2;
856 bg::model::linestring<P2> out;
857 bg::strategy::transform::scale_transformer<float[3], P2> scaler(5);
858 bg::transform(geometry, out, scaler);
859 std::cout << bg::dsv(out) << std::endl;
860}
861
862void test_f3()
863{
864 float vertices[][3] = {
865 {-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1},
866 {-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}
867 };
868 test2(vertices);
869}
870***/
871
872int test_main(int, char* [])
873{
874 test_all<bg::model::d2::point_xy<double> >();
875 return 0;
876}