Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UExtrudedSolid.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4UExtrudedSolid
27//
28// Class description:
29//
30// Wrapper class for G4ExtrudedSolid to make use of VecGeom ExtrudedSolid.
31
32// Author: Gabriele Cosmo (CERN), 17.11.2017
33// --------------------------------------------------------------------
34#ifndef G4UEXTRUDEDSOLID_HH
35#define G4UEXTRUDEDSOLID_HH
36
37#include "G4UAdapter.hh"
38
39#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
40
41#include <VecGeom/volumes/UnplacedExtruded.h>
42#include "G4TwoVector.hh"
43
44#include "G4Polyhedron.hh"
45
46/**
47 * @brief G4UExtrudedSolid is a wrapper class for G4ExtrudedSolid
48 * to make use of VecGeom ExtrudedSolid.
49 */
50
51class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
52{
53 using Shape_t = vecgeom::UnplacedExtruded;
54 using Base_t = G4UAdapter<vecgeom::UnplacedExtruded>;
55
56 public:
57
58 /**
59 * Structure defining a Z section composing the solid.
60 */
61 struct ZSection
62 {
63 ZSection() : fZ(0.), fOffset(0.,0.), fScale(1.) {}
64 ZSection(G4double z, const G4TwoVector& offset, G4double scale)
65 : fZ(z), fOffset(offset), fScale(scale) {}
66
67 G4double fZ;
68 G4TwoVector fOffset;
69 G4double fScale;
70 };
71
72 /**
73 * General constructor for an extruded polygon, through contour and polyline.
74 * @param[in] pName The solid name.
75 * @param[in] polygon The 2D polygonal contour, i.e. the vertices of the
76 * outlined polygon defined in clock-wise order.
77 * @param[in] zsections The 3D polyline with scale factors, i.e. the
78 * Z-sections defined by Z position in increasing order.
79 */
80 G4UExtrudedSolid(const G4String& pName,
81 const std::vector<G4TwoVector>& polygon,
82 const std::vector<ZSection>& zsections);
83
84 /**
85 * Special constructor for an extruded polygon with 2 Z-sections.
86 * @param[in] pName The solid name.
87 * @param[in] polygon The 2D polygonal contour, i.e. the vertices of the
88 * outlined polygon defined in clock-wise order.
89 * @param[in] halfZ Half length in Z, i.e. the distance from the origin
90 * to the sections.
91 * @param[in] off1 (X, Y) position of the first polygon in -halfZ.
92 * @param[in] scale1 Scale factor at -halfZ.
93 * @param[in] off2 (X, Y) position of the second polygon in +halfZ.
94 * @param[in] scale2 Scale factor at +halfZ.
95 */
96 G4UExtrudedSolid(const G4String& pName,
97 const std::vector<G4TwoVector>& polygon,
98 G4double halfZ,
99 const G4TwoVector& off1 = G4TwoVector(0.,0.),
100 G4double scale1 = 1.,
101 const G4TwoVector& off2 = G4TwoVector(0.,0.),
102 G4double scale2 = 1. );
103
104 /**
105 * Default Destructor.
106 */
107 ~G4UExtrudedSolid() override = default;
108
109 /**
110 * Accessors.
111 */
112 G4int GetNofVertices() const;
113 G4TwoVector GetVertex(G4int index) const;
114 std::vector<G4TwoVector> GetPolygon() const;
115 G4int GetNofZSections() const;
116 ZSection GetZSection(G4int index) const;
117 std::vector<ZSection> GetZSections() const;
118
119 /**
120 * Returns the type ID, "G4ExtrudedSolid" of the solid.
121 */
122 inline G4GeometryType GetEntityType() const override;
123
124 /**
125 * Returns true as the solid has only planar faces.
126 */
127 inline G4bool IsFaceted() const override;
128
129 /**
130 * Computes the bounding limits of the solid.
131 * @param[out] pMin The minimum bounding limit point.
132 * @param[out] pMax The maximum bounding limit point.
133 */
134 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
135
136 /**
137 * Calculates the minimum and maximum extent of the solid, when under the
138 * specified transform, and within the specified limits.
139 * @param[in] pAxis The axis along which compute the extent.
140 * @param[in] pVoxelLimit The limiting space dictated by voxels.
141 * @param[in] pTransform The internal transformation applied to the solid.
142 * @param[out] pMin The minimum extent value.
143 * @param[out] pMax The maximum extent value.
144 * @returns True if the solid is intersected by the extent region.
145 */
146 G4bool CalculateExtent(const EAxis pAxis,
147 const G4VoxelLimits& pVoxelLimit,
148 const G4AffineTransform& pTransform,
149 G4double& pMin, G4double& pMax) const override;
150
151 /**
152 * Returns a generated polyhedron as graphical representations.
153 */
154 G4Polyhedron* CreatePolyhedron() const override;
155
156 /**
157 * Copy constructor and assignment operator.
158 */
159 G4UExtrudedSolid( const G4UExtrudedSolid& source );
160 G4UExtrudedSolid &operator=(const G4UExtrudedSolid& source);
161};
162
163// --------------------------------------------------------------------
164// Inline methods
165// --------------------------------------------------------------------
166
167inline G4GeometryType G4UExtrudedSolid::GetEntityType() const
168{
169 return "G4ExtrudedSolid";
170}
171
172inline G4bool G4UExtrudedSolid::IsFaceted() const
173{
174 return true;
175}
176
177#endif // G4GEOM_USE_USOLIDS
178
179#endif
G4ThreadLocal T * G4GeomSplitter< T >::offset
G4PVDivision & operator=(const G4PVDivision &)=delete
CLHEP::Hep3Vector G4ThreeVector
CLHEP::Hep2Vector G4TwoVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4String G4GeometryType
Definition G4VSolid.hh:70
EAxis
Definition geomdefs.hh:54