File indexing completed on 2025-01-18 09:12:14
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Plugins/ActSVG/DetectorVolumeSvgConverter.hpp"
0010
0011 #include "Acts/Detector/DetectorVolume.hpp"
0012 #include "Acts/Detector/Portal.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "Acts/Geometry/VolumeBounds.hpp"
0015 #include "Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp"
0016 #include "Acts/Utilities/Enumerate.hpp"
0017
0018 #include <utility>
0019
0020 std::tuple<Acts::Svg::ProtoVolume, Acts::Svg::ProtoIndexedSurfaceGrid>
0021 Acts::Svg::DetectorVolumeConverter::convert(
0022 const GeometryContext& gctx, const Experimental::DetectorVolume& dVolume,
0023 const DetectorVolumeConverter::Options& volumeOptions) {
0024 ProtoVolume pVolume;
0025 pVolume._name = dVolume.name();
0026
0027 auto volumeTransform = dVolume.transform(gctx);
0028
0029
0030 const auto& boundValues = dVolume.volumeBounds().values();
0031 if (dVolume.volumeBounds().type() == Acts::VolumeBounds::eCylinder) {
0032
0033 for (unsigned int ib = 0; ib < 2u; ++ib) {
0034 pVolume._bound_values.push_back(
0035 static_cast<actsvg::scalar>(boundValues[ib]));
0036 }
0037 pVolume._bound_values.push_back(
0038 static_cast<actsvg::scalar>(volumeTransform.translation().z()));
0039 for (unsigned int ib = 2u; ib < 5u; ++ib) {
0040 pVolume._bound_values.push_back(
0041 static_cast<actsvg::scalar>(boundValues[ib]));
0042 }
0043 }
0044
0045
0046 for (auto [ip, p] : enumerate(dVolume.portals())) {
0047 auto pPortal =
0048 PortalConverter::convert(gctx, *p, volumeOptions.portalOptions);
0049 auto pPortalCandidate = volumeOptions.portalIndices.find(p);
0050 if (pPortalCandidate != volumeOptions.portalIndices.end()) {
0051 pPortal._name = "portal_" + std::to_string(pPortalCandidate->second);
0052 } else {
0053 pPortal._name = dVolume.name() + "_portal_" + std::to_string(ip);
0054 }
0055 pVolume._portals.push_back(pPortal);
0056 }
0057
0058
0059 std::vector<ProtoSurface> pSurfaces;
0060 for (auto [is, s] : enumerate(dVolume.surfaces())) {
0061 auto pSurface =
0062 SurfaceConverter::convert(gctx, *s, volumeOptions.surfaceOptions);
0063 pSurface._name = dVolume.name() + "_surface_" + std::to_string(is);
0064 pSurfaces.push_back(pSurface);
0065 }
0066 pVolume._v_surfaces = pSurfaces;
0067
0068
0069 const auto& internalNavigationDelegate = dVolume.internalNavigation();
0070
0071 IndexedSurfacesConverter::Options isOptions =
0072 volumeOptions.indexedSurfacesOptions;
0073
0074 if (isOptions.surfaceStyles.empty()) {
0075 std::pair<Acts::GeometryIdentifier, Acts::Svg::Style> style{
0076 dVolume.geometryId(), volumeOptions.surfaceOptions.style};
0077 isOptions.surfaceStyles =
0078 Acts::GeometryHierarchyMap<Acts::Svg::Style>({style});
0079 }
0080
0081 auto pSurfacesGrid = IndexedSurfacesConverter::convert(
0082 gctx, dVolume.surfaces(), internalNavigationDelegate, isOptions);
0083
0084 return {pVolume, pSurfacesGrid};
0085 }