9 #include <boost/test/unit_test.hpp>
36 Intersection3D::Status::reachable);
38 Intersection3D::Status::reachable);
40 Intersection3D::Status::reachable);
41 BOOST_CHECK(
bool(fIp));
42 BOOST_CHECK(
bool(sIp));
43 BOOST_CHECK(
bool(tIp));
47 Intersection3D::Status::unreachable);
48 BOOST_CHECK(!
bool(nIp));
50 std::vector<Intersection3D> fstpIntersections = {fIp, sIp, tIp};
51 std::vector<Intersection3D> tsfpIntersections = {tIp, sIp, fIp};
54 std::sort(tsfpIntersections.begin(), tsfpIntersections.end(),
56 BOOST_CHECK_EQUAL(fstpIntersections[0].
pathLength(),
58 BOOST_CHECK_EQUAL(fstpIntersections[1].
pathLength(),
60 BOOST_CHECK_EQUAL(fstpIntersections[2].
pathLength(),
65 std::vector<Intersection3D> ntfspIntersections = {nIp, tIp, fIp, sIp};
66 std::vector<Intersection3D> tfnsnpIntersections = {tIp, fIp, nIp, sIp, nIp};
69 std::sort(ntfspIntersections.begin(), ntfspIntersections.end(),
71 BOOST_CHECK_EQUAL(fstpIntersections[0].
pathLength(),
73 BOOST_CHECK_EQUAL(fstpIntersections[1].
pathLength(),
75 BOOST_CHECK_EQUAL(fstpIntersections[2].
pathLength(),
78 std::sort(tfnsnpIntersections.begin(), tfnsnpIntersections.end(),
80 BOOST_CHECK_EQUAL(fstpIntersections[0].
pathLength(),
82 BOOST_CHECK_EQUAL(fstpIntersections[1].
pathLength(),
84 BOOST_CHECK_EQUAL(fstpIntersections[2].
pathLength(),
89 Intersection3D::Status::reachable);
91 Intersection3D::Status::reachable);
93 Intersection3D::Status::reachable);
95 std::vector<Intersection3D> tsfnIntersections = {tIn, sIn, fIn};
96 std::vector<Intersection3D> fstnIntersections = {fIn, sIn, tIn};
99 std::sort(fstnIntersections.begin(), fstnIntersections.end(),
101 BOOST_CHECK_EQUAL(fstnIntersections[0].
pathLength(),
103 BOOST_CHECK_EQUAL(fstnIntersections[1].
pathLength(),
105 BOOST_CHECK_EQUAL(fstnIntersections[2].
pathLength(),
109 std::vector<Intersection3D> pnsolutions = {tIp, sIn, sIp, fIn, tIn, fIp};
110 std::sort(pnsolutions.begin(), pnsolutions.end(),
113 BOOST_CHECK_EQUAL(pnsolutions[0].
pathLength(), -3.);
114 BOOST_CHECK_EQUAL(pnsolutions[1].
pathLength(), -2.);
115 BOOST_CHECK_EQUAL(pnsolutions[2].
pathLength(), -1.);
116 BOOST_CHECK_EQUAL(pnsolutions[3].
pathLength(), 1.);
117 BOOST_CHECK_EQUAL(pnsolutions[4].
pathLength(), 2.);
118 BOOST_CHECK_EQUAL(pnsolutions[5].
pathLength(), 3.);
122 std::vector<Intersection3D> tszfpIntersections = {tIp, sIp, zI, fIp};
124 std::sort(tszfpIntersections.begin(), tszfpIntersections.end(),
126 BOOST_CHECK_EQUAL(tszfpIntersections[0].
pathLength(), 0.);
127 BOOST_CHECK_EQUAL(tszfpIntersections[1].
pathLength(), 1.);
128 BOOST_CHECK_EQUAL(tszfpIntersections[2].
pathLength(), 2.);
129 BOOST_CHECK_EQUAL(tszfpIntersections[3].
pathLength(), 3.);
131 std::vector<Intersection3D> tfsznIntersections = {tIn, fIn, sIn, zI};
132 std::vector<Intersection3D> ztfsnIntersections = {zI, tIn, fIn, sIn};
134 std::sort(tfsznIntersections.begin(), tfsznIntersections.end(),
136 BOOST_CHECK_EQUAL(tfsznIntersections[0].
pathLength(), -3.);
137 BOOST_CHECK_EQUAL(tfsznIntersections[1].
pathLength(), -2.);
138 BOOST_CHECK_EQUAL(tfsznIntersections[2].
pathLength(), -1.);
139 BOOST_CHECK_EQUAL(tfsznIntersections[3].
pathLength(), 0.);
144 auto psf6 = Surface::makeShared<PlaneSurface>(
Vector3(6., 0., 0.),
146 auto psf7 = Surface::makeShared<PlaneSurface>(
Vector3(7., 0., 0.),
148 auto psf8 = Surface::makeShared<PlaneSurface>(
Vector3(8., 0., 0.),
150 auto psf9 = Surface::makeShared<PlaneSurface>(
Vector3(9., 0., 0.),
152 auto psf10 = Surface::makeShared<PlaneSurface>(
Vector3(10., 0., 0.),
158 Intersection3D::Status::reachable),
161 Intersection3D::Status::reachable),
164 Intersection3D::Status::reachable),
167 Intersection3D::Status::reachable),
169 PlaneIntersection int9b(
171 Intersection3D::Status::reachable),
174 Intersection3D::Status::reachable),
177 std::vector<PlaneIntersection> firstSet = {int6, int7, int9b, int10};
178 std::vector<PlaneIntersection> secondSet = {int8, int9a, int9b, int10};
180 std::vector<PlaneIntersection> unionSetStd = {};
182 std::vector<PlaneIntersection> unionSetCst = {};
185 std::set_union(firstSet.begin(), firstSet.end(), secondSet.begin(),
186 secondSet.end(), std::back_inserter(unionSetStd),
187 PlaneIntersection::forwardOrder);
188 BOOST_CHECK_EQUAL(unionSetStd.size(), 6
u);
192 std::array<IntersectionStatus, 4> status_values = {
193 {IntersectionStatus::missed, IntersectionStatus::unreachable,
194 IntersectionStatus::reachable, IntersectionStatus::onSurface}};
195 std::array<std::string, 4> expected_messages = {
196 {
"missed/unreachable",
"missed/unreachable",
"reachable",
"onSurface"}};
198 for (
int i = 0;
i < 4; ++
i) {
199 std::stringstream ss;
200 ss << status_values[
i];
201 BOOST_CHECK(ss.str() == expected_messages[
i]);