Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4Torus.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//
27// $Id$
28//
29//
30// --------------------------------------------------------------------
31// GEANT 4 class header file
32//
33// G4Torus
34//
35// Class description:
36//
37// A torus or torus segment with curved sides parallel to the z-axis.
38// The torus has a specified swept radius about which it is centered,
39// and a given minimum and maximum radius. A minimum radius of 0
40// signifies a filled torus.
41// The torus segment is specified by starting and delta angles for phi,
42// with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI
43// signifies a complete, unsegmented torus/cylindr.
44//
45// Member functions:
46//
47// As inherited from G4CSGSolid+
48//
49// G4Torus(const G4String &pName
50// G4double pRmin
51// G4double pRmax
52// G4double pRtor
53// G4double pSPhi
54// G4double pDPhi )
55//
56// - Construct a torus with the given name and dimensions.
57// The angles are provided is radians. pRtor >= pRmax
58//
59//
60// Protected:
61//
62// G4ThreeVectorList*
63// CreateRotatedVertices(const G4AffineTransform& pTransform) const
64//
65// - Create the List of transformed vertices in the format required
66// for G4VSolid:: ClipCrossSection and ClipBetweenSections.
67//
68// Member Data:
69//
70// fRmin Inside radius
71// fRmax Outside radius
72// fRtor swept radius of torus
73//
74// fSPhi The starting phi angle in radians,
75// adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
76//
77// fDPhi Delta angle of the segment in radians
78//
79// You could find very often in G4Torus functions values like 'pt' or
80// 'it'. These are the distances from p or i G4ThreeVector points in the
81// plane (Z axis points p or i) to fRtor point in XY plane. This value is
82// similar to rho for G4Tubs and is used for definiton of the point
83// relative to fRmin and fRmax, i.e. for solution of inside/outside
84// problems
85
86// History:
87// 30.10.96 V.Grichine: first version of G4Torus
88// 21.04.98 J.Apostolakis: added SetAllParameters() function
89// 26.05.00 V.Grichine: added new SolveBiQuadratic/Cubic() developed
90// by O.Cremonesi
91// 31.08.00 E.Medernach: added SolveNumeric functions, migrated to
92// numeric solutions
93// --------------------------------------------------------------------
94
95#ifndef G4Torus_HH
96#define G4Torus_HH
97
99
100#include "G4CSGSolid.hh"
101
102class G4Torus : public G4CSGSolid
103{
104
105 public: // with description
106
107 G4Torus(const G4String &pName,
108 G4double pRmin,
109 G4double pRmax,
110 G4double pRtor,
111 G4double pSPhi,
112 G4double pDPhi);
113
114 ~G4Torus();
115
116 // Accessors
117
118 inline G4double GetRmin() const;
119 inline G4double GetRmax() const;
120 inline G4double GetRtor() const;
121 inline G4double GetSPhi() const;
122 inline G4double GetDPhi() const;
123
124 // Methods of solid
125
128
129 EInside Inside(const G4ThreeVector& p) const;
130 G4bool CalculateExtent(const EAxis pAxis,
131 const G4VoxelLimits& pVoxelLimit,
132 const G4AffineTransform& pTransform,
133 G4double& pmin, G4double& pmax) const;
135 const G4int n,
136 const G4VPhysicalVolume* pRep);
138 G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
139 G4double DistanceToIn(const G4ThreeVector& p) const;
141 const G4bool calcNorm=G4bool(false),
142 G4bool *validNorm=0,G4ThreeVector *n=0) const;
143 G4double DistanceToOut(const G4ThreeVector& p) const;
144
146
148
149 G4VSolid* Clone() const;
150
151 std::ostream& StreamInfo(std::ostream& os) const;
152
153 // Visualisation functions
154
155 void DescribeYourselfTo (G4VGraphicsScene& scene) const;
157 G4NURBS* CreateNURBS () const;
158
159 public: // without description
160
161 void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
162 G4double pSPhi, G4double pDPhi);
163
164 G4Torus(__void__&);
165 // Fake default constructor for usage restricted to direct object
166 // persistency for clients requiring preallocation of memory for
167 // persistifiable objects.
168
169 G4Torus(const G4Torus& rhs);
170 G4Torus& operator=(const G4Torus& rhs);
171 // Copy constructor and assignment operator.
172
173 private:
174
175 void TorusRootsJT(const G4ThreeVector& p,
176 const G4ThreeVector& v,
177 G4double r,
178 std::vector<G4double>& roots) const ;
179
180 G4double SolveNumericJT(const G4ThreeVector& p,
181 const G4ThreeVector& v,
182 G4double r,
183 G4bool IsDistanceToIn) const;
184
186 CreateRotatedVertices(const G4AffineTransform& pTransform,
187 G4int& noPolygonVertices) const;
188
189 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
190 // Algorithm for SurfaceNormal() following the original
191 // specification for points not on the surface
192
193 private:
194
195 G4double fRmin,fRmax,fRtor,fSPhi,fDPhi;
196
197 // Used by distanceToOut
198 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi};
199
200 // used by normal
201 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi};
202
203 G4double fRminTolerance, fRmaxTolerance, kRadTolerance, kAngTolerance;
204 // Radial and angular tolerances
205};
206
207#include "G4Torus.icc"
208
209#endif
ENorm
Definition: G4Cons.cc:72
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:85
EInside Inside(const G4ThreeVector &p) const
Definition: G4Torus.cc:632
G4double GetSurfaceArea()
G4Torus & operator=(const G4Torus &rhs)
Definition: G4Torus.cc:212
G4GeometryType GetEntityType() const
Definition: G4Torus.cc:1694
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Torus.cc:1187
~G4Torus()
Definition: G4Torus.cc:193
G4VSolid * Clone() const
Definition: G4Torus.cc:1703
G4double GetCubicVolume()
G4double GetDPhi() const
G4double GetRmin() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Torus.cc:412
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition: G4Torus.cc:100
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Torus.cc:237
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Torus.cc:743
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Torus.cc:987
G4ThreeVector GetPointOnSurface() const
Definition: G4Torus.cc:1735
G4double GetRtor() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Torus.cc:1783
G4NURBS * CreateNURBS() const
Definition: G4Torus.cc:1793
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Torus.cc:1712
G4double GetRmax() const
G4double GetSPhi() const
G4Polyhedron * CreatePolyhedron() const
Definition: G4Torus.cc:1788
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:58