Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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// Declaration of a CSG volume representing a tube with elliptical
31// cross section (geant3 solid 'ELTU'):
32//
33// G4EllipticalTube( const G4String& name,
34// G4double Dx,
35// G4double Dy,
36// G4double Dz )
37//
38// The equation of the lateral surface : (x/dx)^2 + (y/dy)^2 = 1
39
40// Author: David C. Williams (davidw@scipp.ucsc.edu)
41// Revision: Evgueni Tcherniaev (evgueni.tcherniaev@cern.ch), 23.12.2019
42// --------------------------------------------------------------------
43#ifndef G4ELLIPTICALTUBE_HH
44#define G4ELLIPTICALTUBE_HH
45
46#include "G4GeomTypes.hh"
47
48#if defined(G4GEOM_USE_USOLIDS)
49#define G4GEOM_USE_UELLIPTICALTUBE 1
50#endif
51
52#if (defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS))
53 #define G4UEllipticalTube G4EllipticalTube
54 #include "G4UEllipticalTube.hh"
55#else
56
57#include "G4VSolid.hh"
58#include "G4Polyhedron.hh"
59
61{
62 public: // with description
63
64 G4EllipticalTube( const G4String& name,
65 G4double Dx,
66 G4double Dy,
67 G4double Dz );
68
69 virtual ~G4EllipticalTube();
70
71 // Standard methods
72 //
73 void BoundingLimits( G4ThreeVector& pMin, G4ThreeVector& pMax ) const;
74
75 G4bool CalculateExtent( const EAxis pAxis,
76 const G4VoxelLimits& pVoxelLimit,
77 const G4AffineTransform& pTransform,
78 G4double& pmin, G4double& pmax ) const;
79
80 EInside Inside( const G4ThreeVector& p ) const;
81
83
85 const G4ThreeVector& v ) const;
86
87 G4double DistanceToIn( const G4ThreeVector& p ) const;
88
90 const G4ThreeVector& v,
91 const G4bool calcNorm = false,
92 G4bool* validNorm = nullptr,
93 G4ThreeVector* n = nullptr ) const;
94
95 G4double DistanceToOut( const G4ThreeVector& p ) const;
96
98
99 G4VSolid* Clone() const;
100
101 std::ostream& StreamInfo(std::ostream& os) const;
102
105
107
108 // Visualisation methods
109 //
111 G4Polyhedron* GetPolyhedron () const;
112 void DescribeYourselfTo( G4VGraphicsScene& scene ) const;
113 G4VisExtent GetExtent() const;
114
115 // Accessors
116 //
117 inline G4double GetDx() const;
118 inline G4double GetDy() const;
119 inline G4double GetDz() const;
120
121 inline void SetDx( G4double Dx );
122 inline void SetDy( G4double Dy );
123 inline void SetDz( G4double Dz );
124
125 public: // without description
126
127 G4EllipticalTube(__void__&);
128 // Fake default constructor for usage restricted to direct object
129 // persistency for clients requiring preallocation of memory for
130 // persistifiable objects
131
134 // Copy constructor and assignment operator
135
136 private:
137
138 void CheckParameters();
139 // Check parameters and set pre-calculated values
140
141 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
142 // Algorithm for SurfaceNormal() following the original
143 // specification for points not on the surface
144
145 G4double GetCachedSurfaceArea() const;
146 // Calculate surface area and cache it
147
148 private:
149
150 G4double halfTolerance;
151
152 G4double fDx; // semi-axis in X
153 G4double fDy; // semi-axis in Y
154 G4double fDz; // half length in Z
155
156 G4double fCubicVolume = 0.0; // volume
157 G4double fSurfaceArea = 0.0; // surface area
158
159 // Cached pre-calculated values
160 G4double fRsph; // R of bounding sphere
161 G4double fDDx; // Dx squared
162 G4double fDDy; // Dy squared
163 G4double fSx; // X scale factor
164 G4double fSy; // Y scale factor
165 G4double fR; // resulting Radius, after scaling elipse to circle
166 G4double fQ1; // distance approximation : dist = Q1*(x^2 + y^2) - Q2
167 G4double fQ2; // distance approximation : dist = Q1*(x^2 + y^2) - Q2
168 G4double fScratch; // half length of scratching segment squared
169
170 mutable G4bool fRebuildPolyhedron = false;
171 mutable G4Polyhedron* fpPolyhedron = nullptr;
172};
173
174#include "G4EllipticalTube.icc"
175
176#endif // defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS)
177
178#endif // G4ELLIPTICALTUBE_HH
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
G4EllipticalTube & operator=(const G4EllipticalTube &rhs)
std::ostream & StreamInfo(std::ostream &os) const
G4VSolid * Clone() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
virtual ~G4EllipticalTube()
void SetDz(G4double Dz)
G4VisExtent GetExtent() const
G4double GetSurfaceArea()
G4double GetDy() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4double GetCubicVolume()
void SetDx(G4double Dx)
G4ThreeVector GetPointOnSurface() const
G4double GetDx() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
void SetDy(G4double Dy)
EInside Inside(const G4ThreeVector &p) const
G4double GetDz() const
G4GeometryType GetEntityType() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4Polyhedron * GetPolyhedron() const
G4Polyhedron * CreatePolyhedron() const
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:67