Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Trd.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// G4Trd
27//
28// Class description:
29//
30// A G4Trd is a trapezoid with the x and y dimensions varying along z
31// functions:
32//
33// Member Data:
34//
35// fDx1 Half-length along x at the surface positioned at -dz
36// fDx2 Half-length along x at the surface positioned at +dz
37// fDy1 Half-length along y at the surface positioned at -dz
38// fDy2 Half-length along y at the surface positioned at +dz
39// fDz Half-length along z axis
40
41// Author: Paul Kent (CERN), 12.01.1995 - Code converted to thick geometry
42// --------------------------------------------------------------------
43#ifndef G4TRD_HH
44#define G4TRD_HH
45
46#include "G4GeomTypes.hh"
47
48#if defined(G4GEOM_USE_USOLIDS)
49#define G4GEOM_USE_UTRD 1
50#endif
51
52#if defined(G4GEOM_USE_UTRD)
53 #define G4UTrd G4Trd
54 #include "G4UTrd.hh"
55#else
56
57#include "G4CSGSolid.hh"
58#include "G4Polyhedron.hh"
59
60/**
61 * @brief G4Trd is a trapezoid with the X and Y dimensions varying along Z.
62 */
63
64class G4Trd : public G4CSGSolid
65{
66 public:
67
68 /**
69 * Constructs a trapezoid with name, and half lengths.
70 * @param[in] pName The name of the solid.
71 * @param[in] pdx1 Half-length along X at the surface positioned at -dz.
72 * @param[in] pdx2 Half-length along X at the surface positioned at +dz.
73 * @param[in] pdy1 Half-length along Y at the surface positioned at -dz.
74 * @param[in] pdy2 Half-length along Y at the surface positioned at +dz.
75 * @param[in] pdz Half-length along Z axis.
76 */
77 G4Trd( const G4String& pName,
78 G4double pdx1, G4double pdx2,
79 G4double pdy1, G4double pdy2,
80 G4double pdz );
81
82 /**
83 * Default destructor.
84 */
85 ~G4Trd() override = default;
86
87 /**
88 * Accessors.
89 */
90 inline G4double GetXHalfLength1() const;
91 inline G4double GetXHalfLength2() const;
92 inline G4double GetYHalfLength1() const;
93 inline G4double GetYHalfLength2() const;
94 inline G4double GetZHalfLength() const;
95
96 /**
97 * Modifiers.
98 */
99 inline void SetXHalfLength1(G4double val);
100 inline void SetXHalfLength2(G4double val);
101 inline void SetYHalfLength1(G4double val);
102 inline void SetYHalfLength2(G4double val);
103 inline void SetZHalfLength(G4double val);
104
105 /**
106 * Sets all parameters, as for constructor. Checks and sets half-widths.
107 */
108 void SetAllParameters ( G4double pdx1, G4double pdx2,
109 G4double pdy1, G4double pdy2,
110 G4double pdz );
111
112 /**
113 * Returning an estimation of the solid volume (capacity) and
114 * surface area, in internal units.
115 */
116 G4double GetCubicVolume() override;
117 G4double GetSurfaceArea() override;
118
119 /**
120 * Dispatch method for parameterisation replication mechanism and
121 * dimension computation.
122 */
124 const G4int n,
125 const G4VPhysicalVolume* pRep ) override;
126
127 /**
128 * Computes the bounding limits of the solid.
129 * @param[out] pMin The minimum bounding limit point.
130 * @param[out] pMax The maximum bounding limit point.
131 */
132 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
133
134 /**
135 * Calculates the minimum and maximum extent of the solid, when under the
136 * specified transform, and within the specified limits.
137 * @param[in] pAxis The axis along which compute the extent.
138 * @param[in] pVoxelLimit The limiting space dictated by voxels.
139 * @param[in] pTransform The internal transformation applied to the solid.
140 * @param[out] pMin The minimum extent value.
141 * @param[out] pMax The maximum extent value.
142 * @returns True if the solid is intersected by the extent region.
143 */
144 G4bool CalculateExtent(const EAxis pAxis,
145 const G4VoxelLimits& pVoxelLimit,
146 const G4AffineTransform& pTransform,
147 G4double& pMin, G4double& pMax) const override;
148
149 /**
150 * Concrete implementations of the expected query interfaces for
151 * solids, as defined in the base class G4VSolid.
152 */
153 EInside Inside( const G4ThreeVector& p ) const override;
154 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
156 const G4ThreeVector& v ) const override;
157 G4double DistanceToIn( const G4ThreeVector& p ) const override;
159 const G4ThreeVector& v,
160 const G4bool calcNorm = false,
161 G4bool* validNorm = nullptr,
162 G4ThreeVector* n = nullptr ) const override;
163 G4double DistanceToOut( const G4ThreeVector& p ) const override;
164
165 /**
166 * Returns the type ID, "G4Trd" of the solid.
167 */
168 G4GeometryType GetEntityType() const override;
169
170 /**
171 * Returns a random point located and uniformly distributed on the
172 * surface of the solid.
173 */
174 G4ThreeVector GetPointOnSurface() const override;
175
176 /**
177 * Returns true as the solid has only planar faces.
178 */
179 G4bool IsFaceted() const override;
180
181 /**
182 * Makes a clone of the object for use in multi-treading.
183 * @returns A pointer to the new cloned allocated solid.
184 */
185 G4VSolid* Clone() const override;
186
187 /**
188 * Streams the object contents to an output stream.
189 */
190 std::ostream& StreamInfo( std::ostream& os ) const override;
191
192 /**
193 * Methods for creating graphical representations (i.e. for visualisation).
194 */
195 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
196 G4Polyhedron* CreatePolyhedron () const override;
197
198 /**
199 * Fake default constructor for usage restricted to direct object
200 * persistency for clients requiring preallocation of memory for
201 * persistifiable objects.
202 */
203 G4Trd(__void__&);
204
205 /**
206 * Copy constructor and assignment operator.
207 */
208 G4Trd(const G4Trd& rhs);
209 G4Trd& operator=(const G4Trd& rhs);
210
211 private:
212
213 /**
214 * Checks the input parameters.
215 */
216 void CheckParameters();
217
218 /**
219 * Sets the side planes.
220 */
221 void MakePlanes();
222
223 /**
224 * Algorithm for SurfaceNormal() following the original specification
225 * for points not on the surface.
226 */
227 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
228
229 private:
230
231 G4double halfCarTolerance;
232 G4double fDx1,fDx2,fDy1,fDy2,fDz,fHx,fHy;
233 struct { G4double a,b,c,d; } fPlanes[4];
234};
235
236#include "G4Trd.icc"
237
238#endif
239
240#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4String G4GeometryType
Definition G4VSolid.hh:70
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4CSGSolid(const G4String &pName)
Definition G4CSGSolid.cc:49
void SetYHalfLength2(G4double val)
void SetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
Definition G4Trd.cc:126
G4double GetXHalfLength2() const
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Trd.cc:687
G4Trd(const G4String &pName, G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
Definition G4Trd.cc:60
G4double GetSurfaceArea() override
Definition G4Trd.cc:785
G4double b
Definition G4Trd.hh:233
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
Definition G4Trd.cc:249
~G4Trd() override=default
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Trd.cc:800
EInside Inside(const G4ThreeVector &p) const override
Definition G4Trd.cc:300
void SetXHalfLength1(G4double val)
void SetYHalfLength1(G4double val)
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Trd.cc:218
G4Trd & operator=(const G4Trd &rhs)
Definition G4Trd.cc:100
G4double GetYHalfLength2() const
void SetXHalfLength2(G4double val)
G4double a
Definition G4Trd.hh:233
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Trd.cc:428
G4Polyhedron * CreatePolyhedron() const override
Definition G4Trd.cc:805
G4double GetXHalfLength1() const
G4double c
Definition G4Trd.hh:233
G4double d
Definition G4Trd.hh:233
G4ThreeVector GetPointOnSurface() const override
Definition G4Trd.cc:710
G4double GetYHalfLength1() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
Definition G4Trd.cc:542
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Trd.cc:317
G4bool IsFaceted() const override
Definition G4Trd.cc:669
G4double GetCubicVolume() override
Definition G4Trd.cc:770
G4GeometryType GetEntityType() const override
Definition G4Trd.cc:660
void SetZHalfLength(G4double val)
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Trd.cc:207
G4double GetZHalfLength() const
G4VSolid * Clone() const override
Definition G4Trd.cc:678
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54
EInside
Definition geomdefs.hh:67