Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 09:40:21

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Geometry/GeometryHierarchyMap.hpp"
0013 #include "ActsPlugins/ActSVG/IndexedSurfacesSvgConverter.hpp"
0014 #include "ActsPlugins/ActSVG/PortalSvgConverter.hpp"
0015 #include "ActsPlugins/ActSVG/SvgUtils.hpp"
0016 #include <actsvg/core.hpp>
0017 #include <actsvg/meta.hpp>
0018 
0019 #include <map>
0020 #include <string>
0021 #include <tuple>
0022 
0023 namespace Acts::Experimental {
0024 class DetectorVolume;
0025 class Portal;
0026 }  // namespace Acts::Experimental
0027 
0028 namespace ActsPlugins::Svg {
0029 
0030 using ProtoVolume = actsvg::proto::volume<std::vector<Acts::Vector3>>;
0031 
0032 namespace DetectorVolumeConverter {
0033 
0034 /// A nested options class for the layer conversion
0035 struct Options {
0036   /// The Portal indices
0037   std::map<const Acts::Experimental::Portal*, unsigned int> portalIndices;
0038   /// The Portal converter options
0039   PortalConverter::Options portalOptions;
0040   /// The Surface converter options
0041   SurfaceConverter::Options surfaceOptions;
0042   /// The Grid converter options
0043   IndexedSurfacesConverter::Options indexedSurfacesOptions;
0044 };
0045 
0046 /// Write/create the detector volume
0047 ///
0048 /// @param gctx the geometry context
0049 /// @param dVolume the detector volumeto be displayed
0050 /// @param volumeOptions the conversion objects
0051 ///
0052 /// @return a vector of svg objects
0053 std::tuple<ProtoVolume, ProtoIndexedSurfaceGrid> convert(
0054     const Acts::GeometryContext& gctx,
0055     const Acts::Experimental::DetectorVolume& dVolume,
0056     const Options& volumeOptions);
0057 
0058 }  // namespace DetectorVolumeConverter
0059 
0060 namespace View {
0061 
0062 /// Convert into an ActsPlugins::Svg::object with an XY view
0063 ///
0064 /// @param volume is the DetectorVolume (proto representation)
0065 /// @param identification is the to be translated id_ for actsvg
0066 /// @param displayPortals is a directory whether portals should be displayed
0067 ///
0068 /// @return an svg object that can be written out directly to disc
0069 static inline actsvg::svg::object xy(const ProtoVolume& volume,
0070                                      const std::string& identification,
0071                                      bool displayPortals = true) {
0072   actsvg::views::x_y xyView;
0073   return actsvg::display::volume(identification, volume, xyView,
0074                                  displayPortals);
0075 }
0076 
0077 /// Convert into an ActsPlugins::Svg::object with an Zr view
0078 ///
0079 /// @param volume is the DetectorVolume (proto representation)
0080 /// @param identification is the to be translated id_ for actsvg
0081 /// @param displayPortals is a directory whether portals should be displayed
0082 ///
0083 /// @return an svg object that can be written out directly to disc
0084 static inline actsvg::svg::object zr(const ProtoVolume& volume,
0085                                      const std::string& identification,
0086                                      bool displayPortals = true) {
0087   actsvg::views::z_r zrView;
0088   return actsvg::display::volume(identification, volume, zrView,
0089                                  displayPortals);
0090 }
0091 
0092 }  // namespace View
0093 
0094 }  // namespace ActsPlugins::Svg