Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4EllipticalTube.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// G4EllipticalTube
27//
28// Class description:
29//
30// A tube with elliptical cross section:
31//
32// G4EllipticalTube( const G4String& name,
33// G4double Dx,
34// G4double Dy,
35// G4double Dz )
36//
37// The equation of the lateral surface is: (x/dx)^2 + (y/dy)^2 = 1
38
39// Author: David C. Williams (UCSC), 29.03.2000 - First implementation
40// Evgueni Tcherniaev (CERN), 23.12.2019 - Revised
41// --------------------------------------------------------------------
42#ifndef G4ELLIPTICALTUBE_HH
43#define G4ELLIPTICALTUBE_HH
44
45#include "G4GeomTypes.hh"
46
47#if defined(G4GEOM_USE_USOLIDS)
48#define G4GEOM_USE_UELLIPTICALTUBE 1
49#endif
50
51#if (defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS))
52 #define G4UEllipticalTube G4EllipticalTube
53 #include "G4UEllipticalTube.hh"
54#else
55
56#include "G4VSolid.hh"
57#include "G4Polyhedron.hh"
58
59/**
60 * @brief G4EllipticalTube is a tube with elliptical cross section.
61 * The equation of the lateral surface is: (x/dx)^2 + (y/dy)^2 = 1.
62 */
63
65{
66 public:
67
68 /**
69 * Constructs an elliptical tube, given its parameters.
70 * @param[in] name The solid name.
71 * @param[in] Dx Half length of axis along X.
72 * @param[in] Dy Half length of axis along Y.
73 * @param[in] Dz Half length in Z.
74 */
75 G4EllipticalTube( const G4String& name,
76 G4double Dx,
77 G4double Dy,
78 G4double Dz );
79
80 /**
81 * Destructor.
82 */
83 ~G4EllipticalTube() override;
84
85 /**
86 * Accessors.
87 */
88 inline G4double GetDx() const;
89 inline G4double GetDy() const;
90 inline G4double GetDz() const;
91
92 /**
93 * Modifiers.
94 */
95 inline void SetDx( G4double Dx );
96 inline void SetDy( G4double Dy );
97 inline void SetDz( G4double Dz );
98
99 /**
100 * Computes the bounding limits of the solid.
101 * @param[out] pMin The minimum bounding limit point.
102 * @param[out] pMax The maximum bounding limit point.
103 */
104 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
105
106 /**
107 * Calculates the minimum and maximum extent of the solid, when under the
108 * specified transform, and within the specified limits.
109 * @param[in] pAxis The axis along which compute the extent.
110 * @param[in] pVoxelLimit The limiting space dictated by voxels.
111 * @param[in] pTransform The internal transformation applied to the solid.
112 * @param[out] pMin The minimum extent value.
113 * @param[out] pMax The maximum extent value.
114 * @returns True if the solid is intersected by the extent region.
115 */
116 G4bool CalculateExtent(const EAxis pAxis,
117 const G4VoxelLimits& pVoxelLimit,
118 const G4AffineTransform& pTransform,
119 G4double& pmin, G4double& pmax) const override;
120
121 /**
122 * Concrete implementations of the expected query interfaces for
123 * solids, as defined in the base class G4VSolid.
124 */
125 EInside Inside( const G4ThreeVector& p ) const override;
126 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
128 const G4ThreeVector& v ) const override;
129 G4double DistanceToIn( const G4ThreeVector& p ) const override;
131 const G4ThreeVector& v,
132 const G4bool calcNorm = false,
133 G4bool* validNorm = nullptr,
134 G4ThreeVector* n = nullptr ) const override;
135 G4double DistanceToOut( const G4ThreeVector& p ) const override;
136
137 /**
138 * Returns the type ID, "G4EllipticalTube" of the solid.
139 */
140 G4GeometryType GetEntityType() const override;
141
142 /**
143 * Makes a clone of the object for use in multi-treading.
144 * @returns A pointer to the new cloned allocated solid.
145 */
146 G4VSolid* Clone() const override;
147
148 /**
149 * Streams the object contents to an output stream.
150 */
151 std::ostream& StreamInfo(std::ostream& os) const override;
152
153 /**
154 * Returning an estimation of the solid volume (capacity) and
155 * surface area, in internal units.
156 */
157 G4double GetCubicVolume() override;
158 G4double GetSurfaceArea() override;
159
160 /**
161 * Returns a random point located and uniformly distributed on the
162 * surface of the solid.
163 */
164 G4ThreeVector GetPointOnSurface() const override;
165
166 /**
167 * Methods for creating graphical representations (i.e. for visualisation).
168 */
169 G4Polyhedron* CreatePolyhedron() const override;
170 G4Polyhedron* GetPolyhedron() const override;
171 void DescribeYourselfTo( G4VGraphicsScene& scene ) const override;
172 G4VisExtent GetExtent() const override;
173
174 /**
175 * Fake default constructor for usage restricted to direct object
176 * persistency for clients requiring preallocation of memory for
177 * persistifiable objects.
178 */
179 G4EllipticalTube(__void__&);
180
181 /**
182 * Copy constructor and assignment operator.
183 */
186
187 private:
188
189 /**
190 * Checks parameters and sets pre-calculated values.
191 */
192 void CheckParameters();
193
194 /**
195 * Algorithm for SurfaceNormal() following the original
196 * specification for points not on the surface.
197 */
198 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
199
200 /**
201 * Calculates the surface area and caches it.
202 */
203 G4double GetCachedSurfaceArea() const;
204
205 private:
206
207 G4double halfTolerance;
208
209 G4double fDx; // semi-axis in X
210 G4double fDy; // semi-axis in Y
211 G4double fDz; // half length in Z
212
213 G4double fCubicVolume = 0.0; // volume
214 G4double fSurfaceArea = 0.0; // surface area
215
216 /** Cached pre-calculated values. */
217 G4double fRsph; // R of bounding sphere
218 G4double fDDx; // Dx squared
219 G4double fDDy; // Dy squared
220 G4double fSx; // X scale factor
221 G4double fSy; // Y scale factor
222 G4double fR; // resulting Radius, after scaling elipse to circle
223 G4double fQ1; // distance approximation : dist = Q1*(x^2 + y^2) - Q2
224 G4double fQ2; // distance approximation : dist = Q1*(x^2 + y^2) - Q2
225 G4double fScratch; // half length of scratching segment squared
226
227 mutable G4bool fRebuildPolyhedron = false;
228 mutable G4Polyhedron* fpPolyhedron = nullptr;
229};
230
231#include "G4EllipticalTube.icc"
232
233#endif // defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS)
234
235#endif // G4ELLIPTICALTUBE_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...
G4ThreeVector GetPointOnSurface() const override
G4EllipticalTube & operator=(const G4EllipticalTube &rhs)
G4double GetSurfaceArea() override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
EInside Inside(const G4ThreeVector &p) const override
void SetDz(G4double Dz)
G4Polyhedron * CreatePolyhedron() const override
G4double GetDy() const
G4GeometryType GetEntityType() const override
G4VisExtent GetExtent() const override
void SetDx(G4double Dx)
std::ostream & StreamInfo(std::ostream &os) const override
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double GetDx() const
G4Polyhedron * GetPolyhedron() const override
void SetDy(G4double Dy)
G4VSolid * Clone() const override
~G4EllipticalTube() override
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4double GetDz() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
G4EllipticalTube(const G4String &name, G4double Dx, G4double Dy, G4double Dz)
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4double GetCubicVolume() override
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
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