File indexing completed on 2025-01-18 09:11:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Detector/PortalGenerators.hpp"
0010
0011 #include "Acts/Detector/DetectorVolume.hpp"
0012 #include "Acts/Detector/Portal.hpp"
0013 #include "Acts/Geometry/VolumeBounds.hpp"
0014 #include "Acts/Navigation/NavigationDelegates.hpp"
0015 #include "Acts/Navigation/PortalNavigation.hpp"
0016 #include "Acts/Utilities/Enumerate.hpp"
0017
0018 #include <iterator>
0019 #include <stdexcept>
0020 #include <utility>
0021
0022 std::vector<std::shared_ptr<Acts::Experimental::Portal>>
0023 Acts::Experimental::generatePortals(
0024 const Transform3& dTransform, const VolumeBounds& dBounds,
0025 const std::shared_ptr<DetectorVolume>& dVolume) noexcept(false) {
0026 if (dVolume == nullptr) {
0027 throw std::runtime_error("PortalsGenerator: no detector volume provided.");
0028 }
0029
0030 auto orientedSurfaces = dBounds.orientedSurfaces(dTransform);
0031
0032
0033 std::vector<std::shared_ptr<Portal>> portals;
0034 for (auto [i, oSurface] : enumerate(orientedSurfaces)) {
0035
0036 auto portal = std::make_shared<Portal>(oSurface.surface);
0037
0038 auto singleLinkImpl =
0039 std::make_unique<const SingleDetectorVolumeNavigation>(dVolume.get());
0040 ExternalNavigationDelegate singleLink;
0041 singleLink.connect<&SingleDetectorVolumeNavigation::update>(
0042 std::move(singleLinkImpl));
0043
0044 portal->assignPortalNavigation(oSurface.direction, std::move(singleLink),
0045 {dVolume});
0046
0047 portals.push_back(std::move(portal));
0048 }
0049
0050
0051 return portals;
0052 }
0053
0054 Acts::Experimental::PortalGenerator
0055 Acts::Experimental::defaultPortalGenerator() {
0056 PortalGenerator pGenerator;
0057 pGenerator.connect<&generatePortals>();
0058 return pGenerator;
0059 }
0060
0061 std::vector<std::shared_ptr<Acts::Experimental::Portal>>
0062 Acts::Experimental::generatePortalsUpdateInternals(
0063 const Transform3& dTransform, const VolumeBounds& dBounds,
0064 const std::shared_ptr<DetectorVolume>& dVolume) noexcept(false) {
0065 if (dVolume == nullptr) {
0066 throw std::runtime_error(
0067 "generatePortalsUpdateInternals: no detector volume provided.");
0068 }
0069
0070
0071 for (auto& vPtr : dVolume->volumePtrs()) {
0072 for (auto& pPtr : vPtr->portalPtrs()) {
0073
0074 auto motherLinkImpl =
0075 std::make_unique<const SingleDetectorVolumeNavigation>(dVolume.get());
0076 ExternalNavigationDelegate motherLink;
0077 motherLink.connect<&SingleDetectorVolumeNavigation::update>(
0078 std::move(motherLinkImpl));
0079 pPtr->assignPortalNavigation(std::move(motherLink), {dVolume});
0080 }
0081 }
0082
0083 return generatePortals(dTransform, dBounds, dVolume);
0084 }
0085
0086 Acts::Experimental::PortalGenerator
0087 Acts::Experimental::defaultPortalAndSubPortalGenerator() {
0088 PortalGenerator pGenerator;
0089 pGenerator.connect<&generatePortalsUpdateInternals>();
0090 return pGenerator;
0091 }