Geant4  10.02
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: G4Torus.hh 92393 2015-08-31 14:07:30Z gcosmo $
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 
98 #if defined(G4GEOM_USE_USOLIDS)
99 #define G4GEOM_USE_UTORUS 1
100 #endif
101 
102 #if (defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS))
103  #define G4UTorus G4Torus
104  #include "G4UTorus.hh"
105 #else
106 
107 #include <CLHEP/Units/PhysicalConstants.h>
108 
109 #include "G4CSGSolid.hh"
110 
111 class G4Torus : public G4CSGSolid
112 {
113 
114  public: // with description
115 
116  G4Torus(const G4String &pName,
117  G4double pRmin,
118  G4double pRmax,
119  G4double pRtor,
120  G4double pSPhi,
121  G4double pDPhi);
122 
123  ~G4Torus();
124 
125  // Accessors
126 
127  inline G4double GetRmin() const;
128  inline G4double GetRmax() const;
129  inline G4double GetRtor() const;
130  inline G4double GetSPhi() const;
131  inline G4double GetDPhi() const;
132 
133  // Methods of solid
134 
135  inline G4double GetCubicVolume();
136  inline G4double GetSurfaceArea();
137 
138  EInside Inside(const G4ThreeVector& p) const;
139  G4bool CalculateExtent(const EAxis pAxis,
140  const G4VoxelLimits& pVoxelLimit,
141  const G4AffineTransform& pTransform,
142  G4double& pmin, G4double& pmax) const;
144  const G4int n,
145  const G4VPhysicalVolume* pRep);
146  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
147  G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
148  G4double DistanceToIn(const G4ThreeVector& p) const;
150  const G4bool calcNorm=G4bool(false),
151  G4bool *validNorm=0,G4ThreeVector *n=0) const;
152  G4double DistanceToOut(const G4ThreeVector& p) const;
153 
155 
157 
158  G4VSolid* Clone() const;
159 
160  std::ostream& StreamInfo(std::ostream& os) const;
161 
162  // Visualisation functions
163 
164  void DescribeYourselfTo (G4VGraphicsScene& scene) const;
165  G4Polyhedron* CreatePolyhedron () const;
166 
167  public: // without description
168 
169  void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
170  G4double pSPhi, G4double pDPhi);
171 
172  G4Torus(__void__&);
173  // Fake default constructor for usage restricted to direct object
174  // persistency for clients requiring preallocation of memory for
175  // persistifiable objects.
176 
177  G4Torus(const G4Torus& rhs);
178  G4Torus& operator=(const G4Torus& rhs);
179  // Copy constructor and assignment operator.
180 
181  private:
182 
183  void TorusRootsJT(const G4ThreeVector& p,
184  const G4ThreeVector& v,
185  G4double r,
186  std::vector<G4double>& roots) const ;
187 
189  const G4ThreeVector& v,
190  G4double r,
191  G4bool IsDistanceToIn) const;
192 
194  CreateRotatedVertices(const G4AffineTransform& pTransform,
195  G4int& noPolygonVertices) const;
196 
198  // Algorithm for SurfaceNormal() following the original
199  // specification for points not on the surface
200 
201  private:
202 
204 
205  // Used by distanceToOut
207 
208  // used by normal
210 
212  // Radial and angular tolerances
213 
215  // Cached half tolerance values
216 
217 };
218 
219 #include "G4Torus.icc"
220 
221 #endif // defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS)
222 
223 
224 #endif // G4TORUS_HH
G4double GetSPhi() const
EInside Inside(const G4ThreeVector &p) const
Definition: G4Torus.cc:636
G4double fRminTolerance
Definition: G4Torus.hh:211
G4double fRmin
Definition: G4Torus.hh:203
G4Polyhedron * CreatePolyhedron() const
Definition: G4Torus.cc:1787
CLHEP::Hep3Vector G4ThreeVector
G4Torus & operator=(const G4Torus &rhs)
Definition: G4Torus.cc:216
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Torus.cc:1711
G4double fRmax
Definition: G4Torus.hh:203
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Torus.cc:991
G4double SolveNumericJT(const G4ThreeVector &p, const G4ThreeVector &v, G4double r, G4bool IsDistanceToIn) const
Definition: G4Torus.cc:297
G4double GetRmax() const
~G4Torus()
Definition: G4Torus.cc:195
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Torus.cc:416
int G4int
Definition: G4Types.hh:78
G4double GetRtor() const
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform, G4int &noPolygonVertices) const
Definition: G4Torus.cc:1615
G4double kRadTolerance
Definition: G4Torus.hh:211
G4double GetRmin() const
G4double GetCubicVolume()
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4Torus(const G4String &pName, G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition: G4Torus.cc:82
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Torus.cc:747
const G4int n
G4double GetDPhi() const
G4VSolid * Clone() const
Definition: G4Torus.cc:1702
G4ThreeVector GetPointOnSurface() const
Definition: G4Torus.cc:1734
G4double fSPhi
Definition: G4Torus.hh:203
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Torus.cc:243
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Torus.cc:1189
G4double halfCarTolerance
Definition: G4Torus.hh:214
G4double kAngTolerance
Definition: G4Torus.hh:211
EInside
Definition: geomdefs.hh:58
G4double fDPhi
Definition: G4Torus.hh:203
EAxis
Definition: geomdefs.hh:54
G4double halfAngTolerance
Definition: G4Torus.hh:214
G4GeometryType GetEntityType() const
Definition: G4Torus.cc:1693
void TorusRootsJT(const G4ThreeVector &p, const G4ThreeVector &v, G4double r, std::vector< G4double > &roots) const
Definition: G4Torus.cc:257
G4double fRtor
Definition: G4Torus.hh:203
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition: G4Torus.cc:98
double G4double
Definition: G4Types.hh:76
G4double fRmaxTolerance
Definition: G4Torus.hh:211
G4double GetSurfaceArea()
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Torus.cc:1782
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition: G4Torus.cc:882