9 #include <boost/test/unit_test.hpp>
24 Intersection3D::Status::reachable);
26 Intersection3D::Status::reachable);
28 Intersection3D::Status::reachable);
29 BOOST_CHECK(
bool(fIp));
30 BOOST_CHECK(
bool(sIp));
31 BOOST_CHECK(
bool(tIp));
35 Intersection3D::Status::unreachable);
36 BOOST_CHECK(!
bool(nIp));
38 std::vector<Intersection3D> fstpIntersections = {fIp, sIp, tIp};
39 std::vector<Intersection3D> tsfpIntersections = {tIp, sIp, fIp};
42 std::sort(tsfpIntersections.begin(), tsfpIntersections.end());
43 BOOST_CHECK_EQUAL(fstpIntersections[0].
pathLength,
44 tsfpIntersections[0].pathLength);
45 BOOST_CHECK_EQUAL(fstpIntersections[1].pathLength,
46 tsfpIntersections[1].pathLength);
47 BOOST_CHECK_EQUAL(fstpIntersections[2].pathLength,
48 tsfpIntersections[2].pathLength);
51 std::sort(tsfpIntersections.begin(), tsfpIntersections.end(),
53 BOOST_CHECK_EQUAL(fstpIntersections[0].pathLength,
54 tsfpIntersections[2].pathLength);
55 BOOST_CHECK_EQUAL(fstpIntersections[1].pathLength,
56 tsfpIntersections[1].pathLength);
57 BOOST_CHECK_EQUAL(fstpIntersections[2].pathLength,
58 tsfpIntersections[0].pathLength);
62 std::vector<Intersection3D> ntfspIntersections = {nIp, tIp, fIp, sIp};
63 std::vector<Intersection3D> tfnsnpIntersections = {tIp, fIp, nIp, sIp, nIp};
66 std::sort(ntfspIntersections.begin(), ntfspIntersections.end());
67 BOOST_CHECK_EQUAL(fstpIntersections[0].pathLength,
68 ntfspIntersections[0].pathLength);
69 BOOST_CHECK_EQUAL(fstpIntersections[1].pathLength,
70 ntfspIntersections[1].pathLength);
71 BOOST_CHECK_EQUAL(fstpIntersections[2].pathLength,
72 ntfspIntersections[2].pathLength);
73 BOOST_CHECK_EQUAL(
bool(ntfspIntersections[3]),
false);
75 std::sort(tfnsnpIntersections.begin(), tfnsnpIntersections.end());
76 BOOST_CHECK_EQUAL(fstpIntersections[0].pathLength,
77 tfnsnpIntersections[0].pathLength);
78 BOOST_CHECK_EQUAL(fstpIntersections[1].pathLength,
79 tfnsnpIntersections[1].pathLength);
80 BOOST_CHECK_EQUAL(fstpIntersections[2].pathLength,
81 tfnsnpIntersections[2].pathLength);
82 BOOST_CHECK_EQUAL(
bool(tfnsnpIntersections[3]),
false);
83 BOOST_CHECK_EQUAL(
bool(tfnsnpIntersections[4]),
false);
87 Intersection3D::Status::reachable);
89 Intersection3D::Status::reachable);
91 Intersection3D::Status::reachable);
93 std::vector<Intersection3D> tsfnIntersections = {tIn, sIn, fIn};
94 std::vector<Intersection3D> fstnIntersections = {fIn, sIn, tIn};
97 std::sort(fstnIntersections.begin(), fstnIntersections.end());
98 BOOST_CHECK_EQUAL(fstnIntersections[0].pathLength,
99 tsfnIntersections[0].pathLength);
100 BOOST_CHECK_EQUAL(fstnIntersections[1].pathLength,
101 tsfnIntersections[1].pathLength);
102 BOOST_CHECK_EQUAL(fstnIntersections[2].pathLength,
103 tsfnIntersections[2].pathLength);
106 std::sort(fstnIntersections.begin(), fstnIntersections.end(),
108 BOOST_CHECK_EQUAL(fstnIntersections[0].pathLength,
109 tsfnIntersections[2].pathLength);
110 BOOST_CHECK_EQUAL(fstnIntersections[1].pathLength,
111 tsfnIntersections[1].pathLength);
112 BOOST_CHECK_EQUAL(fstnIntersections[2].pathLength,
113 tsfnIntersections[0].pathLength);
116 std::vector<Intersection3D> pnsolutions = {tIp, sIn, sIp, fIn, tIn, fIp};
117 std::sort(pnsolutions.begin(), pnsolutions.end());
119 BOOST_CHECK_EQUAL(pnsolutions[0].pathLength, -3.);
120 BOOST_CHECK_EQUAL(pnsolutions[1].pathLength, -2.);
121 BOOST_CHECK_EQUAL(pnsolutions[2].pathLength, -1.);
122 BOOST_CHECK_EQUAL(pnsolutions[3].pathLength, 1.);
123 BOOST_CHECK_EQUAL(pnsolutions[4].pathLength, 2.);
124 BOOST_CHECK_EQUAL(pnsolutions[5].pathLength, 3.);
128 Intersection3D::Status::onSurface);
129 std::vector<Intersection3D> tszfpIntersections = {tIp, sIp, zI, fIp};
131 std::sort(tszfpIntersections.begin(), tszfpIntersections.end());
132 BOOST_CHECK_EQUAL(tszfpIntersections[0].pathLength, 0.);
133 BOOST_CHECK_EQUAL(tszfpIntersections[1].pathLength, 1.);
134 BOOST_CHECK_EQUAL(tszfpIntersections[2].pathLength, 2.);
135 BOOST_CHECK_EQUAL(tszfpIntersections[3].pathLength, 3.);
137 std::vector<Intersection3D> tfsznIntersections = {tIn, fIn, sIn, zI};
138 std::vector<Intersection3D> ztfsnIntersections = {zI, tIn, fIn, sIn};
140 std::sort(tfsznIntersections.begin(), tfsznIntersections.end(),
142 BOOST_CHECK_EQUAL(tfsznIntersections[0].pathLength, 0.);
143 BOOST_CHECK_EQUAL(tfsznIntersections[1].pathLength, -1.);
144 BOOST_CHECK_EQUAL(tfsznIntersections[2].pathLength, -2.);
145 BOOST_CHECK_EQUAL(tfsznIntersections[3].pathLength, -3.);
147 std::sort(ztfsnIntersections.begin(), ztfsnIntersections.end(),
149 BOOST_CHECK_EQUAL(ztfsnIntersections[0].pathLength, 0.);
150 BOOST_CHECK_EQUAL(ztfsnIntersections[1].pathLength, -1.);
151 BOOST_CHECK_EQUAL(ztfsnIntersections[2].pathLength, -2.);
152 BOOST_CHECK_EQUAL(ztfsnIntersections[3].pathLength, -3.);
157 auto psf6 = Surface::makeShared<PlaneSurface>(
Vector3D(6., 0., 0.),
159 auto psf7 = Surface::makeShared<PlaneSurface>(
Vector3D(7., 0., 0.),
161 auto psf8 = Surface::makeShared<PlaneSurface>(
Vector3D(8., 0., 0.),
163 auto psf9 = Surface::makeShared<PlaneSurface>(
Vector3D(9., 0., 0.),
165 auto psf10 = Surface::makeShared<PlaneSurface>(
Vector3D(10., 0., 0.),
171 Intersection3D::Status::reachable),
174 Intersection3D::Status::reachable),
177 Intersection3D::Status::reachable),
180 Intersection3D::Status::reachable),
182 PlaneIntersection int9b(
184 Intersection3D::Status::reachable),
187 Intersection3D::Status::reachable),
190 std::vector<PlaneIntersection> firstSet = {int6, int7, int9b, int10};
191 std::vector<PlaneIntersection> secondSet = {int8, int9a, int9b, int10};
193 std::vector<PlaneIntersection> unionSetStd = {};
195 std::vector<PlaneIntersection> unionSetCst = {};
198 std::set_union(firstSet.begin(), firstSet.end(), secondSet.begin(),
199 secondSet.end(), std::back_inserter(unionSetStd));
200 BOOST_CHECK_EQUAL(unionSetStd.size(), 6
u);
204 std::set_union(firstSet.begin(), firstSet.end(), secondSet.begin(),
205 secondSet.end(), std::back_inserter(unionSetCst),
207 BOOST_CHECK_EQUAL(unionSetCst.size(), 5
u);