File indexing completed on 2025-01-18 09:12:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Plugins/ActSVG/TrackingGeometrySvgConverter.hpp"
0010
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Geometry/TrackingGeometry.hpp"
0013 #include "Acts/Geometry/TrackingVolume.hpp"
0014
0015 std::vector<actsvg::svg::object> Acts::Svg::TrackingGeometryConverter::convert(
0016 const GeometryContext& gctx, const TrackingGeometry& tGeometry,
0017 const TrackingGeometryConverter::Options& cOptions) {
0018
0019 const TrackingVolume* world = tGeometry.highestTrackingVolume();
0020
0021
0022 TrackingGeometryConverter::State cState;
0023
0024
0025 convert(gctx, *world, cOptions, cState);
0026
0027
0028 std::vector<actsvg::svg::object> finalViews = cState.finalViews;
0029 if (!cState.xyCrossSection.empty()) {
0030 finalViews.push_back(
0031 Acts::Svg::group(cState.xyCrossSection, cOptions.prefix + "layers_xy"));
0032 }
0033 if (!cState.zrCrossSection.empty()) {
0034 finalViews.push_back(
0035 Acts::Svg::group(cState.zrCrossSection, cOptions.prefix + "layers_zr"));
0036 }
0037
0038 return finalViews;
0039 }
0040
0041 void Acts::Svg::TrackingGeometryConverter::convert(
0042 const GeometryContext& gctx, const TrackingVolume& tVolume,
0043 const TrackingGeometryConverter::Options& cOptions,
0044 TrackingGeometryConverter::State& cState) {
0045
0046 if (tVolume.confinedLayers() != nullptr) {
0047 for (const auto& layer : tVolume.confinedLayers()->arrayObjects()) {
0048 if (layer->surfaceArray() != nullptr) {
0049 GeometryIdentifier geoID = layer->geometryId();
0050 std::string layerName = cOptions.prefix + "vol_" +
0051 std::to_string(geoID.volume()) + "_layer_" +
0052 std::to_string(geoID.layer());
0053
0054 LayerConverter::Options lOptions;
0055
0056 auto deflOptions = cOptions.layerOptions.find(geoID);
0057 if (deflOptions != cOptions.layerOptions.end()) {
0058 lOptions = (*deflOptions);
0059 lOptions.name = layerName;
0060 }
0061
0062 auto layerSheets = LayerConverter::convert(gctx, *layer, lOptions);
0063
0064
0065 for (const auto& lSheet : layerSheets) {
0066 if (lSheet.is_defined()) {
0067 cState.finalViews.push_back(lSheet);
0068 }
0069 }
0070
0071 if (layerSheets[LayerConverter::eCrossSectionXY].is_defined() &&
0072 layer->surfaceRepresentation().type() == Acts::Surface::Cylinder) {
0073 cState.xyCrossSection.push_back(
0074 layerSheets[LayerConverter::eCrossSectionXY]);
0075 }
0076
0077 if (layerSheets[LayerConverter::eCrossSectionZR].is_defined()) {
0078 cState.zrCrossSection.push_back(
0079 layerSheets[LayerConverter::eCrossSectionZR]);
0080 }
0081 }
0082 }
0083 }
0084
0085
0086 if (tVolume.confinedVolumes() != nullptr) {
0087 for (const auto& volume : tVolume.confinedVolumes()->arrayObjects()) {
0088 convert(gctx, *volume, cOptions, cState);
0089 }
0090 }
0091 }
0092
0093 std::array<actsvg::svg::object, 2>
0094 Acts::Svg::TrackingGeometryProjections::convert(
0095 const GeometryContext& gctx, const Acts::TrackingGeometry& tGeometry,
0096 const TrackingGeometryProjections::Options& cOptions) {
0097
0098 actsvg::svg::object xyView;
0099 actsvg::svg::object zrView;
0100
0101
0102 const Acts::TrackingVolume* world = tGeometry.highestTrackingVolume();
0103 if (world != nullptr) {
0104
0105 Acts::Svg::TrackingGeometryConverter::State cState;
0106
0107
0108 Acts::Svg::TrackingGeometryConverter::convert(
0109 gctx, *world, cOptions.trackingGeometryOptions, cState);
0110
0111 xyView = Acts::Svg::group(cState.xyCrossSection,
0112 cOptions.prefix + "projection_xy");
0113 zrView = Acts::Svg::group(cState.zrCrossSection,
0114 cOptions.prefix + "projection_zr");
0115 }
0116 return {xyView, zrView};
0117 }