Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Trap.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// G4Trap
27//
28// Class description:
29//
30// A G4Trap is a general trapezoid: The faces perpendicular to the
31// z planes are trapezia, and their centres are not necessarily on
32// a line parallel to the z axis.
33//
34// Note that of the 11 parameters described below, only 9 are really
35// independent - a check for planarity is made in the calculation of the
36// equation for each plane. If the planes are not parallel, a call to
37// G4Exception is made.
38//
39// pDz Half-length along the z-axis
40// pTheta Polar angle of the line joining the centres of the faces
41// at -/+pDz
42// pPhi Azimuthal angle of the line joing the centre of the face at
43// -pDz to the centre of the face at +pDz
44// pDy1 Half-length along y of the face at -pDz
45// pDx1 Half-length along x of the side at y=-pDy1 of the face at -pDz
46// pDx2 Half-length along x of the side at y=+pDy1 of the face at -pDz
47// pAlp1 Angle with respect to the y axis from the centre of the side
48// at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
49//
50// pDy2 Half-length along y of the face at +pDz
51// pDx3 Half-length along x of the side at y=-pDy2 of the face at +pDz
52// pDx4 Half-length along x of the side at y=+pDy2 of the face at +pDz
53// pAlp2 Angle with respect to the y axis from the centre of the side
54// at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
55//
56//
57// Member Data:
58//
59// fDz Half-length along the z axis
60// fTthetaCphi = std::tan(pTheta)*std::cos(pPhi)
61// fTthetaSphi = std::tan(pTheta)*std::sin(pPhi)
62// These combinations are suitable for creation of the trapezoid corners
63//
64// fDy1 Half-length along y of the face at -fDz
65// fDx1 Half-length along x of the side at y=-fDy1 of the face at -fDz
66// fDx2 Half-length along x of the side at y=+fDy1 of the face at -fDz
67// fTalpha1 Tan of Angle with respect to the y axis from the centre of
68// the side at y=-fDy1 to the centre at y=+fDy1 of the face
69// at -fDz
70//
71// fDy2 Half-length along y of the face at +fDz
72// fDx3 Half-length along x of the side at y=-fDy2 of the face at +fDz
73// fDx4 Half-length along x of the side at y=+fDy2 of the face at +fDz
74// fTalpha2 Tan of Angle with respect to the y axis from the centre of
75// the side at y=-fDy2 to the centre at y=+fDy2 of the face
76// at +fDz
77//
78// TrapSidePlane fPlanes[4] Plane equations of the faces not at +/-fDz
79// NOTE: order is important !!!
80
81// 23.3.94 P.Kent: Old C++ code converted to tolerant geometry
82// 9.9.96 V.Grichine: Final modifications before to commit
83// 8.12.97 J.Allison: Added "nominal" contructor and method SetAllParameters
84// --------------------------------------------------------------------
85#ifndef G4TRAP_HH
86#define G4TRAP_HH
87
88#include "G4Types.hh"
89
91{
92 G4double a,b,c,d; // Normal unit vector (a,b,c) and offset (d)
93 // => Ax+By+Cz+D=0
94};
95
96#include "G4GeomTypes.hh"
97
98#if defined(G4GEOM_USE_USOLIDS)
99#define G4GEOM_USE_UTRAP 1
100#endif
101
102#if defined(G4GEOM_USE_UTRAP)
103 #define G4UTrap G4Trap
104 #include "G4UTrap.hh"
105#else
106
107#include "G4CSGSolid.hh"
108
109class G4Trap : public G4CSGSolid
110{
111
112 public: // with description
113
114 G4Trap( const G4String& pName,
115 G4double pDz,
116 G4double pTheta, G4double pPhi,
117 G4double pDy1, G4double pDx1, G4double pDx2,
118 G4double pAlp1,
119 G4double pDy2, G4double pDx3, G4double pDx4,
120 G4double pAlp2 );
121 //
122 // The most general constructor for G4Trap which prepares plane
123 // equations and corner coordinates from parameters
124
125 G4Trap( const G4String& pName,
126 const G4ThreeVector pt[8] ) ;
127 //
128 // Prepares plane equations and parameters from corner coordinates
129
130 G4Trap( const G4String& pName,
131 G4double pZ,
132 G4double pY,
133 G4double pX, G4double pLTX );
134 //
135 // Constructor for Right Angular Wedge from STEP (assumes pLTX<=pX)
136
137 G4Trap( const G4String& pName,
138 G4double pDx1, G4double pDx2,
139 G4double pDy1, G4double pDy2,
140 G4double pDz );
141 //
142 // Constructor for G4Trd
143
144 G4Trap(const G4String& pName,
145 G4double pDx, G4double pDy, G4double pDz,
146 G4double pAlpha, G4double pTheta, G4double pPhi );
147 //
148 // Constructor for G4Para
149
150 G4Trap( const G4String& pName );
151 //
152 // Constructor for "nominal" G4Trap whose parameters are to be set
153 // by a G4VPVParamaterisation later
154
155 virtual ~G4Trap() ;
156 //
157 // Destructor
158
159 // Accessors
160
161 inline G4double GetZHalfLength() const;
162 inline G4double GetYHalfLength1() const;
163 inline G4double GetXHalfLength1() const;
164 inline G4double GetXHalfLength2() const;
165 inline G4double GetTanAlpha1() const;
166 inline G4double GetYHalfLength2() const;
167 inline G4double GetXHalfLength3() const;
168 inline G4double GetXHalfLength4() const;
169 inline G4double GetTanAlpha2() const;
170 //
171 // Returns coordinates of unit vector along straight
172 // line joining centers of -/+fDz planes
173
175 inline G4ThreeVector GetSymAxis() const;
176
177 inline G4double GetPhi() const;
178 inline G4double GetTheta() const;
179 inline G4double GetAlpha1() const;
180 inline G4double GetAlpha2() const;
181 // Obtain (re)computed values of original parameters
182
183 // Modifiers
184
185 void SetAllParameters ( G4double pDz,
186 G4double pTheta,
187 G4double pPhi,
188 G4double pDy1,
189 G4double pDx1,
190 G4double pDx2,
191 G4double pAlp1,
192 G4double pDy2,
193 G4double pDx3,
194 G4double pDx4,
195 G4double pAlp2 );
196
197 // Methods for solid
198
201
203 const G4int n,
204 const G4VPhysicalVolume* pRep );
205
206 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
207
208 G4bool CalculateExtent( const EAxis pAxis,
209 const G4VoxelLimits& pVoxelLimit,
210 const G4AffineTransform& pTransform,
211 G4double& pMin, G4double& pMax ) const;
212
213 EInside Inside( const G4ThreeVector& p ) const;
214
215 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
216
217 G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
218
219 G4double DistanceToIn( const G4ThreeVector& p ) const;
220
222 const G4bool calcNorm = false,
223 G4bool* validNorm = nullptr,
224 G4ThreeVector* n = nullptr) const;
225
226 G4double DistanceToOut( const G4ThreeVector& p ) const;
227
229
231
232 G4VSolid* Clone() const;
233
234 std::ostream& StreamInfo( std::ostream& os ) const;
235
236 // Visualisation functions
237
238 void DescribeYourselfTo ( G4VGraphicsScene& scene ) const;
240
241 public: // without description
242
243 G4Trap(__void__&);
244 // Fake default constructor for usage restricted to direct object
245 // persistency for clients requiring preallocation of memory for
246 // persistifiable objects.
247
248 G4Trap(const G4Trap& rhs);
249 G4Trap& operator=(const G4Trap& rhs);
250 // Copy constructor and assignment operator.
251
252 protected: // with description
253
254 void MakePlanes();
255 void MakePlanes(const G4ThreeVector pt[8]);
256 G4bool MakePlane( const G4ThreeVector& p1,
257 const G4ThreeVector& p2,
258 const G4ThreeVector& p3,
259 const G4ThreeVector& p4,
260 TrapSidePlane& plane ) ;
261 void SetCachedValues();
262
263 private:
264
265 void CheckParameters();
266 // Check parameters
267
268 void GetVertices(G4ThreeVector pt[8]) const;
269 // Compute coordinates of the trap vertices from planes
270
271 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
272 // Algorithm for SurfaceNormal() following the original
273 // specification for points not on the surface
274
275 private:
276
277 G4double halfCarTolerance;
278 G4double fDz,fTthetaCphi,fTthetaSphi;
279 G4double fDy1,fDx1,fDx2,fTalpha1;
280 G4double fDy2,fDx3,fDx4,fTalpha2;
281 TrapSidePlane fPlanes[4];
282 G4double fAreas[6];
283 G4int fTrapType;
284};
285
286#include "G4Trap.icc"
287
288#endif
289
290#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4ThreeVector GetPointOnSurface() const
Definition: G4Trap.cc:1177
G4double GetYHalfLength1() const
void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
Definition: G4Trap.cc:282
G4Polyhedron * CreatePolyhedron() const
Definition: G4Trap.cc:1223
G4double GetAlpha2() const
G4double GetTanAlpha2() const
virtual ~G4Trap()
Definition: G4Trap.cc:232
G4double GetAlpha1() const
G4double GetTheta() const
G4double GetPhi() const
G4double GetXHalfLength2() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Trap.cc:701
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Trap.cc:827
void SetCachedValues()
Definition: G4Trap.cc:434
G4ThreeVector GetSymAxis() const
G4double GetXHalfLength4() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
Definition: G4Trap.cc:589
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Trap.cc:549
G4double GetSurfaceArea()
Definition: G4Trap.cc:513
G4double GetZHalfLength() const
G4VSolid * Clone() const
Definition: G4Trap.cc:1116
G4double GetYHalfLength2() const
EInside Inside(const G4ThreeVector &p) const
Definition: G4Trap.cc:638
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Trap.cc:538
void MakePlanes()
Definition: G4Trap.cc:335
G4double GetTanAlpha1() const
TrapSidePlane GetSidePlane(G4int n) const
G4double GetCubicVolume()
Definition: G4Trap.cc:488
G4bool MakePlane(const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, const G4ThreeVector &p4, TrapSidePlane &plane)
Definition: G4Trap.cc:402
G4GeometryType GetEntityType() const
Definition: G4Trap.cc:1107
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Trap.cc:1125
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
Definition: G4Trap.cc:953
G4double GetXHalfLength3() const
G4double GetXHalfLength1() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Trap.cc:1218
G4Trap & operator=(const G4Trap &rhs)
Definition: G4Trap.cc:255
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:67
G4double b
Definition: G4Trap.hh:92
G4double c
Definition: G4Trap.hh:92
G4double d
Definition: G4Trap.hh:92
G4double a
Definition: G4Trap.hh:92