File indexing completed on 2025-04-04 07:59:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/monomorphic/fwd.hpp>
0010 #include <boost/test/data/test_case.hpp>
0011 #include <boost/test/tools/context.hpp>
0012 #include <boost/test/tools/old/interface.hpp>
0013 #include <boost/test/unit_test.hpp>
0014 #include <boost/test/unit_test_suite.hpp>
0015
0016 #include "Acts/Definitions/Algebra.hpp"
0017 #include "Acts/Definitions/Units.hpp"
0018 #include "Acts/Geometry/CuboidPortalShell.hpp"
0019 #include "Acts/Geometry/CuboidVolumeBounds.hpp"
0020 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0021 #include "Acts/Geometry/GridPortalLink.hpp"
0022 #include "Acts/Geometry/Portal.hpp"
0023 #include "Acts/Geometry/TrackingVolume.hpp"
0024 #include "Acts/Geometry/TrivialPortalLink.hpp"
0025 #include "Acts/Utilities/AxisDefinitions.hpp"
0026
0027 #include <cstddef>
0028 #include <initializer_list>
0029 #include <memory>
0030 #include <stdexcept>
0031 #include <utility>
0032
0033 using namespace Acts::UnitLiterals;
0034
0035 namespace Acts::Test {
0036 GeometryContext gctx;
0037
0038 std::size_t getVolumeIndex() {
0039 static std::size_t i = 1;
0040 return i++;
0041 }
0042
0043 auto makeVolume(auto&&... pars) {
0044 TrackingVolume vol(Transform3::Identity(),
0045 std::make_shared<CuboidVolumeBounds>(
0046 std::forward<decltype(pars)>(pars)...));
0047 vol.setVolumeName("cube" + std::to_string(getVolumeIndex()));
0048 return vol;
0049 };
0050
0051 auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE);
0052
0053 BOOST_AUTO_TEST_SUITE(PortalShellTests)
0054
0055 BOOST_AUTO_TEST_CASE(ConstructionFromVolume) {
0056 auto cube = makeVolume(30_mm, 40_mm, 50_mm);
0057
0058 TrackingVolume cylVolume(
0059 Transform3::Identity(),
0060 std::make_shared<CylinderVolumeBounds>(10_mm, 20_mm, 10_mm));
0061
0062 BOOST_CHECK_THROW(SingleCuboidPortalShell{cylVolume}, std::invalid_argument);
0063
0064 SingleCuboidPortalShell shell1{cube};
0065 BOOST_CHECK_EQUAL(shell1.size(), 6);
0066
0067 using enum CuboidVolumeBounds::Face;
0068
0069
0070 const auto* pXY = shell1.portal(PositiveZFace);
0071 BOOST_REQUIRE_NE(pXY, nullptr);
0072 BOOST_CHECK_EQUAL(
0073 pXY->resolveVolume(gctx, Vector3{25_mm, 20_mm, 50_mm}, -Vector3::UnitZ())
0074 .value(),
0075 &cube);
0076 BOOST_CHECK_EQUAL(
0077 pXY->resolveVolume(gctx, Vector3{25_mm, 20_mm, 50_mm}, Vector3::UnitZ())
0078 .value(),
0079 nullptr);
0080
0081 const auto* nXY = shell1.portal(NegativeZFace);
0082 BOOST_REQUIRE_NE(nXY, nullptr);
0083 BOOST_CHECK_EQUAL(
0084 nXY->resolveVolume(gctx, Vector3{25_mm, 20_mm, -50_mm}, -Vector3::UnitZ())
0085 .value(),
0086 nullptr);
0087 BOOST_CHECK_EQUAL(
0088 nXY->resolveVolume(gctx, Vector3{25_mm, 20_mm, -50_mm}, Vector3::UnitZ())
0089 .value(),
0090 &cube);
0091
0092
0093 const auto* pYZ = shell1.portal(PositiveXFace);
0094 BOOST_REQUIRE_NE(pYZ, nullptr);
0095 BOOST_CHECK_EQUAL(
0096 pYZ->resolveVolume(gctx, Vector3{30_mm, 10_mm, 30_mm}, -Vector3::UnitX())
0097 .value(),
0098 &cube);
0099 BOOST_CHECK_EQUAL(
0100 pYZ->resolveVolume(gctx, Vector3{30_mm, 10_mm, 30_mm}, Vector3::UnitX())
0101 .value(),
0102 nullptr);
0103
0104 const auto* nYZ = shell1.portal(NegativeXFace);
0105 BOOST_REQUIRE_NE(nYZ, nullptr);
0106 BOOST_CHECK_EQUAL(
0107 nYZ->resolveVolume(gctx, Vector3{-30_mm, 10_mm, 30_mm}, -Vector3::UnitX())
0108 .value(),
0109 nullptr);
0110 BOOST_CHECK_EQUAL(
0111 nYZ->resolveVolume(gctx, Vector3{-30_mm, 10_mm, 30_mm}, Vector3::UnitX())
0112 .value(),
0113 &cube);
0114
0115
0116 const auto* pZX = shell1.portal(PositiveYFace);
0117 BOOST_REQUIRE_NE(pZX, nullptr);
0118 BOOST_CHECK_EQUAL(
0119 pZX->resolveVolume(gctx, Vector3{15_mm, 40_mm, -10_mm}, -Vector3::UnitY())
0120 .value(),
0121 &cube);
0122 BOOST_CHECK_EQUAL(
0123 pZX->resolveVolume(gctx, Vector3{15_mm, 40_mm, -10_mm}, Vector3::UnitY())
0124 .value(),
0125 nullptr);
0126
0127 const auto* nZX = shell1.portal(NegativeYFace);
0128 BOOST_REQUIRE_NE(nZX, nullptr);
0129 BOOST_CHECK_EQUAL(nZX->resolveVolume(gctx, Vector3{15_mm, -40_mm, -10_mm},
0130 -Vector3::UnitY())
0131 .value(),
0132 nullptr);
0133 BOOST_CHECK_EQUAL(
0134 nZX->resolveVolume(gctx, Vector3{15_mm, -40_mm, -10_mm}, Vector3::UnitY())
0135 .value(),
0136 &cube);
0137 }
0138
0139 BOOST_AUTO_TEST_CASE(PortalAssignment) {
0140 using enum CuboidVolumeBounds::Face;
0141 TrackingVolume vol(Transform3::Identity(),
0142 std::make_shared<CuboidVolumeBounds>(30_mm, 40_mm, 50_mm));
0143
0144 SingleCuboidPortalShell shell{vol};
0145
0146 const auto* pXY = shell.portal(PositiveZFace);
0147 const auto* nXY = shell.portal(NegativeZFace);
0148 const auto* nYZ = shell.portal(NegativeXFace);
0149 const auto* pZX = shell.portal(PositiveYFace);
0150 auto* pYZ = shell.portal(PositiveXFace);
0151 auto* nZX = shell.portal(NegativeYFace);
0152
0153
0154 BOOST_REQUIRE_NE(pYZ, nullptr);
0155 auto* pYZLink = dynamic_cast<const TrivialPortalLink*>(
0156 pYZ->getLink(Direction::OppositeNormal()));
0157 BOOST_REQUIRE_NE(pYZLink, nullptr);
0158
0159 auto grid = pYZLink->makeGrid(AxisDirection::AxisX);
0160
0161 auto portal2 =
0162 std::make_shared<Portal>(Direction::OppositeNormal(), std::move(grid));
0163 shell.setPortal(portal2, PositiveXFace);
0164 BOOST_CHECK_EQUAL(shell.portal(PositiveXFace), portal2.get());
0165
0166
0167 BOOST_CHECK_EQUAL(shell.portal(PositiveZFace), pXY);
0168 BOOST_CHECK_EQUAL(shell.portal(NegativeZFace), nXY);
0169 BOOST_CHECK_EQUAL(shell.portal(NegativeXFace), nYZ);
0170 BOOST_CHECK_EQUAL(shell.portal(PositiveYFace), pZX);
0171 BOOST_CHECK_EQUAL(shell.portal(NegativeYFace), nZX);
0172
0173
0174 BOOST_REQUIRE_NE(nZX, nullptr);
0175 auto* nZXLink = dynamic_cast<const TrivialPortalLink*>(
0176 nZX->getLink(Direction::AlongNormal()));
0177 BOOST_REQUIRE_NE(nZXLink, nullptr);
0178
0179 grid = nZXLink->makeGrid(AxisDirection::AxisY);
0180
0181 auto portal3 =
0182 std::make_shared<Portal>(Direction::AlongNormal(), std::move(grid));
0183 shell.setPortal(portal3, NegativeYFace);
0184 BOOST_CHECK_EQUAL(shell.portal(NegativeYFace), portal3.get());
0185
0186
0187 BOOST_CHECK_EQUAL(shell.portal(PositiveZFace), pXY);
0188 BOOST_CHECK_EQUAL(shell.portal(NegativeZFace), nXY);
0189 BOOST_CHECK_EQUAL(shell.portal(NegativeXFace), nYZ);
0190 BOOST_CHECK_EQUAL(shell.portal(PositiveYFace), pZX);
0191 BOOST_CHECK_EQUAL(shell.portal(PositiveXFace), portal2.get());
0192 }
0193
0194 BOOST_AUTO_TEST_SUITE(CuboidStack)
0195 BOOST_DATA_TEST_CASE(XYZDirection,
0196 boost::unit_test::data::make(Acts::AxisDirection::AxisX,
0197 Acts::AxisDirection::AxisY,
0198 Acts::AxisDirection::AxisZ),
0199 dir) {
0200 AxisDirection dirOrth1{};
0201 AxisDirection dirOrth2{};
0202 std::size_t dirIdx = 0;
0203 switch (dir) {
0204 case Acts::AxisDirection::AxisX:
0205 dirOrth1 = Acts::AxisDirection::AxisY;
0206 dirOrth2 = Acts::AxisDirection::AxisZ;
0207 dirIdx = 0;
0208 break;
0209 case Acts::AxisDirection::AxisY:
0210 dirOrth1 = Acts::AxisDirection::AxisX;
0211 dirOrth2 = Acts::AxisDirection::AxisZ;
0212 dirIdx = 1;
0213 break;
0214 case Acts::AxisDirection::AxisZ:
0215 dirOrth1 = Acts::AxisDirection::AxisX;
0216 dirOrth2 = Acts::AxisDirection::AxisY;
0217 dirIdx = 2;
0218 break;
0219 default:
0220 throw std::invalid_argument("Invalid direction");
0221 }
0222
0223 auto boundDir = CuboidVolumeBounds::boundsFromAxisDirection(dir);
0224 auto boundDirOrth1 = CuboidVolumeBounds::boundsFromAxisDirection(dirOrth1);
0225 auto boundDirOrth2 = CuboidVolumeBounds::boundsFromAxisDirection(dirOrth2);
0226
0227 auto [frontFace, backFace, sideFaces] =
0228 CuboidVolumeBounds::facesFromAxisDirection(dir);
0229
0230 using enum CuboidVolumeBounds::Face;
0231 auto bounds1 = std::make_shared<CuboidVolumeBounds>(
0232 std::initializer_list<std::pair<CuboidVolumeBounds::BoundValues, double>>{
0233 {boundDir, 100_mm}, {boundDirOrth1, 30_mm}, {boundDirOrth2, 100_mm}});
0234
0235 auto bounds2 = std::make_shared<CuboidVolumeBounds>(
0236 std::initializer_list<std::pair<CuboidVolumeBounds::BoundValues, double>>{
0237 {boundDir, 100_mm}, {boundDirOrth1, 30_mm}, {boundDirOrth2, 100_mm}});
0238
0239 TrackingVolume vol1(Transform3{Translation3{Vector3::Unit(dirIdx) * -100_mm}},
0240 bounds1);
0241 TrackingVolume vol2(Transform3{Translation3{Vector3::Unit(dirIdx) * 100_mm}},
0242 bounds2);
0243
0244 SingleCuboidPortalShell shell1{vol1};
0245 SingleCuboidPortalShell shell2{vol2};
0246
0247 std::map<CuboidVolumeBounds::Face, Vector3> centers1;
0248 std::map<CuboidVolumeBounds::Face, Vector3> centers2;
0249 for (const auto face : sideFaces) {
0250 Vector3 normal{};
0251 switch (face) {
0252 case NegativeZFace:
0253 normal = Vector3::UnitZ();
0254 break;
0255 case PositiveZFace:
0256 normal = -Vector3::UnitZ();
0257 break;
0258 case NegativeYFace:
0259 normal = Vector3::UnitY();
0260 break;
0261 case PositiveYFace:
0262 normal = -Vector3::UnitY();
0263 break;
0264 case NegativeXFace:
0265 normal = Vector3::UnitX();
0266 break;
0267 case PositiveXFace:
0268 normal = -Vector3::UnitX();
0269 break;
0270 }
0271
0272 const auto center1 = shell1.portal(face)->surface().center(gctx);
0273 const auto center2 = shell2.portal(face)->surface().center(gctx);
0274
0275 centers1[face] = center1;
0276 centers2[face] = center2;
0277
0278 BOOST_CHECK_EQUAL(
0279 shell1.portal(face)->resolveVolume(gctx, center1, normal).value(),
0280 &vol1);
0281 BOOST_CHECK_EQUAL(
0282 shell1.portal(face)->resolveVolume(gctx, center1, -normal).value(),
0283 nullptr);
0284
0285 BOOST_CHECK_EQUAL(
0286 shell2.portal(face)->resolveVolume(gctx, center2, normal).value(),
0287 &vol2);
0288 BOOST_CHECK_EQUAL(
0289 shell2.portal(face)->resolveVolume(gctx, center2, -normal).value(),
0290 nullptr);
0291 }
0292
0293 BOOST_CHECK_NE(shell1.portal(backFace), shell2.portal(frontFace));
0294
0295 CuboidStackPortalShell stack(gctx, {&shell1, &shell2}, dir, *logger);
0296 BOOST_CHECK_EQUAL(stack.size(), 6);
0297
0298 BOOST_CHECK_EQUAL(shell1.portal(frontFace), stack.portal(frontFace));
0299 BOOST_CHECK_EQUAL(shell1.portal(backFace), shell2.portal(frontFace));
0300 BOOST_CHECK_EQUAL(shell2.portal(backFace), stack.portal(backFace));
0301
0302 for (const auto& face : sideFaces) {
0303 Vector3 normal{};
0304 switch (face) {
0305 case NegativeZFace:
0306 normal = Vector3::UnitZ();
0307 break;
0308 case PositiveZFace:
0309 normal = -Vector3::UnitZ();
0310 break;
0311 case NegativeYFace:
0312 normal = Vector3::UnitY();
0313 break;
0314 case PositiveYFace:
0315 normal = -Vector3::UnitY();
0316 break;
0317 case NegativeXFace:
0318 normal = Vector3::UnitX();
0319 break;
0320 case PositiveXFace:
0321 normal = -Vector3::UnitX();
0322 break;
0323 }
0324
0325 BOOST_CHECK_EQUAL(shell1.portal(face), stack.portal(face));
0326 BOOST_CHECK_EQUAL(shell2.portal(face), stack.portal(face));
0327
0328 const auto& center1 = centers1.at(face);
0329 const auto& center2 = centers2.at(face);
0330
0331 BOOST_CHECK_EQUAL(
0332 shell1.portal(face)->resolveVolume(gctx, center1, normal).value(),
0333 &vol1);
0334 BOOST_CHECK_EQUAL(
0335 shell1.portal(face)->resolveVolume(gctx, center1, -normal).value(),
0336 nullptr);
0337
0338 BOOST_CHECK_EQUAL(
0339 shell2.portal(face)->resolveVolume(gctx, center2, normal).value(),
0340 &vol2);
0341 BOOST_CHECK_EQUAL(
0342 shell2.portal(face)->resolveVolume(gctx, center2, -normal).value(),
0343 nullptr);
0344 }
0345
0346 shell1 = SingleCuboidPortalShell{vol1};
0347 shell2 = SingleCuboidPortalShell{vol2};
0348
0349 BOOST_CHECK_THROW(
0350 CuboidStackPortalShell(gctx, {&shell1, &shell2}, AxisDirection::AxisR),
0351 std::invalid_argument);
0352 }
0353
0354 BOOST_AUTO_TEST_CASE(NestedStacks) {
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379 Transform3 base = Transform3::Identity();
0380
0381 TrackingVolume vol1(
0382 base, std::make_shared<CuboidVolumeBounds>(30_mm, 100_mm, 200_mm),
0383 "vol1");
0384
0385 TrackingVolume vol2(
0386 base * Translation3(Vector3::UnitZ() * 300_mm),
0387 std::make_shared<CuboidVolumeBounds>(30_mm, 100_mm, 100_mm), "vol2");
0388
0389 TrackingVolume vol3(
0390 base * Translation3(Vector3::UnitZ() * 600_mm),
0391 std::make_shared<CuboidVolumeBounds>(30_mm, 100_mm, 200_mm), "vol3");
0392
0393 TrackingVolume vol4(
0394 base * Translation3{Vector3::UnitX() * 60_mm + Vector3::UnitZ() * 300_mm},
0395 std::make_shared<CuboidVolumeBounds>(30_mm, 100_mm, 500_mm), "vol4");
0396
0397 SingleCuboidPortalShell shell1{vol1};
0398 BOOST_CHECK(shell1.isValid());
0399 SingleCuboidPortalShell shell2{vol2};
0400 BOOST_CHECK(shell2.isValid());
0401 SingleCuboidPortalShell shell3{vol3};
0402 BOOST_CHECK(shell3.isValid());
0403
0404 CuboidStackPortalShell stack{
0405 gctx, {&shell1, &shell2, &shell3}, AxisDirection::AxisZ};
0406
0407 BOOST_CHECK(stack.isValid());
0408
0409 SingleCuboidPortalShell shell4{vol4};
0410 BOOST_CHECK(shell4.isValid());
0411
0412 CuboidStackPortalShell stack2{
0413 gctx, {&stack, &shell4}, AxisDirection::AxisX, *logger};
0414 BOOST_CHECK(stack2.isValid());
0415
0416 using enum CuboidVolumeBounds::Face;
0417
0418 auto lookup = [](auto& shell, CuboidPortalShell::Face face, Vector3 position,
0419 Vector3 direction) -> const TrackingVolume* {
0420 const auto* portal = shell.portal(face);
0421 BOOST_REQUIRE_NE(portal, nullptr);
0422 return portal->resolveVolume(gctx, position, direction).value();
0423 };
0424
0425
0426 BOOST_CHECK_EQUAL(lookup(shell1, NegativeZFace,
0427 Vector3(10_mm, 20_mm, -200_mm), -Vector3::UnitZ()),
0428 nullptr);
0429 BOOST_CHECK_EQUAL(lookup(shell1, NegativeZFace,
0430 Vector3(10_mm, 20_mm, -200_mm), Vector3::UnitZ()),
0431 &vol1);
0432
0433 BOOST_CHECK_EQUAL(lookup(shell1, PositiveZFace, Vector3(10_mm, 20_mm, 200_mm),
0434 -Vector3::UnitZ()),
0435 &vol1);
0436 BOOST_CHECK_EQUAL(lookup(shell1, PositiveZFace, Vector3(10_mm, 20_mm, 200_mm),
0437 Vector3::UnitZ()),
0438 &vol2);
0439
0440 BOOST_CHECK_EQUAL(lookup(shell1, NegativeXFace, Vector3(-30_mm, 10_mm, 20_mm),
0441 -Vector3::UnitX()),
0442 nullptr);
0443 BOOST_CHECK_EQUAL(lookup(shell1, NegativeXFace, Vector3(-30_mm, 10_mm, 20_mm),
0444 Vector3::UnitX()),
0445 &vol1);
0446
0447 BOOST_CHECK_EQUAL(lookup(shell1, PositiveXFace, Vector3(30_mm, 10_mm, 20_mm),
0448 -Vector3::UnitX()),
0449 &vol1);
0450 BOOST_CHECK_EQUAL(lookup(shell1, PositiveXFace, Vector3(30_mm, 10_mm, 20_mm),
0451 Vector3::UnitX()),
0452 &vol4);
0453
0454 BOOST_CHECK_EQUAL(lookup(shell1, NegativeYFace,
0455 Vector3(10_mm, -100_mm, 20_mm), -Vector3::UnitY()),
0456 nullptr);
0457 BOOST_CHECK_EQUAL(lookup(shell1, NegativeYFace,
0458 Vector3(10_mm, -100_mm, 20_mm), Vector3::UnitY()),
0459 &vol1);
0460
0461 BOOST_CHECK_EQUAL(lookup(shell1, PositiveYFace, Vector3(10_mm, 100_mm, 20_mm),
0462 -Vector3::UnitY()),
0463 &vol1);
0464 BOOST_CHECK_EQUAL(lookup(shell1, PositiveYFace, Vector3(10_mm, 100_mm, 20_mm),
0465 Vector3::UnitY()),
0466 nullptr);
0467
0468
0469 BOOST_CHECK_EQUAL(lookup(shell2, NegativeZFace, Vector3(10_mm, 20_mm, 200_mm),
0470 -Vector3::UnitZ()),
0471 &vol1);
0472 BOOST_CHECK_EQUAL(lookup(shell2, NegativeZFace, Vector3(10_mm, 20_mm, 200_mm),
0473 Vector3::UnitZ()),
0474 &vol2);
0475
0476 BOOST_CHECK_EQUAL(lookup(shell2, PositiveZFace, Vector3(10_mm, 20_mm, 400_mm),
0477 -Vector3::UnitZ()),
0478 &vol2);
0479 BOOST_CHECK_EQUAL(lookup(shell2, PositiveZFace, Vector3(10_mm, 20_mm, 400_mm),
0480 Vector3::UnitZ()),
0481 &vol3);
0482
0483 BOOST_CHECK_EQUAL(lookup(shell2, NegativeXFace,
0484 Vector3(-30_mm, 10_mm, 220_mm), -Vector3::UnitX()),
0485 nullptr);
0486 BOOST_CHECK_EQUAL(lookup(shell2, NegativeXFace,
0487 Vector3(-30_mm, 10_mm, 220_mm), Vector3::UnitX()),
0488 &vol2);
0489
0490 BOOST_CHECK_EQUAL(lookup(shell2, PositiveXFace, Vector3(30_mm, 10_mm, 220_mm),
0491 -Vector3::UnitX()),
0492 &vol2);
0493 BOOST_CHECK_EQUAL(lookup(shell2, PositiveXFace, Vector3(30_mm, 10_mm, 220_mm),
0494 Vector3::UnitX()),
0495 &vol4);
0496
0497 BOOST_CHECK_EQUAL(lookup(shell2, NegativeYFace,
0498 Vector3(10_mm, -100_mm, 220_mm), -Vector3::UnitY()),
0499 nullptr);
0500 BOOST_CHECK_EQUAL(lookup(shell2, NegativeYFace,
0501 Vector3(10_mm, -100_mm, 220_mm), Vector3::UnitY()),
0502 &vol2);
0503
0504 BOOST_CHECK_EQUAL(lookup(shell2, PositiveYFace,
0505 Vector3(10_mm, 100_mm, 220_mm), -Vector3::UnitY()),
0506 &vol2);
0507 BOOST_CHECK_EQUAL(lookup(shell2, PositiveYFace,
0508 Vector3(10_mm, 100_mm, 220_mm), Vector3::UnitY()),
0509 nullptr);
0510
0511
0512 BOOST_CHECK_EQUAL(lookup(shell3, NegativeZFace, Vector3(10_mm, 20_mm, 400_mm),
0513 -Vector3::UnitZ()),
0514 &vol2);
0515 BOOST_CHECK_EQUAL(lookup(shell3, NegativeZFace, Vector3(10_mm, 20_mm, 400_mm),
0516 Vector3::UnitZ()),
0517 &vol3);
0518
0519 BOOST_CHECK_EQUAL(lookup(shell3, PositiveZFace, Vector3(10_mm, 20_mm, 800_mm),
0520 -Vector3::UnitZ()),
0521 &vol3);
0522 BOOST_CHECK_EQUAL(lookup(shell3, PositiveZFace, Vector3(10_mm, 20_mm, 800_mm),
0523 Vector3::UnitZ()),
0524 nullptr);
0525
0526 BOOST_CHECK_EQUAL(lookup(shell3, NegativeXFace,
0527 Vector3(-30_mm, 10_mm, 420_mm), -Vector3::UnitX()),
0528 nullptr);
0529 BOOST_CHECK_EQUAL(lookup(shell3, NegativeXFace,
0530 Vector3(-30_mm, 10_mm, 420_mm), Vector3::UnitX()),
0531 &vol3);
0532
0533 BOOST_CHECK_EQUAL(lookup(shell3, PositiveXFace, Vector3(30_mm, 10_mm, 420_mm),
0534 -Vector3::UnitX()),
0535 &vol3);
0536 BOOST_CHECK_EQUAL(lookup(shell3, PositiveXFace, Vector3(30_mm, 10_mm, 420_mm),
0537 Vector3::UnitX()),
0538 &vol4);
0539
0540 BOOST_CHECK_EQUAL(lookup(shell3, NegativeYFace,
0541 Vector3(10_mm, -100_mm, 420_mm), -Vector3::UnitY()),
0542 nullptr);
0543 BOOST_CHECK_EQUAL(lookup(shell3, NegativeYFace,
0544 Vector3(10_mm, -100_mm, 420_mm), Vector3::UnitY()),
0545 &vol3);
0546
0547 BOOST_CHECK_EQUAL(lookup(shell3, PositiveYFace,
0548 Vector3(10_mm, 100_mm, 420_mm), -Vector3::UnitY()),
0549 &vol3);
0550 BOOST_CHECK_EQUAL(lookup(shell3, PositiveYFace,
0551 Vector3(10_mm, 100_mm, 420_mm), Vector3::UnitY()),
0552 nullptr);
0553
0554
0555 BOOST_CHECK_EQUAL(lookup(shell4, NegativeZFace,
0556 Vector3(50_mm, 20_mm, -200_mm), -Vector3::UnitZ()),
0557 nullptr);
0558 BOOST_CHECK_EQUAL(lookup(shell4, NegativeZFace,
0559 Vector3(50_mm, 20_mm, -200_mm), Vector3::UnitZ()),
0560 &vol4);
0561
0562 BOOST_CHECK_EQUAL(lookup(shell4, PositiveZFace, Vector3(50_mm, 20_mm, 800_mm),
0563 -Vector3::UnitZ()),
0564 &vol4);
0565 BOOST_CHECK_EQUAL(lookup(shell4, PositiveZFace, Vector3(50_mm, 20_mm, 800_mm),
0566 Vector3::UnitZ()),
0567 nullptr);
0568
0569 BOOST_CHECK_EQUAL(lookup(shell4, NegativeXFace, Vector3(30_mm, 10_mm, 0_mm),
0570 -Vector3::UnitX()),
0571 &vol1);
0572 BOOST_CHECK_EQUAL(lookup(shell4, NegativeXFace, Vector3(30_mm, 10_mm, 220_mm),
0573 -Vector3::UnitX()),
0574 &vol2);
0575 BOOST_CHECK_EQUAL(lookup(shell4, NegativeXFace, Vector3(30_mm, 10_mm, 420_mm),
0576 -Vector3::UnitX()),
0577 &vol3);
0578 BOOST_CHECK_EQUAL(lookup(shell4, NegativeXFace, Vector3(30_mm, 10_mm, 300_mm),
0579 Vector3::UnitX()),
0580 &vol4);
0581
0582 BOOST_CHECK_EQUAL(lookup(shell4, PositiveXFace, Vector3(90_mm, 10_mm, 300_mm),
0583 -Vector3::UnitX()),
0584 &vol4);
0585 BOOST_CHECK_EQUAL(lookup(shell4, PositiveXFace, Vector3(90_mm, 10_mm, 300_mm),
0586 Vector3::UnitX()),
0587 nullptr);
0588
0589 BOOST_CHECK_EQUAL(lookup(shell4, NegativeYFace,
0590 Vector3(50_mm, -100_mm, 300_mm), -Vector3::UnitY()),
0591 nullptr);
0592 BOOST_CHECK_EQUAL(lookup(shell4, NegativeYFace,
0593 Vector3(50_mm, -100_mm, 300_mm), Vector3::UnitY()),
0594 &vol4);
0595
0596 BOOST_CHECK_EQUAL(lookup(shell4, PositiveYFace,
0597 Vector3(50_mm, 100_mm, 300_mm), -Vector3::UnitY()),
0598 &vol4);
0599 BOOST_CHECK_EQUAL(lookup(shell4, PositiveYFace,
0600 Vector3(50_mm, 100_mm, 300_mm), Vector3::UnitY()),
0601 nullptr);
0602
0603
0604 BOOST_CHECK_EQUAL(lookup(stack, NegativeZFace, Vector3(10_mm, 20_mm, -200_mm),
0605 -Vector3::UnitZ()),
0606 nullptr);
0607 BOOST_CHECK_EQUAL(lookup(stack, NegativeZFace, Vector3(10_mm, 20_mm, -200_mm),
0608 Vector3::UnitZ()),
0609 &vol1);
0610
0611 BOOST_CHECK_EQUAL(lookup(stack, PositiveZFace, Vector3(10_mm, 20_mm, 800_mm),
0612 -Vector3::UnitZ()),
0613 &vol3);
0614 BOOST_CHECK_EQUAL(lookup(stack, PositiveZFace, Vector3(10_mm, 20_mm, 800_mm),
0615 Vector3::UnitZ()),
0616 nullptr);
0617
0618 BOOST_CHECK_EQUAL(lookup(stack, NegativeXFace, Vector3(-30_mm, 10_mm, 300_mm),
0619 -Vector3::UnitX()),
0620 nullptr);
0621 BOOST_CHECK_EQUAL(lookup(stack, NegativeXFace, Vector3(-30_mm, 10_mm, 0_mm),
0622 Vector3::UnitX()),
0623 &vol1);
0624 BOOST_CHECK_EQUAL(lookup(stack, NegativeXFace, Vector3(-30_mm, 10_mm, 220_mm),
0625 Vector3::UnitX()),
0626 &vol2);
0627 BOOST_CHECK_EQUAL(lookup(stack, NegativeXFace, Vector3(-30_mm, 10_mm, 420_mm),
0628 Vector3::UnitX()),
0629 &vol3);
0630
0631 BOOST_CHECK_EQUAL(lookup(stack, PositiveXFace, Vector3(30_mm, 10_mm, 0_mm),
0632 -Vector3::UnitX()),
0633 &vol1);
0634 BOOST_CHECK_EQUAL(lookup(stack, PositiveXFace, Vector3(30_mm, 10_mm, 220_mm),
0635 -Vector3::UnitX()),
0636 &vol2);
0637 BOOST_CHECK_EQUAL(lookup(stack, PositiveXFace, Vector3(30_mm, 10_mm, 420_mm),
0638 -Vector3::UnitX()),
0639 &vol3);
0640 BOOST_CHECK_EQUAL(lookup(stack, PositiveXFace, Vector3(30_mm, 10_mm, 300_mm),
0641 Vector3::UnitX()),
0642 &vol4);
0643
0644 BOOST_CHECK_EQUAL(lookup(stack, NegativeYFace,
0645 Vector3(10_mm, -100_mm, 300_mm), -Vector3::UnitY()),
0646 nullptr);
0647 BOOST_CHECK_EQUAL(lookup(stack, NegativeYFace, Vector3(10_mm, -100_mm, 0_mm),
0648 Vector3::UnitY()),
0649 &vol1);
0650 BOOST_CHECK_EQUAL(lookup(stack, NegativeYFace,
0651 Vector3(10_mm, -100_mm, 220_mm), Vector3::UnitY()),
0652 &vol2);
0653 BOOST_CHECK_EQUAL(lookup(stack, NegativeYFace,
0654 Vector3(10_mm, -100_mm, 420_mm), Vector3::UnitY()),
0655 &vol3);
0656
0657 BOOST_CHECK_EQUAL(lookup(stack, PositiveYFace, Vector3(10_mm, 100_mm, 0_mm),
0658 -Vector3::UnitY()),
0659 &vol1);
0660 BOOST_CHECK_EQUAL(lookup(stack, PositiveYFace, Vector3(10_mm, 100_mm, 220_mm),
0661 -Vector3::UnitY()),
0662 &vol2);
0663 BOOST_CHECK_EQUAL(lookup(stack, PositiveYFace, Vector3(10_mm, 100_mm, 420_mm),
0664 -Vector3::UnitY()),
0665 &vol3);
0666 BOOST_CHECK_EQUAL(lookup(stack, PositiveYFace, Vector3(10_mm, 100_mm, 300_mm),
0667 Vector3::UnitY()),
0668 nullptr);
0669
0670
0671 BOOST_CHECK_EQUAL(lookup(stack2, NegativeZFace,
0672 Vector3(10_mm, 20_mm, -200_mm), -Vector3::UnitZ()),
0673 nullptr);
0674 BOOST_CHECK_EQUAL(lookup(stack2, NegativeZFace,
0675 Vector3(10_mm, 20_mm, -200_mm), Vector3::UnitZ()),
0676 &vol1);
0677 BOOST_CHECK_EQUAL(lookup(stack2, NegativeZFace,
0678 Vector3(50_mm, 20_mm, -200_mm), Vector3::UnitZ()),
0679 &vol4);
0680
0681 BOOST_CHECK_EQUAL(lookup(stack2, PositiveZFace, Vector3(10_mm, 20_mm, 800_mm),
0682 -Vector3::UnitZ()),
0683 &vol3);
0684 BOOST_CHECK_EQUAL(lookup(stack2, PositiveZFace, Vector3(50_mm, 20_mm, 800_mm),
0685 -Vector3::UnitZ()),
0686 &vol4);
0687 BOOST_CHECK_EQUAL(lookup(stack2, PositiveZFace, Vector3(10_mm, 20_mm, 800_mm),
0688 Vector3::UnitZ()),
0689 nullptr);
0690
0691 BOOST_CHECK_EQUAL(lookup(stack2, NegativeXFace,
0692 Vector3(-30_mm, 10_mm, 300_mm), -Vector3::UnitX()),
0693 nullptr);
0694 BOOST_CHECK_EQUAL(lookup(stack2, NegativeXFace, Vector3(-30_mm, 10_mm, 0_mm),
0695 Vector3::UnitX()),
0696 &vol1);
0697 BOOST_CHECK_EQUAL(lookup(stack2, NegativeXFace,
0698 Vector3(-30_mm, 10_mm, 220_mm), Vector3::UnitX()),
0699 &vol2);
0700 BOOST_CHECK_EQUAL(lookup(stack2, NegativeXFace,
0701 Vector3(-30_mm, 10_mm, 420_mm), Vector3::UnitX()),
0702 &vol3);
0703
0704 BOOST_CHECK_EQUAL(lookup(shell4, PositiveXFace, Vector3(90_mm, 10_mm, 300_mm),
0705 -Vector3::UnitX()),
0706 &vol4);
0707 BOOST_CHECK_EQUAL(lookup(shell4, PositiveXFace, Vector3(90_mm, 10_mm, 300_mm),
0708 Vector3::UnitX()),
0709 nullptr);
0710
0711 BOOST_CHECK_EQUAL(lookup(stack2, NegativeYFace,
0712 Vector3(10_mm, -100_mm, 300_mm), -Vector3::UnitY()),
0713 nullptr);
0714 BOOST_CHECK_EQUAL(lookup(stack2, NegativeYFace, Vector3(10_mm, -100_mm, 0_mm),
0715 Vector3::UnitY()),
0716 &vol1);
0717 BOOST_CHECK_EQUAL(lookup(stack2, NegativeYFace,
0718 Vector3(10_mm, -100_mm, 220_mm), Vector3::UnitY()),
0719 &vol2);
0720 BOOST_CHECK_EQUAL(lookup(stack2, NegativeYFace,
0721 Vector3(10_mm, -100_mm, 420_mm), Vector3::UnitY()),
0722 &vol3);
0723 BOOST_CHECK_EQUAL(lookup(stack2, NegativeYFace,
0724 Vector3(50_mm, -100_mm, 420_mm), Vector3::UnitY()),
0725 &vol4);
0726
0727 BOOST_CHECK_EQUAL(lookup(stack2, PositiveYFace, Vector3(10_mm, 100_mm, 0_mm),
0728 -Vector3::UnitY()),
0729 &vol1);
0730 BOOST_CHECK_EQUAL(lookup(stack2, PositiveYFace,
0731 Vector3(10_mm, 100_mm, 220_mm), -Vector3::UnitY()),
0732 &vol2);
0733 BOOST_CHECK_EQUAL(lookup(stack2, PositiveYFace,
0734 Vector3(10_mm, 100_mm, 420_mm), -Vector3::UnitY()),
0735 &vol3);
0736 BOOST_CHECK_EQUAL(lookup(stack2, PositiveYFace,
0737 Vector3(50_mm, 100_mm, 420_mm), -Vector3::UnitY()),
0738 &vol4);
0739 BOOST_CHECK_EQUAL(lookup(stack2, PositiveYFace,
0740 Vector3(10_mm, 100_mm, 300_mm), Vector3::UnitY()),
0741 nullptr);
0742 }
0743
0744 BOOST_AUTO_TEST_CASE(Fill) {
0745 Transform3 base = Transform3::Identity();
0746
0747 TrackingVolume vol1(
0748 base, std::make_shared<CuboidVolumeBounds>(30_mm, 100_mm, 200_mm),
0749 "vol1");
0750
0751 TrackingVolume vol2(
0752 base * Translation3(Vector3::UnitZ() * 300_mm),
0753 std::make_shared<CuboidVolumeBounds>(30_mm, 100_mm, 100_mm), "vol2");
0754
0755 SingleCuboidPortalShell shell{vol1};
0756
0757 using enum CuboidVolumeBounds::Face;
0758
0759 BOOST_CHECK_EQUAL(
0760 shell.portal(PositiveZFace)->getLink(Direction::AlongNormal()), nullptr);
0761
0762 shell.fill(vol2);
0763
0764 BOOST_CHECK_NE(shell.portal(PositiveZFace)->getLink(Direction::AlongNormal()),
0765 nullptr);
0766 }
0767
0768 BOOST_AUTO_TEST_CASE(RegisterInto) {
0769 using enum CuboidVolumeBounds::Face;
0770 TrackingVolume vol1(
0771 Transform3::Identity(),
0772 std::make_shared<CuboidVolumeBounds>(100_mm, 100_mm, 100_mm));
0773
0774 SingleCuboidPortalShell shell{vol1};
0775
0776 BOOST_CHECK_EQUAL(vol1.portals().size(), 0);
0777
0778 shell.applyToVolume();
0779 BOOST_CHECK_EQUAL(vol1.portals().size(), 6);
0780 }
0781
0782 BOOST_AUTO_TEST_SUITE_END()
0783 BOOST_AUTO_TEST_SUITE_END()
0784
0785 }