Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Para.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// G4Para
27//
28// Class description:
29//
30// A parallelepiped, essentially a box with half lengths dx,dy,dz
31// 'skewed' so that there are angles theta & phi of the polar line
32// joining the faces at +-dz in z, and alpha formed by the y axis
33// and the plane joining the centre of the faces parallel to the
34// z-x plane at -dy and +dy.
35//
36// A G4Para is defined by:
37// dx,dy,dz - Half-length in x,y,z
38// alpha - Angle formed by the y axis and by the plane joining
39// the centre of the faces parallel to the z-x plane
40// at -dy and +dy
41// theta - Polar angle of the line joining the centres of the
42// faces at -dz and +dz in z
43// phi - Azimuthal angle of the line joining the centres of the
44// faces at -dz and +dz in z
45// Member data:
46//
47// Note that the angles parameters are not stored - precomputed trig is
48// stored instead.
49//
50// fDx Half-length in x
51// fDy Half-length in y
52// fDz Half-length in z
53//
54// fTalpha Tan of alpha
55// fTthetaCphi Tan theta * Cos phi
56// fTthetaSphi Tan theta * Sin phi
57
58// Author: Paul Kent (CERN), 21.03.1994 - Code converted to tolerant geometry
59// --------------------------------------------------------------------
60#ifndef G4PARA_HH
61#define G4PARA_HH
62
63#include "G4GeomTypes.hh"
64
65#if defined(G4GEOM_USE_USOLIDS)
66#define G4GEOM_USE_UPARA 1
67#endif
68
69#if defined(G4GEOM_USE_UPARA)
70 #define G4UPara G4Para
71 #include "G4UPara.hh"
72#else
73
74#include "G4CSGSolid.hh"
75#include "G4Polyhedron.hh"
76
77/**
78 * @brief G4Para represents a parallelepiped, essentially a box with half
79 * lengths dx,dy,dz 'skewed' so that there are angles theta & phi of the
80 * polar line joining the faces at +-dz in z, and alpha formed by the y axis
81 * and the plane joining the centre of the faces parallel to the z-x plane
82 * at -dy and +dy.
83 */
84
85class G4Para : public G4CSGSolid
86{
87 public:
88
89 /**
90 * Constructs a parallelepiped, given a name and its parameters.
91 * @param[in] pName The name of the solid.
92 * @param[in] pDx Half-length in x.
93 * @param[in] pDy Half-length in y.
94 * @param[in] pDz Half-length in z.
95 * @param[in] pAlpha Angle formed by the Y axis and by the plane joining
96 * the centre of the faces parallel to the Z-X plane at -dy
97 * and +dy.
98 * @param[in] pTheta Polar angle of the line joining the centres of the
99 * faces at -dz and +dz in Z.
100 * @param[in] pPhi Azimuthal angle of the line joining the centres of
101 * the faces at -dz and +dz in Z.
102 */
103 G4Para(const G4String& pName,
104 G4double pDx, G4double pDy, G4double pDz,
105 G4double pAlpha, G4double pTheta, G4double pPhi);
106
107 /**
108 * Constructs a parallelepiped, given a name and its 8 vertices.
109 * @param[in] pName The name of the solid.
110 * @param[in] pt Points of the 8 vertices.
111 */
112 G4Para(const G4String& pName,
113 const G4ThreeVector pt[8]);
114
115 /**
116 * Default destructor.
117 */
118 ~G4Para() override = default;
119
120 /**
121 * Accessors. Obtain (re)computed values of the original parameters.
122 */
123 inline G4double GetZHalfLength() const;
124 inline G4ThreeVector GetSymAxis() const;
125 inline G4double GetYHalfLength() const;
126 inline G4double GetXHalfLength() const;
127 inline G4double GetTanAlpha() const;
128 inline G4double GetAlpha() const;
129 inline G4double GetTheta() const;
130 inline G4double GetPhi() const;
131
132 /**
133 * Modifiers.
134 */
135 inline void SetXHalfLength(G4double val);
136 inline void SetYHalfLength(G4double val);
137 inline void SetZHalfLength(G4double val);
138 inline void SetAlpha(G4double alpha);
139 inline void SetTanAlpha(G4double val);
140 inline void SetThetaAndPhi(G4double pTheta, G4double pPhi);
141
142 /**
143 * Sets all parameters, as for constructor.
144 */
145 void SetAllParameters(G4double pDx, G4double pDy, G4double pDz,
146 G4double pAlpha, G4double pTheta, G4double pPhi);
147
148 /**
149 * Returning an estimation of the solid volume (capacity) and
150 * surface area, in internal units.
151 */
152 G4double GetCubicVolume() override;
153 G4double GetSurfaceArea() override;
154
155 /**
156 * Dispatch method for parameterisation replication mechanism and
157 * dimension computation.
158 */
160 const G4int n,
161 const G4VPhysicalVolume* pRep) override;
162
163 /**
164 * Computes the bounding limits of the solid.
165 * @param[out] pMin The minimum bounding limit point.
166 * @param[out] pMax The maximum bounding limit point.
167 */
168 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
169
170 /**
171 * Calculates the minimum and maximum extent of the solid, when under the
172 * specified transform, and within the specified limits.
173 * @param[in] pAxis The axis along which compute the extent.
174 * @param[in] pVoxelLimit The limiting space dictated by voxels.
175 * @param[in] pTransform The internal transformation applied to the solid.
176 * @param[out] pMin The minimum extent value.
177 * @param[out] pMax The maximum extent value.
178 * @returns True if the solid is intersected by the extent region.
179 */
180 G4bool CalculateExtent(const EAxis pAxis,
181 const G4VoxelLimits& pVoxelLimit,
182 const G4AffineTransform& pTransform,
183 G4double& pMin, G4double& pMax) const override;
184
185 /**
186 * Concrete implementations of the expected query interfaces for
187 * solids, as defined in the base class G4VSolid.
188 */
189 EInside Inside(const G4ThreeVector& p) const override;
190 G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
192 const G4ThreeVector& v) const override;
193 G4double DistanceToIn(const G4ThreeVector& p) const override;
195 const G4bool calcNorm = false,
196 G4bool* validNorm = nullptr,
197 G4ThreeVector* n = nullptr) const override;
198 G4double DistanceToOut(const G4ThreeVector& p) const override;
199
200 /**
201 * Returns the type ID, "G4Para" of the solid.
202 */
203 G4GeometryType GetEntityType() const override;
204
205 /**
206 * Returns a random point located and uniformly distributed on the
207 * surface of the solid.
208 */
209 G4ThreeVector GetPointOnSurface() const override;
210
211 /**
212 * Returns true as the solid has only planar faces.
213 */
214 G4bool IsFaceted() const override;
215
216 /**
217 * Makes a clone of the object for use in multi-treading.
218 * @returns A pointer to the new cloned allocated solid.
219 */
220 G4VSolid* Clone() const override;
221
222 /**
223 * Streams the object contents to an output stream.
224 */
225 std::ostream& StreamInfo(std::ostream& os) const override;
226
227 /**
228 * Methods for creating graphical representations (i.e. for visualisation).
229 */
230 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
231 G4Polyhedron* CreatePolyhedron () const override;
232
233 /**
234 * Fake default constructor for usage restricted to direct object
235 * persistency for clients requiring preallocation of memory for
236 * persistifiable objects.
237 */
238 G4Para(__void__&);
239
240 /**
241 * Copy constructor and assignment operator.
242 */
243 G4Para(const G4Para& rhs);
244 G4Para& operator=(const G4Para& rhs);
245
246 private:
247
248 /**
249 * Checks the dimension parameters given in input.
250 */
251 void CheckParameters();
252
253 /**
254 * Sets the side planes.
255 */
256 void MakePlanes();
257
258 /**
259 * Algorithm for SurfaceNormal() following the original specification
260 * for points not on the surface.
261 */
262 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
263
264 private:
265
266 G4double halfCarTolerance;
267 G4double fDx,fDy,fDz;
268 G4double fTalpha,fTthetaCphi,fTthetaSphi;
269 struct { G4double a,b,c,d; } fPlanes[4];
270};
271
272#include "G4Para.icc"
273
274#endif
275
276#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
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Para.cc:510
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Para.cc:795
EInside Inside(const G4ThreeVector &p) const override
Definition G4Para.cc:377
G4double GetPhi() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
Definition G4Para.cc:322
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
Definition G4Para.cc:625
void SetYHalfLength(G4double val)
void SetTanAlpha(G4double val)
G4double GetSurfaceArea() override
Definition G4Para.cc:875
G4Polyhedron * CreatePolyhedron() const override
Definition G4Para.cc:898
G4double GetTanAlpha() const
G4GeometryType GetEntityType() const override
Definition G4Para.cc:768
G4ThreeVector GetPointOnSurface() const override
Definition G4Para.cc:824
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Para.cc:398
void SetZHalfLength(G4double val)
G4ThreeVector GetSymAxis() const
void SetXHalfLength(G4double val)
G4Para & operator=(const G4Para &rhs)
Definition G4Para.cc:155
G4Para(const G4String &pName, G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
Definition G4Para.cc:59
G4VSolid * Clone() const override
Definition G4Para.cc:786
void SetAllParameters(G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
Definition G4Para.cc:183
G4double GetAlpha() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Para.cc:279
void SetThetaAndPhi(G4double pTheta, G4double pPhi)
G4bool IsFaceted() const override
Definition G4Para.cc:777
G4double GetYHalfLength() const
G4double d
Definition G4Para.hh:269
~G4Para() override=default
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Para.cc:268
G4double GetZHalfLength() const
G4double GetCubicVolume() override
Definition G4Para.cc:860
void SetAlpha(G4double alpha)
G4double a
Definition G4Para.hh:269
G4double GetXHalfLength() const
G4double GetTheta() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Para.cc:893
G4double b
Definition G4Para.hh:269
G4double c
Definition G4Para.hh:269
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