9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
31 namespace tt = boost::test_tools;
32 using boost::test_tools::output_test_stream;
33 namespace utf = boost::unit_test;
42 BOOST_AUTO_TEST_SUITE(ConeSurfaces)
50 double alpha{M_PI / 8.}, halfPhiSector{M_PI / 16.}, zMin{1.0}, zMax{10.};
51 bool symmetric(
false);
55 Surface::makeShared<ConeSurface>(Transform3::Identity(),
alpha, symmetric)
59 Surface::makeShared<ConeSurface>(pTransform,
alpha, symmetric)->
type(),
63 BOOST_CHECK_EQUAL(Surface::makeShared<ConeSurface>(pTransform,
alpha, zMin,
72 std::make_shared<const ConeBounds>(
alpha, zMin, zMax, halfPhiSector, 0.);
74 Surface::makeShared<ConeSurface>(pTransform, pConeBounds)->
type(),
79 auto coneSurfaceObject =
80 Surface::makeShared<ConeSurface>(pTransform,
alpha, symmetric);
81 auto copiedConeSurface = Surface::makeShared<ConeSurface>(*coneSurfaceObject);
83 BOOST_CHECK(*copiedConeSurface == *coneSurfaceObject);
86 auto copiedTransformedConeSurface = Surface::makeShared<ConeSurface>(
87 tgContext, *coneSurfaceObject, pTransform);
88 BOOST_CHECK_EQUAL(copiedTransformedConeSurface->type(),
Surface::Cone);
91 BOOST_CHECK_THROW(
auto nullBounds = Surface::makeShared<ConeSurface>(
92 Transform3::Identity(),
nullptr),
99 double alpha{M_PI / 8.} ;
100 bool symmetric(
false);
103 auto coneSurfaceObject =
104 Surface::makeShared<ConeSurface>(pTransform,
alpha, symmetric);
110 Vector3 binningPosition{0., 1., 2.};
113 binningPosition, 1
e-6);
116 Vector3 globalPosition{2.0, 2.0, 2.0};
118 double rootHalf = std::sqrt(0.5);
120 expectedFrame << -rootHalf, 0., rootHalf, rootHalf, 0., rootHalf, 0., 1., 0.;
123 expectedFrame, 1
e-6, 1e-9);
127 Vector3 normal3D = {0., -1., 0.};
131 Vector2 positionPiBy2(1.0, M_PI / 2.);
132 Vector3 normalAtPiBy2{0.0312768, 0.92335, -0.382683};
135 normalAtPiBy2, 1e-2, 1e-9);
138 Vector3 symmetryAxis{0., 0., 1.};
146 Vector2 localPosition{1.0, M_PI / 2.0};
150 Vector3 expectedPosition{0.0220268, 1.65027, 3.5708};
159 Vector2 expectedLocalPosition{1.0, M_PI / 2.0};
165 BOOST_CHECK(coneSurfaceObject->isOnSurface(
tgContext, globalPosition,
173 0.40218866453252877, 0.01);
176 BOOST_CHECK_EQUAL(coneSurfaceObject->name(),
195 double alpha{M_PI / 8.} ;
196 bool symmetric(
false);
199 auto coneSurfaceObject =
200 Surface::makeShared<ConeSurface>(pTransform,
alpha, symmetric);
202 auto coneSurfaceObject2 =
203 Surface::makeShared<ConeSurface>(pTransform,
alpha, symmetric);
206 BOOST_CHECK(*coneSurfaceObject == *coneSurfaceObject2);
208 BOOST_TEST_CHECKPOINT(
209 "Create and then assign a ConeSurface object to the existing one");
211 auto assignedConeSurface =
212 Surface::makeShared<ConeSurface>(Transform3::Identity(), 0.1,
true);
213 *assignedConeSurface = *coneSurfaceObject;
215 BOOST_CHECK(*assignedConeSurface == *coneSurfaceObject);
219 double alpha{M_PI / 8.}, zMin{0.}, zMax{10.};
225 auto pConeBounds = std::make_shared<const ConeBounds>(
alpha, zMin, zMax);
226 auto pCone = Surface::makeShared<ConeSurface>(pTransform, pConeBounds);
227 auto pConeExtent = pCone->polyhedronRepresentation(
tgContext, 1).extent();
229 double rMax = zMax * std::tan(alpha);
240 double halfPhiSector = M_PI / 8.;
242 std::make_shared<const ConeBounds>(
alpha, zMin, zMax, halfPhiSector, 0.);
243 pCone = Surface::makeShared<ConeSurface>(pTransform, pConeBounds);
244 pConeExtent = pCone->polyhedronRepresentation(
tgContext, 1).extent();
254 double alpha{M_PI / 8.};
255 bool symmetric(
false);
258 auto coneSurfaceObject =
259 Surface::makeShared<ConeSurface>(pTransform,
alpha, symmetric);
261 const auto& rotation = pTransform.rotation();
263 const Vector3 localZAxis = rotation.col(2);
268 Vector3 globalPosition{0, 1. + std::tan(alpha), 3};
272 const auto& loc3DToLocBound =
273 coneSurfaceObject->localCartesianToBoundLocalDerivative(
tgContext,
277 expLoc3DToLocBound << -1, 0, M_PI / 2. * std::tan(alpha), 0, 0, 1;
281 BOOST_AUTO_TEST_SUITE_END()