EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VolumeView3DBase.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VolumeView3DBase.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
19 
20 #include <fstream>
21 #include <sstream>
22 #include <string>
23 
24 namespace Acts {
25 
26 namespace VolumeView3DTest {
27 
35 
36 static inline std::string run(IVisualization3D& helper, bool triangulate,
37  const std::string& tag) {
38  auto gctx = GeometryContext();
39  auto identity = Transform3D::Identity();
40  std::stringstream cStream;
41 
42  double halfPhiSector = M_PI / 4.;
43 
44  ViewConfig vConfig = s_viewVolume;
45  vConfig.triangulate = triangulate;
46 
47  // ---------------------------------------------------
48  // Cuboid surface section
49  auto box = std::make_shared<CuboidVolumeBounds>(4., 3., 6.);
50  auto cuboid = std::make_shared<AbstractVolume>(identity, box);
51  GeometryView3D::drawVolume(helper, *cuboid, gctx, Transform3D::Identity(),
52  vConfig);
53  helper.write(std::string("Volumes_CuboidVolume") + tag);
54  helper.write(cStream);
55  helper.clear();
56 
57  //----------------------------------------------------
58  // Cone volume section
59  // Single solid Cone
60  auto solidCone =
61  std::make_shared<ConeVolumeBounds>(0., 0., 0.45, 5., 5., 0., M_PI);
62  auto cone = std::make_shared<AbstractVolume>(identity, solidCone);
63  GeometryView3D::drawVolume(helper, *cone, gctx, Transform3D::Identity(),
64  vConfig);
65  helper.write("Volumes_ConeVolumeSolid");
66  helper.write(cStream);
67  helper.clear();
68 
69  // Single solid Cone - with cut off
70  auto cutOffCone =
71  std::make_shared<ConeVolumeBounds>(0., 0., 0.45, 8., 5., 0., M_PI);
72  cone = std::make_shared<AbstractVolume>(identity, cutOffCone);
73  GeometryView3D::drawVolume(helper, *cone, gctx, Transform3D::Identity(),
74  vConfig);
75  helper.write("Volumes_ConeVolumeSolidCutOff");
76  helper.write(cStream);
77  helper.clear();
78 
79  // Cone - Cone inlay
80  auto cutOffHollowCone =
81  std::make_shared<ConeVolumeBounds>(0.35, 7., 0.45, 8., 5, 0., M_PI);
82  cone = std::make_shared<AbstractVolume>(identity, cutOffHollowCone);
83  GeometryView3D::drawVolume(helper, *cone, gctx, Transform3D::Identity(),
84  vConfig);
85  helper.write("Volumes_ConeVolumeConeCone");
86  helper.write(cStream);
87  helper.clear();
88 
89  // Sectoral Cone - Cone inlay
90  auto cutOffHollowSectoralCone =
91  std::make_shared<ConeVolumeBounds>(0.35, 7., 0.45, 8., 5., 0., 0.456);
92  cone = std::make_shared<AbstractVolume>(identity, cutOffHollowSectoralCone);
93  GeometryView3D::drawVolume(helper, *cone, gctx, Transform3D::Identity(),
94  vConfig);
95  helper.write("Volumes_ConeVolumeConeConeSectoral");
96  helper.write(cStream);
97  helper.clear();
98 
99  // Single Hollow Cone - cylindrical inlay
100  auto cutOffHollowCylCone =
101  std::make_shared<ConeVolumeBounds>(1., 0.45, 8., 5., 0., M_PI);
102  cone = std::make_shared<AbstractVolume>(identity, cutOffHollowCylCone);
103  GeometryView3D::drawVolume(helper, *cone, gctx, Transform3D::Identity(),
104  vConfig);
105  helper.write("Volumes_ConeVolumeConeCylinder");
106  helper.write(cStream);
107  helper.clear();
108 
109  // Single Hollow Cylinder - Cone inlay
110  auto cutOffHollowConeCyl =
111  std::make_shared<ConeVolumeBounds>(12., 0.35, 7., 5., 0., M_PI);
112  cone = std::make_shared<AbstractVolume>(identity, cutOffHollowConeCyl);
113  GeometryView3D::drawVolume(helper, *cone, gctx, Transform3D::Identity(),
114  vConfig);
115  helper.write("Volumes_ConeVolumeCylinderCone");
116  helper.write(cStream);
117  helper.clear();
118 
119  //----------------------------------------------------
120  // Cylinder volume section
121  double cylinderInnerR = 1.;
122  double cylinderOuterR = 5.;
123  double cylinderHalfZ = 10.;
124 
125  auto fullCylinder =
126  std::make_shared<CylinderVolumeBounds>(0., cylinderOuterR, cylinderHalfZ);
127  auto cylinder = std::make_shared<AbstractVolume>(identity, fullCylinder);
128  GeometryView3D::drawVolume(helper, *cylinder, gctx, Transform3D::Identity(),
129  vConfig);
130  helper.write("Volumes_CylinderVolumeFull");
131  helper.write(cStream);
132  helper.clear();
133 
134  auto tubeCylinder = std::make_shared<CylinderVolumeBounds>(
135  cylinderInnerR, cylinderOuterR, cylinderHalfZ);
136  cylinder = std::make_shared<AbstractVolume>(identity, tubeCylinder);
137  GeometryView3D::drawVolume(helper, *cylinder, gctx, Transform3D::Identity(),
138  vConfig);
139  helper.write("Volumes_CylinderVolumeTube");
140  helper.write(cStream);
141  helper.clear();
142 
143  tubeCylinder = std::make_shared<CylinderVolumeBounds>(
144  cylinderInnerR, cylinderOuterR, cylinderHalfZ, halfPhiSector);
145  cylinder = std::make_shared<AbstractVolume>(identity, tubeCylinder);
146  GeometryView3D::drawVolume(helper, *cylinder, gctx, Transform3D::Identity(),
147  vConfig);
148  helper.write("Volumes_CylinderVolumeTubeSector");
149  helper.write(cStream);
150  helper.clear();
151 
152  //----------------------------------------------------
153  // Trapezoid volume section
154  std::array<Vector3D, 8> vertices;
155  vertices = {{{0, 0, 0},
156  {2, 0, 0},
157  {2, 1, 0},
158  {0, 1, 0},
159  {0, 0, 1},
160  {2, 0, 1},
161  {2, 1, 1},
162  {0, 1, 1}}};
163  auto genericCuboid = std::make_shared<GenericCuboidVolumeBounds>(vertices);
164  auto generic = std::make_shared<AbstractVolume>(identity, genericCuboid);
165  GeometryView3D::drawVolume(helper, *generic, gctx, Transform3D::Identity(),
166  vConfig);
167  helper.write("Volumes_GenericCuboidVolume");
168  helper.write(cStream);
169  helper.clear();
170 
171  //----------------------------------------------------
172  // Trapezoid volume section
173  auto trapezoid = std::make_shared<TrapezoidVolumeBounds>(2., 4., 5., 6.);
174  auto trapezoidVolume = std::make_shared<AbstractVolume>(identity, trapezoid);
175  GeometryView3D::drawVolume(helper, *trapezoidVolume, gctx,
176  Transform3D::Identity(), vConfig);
177  helper.write("Volumes_TrapezoidVolume");
178  helper.write(cStream);
179  helper.clear();
180 
181  return cStream.str();
182 }
183 
184 } // namespace VolumeView3DTest
185 } // namespace Acts