1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "gtest/gtest.h"
7
8 #include "BSPTree.h"
9 #include "Polygon.h"
10 #include "PolygonTestUtils.h"
11
12 #include <deque>
13
14 using namespace mozilla::gfx;
15 using namespace mozilla::layers;
16
17 namespace {
18
19 static void RunTest(std::deque<Polygon3D> aPolygons,
20 std::deque<Polygon3D> aExpected)
21 {
22 std::deque<LayerPolygon> layers;
23 for (Polygon3D& polygon : aPolygons) {
24 layers.push_back(LayerPolygon(nullptr, Move(polygon)));
25 }
26
27 const BSPTree tree(layers);
28 const nsTArray<LayerPolygon> order = tree.GetDrawOrder();
29
30 EXPECT_EQ(aExpected.size(), order.Length());
31
32 for (size_t i = 0; i < order.Length(); ++i) {
33 EXPECT_TRUE(aExpected[i] == *order[i].geometry);
34 }
35 }
36
37 } // namespace
38
39
40 TEST(BSPTree, SameNode)
41 {
42 const std::deque<Polygon3D> polygons {
43 Polygon3D {
44 Point3D(0.0f, 0.0f, 0.0f),
45 Point3D(1.0f, 0.0f, 0.0f),
46 Point3D(1.0f, 1.0f, 0.0f),
47 Point3D(0.0f, 1.0f, 0.0f)
48 },
49 Polygon3D {
50 Point3D(0.0f, 0.0f, 0.0f),
51 Point3D(1.0f, 0.0f, 0.0f),
52 Point3D(1.0f, 1.0f, 0.0f),
53 Point3D(0.0f, 1.0f, 0.0f)
54 }
55 };
56
57 ::RunTest(polygons, polygons);
58 }
59
60 TEST(BSPTree, OneChild)
61 {
62 const Polygon3D p1 {
63 Point3D(0.0f, 0.0f, 0.0f),
64 Point3D(1.0f, 0.0f, 0.0f),
65 Point3D(1.0f, 1.0f, 0.0f),
66 Point3D(0.0f, 1.0f, 0.0f)
67 };
68
69 const Polygon3D p2 {
70 Point3D(0.0f, 0.0f, 1.0f),
71 Point3D(1.0f, 0.0f, 1.0f),
72 Point3D(1.0f, 1.0f, 1.0f),
73 Point3D(0.0f, 1.0f, 1.0f)
74 };
75
76 ::RunTest({p1, p2}, {p1, p2});
77 ::RunTest({p2, p1}, {p1, p2});
78 }
79
80 TEST(BSPTree, SharedEdge1)
81 {
82 Polygon3D p1 {
83 Point3D(1.0f, 0.0f, 1.0f),
84 Point3D(0.0f, 0.0f, 1.0f),
85 Point3D(0.0f, 1.0f, 1.0f),
86 Point3D(1.0f, 1.0f, 1.0f)
87 };
dissect_snp_authentication_clv(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,int offset,isis_data_t * isis _U_,int length)88
89 Polygon3D p2 {
90 Point3D(1.0f, 0.0f, 1.0f),
91 Point3D(1.0f, 1.0f, 1.0f),
92 Point3D(2.0f, 2.0f, 1.0f),
93 Point3D(2.0f, 0.0f, 1.0f)
94 };
dissect_csnp_ip_authentication_clv(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,int offset,isis_data_t * isis _U_,int length)95
96 ::RunTest({p1, p2}, {p1, p2});
97 }
98
99 TEST(BSPTree, SharedEdge2)
100 {
101 Polygon3D p1 {
102 Point3D(1.0f, 0.0f, 1.0f),
103 Point3D(0.0f, 0.0f, 1.0f),
dissect_psnp_ip_authentication_clv(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,int offset,isis_data_t * isis _U_,int length)104 Point3D(0.0f, 1.0f, 1.0f),
105 Point3D(1.0f, 1.0f, 1.0f)
106 };
107
108 Polygon3D p2 {
109 Point3D(1.0f, 0.0f, 1.0f),
110 Point3D(1.0f, 1.0f, 1.0f),
111 Point3D(2.0f, 2.0f, 0.0f),
112 Point3D(2.0f, 0.0f, 0.0f)
113 };
114
115 ::RunTest({p1, p2}, {p2, p1});
116 }
117
118 TEST(BSPTree, SplitSharedEdge)
dissect_snp_checksum_clv(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,int offset,isis_data_t * isis,int length)119 {
120 Polygon3D p1 {
121 Point3D(1.0f, 0.0f, 1.0f),
122 Point3D(0.0f, 0.0f, 1.0f),
123 Point3D(0.0f, 1.0f, 1.0f),
124 Point3D(1.0f, 1.0f, 1.0f)
125 };
126
127 Polygon3D p2 {
128 Point3D(1.0f, 0.0f, 2.0f),
129 Point3D(1.0f, 1.0f, 2.0f),
130 Point3D(1.0f, 1.0f, 0.0f),
131 Point3D(1.0f, 0.0f, 0.0f)
132 };
133
134 const std::deque<Polygon3D> expected {
135 Polygon3D {
136 Point3D(1.0f, 1.0f, 1.0f),
137 Point3D(1.0f, 1.0f, 0.0f),
138 Point3D(1.0f, 0.0f, 0.0f),
139 Point3D(1.0f, 0.0f, 1.0f)
140 },
141 Polygon3D {
142 Point3D(1.0f, 0.0f, 1.0f),
143 Point3D(0.0f, 0.0f, 1.0f),
144 Point3D(0.0f, 1.0f, 1.0f),
145 Point3D(1.0f, 1.0f, 1.0f)
146 },
147 Polygon3D {
148 Point3D(1.0f, 0.0f, 2.0f),
149 Point3D(1.0f, 1.0f, 2.0f),
150 Point3D(1.0f, 1.0f, 1.0f),
151 Point3D(1.0f, 0.0f, 1.0f)
152 }
153 };
154
155 ::RunTest({p1, p2}, expected);
156 }
157
158 TEST(BSPTree, SplitSimple1)
dissect_snp_lsp_entries_clv(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,int offset,isis_data_t * isis,int length)159 {
160 Polygon3D p1 {
161 Point3D(0.0f, 0.0f, 1.0f),
162 Point3D(1.0f, 0.0f, 1.0f),
163 Point3D(1.0f, 1.0f, 1.0f),
164 Point3D(0.0f, 1.0f, 1.0f)
165 };
166
167 Polygon3D p2 {
168 Point3D(0.0f, 0.0f, 2.0f),
169 Point3D(1.0f, 0.0f, 2.0f),
170 Point3D(1.0f, 1.0f, 0.0f),
171 Point3D(0.0f, 1.0f, 0.0f)
172 };
173
174 const std::deque<Polygon3D> expected {
175 Polygon3D {
176 Point3D(0.0f, 1.0f, 0.0f),
177 Point3D(0.0f, 0.5f, 1.0f),
178 Point3D(1.0f, 0.5f, 1.0f),
179 Point3D(1.0f, 1.0f, 0.0f)
180 },
181 p1,
182 Polygon3D {
183 Point3D(0.0f, 0.0f, 2.0f),
184 Point3D(1.0f, 0.0f, 2.0f),
185 Point3D(1.0f, 0.5f, 1.0f),
186 Point3D(0.0f, 0.5f, 1.0f)
187 }
188 };
189
190 ::RunTest({p1, p2}, expected);
191 }
192
193 TEST(BSPTree, SplitSimple2) {
194 const std::deque<Polygon3D> polygons {
195 Polygon3D {
196 Point3D(-5.00000f, -5.00000f, 0.00000f),
197 Point3D(-5.00000f, 5.00000f, 0.00000f),
198 Point3D(5.00000f, 5.00000f, 0.00000f),
199 Point3D(5.00000f, -5.00000f, 0.00000f)
200 },
201 Polygon3D {
202 Point3D(0.00000f, -5.00000f, -5.00000f),
203 Point3D(0.00000f, 5.00000f, -5.00000f),
dissect_snp_instance_identifier_clv(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * tree,int offset,isis_data_t * isis _U_,int length)204 Point3D(0.00000f, 5.00000f, 5.00000f),
205 Point3D(0.00000f, -5.00000f, 5.00000f)
206 }
207 };
208
209 const std::deque<Polygon3D> expected {
210 Polygon3D {
211 Point3D(0.00000f, -5.00000f, 0.00000f),
212 Point3D(0.00000f, -5.00000f, -5.00000f),
213 Point3D(0.00000f, 5.00000f, -5.00000f),
214 Point3D(0.00000f, 5.00000f, 0.00000f)
215 },
216 Polygon3D {
217 Point3D(-5.00000f, -5.00000f, 0.00000f),
218 Point3D(-5.00000f, 5.00000f, 0.00000f),
219 Point3D(5.00000f, 5.00000f, 0.00000f),
220 Point3D(5.00000f, -5.00000f, 0.00000f)
221 },
222 Polygon3D {
223 Point3D(0.00000f, 5.00000f, 0.00000f),
224 Point3D(0.00000f, 5.00000f, 5.00000f),
225 Point3D(0.00000f, -5.00000f, 5.00000f),
226 Point3D(0.00000f, -5.00000f, 0.00000f)
227 }
228 };
229 ::RunTest(polygons, expected);
230 }
231
232 TEST(BSPTree, NoSplit1) {
233 const std::deque<Polygon3D> polygons {
234 Polygon3D {
235 Point3D(0.00000f, 10.00000f, 0.00000f),
236 Point3D(0.00000f, 0.00000f, 0.00000f),
237 Point3D(10.00000f, 0.00000f, 0.00000f),
238 Point3D(10.00000f, 10.00000f, 0.00000f)
239 },
240 Polygon3D {
241 Point3D(0.00000f, 10.00000f, -5.00000f),
242 Point3D(0.00000f, 0.00000f, -5.00000f),
243 Point3D(10.00000f, 0.00000f, -5.00000f),
244 Point3D(10.00000f, 10.00000f, -5.00000f)
245 },
246 Polygon3D {
247 Point3D(0.00000f, 10.00000f, 5.00000f),
248 Point3D(0.00000f, 0.00000f, 5.00000f),
249 Point3D(10.00000f, 0.00000f, 5.00000f),
250 Point3D(10.00000f, 10.00000f, 5.00000f)
251 }
252 };
253
254 const std::deque<Polygon3D> expected {
255 Polygon3D {
256 Point3D(0.00000f, 10.00000f, -5.00000f),
257 Point3D(0.00000f, 0.00000f, -5.00000f),
258 Point3D(10.00000f, 0.00000f, -5.00000f),
259 Point3D(10.00000f, 10.00000f, -5.00000f)
260 },
261 Polygon3D {
262 Point3D(0.00000f, 10.00000f, 0.00000f),
263 Point3D(0.00000f, 0.00000f, 0.00000f),
264 Point3D(10.00000f, 0.00000f, 0.00000f),
265 Point3D(10.00000f, 10.00000f, 0.00000f)
266 },
267 Polygon3D {
268 Point3D(0.00000f, 10.00000f, 5.00000f),
269 Point3D(0.00000f, 0.00000f, 5.00000f),
270 Point3D(10.00000f, 0.00000f, 5.00000f),
271 Point3D(10.00000f, 10.00000f, 5.00000f)
272 }
273 };
274 ::RunTest(polygons, expected);
275 }
276
277 TEST(BSPTree, NoSplit2) {
278 const std::deque<Polygon3D> polygons {
279 Polygon3D {
280 Point3D(-5.00000f, -5.00000f, 0.00000f),
281 Point3D(-5.00000f, 5.00000f, 0.00000f),
282 Point3D(5.00000f, 5.00000f, 0.00000f),
283 Point3D(5.00000f, -5.00000f, 0.00000f)
284 },
285 Polygon3D {
286 Point3D(0.00000f, 5.00000f, -15.00000f),
287 Point3D(0.00000f, -5.00000f, -15.00000f),
288 Point3D(0.00000f, -5.00000f, -10.00000f),
289 Point3D(0.00000f, 5.00000f, -10.00000f)
290 }
291 };
292
293 const std::deque<Polygon3D> expected {
294 Polygon3D {
295 Point3D(0.00000f, 5.00000f, -15.00000f),
296 Point3D(0.00000f, -5.00000f, -15.00000f),
297 Point3D(0.00000f, -5.00000f, -10.00000f),
298 Point3D(0.00000f, 5.00000f, -10.00000f)
299 },
300 Polygon3D {
301 Point3D(-5.00000f, -5.00000f, 0.00000f),
302 Point3D(-5.00000f, 5.00000f, 0.00000f),
303 Point3D(5.00000f, 5.00000f, 0.00000f),
304 Point3D(5.00000f, -5.00000f, 0.00000f)
305 }
306 };
307 ::RunTest(polygons, expected);
308 }
309
310 TEST(BSPTree, TwoPlaneIntersectRotate0degrees) {
311 const std::deque<Polygon3D> polygons {
312 Polygon3D {
313 Point3D(-0.00000f, 2.00000f, 2.00000f),
314 Point3D(-0.00000f, -2.00000f, 2.00000f),
315 Point3D(0.00010f, -2.00000f, -2.00000f),
316 Point3D(0.00010f, 2.00000f, -2.00000f)
317 },
318 Polygon3D {
319 Point3D(2.00000f, 0.00000f, 2.00000f),
320 Point3D(2.00000f, -0.00000f, -2.00000f),
321 Point3D(-2.00000f, 0.00000f, -2.00000f),
322 Point3D(-2.00000f, 0.00010f, 2.00000f)
323 }
324 };
325
326 const std::deque<Polygon3D> expected {
327 Polygon3D {
328 Point3D(2.00000f, 0.00000f, 2.00000f),
329 Point3D(2.00000f, -0.00000f, -2.00000f),
330 Point3D(-2.00000f, 0.00000f, -2.00000f),
331 Point3D(-2.00000f, 0.00010f, 2.00000f)
332 },
333 Polygon3D {
334 Point3D(-0.00000f, 2.00000f, 2.00000f),
335 Point3D(-0.00000f, -2.00000f, 2.00000f),
336 Point3D(0.00010f, -2.00000f, -2.00000f),
337 Point3D(0.00010f, 2.00000f, -2.00000f)
338 }
339 };
340 ::RunTest(polygons, expected);
341 }
342
343 TEST(BSPTree, TwoPlaneIntersectRotate20degrees) {
344 const std::deque<Polygon3D> polygons {
345 Polygon3D {
346 Point3D(-0.00000f, 1.19540f, 2.56350f),
347 Point3D(-0.00000f, -2.56340f, 1.19540f),
348 Point3D(0.00010f, -1.19530f, -2.56340f),
349 Point3D(0.00010f, 2.56350f, -1.19530f)
350 },
351 Polygon3D {
352 Point3D(2.00000f, -0.68400f, 1.87940f),
353 Point3D(2.00000f, 0.68410f, -1.87930f),
354 Point3D(-2.00000f, 0.68410f, -1.87930f),
dissect_isis_csnp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,int offset,const isis_clv_handle_t * opts,isis_data_t * isis)355 Point3D(-2.00000f, -0.68400f, 1.87940f)
356 }
357 };
358
359 const std::deque<Polygon3D> expected {
360 Polygon3D {
361 Point3D(2.00000f, -0.68400f, 1.87940f),
362 Point3D(2.00000f, 0.68410f, -1.87930f),
363 Point3D(-2.00000f, 0.68410f, -1.87930f),
364 Point3D(-2.00000f, -0.68400f, 1.87940f)
365 },
366 Polygon3D {
367 Point3D(-0.00000f, 1.19540f, 2.56350f),
368 Point3D(-0.00000f, -2.56340f, 1.19540f),
369 Point3D(0.00010f, -1.19530f, -2.56340f),
370 Point3D(0.00010f, 2.56350f, -1.19530f)
371 }
372 };
373 ::RunTest(polygons, expected);
374 }
375
376 TEST(BSPTree, TwoPlaneIntersectRotate40degrees) {
377 const std::deque<Polygon3D> polygons {
378 Polygon3D {
379 Point3D(-0.00000f, -0.73200f, 2.73210f),
380 Point3D(-0.00000f, -2.73200f, -0.73200f),
381 Point3D(0.00010f, 0.73210f, -2.73200f),
382 Point3D(0.00010f, 2.73210f, 0.73210f)
383 },
384 Polygon3D {
385 Point3D(2.00000f, -1.73200f, 1.00000f),
386 Point3D(2.00000f, 1.73210f, -0.99990f),
387 Point3D(-2.00000f, 1.73210f, -0.99990f),
388 Point3D(-2.00000f, -1.73200f, 1.00000f)
389 }
390 };
391
392 const std::deque<Polygon3D> expected {
393 Polygon3D {
394 Point3D(2.00000f, -1.73200f, 1.00000f),
395 Point3D(2.00000f, 1.73210f, -0.99990f),
396 Point3D(-2.00000f, 1.73210f, -0.99990f),
397 Point3D(-2.00000f, -1.73200f, 1.00000f)
398 },
399 Polygon3D {
400 Point3D(-0.00000f, -0.73200f, 2.73210f),
401 Point3D(-0.00000f, -2.73200f, -0.73200f),
402 Point3D(0.00010f, 0.73210f, -2.73200f),
403 Point3D(0.00010f, 2.73210f, 0.73210f)
404 }
405 };
406 ::RunTest(polygons, expected);
407 }
408
409 TEST(BSPTree, TwoPlaneIntersectRotate60degrees) {
410 const std::deque<Polygon3D> polygons {
411 Polygon3D {
412 Point3D(-0.00000f, -2.73200f, 0.73210f),
413 Point3D(-0.00000f, -0.73200f, -2.73200f),
414 Point3D(0.00010f, 2.73210f, -0.73200f),
415 Point3D(0.00010f, 0.73210f, 2.73210f)
416 },
417 Polygon3D {
418 Point3D(2.00000f, -1.73200f, -1.00000f),
419 Point3D(2.00000f, 1.73210f, 1.00010f),
420 Point3D(-2.00000f, 1.73210f, 1.00010f),
421 Point3D(-2.00000f, -1.73200f, -1.00000f)
422 }
423 };
424
425 const std::deque<Polygon3D> expected {
426 Polygon3D {
427 Point3D(-2.00000f, 1.26793f, 0.73210f),
428 Point3D(-2.00000f, -1.73200f, -1.00000f),
429 Point3D(2.00000f, -1.73200f, -1.00000f),
430 Point3D(2.00000f, 1.26793f, 0.73210f)
431 },
432 Polygon3D {
433 Point3D(-0.00000f, -2.73200f, 0.73210f),
dissect_isis_l1_csnp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data)434 Point3D(-0.00000f, -0.73200f, -2.73200f),
435 Point3D(0.00010f, 2.73210f, -0.73200f),
436 Point3D(0.00010f, 0.73210f, 2.73210f)
437 },
438 Polygon3D {
439 Point3D(2.00000f, 1.26793f, 0.73210f),
440 Point3D(2.00000f, 1.73210f, 1.00010f),
441 Point3D(-2.00000f, 1.73210f, 1.00010f),
442 Point3D(-2.00000f, 1.26793f, 0.73210f)
443 }
444 };
445 ::RunTest(polygons, expected);
446 }
447
448 TEST(BSPTree, TwoPlaneIntersectRotate80degrees) {
449 const std::deque<Polygon3D> polygons {
dissect_isis_psnp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,int offset,const isis_clv_handle_t * opts,isis_data_t * isis)450 Polygon3D {
451 Point3D(-0.00000f, -1.19530f, -2.56340f),
452 Point3D(-0.00000f, 2.56350f, -1.19530f),
453 Point3D(0.00010f, 1.19540f, 2.56350f),
454 Point3D(0.00010f, -2.56340f, 1.19540f)
455 },
456 Polygon3D {
457 Point3D(2.00000f, 0.68410f, -1.87930f),
458 Point3D(2.00000f, -0.68400f, 1.87940f),
459 Point3D(-2.00000f, -0.68400f, 1.87940f),
460 Point3D(-2.00000f, 0.68410f, -1.87930f)
461 }
462 };
463
464 const std::deque<Polygon3D> expected {
465 Polygon3D {
466 Point3D(-0.00000f, -1.19530f, -2.56340f),
467 Point3D(-0.00000f, 2.56350f, -1.19530f),
468 Point3D(0.00010f, 1.19540f, 2.56350f),
469 Point3D(0.00010f, -2.56340f, 1.19540f)
470 },
471 Polygon3D {
472 Point3D(2.00000f, 0.68410f, -1.87930f),
473 Point3D(2.00000f, -0.68400f, 1.87940f),
474 Point3D(-2.00000f, -0.68400f, 1.87940f),
475 Point3D(-2.00000f, 0.68410f, -1.87930f)
476 }
477 };
478 ::RunTest(polygons, expected);
479 }
480
481 TEST(BSPTree, TwoPlaneIntersectRotate100degrees) {
482 const std::deque<Polygon3D> polygons {
483 Polygon3D {
484 Point3D(-0.00000f, 2.73210f, -0.73200f),
485 Point3D(-0.00000f, 0.73210f, 2.73210f),
486 Point3D(0.00010f, -2.73200f, 0.73210f),
487 Point3D(0.00010f, -0.73200f, -2.73200f)
488 },
489 Polygon3D {
490 Point3D(2.00000f, 1.73210f, 1.00010f),
491 Point3D(2.00000f, -1.73200f, -1.00000f),
492 Point3D(-2.00000f, -1.73200f, -1.00000f),
493 Point3D(-2.00000f, 1.73210f, 1.00010f)
494 }
495 };
496
497 const std::deque<Polygon3D> expected {
498 Polygon3D {
499 Point3D(2.00000f, -1.26783f, -0.73200f),
500 Point3D(2.00000f, -1.73200f, -1.00000f),
501 Point3D(-2.00000f, -1.73200f, -1.00000f),
502 Point3D(-2.00000f, -1.26783f, -0.73200f)
503 },
504 Polygon3D {
505 Point3D(-0.00000f, 2.73210f, -0.73200f),
506 Point3D(-0.00000f, 0.73210f, 2.73210f),
507 Point3D(0.00010f, -2.73200f, 0.73210f),
508 Point3D(0.00010f, -0.73200f, -2.73200f)
509 },
510 Polygon3D {
511 Point3D(-2.00000f, -1.26783f, -0.73200f),
dissect_isis_l1_psnp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data)512 Point3D(-2.00000f, 1.73210f, 1.00010f),
513 Point3D(2.00000f, 1.73210f, 1.00010f),
514 Point3D(2.00000f, -1.26783f, -0.73200f)
515 }
516 };
517 ::RunTest(polygons, expected);
518 }
519
dissect_isis_l2_psnp(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data)520 TEST(BSPTree, TwoPlaneIntersectRotate120degrees) {
521 const std::deque<Polygon3D> polygons {
522 Polygon3D {
523 Point3D(-0.00000f, -0.73200f, 2.73210f),
524 Point3D(-0.00000f, -2.73200f, -0.73200f),
525 Point3D(0.00010f, 0.73210f, -2.73200f),
526 Point3D(0.00010f, 2.73210f, 0.73210f)
527 },
528 Polygon3D {
529 Point3D(2.00000f, -1.73200f, 1.00000f),
530 Point3D(2.00000f, 1.73210f, -0.99990f),
531 Point3D(-2.00000f, 1.73210f, -0.99990f),
532 Point3D(-2.00000f, -1.73200f, 1.00000f)
533 }
534 };
535
536 const std::deque<Polygon3D> expected {
537 Polygon3D {
538 Point3D(2.00000f, -1.73200f, 1.00000f),
539 Point3D(2.00000f, 1.73210f, -0.99990f),
540 Point3D(-2.00000f, 1.73210f, -0.99990f),
541 Point3D(-2.00000f, -1.73200f, 1.00000f)
542 },
543 Polygon3D {
544 Point3D(-0.00000f, -0.73200f, 2.73210f),
545 Point3D(-0.00000f, -2.73200f, -0.73200f),
546 Point3D(0.00010f, 0.73210f, -2.73200f),
547 Point3D(0.00010f, 2.73210f, 0.73210f)
548 }
549 };
550 ::RunTest(polygons, expected);
551 }
552
553 TEST(BSPTree, TwoPlaneIntersectRotate140degrees) {
554 const std::deque<Polygon3D> polygons {
555 Polygon3D {
556 Point3D(-0.00000f, -1.19530f, -2.56340f),
557 Point3D(-0.00000f, 2.56350f, -1.19530f),
558 Point3D(0.00010f, 1.19540f, 2.56350f),
559 Point3D(0.00010f, -2.56340f, 1.19540f)
560 },
561 Polygon3D {
562 Point3D(2.00000f, 0.68410f, -1.87930f),
563 Point3D(2.00000f, -0.68400f, 1.87940f),
564 Point3D(-2.00000f, -0.68400f, 1.87940f),
565 Point3D(-2.00000f, 0.68410f, -1.87930f)
566 }
567 };
568
569 const std::deque<Polygon3D> expected {
570 Polygon3D {
571 Point3D(-0.00000f, -1.19530f, -2.56340f),
572 Point3D(-0.00000f, 2.56350f, -1.19530f),
573 Point3D(0.00010f, 1.19540f, 2.56350f),
574 Point3D(0.00010f, -2.56340f, 1.19540f)
575 },
576 Polygon3D {
577 Point3D(2.00000f, 0.68410f, -1.87930f),
578 Point3D(2.00000f, -0.68400f, 1.87940f),
579 Point3D(-2.00000f, -0.68400f, 1.87940f),
580 Point3D(-2.00000f, 0.68410f, -1.87930f)
581 }
582 };
583 ::RunTest(polygons, expected);
584 }
585
586 TEST(BSPTree, TwoPlaneIntersectRotate160degrees) {
587 const std::deque<Polygon3D> polygons {
588 Polygon3D {
589 Point3D(-0.00000f, 2.00000f, 2.00000f),
590 Point3D(-0.00000f, -2.00000f, 2.00000f),
591 Point3D(0.00010f, -2.00000f, -2.00000f),
592 Point3D(0.00010f, 2.00000f, -2.00000f)
593 },
594 Polygon3D {
595 Point3D(2.00000f, -0.00000f, 2.00000f),
596 Point3D(2.00000f, 0.00010f, -2.00000f),
597 Point3D(-2.00000f, 0.00010f, -2.00000f),
598 Point3D(-2.00000f, -0.00000f, 2.00000f)
599 }
600 };
601
602 const std::deque<Polygon3D> expected {
603 Polygon3D {
604 Point3D(2.00000f, -0.00000f, 2.00000f),
605 Point3D(2.00000f, 0.00010f, -2.00000f),
606 Point3D(-2.00000f, 0.00010f, -2.00000f),
607 Point3D(-2.00000f, -0.00000f, 2.00000f)
608 },
609 Polygon3D {
610 Point3D(-0.00000f, 2.00000f, 2.00000f),
611 Point3D(-0.00000f, -2.00000f, 2.00000f),
612 Point3D(0.00010f, -2.00000f, -2.00000f),
613 Point3D(0.00010f, 2.00000f, -2.00000f)
614 }
proto_reg_handoff_isis_csnp(void)615 };
616 ::RunTest(polygons, expected);
617 }
618
619 TEST(BSPTree, TwoPlaneIntersectRotate180degrees) {
620 const std::deque<Polygon3D> polygons {
621 Polygon3D {
proto_register_isis_psnp(void)622 Point3D(-0.00000f, -2.00000f, -2.00000f),
623 Point3D(-0.00000f, 2.00000f, -2.00000f),
624 Point3D(0.00010f, 2.00000f, 2.00000f),
625 Point3D(0.00010f, -2.00000f, 2.00000f)
626 },
627 Polygon3D {
628 Point3D(2.00000f, 0.00010f, -2.00000f),
629 Point3D(2.00000f, -0.00000f, 2.00000f),
630 Point3D(-2.00000f, -0.00000f, 2.00000f),
631 Point3D(-2.00000f, 0.00010f, -2.00000f)
632 }
633 };
634
635 const std::deque<Polygon3D> expected {
636 Polygon3D {
637 Point3D(-0.00000f, -2.00000f, -2.00000f),
638 Point3D(-0.00000f, 2.00000f, -2.00000f),
639 Point3D(0.00010f, 2.00000f, 2.00000f),
640 Point3D(0.00010f, -2.00000f, 2.00000f)
641 },
642 Polygon3D {
643 Point3D(2.00000f, 0.00010f, -2.00000f),
644 Point3D(2.00000f, -0.00000f, 2.00000f),
645 Point3D(-2.00000f, -0.00000f, 2.00000f),
646 Point3D(-2.00000f, 0.00010f, -2.00000f)
647 }
648 };
649 ::RunTest(polygons, expected);
650 }
651
652 TEST(BSPTree, TwoPlaneIntersectRotate200degrees) {
653 const std::deque<Polygon3D> polygons {
654 Polygon3D {
655 Point3D(-0.00000f, 1.19540f, 2.56350f),
656 Point3D(-0.00000f, -2.56340f, 1.19540f),
657 Point3D(0.00010f, -1.19530f, -2.56340f),
658 Point3D(0.00010f, 2.56350f, -1.19530f)
659 },
660 Polygon3D {
661 Point3D(2.00000f, -0.68400f, 1.87940f),
662 Point3D(2.00000f, 0.68410f, -1.87930f),
663 Point3D(-2.00000f, 0.68410f, -1.87930f),
664 Point3D(-2.00000f, -0.68400f, 1.87940f)
665 }
666 };
667
668 const std::deque<Polygon3D> expected {
669 Polygon3D {
670 Point3D(2.00000f, -0.68400f, 1.87940f),
671 Point3D(2.00000f, 0.68410f, -1.87930f),
proto_reg_handoff_isis_psnp(void)672 Point3D(-2.00000f, 0.68410f, -1.87930f),
673 Point3D(-2.00000f, -0.68400f, 1.87940f)
674 },
675 Polygon3D {
676 Point3D(-0.00000f, 1.19540f, 2.56350f),
677 Point3D(-0.00000f, -2.56340f, 1.19540f),
678 Point3D(0.00010f, -1.19530f, -2.56340f),
679 Point3D(0.00010f, 2.56350f, -1.19530f)
680 }
681 };
682 ::RunTest(polygons, expected);
683 }
684
685 TEST(BSPTree, TwoPlaneIntersectRotate220degrees) {
686 const std::deque<Polygon3D> polygons {
687 Polygon3D {
688 Point3D(-0.00000f, 0.73210f, -2.73200f),
689 Point3D(-0.00000f, 2.73210f, 0.73210f),
690 Point3D(0.00010f, -0.73200f, 2.73210f),
691 Point3D(0.00010f, -2.73200f, -0.73200f)
692 },
693 Polygon3D {
694 Point3D(2.00000f, 1.73210f, -0.99990f),
695 Point3D(2.00000f, -1.73200f, 1.00000f),
696 Point3D(-2.00000f, -1.73200f, 1.00000f),
697 Point3D(-2.00000f, 1.73210f, -0.99990f)
698 }
699 };
700
701 const std::deque<Polygon3D> expected {
702 Polygon3D {
703 Point3D(-0.00000f, 0.73210f, -2.73200f),
704 Point3D(-0.00000f, 2.73210f, 0.73210f),
705 Point3D(0.00010f, -0.73200f, 2.73210f),
706 Point3D(0.00010f, -2.73200f, -0.73200f)
707 },
708 Polygon3D {
709 Point3D(2.00000f, 1.73210f, -0.99990f),
710 Point3D(2.00000f, -1.73200f, 1.00000f),
711 Point3D(-2.00000f, -1.73200f, 1.00000f),
712 Point3D(-2.00000f, 1.73210f, -0.99990f)
713 }
714 };
715 ::RunTest(polygons, expected);
716 }
717
718 TEST(BSPTree, TwoPlaneIntersectRotate240degrees) {
719 const std::deque<Polygon3D> polygons {
720 Polygon3D {
721 Point3D(-0.00000f, -2.73200f, 0.73210f),
722 Point3D(-0.00000f, -0.73200f, -2.73200f),
723 Point3D(0.00010f, 2.73210f, -0.73200f),
724 Point3D(0.00010f, 0.73210f, 2.73210f)
725 },
726 Polygon3D {
727 Point3D(2.00000f, -1.73200f, -1.00000f),
728 Point3D(2.00000f, 1.73210f, 1.00010f),
729 Point3D(-2.00000f, 1.73210f, 1.00010f),
730 Point3D(-2.00000f, -1.73200f, -1.00000f)
731 }
732 };
733
734 const std::deque<Polygon3D> expected {
735 Polygon3D {
736 Point3D(-2.00000f, 1.26793f, 0.73210f),
737 Point3D(-2.00000f, -1.73200f, -1.00000f),
738 Point3D(2.00000f, -1.73200f, -1.00000f),
739 Point3D(2.00000f, 1.26793f, 0.73210f)
740 },
741 Polygon3D {
742 Point3D(-0.00000f, -2.73200f, 0.73210f),
743 Point3D(-0.00000f, -0.73200f, -2.73200f),
744 Point3D(0.00010f, 2.73210f, -0.73200f),
745 Point3D(0.00010f, 0.73210f, 2.73210f)
746 },
747 Polygon3D {
748 Point3D(2.00000f, 1.26793f, 0.73210f),
749 Point3D(2.00000f, 1.73210f, 1.00010f),
750 Point3D(-2.00000f, 1.73210f, 1.00010f),
751 Point3D(-2.00000f, 1.26793f, 0.73210f)
752 }
753 };
754 ::RunTest(polygons, expected);
755 }
756
757 TEST(BSPTree, TwoPlaneIntersectRotate260degrees) {
758 const std::deque<Polygon3D> polygons {
759 Polygon3D {
760 Point3D(-0.00000f, 1.19540f, 2.56350f),
761 Point3D(-0.00000f, -2.56340f, 1.19540f),
762 Point3D(0.00010f, -1.19530f, -2.56340f),
763 Point3D(0.00010f, 2.56350f, -1.19530f)
764 },
765 Polygon3D {
766 Point3D(2.00000f, -0.68400f, 1.87940f),
767 Point3D(2.00000f, 0.68410f, -1.87930f),
768 Point3D(-2.00000f, 0.68410f, -1.87930f),
769 Point3D(-2.00000f, -0.68400f, 1.87940f)
770 }
771 };
772
773 const std::deque<Polygon3D> expected {
774 Polygon3D {
775 Point3D(2.00000f, -0.68400f, 1.87940f),
776 Point3D(2.00000f, 0.68410f, -1.87930f),
777 Point3D(-2.00000f, 0.68410f, -1.87930f),
778 Point3D(-2.00000f, -0.68400f, 1.87940f)
779 },
780 Polygon3D {
781 Point3D(-0.00000f, 1.19540f, 2.56350f),
782 Point3D(-0.00000f, -2.56340f, 1.19540f),
783 Point3D(0.00010f, -1.19530f, -2.56340f),
784 Point3D(0.00010f, 2.56350f, -1.19530f)
785 }
786 };
787 ::RunTest(polygons, expected);
788 }
789
790 TEST(BSPTree, TwoPlaneIntersectRotate280degrees) {
791 const std::deque<Polygon3D> polygons {
792 Polygon3D {
793 Point3D(-0.00000f, 2.73210f, -0.73200f),
794 Point3D(-0.00000f, 0.73210f, 2.73210f),
795 Point3D(0.00010f, -2.73200f, 0.73210f),
796 Point3D(0.00010f, -0.73200f, -2.73200f)
797 },
798 Polygon3D {
799 Point3D(2.00000f, 1.73210f, 1.00010f),
800 Point3D(2.00000f, -1.73200f, -1.00000f),
801 Point3D(-2.00000f, -1.73200f, -1.00000f),
802 Point3D(-2.00000f, 1.73210f, 1.00010f)
803 }
804 };
805
806 const std::deque<Polygon3D> expected {
807 Polygon3D {
808 Point3D(2.00000f, -1.26783f, -0.73200f),
809 Point3D(2.00000f, -1.73200f, -1.00000f),
810 Point3D(-2.00000f, -1.73200f, -1.00000f),
811 Point3D(-2.00000f, -1.26783f, -0.73200f)
812 },
813 Polygon3D {
814 Point3D(-0.00000f, 2.73210f, -0.73200f),
815 Point3D(-0.00000f, 0.73210f, 2.73210f),
816 Point3D(0.00010f, -2.73200f, 0.73210f),
817 Point3D(0.00010f, -0.73200f, -2.73200f)
818 },
819 Polygon3D {
820 Point3D(-2.00000f, -1.26783f, -0.73200f),
821 Point3D(-2.00000f, 1.73210f, 1.00010f),
822 Point3D(2.00000f, 1.73210f, 1.00010f),
823 Point3D(2.00000f, -1.26783f, -0.73200f)
824 }
825 };
826 ::RunTest(polygons, expected);
827 }
828
829 TEST(BSPTree, TwoPlaneIntersectRotate300degrees) {
830 const std::deque<Polygon3D> polygons {
831 Polygon3D {
832 Point3D(-0.00000f, 0.73210f, -2.73200f),
833 Point3D(-0.00000f, 2.73210f, 0.73210f),
834 Point3D(0.00010f, -0.73200f, 2.73210f),
835 Point3D(0.00010f, -2.73200f, -0.73200f)
836 },
837 Polygon3D {
838 Point3D(2.00000f, 1.73210f, -0.99990f),
839 Point3D(2.00000f, -1.73200f, 1.00000f),
840 Point3D(-2.00000f, -1.73200f, 1.00000f),
841 Point3D(-2.00000f, 1.73210f, -0.99990f)
842 }
843 };
844
845 const std::deque<Polygon3D> expected {
846 Polygon3D {
847 Point3D(-0.00000f, 0.73210f, -2.73200f),
848 Point3D(-0.00000f, 2.73210f, 0.73210f),
849 Point3D(0.00010f, -0.73200f, 2.73210f),
850 Point3D(0.00010f, -2.73200f, -0.73200f)
851 },
852 Polygon3D {
853 Point3D(2.00000f, 1.73210f, -0.99990f),
854 Point3D(2.00000f, -1.73200f, 1.00000f),
855 Point3D(-2.00000f, -1.73200f, 1.00000f),
856 Point3D(-2.00000f, 1.73210f, -0.99990f)
857 }
858 };
859 ::RunTest(polygons, expected);
860 }
861
862 TEST(BSPTree, TwoPlaneIntersectRotate320degrees) {
863 const std::deque<Polygon3D> polygons {
864 Polygon3D {
865 Point3D(-0.00000f, -1.19530f, -2.56340f),
866 Point3D(-0.00000f, 2.56350f, -1.19530f),
867 Point3D(0.00010f, 1.19540f, 2.56350f),
868 Point3D(0.00010f, -2.56340f, 1.19540f)
869 },
870 Polygon3D {
871 Point3D(2.00000f, 0.68410f, -1.87930f),
872 Point3D(2.00000f, -0.68400f, 1.87940f),
873 Point3D(-2.00000f, -0.68400f, 1.87940f),
874 Point3D(-2.00000f, 0.68410f, -1.87930f)
875 }
876 };
877
878 const std::deque<Polygon3D> expected {
879 Polygon3D {
880 Point3D(-0.00000f, -1.19530f, -2.56340f),
881 Point3D(-0.00000f, 2.56350f, -1.19530f),
882 Point3D(0.00010f, 1.19540f, 2.56350f),
883 Point3D(0.00010f, -2.56340f, 1.19540f)
884 },
885 Polygon3D {
886 Point3D(2.00000f, 0.68410f, -1.87930f),
887 Point3D(2.00000f, -0.68400f, 1.87940f),
888 Point3D(-2.00000f, -0.68400f, 1.87940f),
889 Point3D(-2.00000f, 0.68410f, -1.87930f)
890 }
891 };
892 ::RunTest(polygons, expected);
893 }
894
895 TEST(BSPTree, TwoPlaneIntersectRotate340degrees) {
896 const std::deque<Polygon3D> polygons {
897 Polygon3D {
898 Point3D(-0.00000f, -2.00000f, -2.00000f),
899 Point3D(-0.00000f, 2.00000f, -2.00000f),
900 Point3D(0.00010f, 2.00000f, 2.00000f),
901 Point3D(0.00010f, -2.00000f, 2.00000f)
902 },
903 Polygon3D {
904 Point3D(2.00000f, 0.00010f, -2.00000f),
905 Point3D(2.00000f, -0.00000f, 2.00000f),
906 Point3D(-2.00000f, -0.00000f, 2.00000f),
907 Point3D(-2.00000f, 0.00010f, -2.00000f)
908 }
909 };
910
911 const std::deque<Polygon3D> expected {
912 Polygon3D {
913 Point3D(-0.00000f, -2.00000f, -2.00000f),
914 Point3D(-0.00000f, 2.00000f, -2.00000f),
915 Point3D(0.00010f, 2.00000f, 2.00000f),
916 Point3D(0.00010f, -2.00000f, 2.00000f)
917 },
918 Polygon3D {
919 Point3D(2.00000f, 0.00010f, -2.00000f),
920 Point3D(2.00000f, -0.00000f, 2.00000f),
921 Point3D(-2.00000f, -0.00000f, 2.00000f),
922 Point3D(-2.00000f, 0.00010f, -2.00000f)
923 }
924 };
925 ::RunTest(polygons, expected);
926 }
927
928 TEST(BSPTree, TwoPlaneIntersectRotate360degrees) {
929 const std::deque<Polygon3D> polygons {
930 Polygon3D {
931 Point3D(-0.00000f, -2.00000f, -2.00000f),
932 Point3D(-0.00000f, 2.00000f, -2.00000f),
933 Point3D(0.00010f, 2.00000f, 2.00000f),
934 Point3D(0.00010f, -2.00000f, 2.00000f)
935 },
936 Polygon3D {
937 Point3D(2.00000f, 0.00010f, -2.00000f),
938 Point3D(2.00000f, -0.00000f, 2.00000f),
939 Point3D(-2.00000f, -0.00000f, 2.00000f),
940 Point3D(-2.00000f, 0.00010f, -2.00000f)
941 }
942 };
943
944 const std::deque<Polygon3D> expected {
945 Polygon3D {
946 Point3D(-0.00000f, -2.00000f, -2.00000f),
947 Point3D(-0.00000f, 2.00000f, -2.00000f),
948 Point3D(0.00010f, 2.00000f, 2.00000f),
949 Point3D(0.00010f, -2.00000f, 2.00000f)
950 },
951 Polygon3D {
952 Point3D(2.00000f, 0.00010f, -2.00000f),
953 Point3D(2.00000f, -0.00000f, 2.00000f),
954 Point3D(-2.00000f, -0.00000f, 2.00000f),
955 Point3D(-2.00000f, 0.00010f, -2.00000f)
956 }
957 };
958 ::RunTest(polygons, expected);
959 }
960