9 #include <boost/test/unit_test.hpp>
36 BOOST_AUTO_TEST_SUITE(Volumes)
40 vertices = {{{0, 0, 0},
50 BOOST_CHECK(cubo.
inside({0.5, 0.5, 0.5}));
51 BOOST_CHECK(cubo.inside({1.5, 0.5, 0.5}));
52 BOOST_CHECK(!cubo.inside({2.5, 0.5, 0.5}));
53 BOOST_CHECK(!cubo.inside({0.5, 1.5, 0.5}));
54 BOOST_CHECK(!cubo.inside({0.5, 0.5, 1.5}));
55 BOOST_CHECK(!cubo.inside({-0.5, 0.5, 0.5}));
57 BOOST_CHECK(!cubo.inside({2.2, 1, 1}, 0.1));
58 BOOST_CHECK(cubo.inside({2.2, 1, 1}, 0.21));
59 BOOST_CHECK(cubo.inside({2.2, 1, 1}, 0.3));
64 vertices = {{{0, 0, 0},
74 auto is_in = [](
const auto& tvtx,
const auto& vertices_) {
75 for (
const auto& vtx : vertices_) {
84 for (
const auto& srf : surfaces) {
85 auto pbounds =
dynamic_cast<const PlanarBounds*
>(&srf.first->bounds());
86 for (
const auto& vtx : pbounds->vertices()) {
87 Vector3 glob = srf.first->localToGlobal(
gctx, vtx, {});
89 BOOST_CHECK(is_in(glob, vertices));
93 vertices = {{{0, 0, 0},
104 for (
const auto& srf : surfaces) {
105 auto pbounds =
dynamic_cast<const PlanarBounds*
>(&srf.first->bounds());
106 for (
const auto& vtx : pbounds->vertices()) {
107 Vector3 glob = srf.first->localToGlobal(
gctx, vtx, {});
109 BOOST_CHECK(is_in(glob, vertices));
118 for (
const auto& srf : surfaces) {
119 auto pbounds =
dynamic_cast<const PlanarBounds*
>(&srf.first->bounds());
120 for (
const auto& vtx : pbounds->vertices()) {
121 Vector3 glob = srf.first->localToGlobal(
gctx, vtx, {});
123 BOOST_CHECK(is_in(trf.inverse() * glob,
vertices));
130 vertices = {{{0, 0, 0},
142 std::ofstream
os(
"cuboid.ply");
150 vertices = {{{0, 0, 0},
163 rot =
AngleAxis3(M_PI / 2., Vector3::UnitX());
165 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
166 BOOST_CHECK_EQUAL(bb.max(),
Vector3(2, 1, 1));
167 BOOST_CHECK_EQUAL(bb.min(),
Vector3(0., 0., 0.));
171 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
173 BOOST_CHECK_EQUAL(bb.min(),
Vector3(0, -1, 0));
175 rot =
AngleAxis3(M_PI / 2., Vector3::UnitZ());
177 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
185 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
190 const auto boundValues = gcvb.
values();
191 BOOST_CHECK(boundValues.size() == 24
u);
194 to_array<GenericCuboidVolumeBounds::BoundValues::eSize, ActsScalar>(
197 BOOST_CHECK(gcvbCopy.values().size() == 24
u);
203 bb = gcvbCopy.boundingBox(&rot);
204 BOOST_CHECK_EQUAL(bb.entity(),
nullptr);
211 vertices = {{{0, 0, 0},
223 BOOST_CHECK_EQUAL(gcvbOrientedSurfaces.size(), 6);
225 for (
auto&
os : gcvbOrientedSurfaces) {
227 auto osCenter =
os.first->center(
geoCtx);
228 auto osNormal =
os.first->normal(
geoCtx);
230 Vector3 insideGcvb = osCenter +
os.second * osNormal;
231 Vector3 outsideGcvb = osCenter -
os.second * osNormal;
232 BOOST_CHECK(cubo.
inside(insideGcvb));
233 BOOST_CHECK(!cubo.
inside(outsideGcvb));
237 BOOST_AUTO_TEST_SUITE_END()