9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
33 namespace tt = boost::test_tools;
39 BOOST_AUTO_TEST_SUITE(Geometry)
42 double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.};
50 BOOST_CHECK_EQUAL(solidCylinderSector.orientedSurfaces().size(), 5);
54 BOOST_CHECK_EQUAL(tubeCylinder.orientedSurfaces().size(), 4);
58 BOOST_CHECK_EQUAL(tubeCylinderSector.orientedSurfaces().size(), 6);
63 double rmed = 0.5 * (rmin + rmax);
64 double rthickness = (rmax - rmin);
67 BOOST_CHECK_EQUAL(original, fromCylinder);
72 BOOST_CHECK_EQUAL(original, fromDisc);
76 BOOST_CHECK_EQUAL(original, copied);
80 BOOST_CHECK_EQUAL(original, assigned);
84 double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.};
87 std::array<double, CylinderVolumeBounds::eSize>
values{};
88 std::vector<double> valvector = original.
values();
91 BOOST_CHECK_EQUAL(original, recreated);
95 double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.};
126 double rmed = 0.5 * (rmin + rmax);
141 double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.};
155 bdata::random(-M_PI, M_PI) ^ bdata::random(-M_PI, M_PI) ^
156 bdata::random(-M_PI, M_PI) ^ bdata::random(-10., 10.) ^
157 bdata::random(-10., 10.) ^ bdata::random(-10., 10.) ^
159 alpha, beta, gamma, posX, posY, posZ,
index) {
190 (pos - boundarySurfaces.at(0).first->center(tgContext)).
norm(),
193 (pos - boundarySurfaces.at(1).first->center(tgContext)).
norm(),
197 (
transform.inverse() * boundarySurfaces.at(1).first->center(tgContext))
201 (
transform.inverse() * boundarySurfaces.at(0).first->center(tgContext))
204 BOOST_CHECK_LT(centerPosZ, posDiscPosZ);
205 BOOST_CHECK_GT(centerPosZ, negDiscPosZ);
218 transform.rotation().col(2).dot(boundarySurfaces.at(1).first->normal(
224 transform.rotation().col(2).dot(boundarySurfaces.at(0).first->normal(
241 rot =
AngleAxis3(M_PI / 2., Vector3::UnitX());
243 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
244 BOOST_CHECK_EQUAL(bb.max(),
Vector3(5, 5, 10));
245 BOOST_CHECK_EQUAL(bb.min(),
Vector3(-5, -5, -10));
248 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
253 bb = cvb.boundingBox();
254 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
255 BOOST_CHECK_EQUAL(bb.max(),
Vector3(8, 8, 12));
256 BOOST_CHECK_EQUAL(bb.min(),
Vector3(-8, -8, -12));
258 double angle = M_PI / 8.;
260 bb = cvb.boundingBox();
261 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
264 Vector3(5 * std::cos(angle), -8 * std::sin(angle), -13), tol);
266 rot =
AngleAxis3(M_PI / 2., Vector3::UnitZ());
267 bb = cvb.boundingBox(&rot);
268 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
271 Vector3(-8 * std::sin(angle), 5 * std::cos(angle), -13), tol);
274 bb = cvb.boundingBox(&rot);
275 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
286 BOOST_CHECK_EQUAL(cvbOrientedSurfaces.size(), 4);
293 for (
auto&
os : cvbOrientedSurfaces) {
294 auto onSurface =
os.first->binningPosition(geoCtx,
binR);
295 auto osNormal =
os.first->normal(geoCtx, onSurface);
297 Vector3 insideCvb = onSurface +
os.second * osNormal;
298 Vector3 outsideCvb = onSurface -
os.second * osNormal;
300 BOOST_CHECK(cvb.
inside(insideCvb));
301 BOOST_CHECK(!cvb.
inside(outsideCvb));
304 auto rot =
os.first->transform(geoCtx).rotation();
305 BOOST_CHECK(rot.col(0).isApprox(xaxis));
306 BOOST_CHECK(rot.col(1).isApprox(yaxis));
307 BOOST_CHECK(rot.col(2).isApprox(zaxis));
311 BOOST_AUTO_TEST_SUITE_END()