Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:04

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/ConeVolumeBounds.hpp"
0012 #include "Acts/Geometry/CuboidVolumeBounds.hpp"
0013 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0014 #include "Acts/Geometry/GenericCuboidVolumeBounds.hpp"
0015 #include "Acts/Geometry/TrapezoidVolumeBounds.hpp"
0016 #include "Acts/Geometry/Volume.hpp"
0017 #include "Acts/Visualization/GeometryView3D.hpp"
0018 #include "Acts/Visualization/IVisualization3D.hpp"
0019 
0020 #include <fstream>
0021 #include <numbers>
0022 #include <sstream>
0023 #include <string>
0024 
0025 namespace Acts::VolumeView3DTest {
0026 
0027 /// Helper method to visualize all types of surfaces
0028 ///
0029 /// @param helper The visualization helper
0030 /// @param triangulate The directive whether to create triangular meshes
0031 /// @param tag The test tag (mode) identification
0032 ///
0033 /// @return a string containing all written characters
0034 
0035 static inline std::string run(IVisualization3D& helper, bool triangulate,
0036                               const std::string& tag) {
0037   auto gctx = GeometryContext();
0038   auto identity = Transform3::Identity();
0039   std::stringstream cStream;
0040 
0041   const double halfPhiSector = std::numbers::pi / 4.;
0042 
0043   ViewConfig vConfig = s_viewVolume;
0044   vConfig.triangulate = triangulate;
0045 
0046   // ---------------------------------------------------
0047   // Cuboid surface section
0048   auto box = std::make_shared<CuboidVolumeBounds>(4., 3., 6.);
0049   auto cuboid = std::make_shared<Volume>(identity, box);
0050   GeometryView3D::drawVolume(helper, *cuboid, gctx, Transform3::Identity(),
0051                              vConfig);
0052   helper.write(std::string("Volumes_CuboidVolume") + tag);
0053   helper.write(cStream);
0054   helper.clear();
0055 
0056   //----------------------------------------------------
0057   // Cone volume section
0058   // Single solid Cone
0059   auto solidCone = std::make_shared<ConeVolumeBounds>(0., 0., 0.45, 5., 5., 0.,
0060                                                       std::numbers::pi);
0061   auto cone = std::make_shared<Volume>(identity, solidCone);
0062   GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(),
0063                              vConfig);
0064   helper.write("Volumes_ConeVolumeSolid");
0065   helper.write(cStream);
0066   helper.clear();
0067 
0068   // Single solid Cone - with cut off
0069   auto cutOffCone = std::make_shared<ConeVolumeBounds>(0., 0., 0.45, 8., 5., 0.,
0070                                                        std::numbers::pi);
0071   cone = std::make_shared<Volume>(identity, cutOffCone);
0072   GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(),
0073                              vConfig);
0074   helper.write("Volumes_ConeVolumeSolidCutOff");
0075   helper.write(cStream);
0076   helper.clear();
0077 
0078   // Cone - Cone inlay
0079   auto cutOffHollowCone = std::make_shared<ConeVolumeBounds>(
0080       0.35, 7., 0.45, 8., 5, 0., std::numbers::pi);
0081   cone = std::make_shared<Volume>(identity, cutOffHollowCone);
0082   GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(),
0083                              vConfig);
0084   helper.write("Volumes_ConeVolumeConeCone");
0085   helper.write(cStream);
0086   helper.clear();
0087 
0088   // Sectoral Cone - Cone inlay
0089   auto cutOffHollowSectoralCone =
0090       std::make_shared<ConeVolumeBounds>(0.35, 7., 0.45, 8., 5., 0., 0.456);
0091   cone = std::make_shared<Volume>(identity, cutOffHollowSectoralCone);
0092   GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(),
0093                              vConfig);
0094   helper.write("Volumes_ConeVolumeConeConeSectoral");
0095   helper.write(cStream);
0096   helper.clear();
0097 
0098   // Single Hollow Cone - cylindrical inlay
0099   auto cutOffHollowCylCone = std::make_shared<ConeVolumeBounds>(
0100       1., 0.45, 8., 5., 0., std::numbers::pi);
0101   cone = std::make_shared<Volume>(identity, cutOffHollowCylCone);
0102   GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(),
0103                              vConfig);
0104   helper.write("Volumes_ConeVolumeConeCylinder");
0105   helper.write(cStream);
0106   helper.clear();
0107 
0108   // Single Hollow Cylinder - Cone inlay
0109   auto cutOffHollowConeCyl = std::make_shared<ConeVolumeBounds>(
0110       12., 0.35, 7., 5., 0., std::numbers::pi);
0111   cone = std::make_shared<Volume>(identity, cutOffHollowConeCyl);
0112   GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(),
0113                              vConfig);
0114   helper.write("Volumes_ConeVolumeCylinderCone");
0115   helper.write(cStream);
0116   helper.clear();
0117 
0118   //----------------------------------------------------
0119   // Cylinder volume section
0120   double cylinderInnerR = 1.;
0121   double cylinderOuterR = 5.;
0122   double cylinderHalfZ = 10.;
0123 
0124   auto fullCylinder =
0125       std::make_shared<CylinderVolumeBounds>(0., cylinderOuterR, cylinderHalfZ);
0126   auto cylinder = std::make_shared<Volume>(identity, fullCylinder);
0127   GeometryView3D::drawVolume(helper, *cylinder, gctx, Transform3::Identity(),
0128                              vConfig);
0129   helper.write("Volumes_CylinderVolumeFull");
0130   helper.write(cStream);
0131   helper.clear();
0132 
0133   auto tubeCylinder = std::make_shared<CylinderVolumeBounds>(
0134       cylinderInnerR, cylinderOuterR, cylinderHalfZ);
0135   cylinder = std::make_shared<Volume>(identity, tubeCylinder);
0136   GeometryView3D::drawVolume(helper, *cylinder, gctx, Transform3::Identity(),
0137                              vConfig);
0138   helper.write("Volumes_CylinderVolumeTube");
0139   helper.write(cStream);
0140   helper.clear();
0141 
0142   tubeCylinder = std::make_shared<CylinderVolumeBounds>(
0143       cylinderInnerR, cylinderOuterR, cylinderHalfZ, halfPhiSector);
0144   cylinder = std::make_shared<Volume>(identity, tubeCylinder);
0145   GeometryView3D::drawVolume(helper, *cylinder, gctx, Transform3::Identity(),
0146                              vConfig);
0147   helper.write("Volumes_CylinderVolumeTubeSector");
0148   helper.write(cStream);
0149   helper.clear();
0150 
0151   //----------------------------------------------------
0152   // Trapezoid volume section
0153   std::array<Vector3, 8> vertices;
0154   vertices = {{{0, 0, 0},
0155                {2, 0, 0},
0156                {2, 1, 0},
0157                {0, 1, 0},
0158                {0, 0, 1},
0159                {2, 0, 1},
0160                {2, 1, 1},
0161                {0, 1, 1}}};
0162   auto genericCuboid = std::make_shared<GenericCuboidVolumeBounds>(vertices);
0163   auto generic = std::make_shared<Volume>(identity, genericCuboid);
0164   GeometryView3D::drawVolume(helper, *generic, gctx, Transform3::Identity(),
0165                              vConfig);
0166   helper.write("Volumes_GenericCuboidVolume");
0167   helper.write(cStream);
0168   helper.clear();
0169 
0170   //----------------------------------------------------
0171   // Trapezoid volume section
0172   auto trapezoid = std::make_shared<TrapezoidVolumeBounds>(2., 4., 5., 6.);
0173   auto trapezoidVolume = std::make_shared<Volume>(identity, trapezoid);
0174   GeometryView3D::drawVolume(helper, *trapezoidVolume, gctx,
0175                              Transform3::Identity(), vConfig);
0176   helper.write("Volumes_TrapezoidVolume");
0177   helper.write(cStream);
0178   helper.clear();
0179 
0180   return cStream.str();
0181 }
0182 
0183 }  // namespace Acts::VolumeView3DTest