Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4EllipticalCone.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// G4EllipticalCone
27//
28// Class description:
29//
30// G4EllipticalCone is a full cone with elliptical base which can be cut in Z.
31//
32// Member Data:
33//
34// xSemiAxis semi-axis, x, without dimentions
35// ySemiAxis semi-axis, y, without dimentions
36// zheight height, z
37// zTopCut upper cut plane level, z
38//
39// The height in Z corresponds to where the elliptical cone hits the
40// Z-axis if it had no Z cut. Also the cone is centered at zero having a
41// base at zTopCut and another at -zTopCut. The semi-major axes at the Z=0
42// plane are given by xSemiAxis*zheight and ySemiAxis*zheight so that the
43// curved surface of our cone satisfies the equation:
44//
45// ***************************************************************************
46// * *
47// * (x/xSemiAxis)^2 + (y/ySemiAxis)^2 = (zheight - z)^2 *
48// * *
49// ***************************************************************************
50//
51// In case you want to construct G4EllipticalCone from:
52// 1. halflength in Z = zTopCut
53// 2. Dx and Dy = halflength of ellipse axis at z = -zTopCut
54// 3. dx and dy = halflength of ellipse axis at z = zTopCut
55// ! Attention : dx/dy=Dx/Dy
56//
57// You need to find xSemiAxis,ySemiAxis and zheight:
58//
59// xSemiAxis = (Dx-dx)/(2*zTopCut)
60// ySemiAxis = (Dy-dy)/(2*zTopCut)
61// zheight = (Dx+dx)/(2*xSemiAxis)
62
63// Author: Dionysios Anninos (CERN), 08.09.2005 - Created
64// Lukas Lindroos, Tatiana Nikitina (CERN), 20.08.2007 - Revised
65// Evgueni Tcherniaev (CERN), 20.07.2017 - New revision
66// --------------------------------------------------------------------
67#ifndef G4ELLIPTICALCONE_HH
68#define G4ELLIPTICALCONE_HH
69
70#include "G4GeomTypes.hh"
71
72#if defined(G4GEOM_USE_USOLIDS)
73#define G4GEOM_USE_UELLIPTICALCONE 1
74#endif
75
76#if (defined(G4GEOM_USE_UELLIPTICALCONE) && defined(G4GEOM_USE_SYS_USOLIDS))
77 #define G4UEllipticalCone G4EllipticalCone
78 #include "G4UEllipticalCone.hh"
79#else
80
82
83#include "G4VSolid.hh"
84#include "G4Polyhedron.hh"
85
86/**
87 * @brief G4EllipticalCone is a full cone with elliptical base which
88 * can be cut in Z. The height in Z corresponds to where the elliptical
89 * cone hits the Z-axis if it had no Z cut.
90 */
91
93{
94 public:
95
96 /**
97 * Constructs an elliptical cone, with cut in Z.
98 * @param[in] name The solid name.
99 * @param[in] pxSemiAxis Scalar value, defining the scaling along X-axis.
100 * @param[in] pySemiAxis Scalar value, defining the scaling along Y-axis.
101 * @param[in] zMax The Z-coordinate at the apex.
102 * @param[in] pzTopCut Upper cut plane level.
103 */
104 G4EllipticalCone(const G4String& pName,
105 G4double pxSemiAxis,
106 G4double pySemiAxis,
107 G4double zMax,
108 G4double pzTopCut);
109
110 /**
111 * Destructor.
112 */
113 ~G4EllipticalCone() override;
114
115 /**
116 * Accessors.
117 */
118 inline G4double GetSemiAxisMin () const;
119 inline G4double GetSemiAxisMax () const;
120 inline G4double GetSemiAxisX () const;
121 inline G4double GetSemiAxisY () const;
122 inline G4double GetZMax() const;
123 inline G4double GetZTopCut() const;
124
125 /**
126 * Modifiers.
127 */
128 void SetSemiAxis (G4double x, G4double y, G4double z);
129 void SetZCut (G4double newzTopCut);
130
131 /**
132 * Returning an estimation of the solid volume (capacity) and
133 * surface area, in internal units.
134 */
135 G4double GetCubicVolume() override;
136 G4double GetSurfaceArea() override;
137
138 /**
139 * Computes the bounding limits of the solid.
140 * @param[out] pMin The minimum bounding limit point.
141 * @param[out] pMax The maximum bounding limit point.
142 */
143 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
144
145 /**
146 * Calculates the minimum and maximum extent of the solid, when under the
147 * specified transform, and within the specified limits.
148 * @param[in] pAxis The axis along which compute the extent.
149 * @param[in] pVoxelLimit The limiting space dictated by voxels.
150 * @param[in] pTransform The internal transformation applied to the solid.
151 * @param[out] pMin The minimum extent value.
152 * @param[out] pMax The maximum extent value.
153 * @returns True if the solid is intersected by the extent region.
154 */
155 G4bool CalculateExtent(const EAxis pAxis,
156 const G4VoxelLimits& pVoxelLimit,
157 const G4AffineTransform& pTransform,
158 G4double& pMin, G4double& pMax) const override;
159
160 /**
161 * Concrete implementations of the expected query interfaces for
162 * solids, as defined in the base class G4VSolid.
163 */
164 EInside Inside(const G4ThreeVector& p) const override;
165 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
167 const G4ThreeVector& v) const override;
168 G4double DistanceToIn(const G4ThreeVector& p) const override;
170 const G4ThreeVector& v,
171 const G4bool calcNorm = false,
172 G4bool* validNorm = nullptr,
173 G4ThreeVector* n = nullptr) const override;
174 G4double DistanceToOut(const G4ThreeVector& p) const override;
175
176 /**
177 * Returns the type ID, "G4EllipticalCone" of the solid.
178 */
179 G4GeometryType GetEntityType() 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 * Returns a random point located and uniformly distributed on the
189 * surface of the solid.
190 */
191 G4ThreeVector GetPointOnSurface() const override;
192
193 /**
194 * Streams the object contents to an output stream.
195 */
196 std::ostream& StreamInfo(std::ostream& os) const override;
197
198 /**
199 * Methods for creating graphical representations (i.e. for visualisation).
200 */
201 G4Polyhedron* GetPolyhedron() const override;
202 void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
203 G4VisExtent GetExtent() const override;
204 G4Polyhedron* CreatePolyhedron() const override;
205
206 /**
207 * Fake default constructor for usage restricted to direct object
208 * persistency for clients requiring preallocation of memory for
209 * persistifiable objects.
210 */
211 G4EllipticalCone(__void__&);
212
213 /**
214 * Copy constructor and assignment operator.
215 */
218
219 protected:
220
221 mutable G4bool fRebuildPolyhedron = false;
222 mutable G4Polyhedron* fpPolyhedron = nullptr;
223
224 private:
225
226 /**
227 * Algorithm for SurfaceNormal() following the original
228 * specification for points not on the surface.
229 */
230 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
231
232 private:
233
234 G4double halfCarTol;
235 G4double fCubicVolume = 0.0;
236 G4double fSurfaceArea = 0.0;
237 G4double fMinZBaseArea = 0.0;
238 G4double fMaxZBaseArea = 0.0;
239 G4double xSemiAxis, ySemiAxis, zheight, zTopCut;
240 G4double cosAxisMin, invXX, invYY;
241};
242
243#include "G4EllipticalCone.icc"
244
245#endif // defined(G4GEOM_USE_UELLIPTICALCONE) && defined(G4GEOM_USE_SYS_USOLIDS)
246
247#endif // G4ELLIPTICALCONE_HH
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
G4String G4GeometryType
Definition G4VSolid.hh:70
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4double GetSemiAxisMin() const
void SetSemiAxis(G4double x, G4double y, G4double z)
G4double GetSurfaceArea() override
G4VSolid * Clone() const override
EInside Inside(const G4ThreeVector &p) const override
G4double GetSemiAxisMax() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
G4VisExtent GetExtent() const override
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4EllipticalCone(const G4String &pName, G4double pxSemiAxis, G4double pySemiAxis, G4double zMax, G4double pzTopCut)
G4double GetCubicVolume() override
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
void SetZCut(G4double newzTopCut)
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4GeometryType GetEntityType() const override
G4double GetSemiAxisX() const
G4Polyhedron * GetPolyhedron() const override
G4Polyhedron * fpPolyhedron
G4ThreeVector GetPointOnSurface() const override
G4double GetSemiAxisY() const
~G4EllipticalCone() override
std::ostream & StreamInfo(std::ostream &os) const override
G4double GetZMax() const
G4Polyhedron * CreatePolyhedron() const override
G4double GetZTopCut() const
G4EllipticalCone & operator=(const G4EllipticalCone &rhs)
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