Geant4  10.01.p03
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 72938 2013-08-14 13:24:12Z 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 #include <CLHEP/Units/PhysicalConstants.h>
99 
100 #include "G4CSGSolid.hh"
101 
102 class 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 
126  inline G4double GetCubicVolume();
127  inline G4double GetSurfaceArea();
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);
137  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
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;
156  G4Polyhedron* CreatePolyhedron () const;
157 
158  public: // without description
159 
160  void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
161  G4double pSPhi, G4double pDPhi);
162 
163  G4Torus(__void__&);
164  // Fake default constructor for usage restricted to direct object
165  // persistency for clients requiring preallocation of memory for
166  // persistifiable objects.
167 
168  G4Torus(const G4Torus& rhs);
169  G4Torus& operator=(const G4Torus& rhs);
170  // Copy constructor and assignment operator.
171 
172  private:
173 
174  void TorusRootsJT(const G4ThreeVector& p,
175  const G4ThreeVector& v,
176  G4double r,
177  std::vector<G4double>& roots) const ;
178 
180  const G4ThreeVector& v,
181  G4double r,
182  G4bool IsDistanceToIn) const;
183 
185  CreateRotatedVertices(const G4AffineTransform& pTransform,
186  G4int& noPolygonVertices) const;
187 
189  // Algorithm for SurfaceNormal() following the original
190  // specification for points not on the surface
191 
192  private:
193 
195 
196  // Used by distanceToOut
198 
199  // used by normal
201 
203  // Radial and angular tolerances
204 
206  // Cached half tolerance values
207 
208 };
209 
210 #include "G4Torus.icc"
211 
212 #endif
G4double GetSPhi() const
EInside Inside(const G4ThreeVector &p) const
Definition: G4Torus.cc:634
G4double fRminTolerance
Definition: G4Torus.hh:202
G4double fRmin
Definition: G4Torus.hh:194
G4Polyhedron * CreatePolyhedron() const
Definition: G4Torus.cc:1785
CLHEP::Hep3Vector G4ThreeVector
G4Torus & operator=(const G4Torus &rhs)
Definition: G4Torus.cc:214
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Torus.cc:1709
G4double fRmax
Definition: G4Torus.hh:194
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Torus.cc:989
G4double SolveNumericJT(const G4ThreeVector &p, const G4ThreeVector &v, G4double r, G4bool IsDistanceToIn) const
Definition: G4Torus.cc:295
G4double GetRmax() const
~G4Torus()
Definition: G4Torus.cc:193
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Torus.cc:414
int G4int
Definition: G4Types.hh:78
G4double GetRtor() const
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform, G4int &noPolygonVertices) const
Definition: G4Torus.cc:1613
G4double kRadTolerance
Definition: G4Torus.hh:202
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:80
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Torus.cc:745
const G4int n
G4double GetDPhi() const
G4VSolid * Clone() const
Definition: G4Torus.cc:1700
G4ThreeVector GetPointOnSurface() const
Definition: G4Torus.cc:1732
G4double fSPhi
Definition: G4Torus.hh:194
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Torus.cc:241
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Torus.cc:1187
G4double halfCarTolerance
Definition: G4Torus.hh:205
G4double kAngTolerance
Definition: G4Torus.hh:202
EInside
Definition: geomdefs.hh:58
G4double fDPhi
Definition: G4Torus.hh:194
EAxis
Definition: geomdefs.hh:54
G4double halfAngTolerance
Definition: G4Torus.hh:205
G4GeometryType GetEntityType() const
Definition: G4Torus.cc:1691
void TorusRootsJT(const G4ThreeVector &p, const G4ThreeVector &v, G4double r, std::vector< G4double > &roots) const
Definition: G4Torus.cc:255
G4double fRtor
Definition: G4Torus.hh:194
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition: G4Torus.cc:96
double G4double
Definition: G4Types.hh:76
G4double fRmaxTolerance
Definition: G4Torus.hh:202
G4double GetSurfaceArea()
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Torus.cc:1780
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition: G4Torus.cc:880