Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Ellipsoid.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// G4Ellipsoid
27//
28// Class description:
29//
30// A G4Ellipsoid is an ellipsoidal solid, optionally cut at a given z.
31//
32// Member Data:
33// xSemiAxis semi-axis, X
34// ySemiAxis semi-axis, Y
35// zSemiAxis semi-axis, Z
36// zBottomCut lower cut in Z (solid lies above this plane)
37// zTopCut upper cut in Z (solid lies below this plane)
38
39// Author: G.Horton-Smith (Caltech, USA), 10.11.1999 - First implementation
40// G.Guerrieri (INFN Genova, Italy), 10.02.2005 - Revision
41// E.Tcherniaev (CERN), 15.12.2019 - Complete revision
42// --------------------------------------------------------------------
43#ifndef G4ELLIPSOID_HH
44#define G4ELLIPSOID_HH
45
46#include "G4GeomTypes.hh"
47
48#if defined(G4GEOM_USE_USOLIDS)
49#define G4GEOM_USE_UELLIPSOID 1
50#endif
51
52#if (defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS))
53 #define G4UEllipsoid G4Ellipsoid
54 #include "G4UEllipsoid.hh"
55#else
56
58
59#include "G4VSolid.hh"
60#include "G4Polyhedron.hh"
61
62/**
63 * @brief G4Ellipsoid is an ellipsoidal solid, optionally cut at a given Z.
64 */
65
66class G4Ellipsoid : public G4VSolid
67{
68 public:
69
70 /**
71 * Constructs an ellipsoid, given its input parameters.
72 * @param[in] name The solid name.
73 * @param[in] xSemiAxis Semiaxis in X.
74 * @param[in] ySemiAxis Semiaxis in Y.
75 * @param[in] zSemiAxis Semiaxis in Z.
76 * @param[in] zBottomCut Optional lower cut plane level in Z.
77 * @param[in] zTopCut Optional upper cut plane level in Z.
78 */
79 G4Ellipsoid(const G4String& name,
80 G4double xSemiAxis,
81 G4double ySemiAxis,
82 G4double zSemiAxis,
83 G4double zBottomCut = 0.,
84 G4double zTopCut = 0.);
85
86 /**
87 * Destructor.
88 */
89 ~G4Ellipsoid() override;
90
91 /**
92 * Accessors.
93 */
94 inline G4double GetDx() const;
95 inline G4double GetDy() const;
96 inline G4double GetDz() const;
97 inline G4double GetSemiAxisMax (G4int i) const;
98 inline G4double GetZBottomCut() const;
99 inline G4double GetZTopCut() const;
100
101 /**
102 * Modifiers.
103 */
104 inline void SetSemiAxis (G4double x, G4double y, G4double z);
105 inline void SetZCuts (G4double newzBottomCut, G4double newzTopCut);
106
107 /**
108 * Dispatch method for parameterisation replication mechanism and
109 * dimension computation.
110 */
112 const G4int n,
113 const G4VPhysicalVolume* pRep) override;
114
115 /**
116 * Computes the bounding limits of the solid.
117 * @param[out] pMin The minimum bounding limit point.
118 * @param[out] pMax The maximum bounding limit point.
119 */
120 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
121
122 /**
123 * Calculates the minimum and maximum extent of the solid, when under the
124 * specified transform, and within the specified limits.
125 * @param[in] pAxis The axis along which compute the extent.
126 * @param[in] pVoxelLimit The limiting space dictated by voxels.
127 * @param[in] pTransform The internal transformation applied to the solid.
128 * @param[out] pMin The minimum extent value.
129 * @param[out] pMax The maximum extent value.
130 * @returns True if the solid is intersected by the extent region.
131 */
132 G4bool CalculateExtent(const EAxis pAxis,
133 const G4VoxelLimits& pVoxelLimit,
134 const G4AffineTransform& pTransform,
135 G4double& pmin, G4double& pmax) const override;
136
137 /**
138 * Concrete implementations of the expected query interfaces for
139 * solids, as defined in the base class G4VSolid.
140 */
141 EInside Inside(const G4ThreeVector& p) const override;
142 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
144 const G4ThreeVector& v) const override;
145 G4double DistanceToIn(const G4ThreeVector& p) const override;
147 const G4ThreeVector& v,
148 const G4bool calcNorm = false,
149 G4bool* validNorm = nullptr,
150 G4ThreeVector* n = nullptr) const override;
151 G4double DistanceToOut(const G4ThreeVector& p) const override;
152
153 /**
154 * Returns the type ID, "G4Ellipsoid" of the solid.
155 */
156 G4GeometryType GetEntityType() const override;
157
158 /**
159 * Makes a clone of the object for use in multi-treading.
160 * @returns A pointer to the new cloned allocated solid.
161 */
162 G4VSolid* Clone() const override;
163
164 /**
165 * Streams the object contents to an output stream.
166 */
167 std::ostream& StreamInfo(std::ostream& os) const override;
168
169 /**
170 * Returning an estimation of the solid volume (capacity) and
171 * surface area, in internal units.
172 */
173 G4double GetCubicVolume() override;
174 G4double GetSurfaceArea() override;
175
176 /**
177 * Returns a random point located and uniformly distributed on the
178 * surface of the solid.
179 */
180 G4ThreeVector GetPointOnSurface() const override;
181
182 /**
183 * Methods for creating graphical representations (i.e. for visualisation).
184 */
185 void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
186 G4VisExtent GetExtent() const override;
187 G4Polyhedron* CreatePolyhedron() const override;
188 G4Polyhedron* GetPolyhedron() const override;
189
190 /**
191 * Fake default constructor for usage restricted to direct object
192 * persistency for clients requiring preallocation of memory for
193 * persistifiable objects.
194 */
195 G4Ellipsoid(__void__&);
196
197 /**
198 * Copy constructor and assignment operator.
199 */
200 G4Ellipsoid(const G4Ellipsoid& rhs);
201 G4Ellipsoid& operator=(const G4Ellipsoid& rhs);
202
203 private:
204
205 /**
206 * Checks parameters and sets cached values.
207 */
208 void CheckParameters();
209
210 /**
211 * Algorithm for SurfaceNormal() following the original specification
212 * for points not on the surface.
213 */
214 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
215
216 /**
217 * Calculates the area of lateral surface.
218 */
219 G4double LateralSurfaceArea() const;
220
221 private:
222
223 /** Ellipsoid parameters. */
224 G4double fDx; // X semi-axis
225 G4double fDy; // Y semi-axis
226 G4double fDz; // Z semi-axis
227 G4double fZBottomCut; // Bottom cut in Z
228 G4double fZTopCut; // Top cut in Z
229
230 /** Precalculated cached values. */
231 G4double halfTolerance; // Surface tolerance
232 G4double fXmax; // X extent
233 G4double fYmax; // Y extent
234 G4double fRsph; // Radius of bounding sphere
235 G4double fR; // Radius of sphere after scaling
236 G4double fSx; // X scale factor
237 G4double fSy; // Y scale factor
238 G4double fSz; // Z scale factor
239 G4double fZMidCut; // Middle position between cuts after scaling
240 G4double fZDimCut; // Half distance between cut after scaling
241 G4double fQ1; // 1st coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2
242 G4double fQ2; // 2nd coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2
243
244 G4double fCubicVolume = 0.0; // Volume
245 G4double fSurfaceArea = 0.0; // Surface area
246 mutable G4double fLateralArea = 0.0; // Lateral surface area
247 mutable G4bool fRebuildPolyhedron = false;
248 mutable G4Polyhedron* fpPolyhedron = nullptr;
249};
250
251#include "G4Ellipsoid.icc"
252
253#endif // defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS)
254
255#endif // G4ELLIPSOID_HH
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...
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double GetSemiAxisMax(G4int i) const
G4double GetDx() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
void SetZCuts(G4double newzBottomCut, G4double newzTopCut)
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
G4Ellipsoid(const G4String &name, G4double xSemiAxis, G4double ySemiAxis, G4double zSemiAxis, G4double zBottomCut=0., G4double zTopCut=0.)
EInside Inside(const G4ThreeVector &p) const override
G4Polyhedron * CreatePolyhedron() const override
~G4Ellipsoid() override
G4double GetDy() const
G4double GetSurfaceArea() override
G4VSolid * Clone() const override
G4ThreeVector GetPointOnSurface() const override
G4double GetZTopCut() const
G4double GetZBottomCut() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
G4double GetCubicVolume() override
G4GeometryType GetEntityType() const override
G4double GetDz() const
G4Polyhedron * GetPolyhedron() const override
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
void SetSemiAxis(G4double x, G4double y, G4double z)
G4VisExtent GetExtent() const override
G4Ellipsoid & operator=(const G4Ellipsoid &rhs)
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
std::ostream & StreamInfo(std::ostream &os) const override
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
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