]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/overlay/select_rings.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / overlay / select_rings.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 //
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 //
5 // This file was modified by Oracle on 2017-2021.
6 // Modifications copyright (c) 2017-2021 Oracle and/or its affiliates.
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 //
9 // Use, modification and distribution is subject to the Boost Software License,
10 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12
13 #include <geometry_test_common.hpp>
14
15 #include <initializer_list>
16
17 #include <algorithms/test_overlay.hpp>
18
19 #include <boost/geometry/algorithms/detail/overlay/select_rings.hpp>
20 #include <boost/geometry/algorithms/detail/overlay/assign_parents.hpp>
21
22 #include <boost/geometry/geometries/point_xy.hpp>
23 #include <boost/geometry/geometries/polygon.hpp>
24
25 #include <boost/geometry/io/wkt/read.hpp>
26
27 template
28 <
29 typename Geometry1,
30 typename Geometry2,
31 bg::overlay_type OverlayType,
32 typename RingId
33 >
34 void test_geometry(std::string const& wkt1, std::string const& wkt2,
35 std::initializer_list<RingId> const& expected_ids)
36 {
37 typedef bg::detail::overlay::ring_properties
38 <
39 typename bg::point_type<Geometry1>::type,
40 double
41 > properties;
42
43 Geometry1 geometry1;
44 Geometry2 geometry2;
45
46 bg::read_wkt(wkt1, geometry1);
47 bg::read_wkt(wkt2, geometry2);
48
49 typedef std::map<bg::ring_identifier, properties> map_type;
50 map_type selected;
51 std::map<bg::ring_identifier, bg::detail::overlay::ring_turn_info> empty;
52
53 typedef typename bg::strategies::relate::services::default_strategy
54 <
55 Geometry1, Geometry2
56 >::type strategy_type;
57
58 bg::detail::overlay::select_rings<OverlayType>(geometry1, geometry2, empty, selected, strategy_type());
59
60 BOOST_CHECK_EQUAL(selected.size(), expected_ids.size());
61
62 if (selected.size() <= expected_ids.size())
63 {
64 auto eit = expected_ids.begin();
65 for (auto it = selected.begin(); it != selected.end(); ++it, ++eit)
66 {
67 bg::ring_identifier const ring_id = it->first;
68 BOOST_CHECK_EQUAL(ring_id.source_index, eit->source_index);
69 BOOST_CHECK_EQUAL(ring_id.multi_index, eit->multi_index);
70 BOOST_CHECK_EQUAL(ring_id.ring_index, eit->ring_index);
71 }
72 }
73 }
74
75
76
77
78 template <typename P>
79 void test_all()
80 {
81 // Point in correct clockwise ring -> should return true
82 typedef bg::ring_identifier rid;
83
84 test_geometry<bg::model::polygon<P>, bg::model::polygon<P>, bg::overlay_union>(
85 winded[0], winded[1],
86 { rid(0,-1,-1),
87 rid(0,-1, 0),
88 rid(0,-1, 1),
89 rid(0,-1, 3),
90 rid(1,-1, 1),
91 rid(1,-1, 2) });
92
93 test_geometry<bg::model::polygon<P>, bg::model::polygon<P>, bg::overlay_intersection>(
94 winded[0], winded[1],
95 { rid(0,-1, 2),
96 rid(1,-1,-1),
97 rid(1,-1, 0),
98 rid(1,-1, 3), });
99 }
100
101
102
103
104 int test_main( int , char* [] )
105 {
106 test_all<bg::model::d2::point_xy<double> >();
107
108 return 0;
109 }