Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 100820 2016-11-02 15:18:48Z 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 // Member Data:
60 //
61 // fRmin Inside radius
62 // fRmax Outside radius
63 // fRtor swept radius of torus
64 //
65 // fSPhi The starting phi angle in radians,
66 // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
67 //
68 // fDPhi Delta angle of the segment in radians
69 //
70 // You could find very often in G4Torus functions values like 'pt' or
71 // 'it'. These are the distances from p or i G4ThreeVector points in the
72 // plane (Z axis points p or i) to fRtor point in XY plane. This value is
73 // similar to rho for G4Tubs and is used for definiton of the point
74 // relative to fRmin and fRmax, i.e. for solution of inside/outside
75 // problems
76 
77 // History:
78 // 30.10.96 V.Grichine: first version of G4Torus
79 // 21.04.98 J.Apostolakis: added SetAllParameters() function
80 // 26.05.00 V.Grichine: added new SolveBiQuadratic/Cubic() developed
81 // by O.Cremonesi
82 // 31.08.00 E.Medernach: added SolveNumeric functions, migrated to
83 // numeric solutions
84 // --------------------------------------------------------------------
85 
86 #ifndef G4TORUS_HH
87 #define G4TORUS_HH
88 
89 #if defined(G4GEOM_USE_USOLIDS)
90 #define G4GEOM_USE_UTORUS 1
91 #endif
92 
93 #if (defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS))
94  #define G4UTorus G4Torus
95  #include "G4UTorus.hh"
96 #else
97 
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  inline G4double GetSinStartPhi () const;
124  inline G4double GetCosStartPhi () const;
125  inline G4double GetSinEndPhi () const;
126  inline G4double GetCosEndPhi () const;
127 
128  // Methods of solid
129 
130  inline G4double GetCubicVolume();
131  inline G4double GetSurfaceArea();
132 
133  EInside Inside(const G4ThreeVector& p) const;
134  void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
135  G4bool CalculateExtent(const EAxis pAxis,
136  const G4VoxelLimits& pVoxelLimit,
137  const G4AffineTransform& pTransform,
138  G4double& pmin, G4double& pmax) const;
140  const G4int n,
141  const G4VPhysicalVolume* pRep);
142  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
143  G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
144  G4double DistanceToIn(const G4ThreeVector& p) const;
146  const G4bool calcNorm=G4bool(false),
147  G4bool *validNorm=0,G4ThreeVector *n=0) const;
148  G4double DistanceToOut(const G4ThreeVector& p) const;
149 
151 
153 
154  G4VSolid* Clone() const;
155 
156  std::ostream& StreamInfo(std::ostream& os) const;
157 
158  // Visualisation functions
159 
160  void DescribeYourselfTo (G4VGraphicsScene& scene) const;
161  G4Polyhedron* CreatePolyhedron () const;
162 
163  public: // without description
164 
165  void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
166  G4double pSPhi, G4double pDPhi);
167 
168  G4Torus(__void__&);
169  // Fake default constructor for usage restricted to direct object
170  // persistency for clients requiring preallocation of memory for
171  // persistifiable objects.
172 
173  G4Torus(const G4Torus& rhs);
174  G4Torus& operator=(const G4Torus& rhs);
175  // Copy constructor and assignment operator.
176 
177  private:
178 
179  void TorusRootsJT(const G4ThreeVector& p,
180  const G4ThreeVector& v,
181  G4double r,
182  std::vector<G4double>& roots) const ;
183 
184  G4double SolveNumericJT(const G4ThreeVector& p,
185  const G4ThreeVector& v,
186  G4double r,
187  G4bool IsDistanceToIn) 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  G4double halfCarTolerance, halfAngTolerance;
207  // Cached half tolerance values
208 
209 };
210 
211 #include "G4Torus.icc"
212 
213 #endif // defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS)
214 
215 
216 #endif // G4TORUS_HH
G4double GetSPhi() const
EInside Inside(const G4ThreeVector &p) const
Definition: G4Torus.cc:599
G4Polyhedron * CreatePolyhedron() const
Definition: G4Torus.cc:1641
G4Torus & operator=(const G4Torus &rhs)
Definition: G4Torus.cc:221
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Torus.cc:1565
const char * p
Definition: xmltok.h:285
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Torus.cc:947
G4double GetRmax() const
~G4Torus()
Definition: G4Torus.cc:200
G4double GetSinStartPhi() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Torus.cc:461
int G4int
Definition: G4Types.hh:78
G4double GetRtor() const
G4double GetSinEndPhi() const
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Torus.cc:417
G4double GetRmin() const
G4double GetCubicVolume()
G4double GetCosEndPhi() const
bool G4bool
Definition: G4Types.hh:79
G4Torus(const G4String &pName, G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition: G4Torus.cc:87
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Torus.cc:710
const G4int n
G4double GetDPhi() const
tuple v
Definition: test.py:18
G4VSolid * Clone() const
Definition: G4Torus.cc:1556
G4ThreeVector GetPointOnSurface() const
Definition: G4Torus.cc:1588
G4double GetCosStartPhi() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Torus.cc:248
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Torus.cc:1140
EInside
Definition: geomdefs.hh:58
EAxis
Definition: geomdefs.hh:54
G4GeometryType GetEntityType() const
Definition: G4Torus.cc:1547
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi)
Definition: G4Torus.cc:103
double G4double
Definition: G4Types.hh:76
G4double GetSurfaceArea()
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Torus.cc:1636