9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
36 namespace tt = boost::test_tools;
37 using boost::test_tools::output_test_stream;
38 namespace utf = boost::unit_test;
47 BOOST_AUTO_TEST_SUITE(PlaneSurfaces)
52 auto rBounds = std::make_shared<const RectangleBounds>(3., 4.);
58 Surface::makeShared<PlaneSurface>(pTransform,
rBounds)->
type(),
61 auto planeSurfaceObject =
62 Surface::makeShared<PlaneSurface>(pTransform,
rBounds);
63 auto copiedPlaneSurface =
64 Surface::makeShared<PlaneSurface>(*planeSurfaceObject);
66 BOOST_CHECK(*copiedPlaneSurface == *planeSurfaceObject);
69 auto copiedTransformedPlaneSurface = Surface::makeShared<PlaneSurface>(
70 tgContext, *planeSurfaceObject, pTransform);
71 BOOST_CHECK_EQUAL(copiedTransformedPlaneSurface->type(),
Surface::Plane);
76 auto nullBounds = Surface::makeShared<PlaneSurface>(
nullptr, detElem),
83 auto rBounds = std::make_shared<const RectangleBounds>(3., 4.);
87 auto planeSurfaceObject =
88 Surface::makeShared<PlaneSurface>(pTransform,
rBounds);
92 auto planeSurfaceObject2 =
93 Surface::makeShared<PlaneSurface>(pTransform2,
rBounds);
98 Vector3 binningPosition{0., 1., 2.};
104 Vector3 globalPosition{2.0, 2.0, 0.0};
107 expectedFrame << 1., 0., 0., 0., 1., 0., 0., 0., 1.;
111 expectedFrame, 1
e-6, 1e-9);
115 BOOST_CHECK_EQUAL(planeSurfaceObject->normal(
tgContext), normal3D);
118 BOOST_CHECK_EQUAL(planeSurfaceObject->bounds().type(),
122 Vector2 localPosition{1.5, 1.7};
136 Vector2 expectedLocalPosition{1.5, 1.7};
142 planeSurfaceObject->normal(
tgContext, localPosition) * 0.1;
147 BOOST_CHECK(planeSurfaceObject
150 BOOST_CHECK(planeSurfaceObject
156 BOOST_CHECK(planeSurfaceObject->isOnSurface(
tgContext, globalPosition,
163 auto sfIntersection =
164 planeSurfaceObject->intersect(
tgContext, offSurface, direction,
true)
167 Intersection3D::Status::reachable};
168 BOOST_CHECK(sfIntersection);
169 BOOST_CHECK_EQUAL(sfIntersection.position(), expectedIntersect.position());
170 BOOST_CHECK_EQUAL(sfIntersection.pathLength(),
171 expectedIntersect.pathLength());
172 BOOST_CHECK_EQUAL(sfIntersection.object(), planeSurfaceObject.get());
181 BOOST_CHECK_EQUAL(planeSurfaceObject->name(),
201 auto rBounds = std::make_shared<const RectangleBounds>(3., 4.);
204 auto planeSurfaceObject =
205 Surface::makeShared<PlaneSurface>(pTransform,
rBounds);
206 auto planeSurfaceObject2 =
207 Surface::makeShared<PlaneSurface>(pTransform,
rBounds);
210 BOOST_CHECK(*planeSurfaceObject == *planeSurfaceObject2);
212 BOOST_TEST_CHECKPOINT(
213 "Create and then assign a PlaneSurface object to the existing one");
215 auto assignedPlaneSurface =
216 Surface::makeShared<PlaneSurface>(Transform3::Identity(),
nullptr);
217 *assignedPlaneSurface = *planeSurfaceObject;
219 BOOST_CHECK(*assignedPlaneSurface == *planeSurfaceObject);
227 Transform3::Identity();
232 auto rBounds = std::make_shared<RectangleBounds>(rHx, rHy);
234 auto plane = Surface::makeShared<PlaneSurface>(
237 auto planeExtent = plane->polyhedronRepresentation(
tgContext, 1).extent();
250 double alpha = 0.123;
251 auto planeRot = Surface::makeShared<PlaneSurface>(
256 auto planeExtentRot =
257 planeRot->polyhedronRepresentation(
tgContext, 1).extent();
275 auto rBounds = std::make_shared<const RectangleBounds>(3., 4.);
279 auto planeSurfaceObject =
280 Surface::makeShared<PlaneSurface>(pTransform,
rBounds);
281 const auto& rotation = pTransform.rotation();
283 const Vector3 localZAxis = rotation.col(2);
296 parameters.head<3>() = globalPosition;
297 parameters.segment<3>(
eFreeDir0) = direction;
301 planeSurfaceObject->alignmentToPathDerivative(
tgContext, parameters);
304 expAlignToPath << 0, 0, 1, 2, -1, 0;
310 const auto& loc3DToLocBound =
311 planeSurfaceObject->localCartesianToBoundLocalDerivative(
tgContext,
319 derivatives.head<3>() = direction;
321 planeSurfaceObject->alignmentToBoundDerivative(
tgContext, parameters,
329 expAlignToloc0 << -1, 0, 0, 0, 0, 2;
331 expAlignToloc1 << 0, -1, 0, 0, 0, -1;
337 BOOST_AUTO_TEST_SUITE_END()