Geant4  10.01.p01
G4Sphere.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: G4Sphere.hh 79491 2014-03-05 15:24:29Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // G4Sphere
34 //
35 // Class description:
36 //
37 // A G4Sphere is, in the general case, a section of a spherical shell,
38 // between specified phi and theta angles
39 //
40 // The phi and theta segments are described by a starting angle,
41 // and the +ve delta angle for the shape.
42 // If the delta angle is >=2*pi, or >=pi the shape is treated as
43 // continuous in phi or theta respectively.
44 //
45 // Theta must lie between 0-pi (incl).
46 //
47 // Member Data:
48 //
49 // fRmin inner radius
50 // fRmax outer radius
51 //
52 // fSPhi starting angle of the segment in radians
53 // fDPhi delta angle of the segment in radians
54 //
55 // fSTheta starting angle of the segment in radians
56 // fDTheta delta angle of the segment in radians
57 //
58 //
59 // Note:
60 // Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
61 // and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
62 // made with (say) Phi of a point.
63 
64 // History:
65 // 28.3.94 P.Kent: old C++ code converted to tolerant geometry
66 // 17.9.96 V.Grichine: final modifications to commit
67 // --------------------------------------------------------------------
68 
69 #ifndef G4Sphere_HH
70 #define G4Sphere_HH
71 
72 #if defined(G4GEOM_USE_USOLIDS)
73 #define G4GEOM_USE_USPHERE 1
74 #endif
75 
76 #if defined(G4GEOM_USE_USPHERE)
77  #define G4USphere G4Sphere
78  #include "G4USphere.hh"
79 #else
80 
81 #include <CLHEP/Units/PhysicalConstants.h>
82 #include "G4CSGSolid.hh"
83 #include "G4Polyhedron.hh"
84 
85 class G4VisExtent;
86 
87 class G4Sphere : public G4CSGSolid
88 {
89  public: // with description
90 
91  G4Sphere(const G4String& pName,
92  G4double pRmin, G4double pRmax,
93  G4double pSPhi, G4double pDPhi,
94  G4double pSTheta, G4double pDTheta);
95  //
96  // Constructs a sphere or sphere shell section
97  // with the given name and dimensions
98 
99  ~G4Sphere();
100  //
101  // Destructor
102 
103  // Accessors
104 
105  inline G4double GetInnerRadius () const;
106  inline G4double GetOuterRadius () const;
107  inline G4double GetStartPhiAngle () const;
108  inline G4double GetDeltaPhiAngle () const;
109  inline G4double GetStartThetaAngle() const;
110  inline G4double GetDeltaThetaAngle() const;
111 
112  // Modifiers
113 
114  inline void SetInnerRadius (G4double newRMin);
115  inline void SetOuterRadius (G4double newRmax);
116  inline void SetStartPhiAngle (G4double newSphi, G4bool trig=true);
117  inline void SetDeltaPhiAngle (G4double newDphi);
118  inline void SetStartThetaAngle(G4double newSTheta);
119  inline void SetDeltaThetaAngle(G4double newDTheta);
120 
121  // Methods for solid
122 
123  inline G4double GetCubicVolume();
125 
127  const G4int n,
128  const G4VPhysicalVolume* pRep);
129 
130  G4bool CalculateExtent(const EAxis pAxis,
131  const G4VoxelLimits& pVoxelLimit,
132  const G4AffineTransform& pTransform,
133  G4double& pmin, G4double& pmax) const;
134 
135  EInside Inside(const G4ThreeVector& p) const;
136 
137  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
138 
140  const G4ThreeVector& v) const;
141 
142  G4double DistanceToIn(const G4ThreeVector& p) const;
143 
145  const G4ThreeVector& v,
146  const G4bool calcNorm=G4bool(false),
147  G4bool *validNorm=0,
148  G4ThreeVector *n=0) const;
149 
150  G4double DistanceToOut(const G4ThreeVector& p) const;
151 
153 
155 
156  G4VSolid* Clone() const;
157 
158  std::ostream& StreamInfo(std::ostream& os) const;
159 
160  // Visualisation functions
161 
162  G4VisExtent GetExtent () const;
163  void DescribeYourselfTo(G4VGraphicsScene& scene) const;
165 
166  public: // without description
167 
168  G4Sphere(__void__&);
169  //
170  // Fake default constructor for usage restricted to direct object
171  // persistency for clients requiring preallocation of memory for
172  // persistifiable objects.
173 
174  G4Sphere(const G4Sphere& rhs);
175  G4Sphere& operator=(const G4Sphere& rhs);
176  // Copy constructor and assignment operator.
177 
178  // Old access functions
179 
180  inline G4double GetRmin() const;
181  inline G4double GetRmax() const;
182  inline G4double GetSPhi() const;
183  inline G4double GetDPhi() const;
184  inline G4double GetSTheta() const;
185  inline G4double GetDTheta() const;
186  inline G4double GetInsideRadius() const;
187  inline void SetInsideRadius(G4double newRmin);
188 
189  private:
190 
192  CreateRotatedVertices(const G4AffineTransform& pTransform,
193  G4int& noPolygonVertices) const;
194  //
195  // Creates the List of transformed vertices in the format required
196  // for G4VSolid:: ClipCrossSection and ClipBetweenSections
197 
198  inline void Initialize();
199  //
200  // Reset relevant values to zero
201 
202  inline void CheckThetaAngles(G4double sTheta, G4double dTheta);
203  inline void CheckSPhiAngle(G4double sPhi);
204  inline void CheckDPhiAngle(G4double dPhi);
205  inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
206  //
207  // Reset relevant flags and angle values
208 
209  inline void InitializePhiTrigonometry();
210  inline void InitializeThetaTrigonometry();
211  //
212  // Recompute relevant trigonometric values and cache them
213 
215  //
216  // Algorithm for SurfaceNormal() following the original
217  // specification for points not on the surface
218 
219  private:
220 
221  // Used by distanceToOut
222  //
224 
225  // used by normal
226  //
228 
231  //
232  // Radial and angular tolerances
233 
235  //
236  // Radial and angular dimensions
237 
240  //
241  // Cached trigonometric values for Phi angle
242 
245  //
246  // Cached trigonometric values for Theta angle
247 
249  //
250  // Flags for identification of section, shell or full sphere
251 
253  //
254  // Cached half tolerance values
255 };
256 
257 #include "G4Sphere.icc"
258 
259 #endif
260 
261 #endif
G4double ePhi
Definition: G4Sphere.hh:238
G4bool fFullSphere
Definition: G4Sphere.hh:248
void InitializeThetaTrigonometry()
G4double fDTheta
Definition: G4Sphere.hh:234
G4double fDPhi
Definition: G4Sphere.hh:234
G4double halfCarTolerance
Definition: G4Sphere.hh:252
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Sphere.cc:871
G4double fEpsilon
Definition: G4Sphere.hh:229
void SetStartPhiAngle(G4double newSphi, G4bool trig=true)
CLHEP::Hep3Vector G4ThreeVector
G4double tanETheta2
Definition: G4Sphere.hh:243
G4double fSTheta
Definition: G4Sphere.hh:234
G4double fRmin
Definition: G4Sphere.hh:234
G4double fRminTolerance
Definition: G4Sphere.hh:229
G4double hDPhi
Definition: G4Sphere.hh:238
void CheckSPhiAngle(G4double sPhi)
G4Polyhedron * CreatePolyhedron() const
Definition: G4Sphere.cc:3182
G4double GetInsideRadius() const
G4double fSPhi
Definition: G4Sphere.hh:234
void InitializePhiTrigonometry()
G4double GetDeltaPhiAngle() const
int G4int
Definition: G4Types.hh:78
G4Sphere(const G4String &pName, G4double pRmin, G4double pRmax, G4double pSPhi, G4double pDPhi, G4double pSTheta, G4double pDTheta)
Definition: G4Sphere.cc:89
void CheckDPhiAngle(G4double dPhi)
G4double cosSTheta
Definition: G4Sphere.hh:243
G4double sinSPhi
Definition: G4Sphere.hh:238
G4ThreeVector GetPointOnSurface() const
Definition: G4Sphere.cc:3042
G4double GetSPhi() const
~G4Sphere()
Definition: G4Sphere.cc:144
void SetDeltaThetaAngle(G4double newDTheta)
G4double cosHDPhiOT
Definition: G4Sphere.hh:238
void SetStartThetaAngle(G4double newSTheta)
G4double GetRmin() const
G4double GetDPhi() const
G4double sinEPhi
Definition: G4Sphere.hh:238
G4double GetStartThetaAngle() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Sphere.cc:227
G4double GetDTheta() const
void CheckThetaAngles(G4double sTheta, G4double dTheta)
G4double fRmax
Definition: G4Sphere.hh:234
bool G4bool
Definition: G4Types.hh:79
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Sphere.cc:1899
G4double tanSTheta
Definition: G4Sphere.hh:243
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform, G4int &noPolygonVertices) const
Definition: G4Sphere.cc:2873
EInside Inside(const G4ThreeVector &p) const
Definition: G4Sphere.cc:472
G4double cosSPhi
Definition: G4Sphere.hh:238
void CheckPhiAngles(G4double sPhi, G4double dPhi)
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4GeometryType GetEntityType() const
Definition: G4Sphere.cc:3000
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Sphere.cc:569
const G4int n
G4double sinCPhi
Definition: G4Sphere.hh:238
void SetOuterRadius(G4double newRmax)
void SetInsideRadius(G4double newRmin)
G4double GetInnerRadius() const
G4double cosETheta
Definition: G4Sphere.hh:243
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition: G4Sphere.cc:698
G4VSolid * Clone() const
Definition: G4Sphere.cc:3009
G4Sphere & operator=(const G4Sphere &rhs)
Definition: G4Sphere.cc:178
G4double fRmaxTolerance
Definition: G4Sphere.hh:229
G4double tanSTheta2
Definition: G4Sphere.hh:243
G4double GetRmax() const
void SetDeltaPhiAngle(G4double newDphi)
G4double kRadTolerance
Definition: G4Sphere.hh:229
G4double tanETheta
Definition: G4Sphere.hh:243
G4double eTheta
Definition: G4Sphere.hh:243
EInside
Definition: geomdefs.hh:58
G4bool fFullPhiSphere
Definition: G4Sphere.hh:248
EAxis
Definition: geomdefs.hh:54
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Sphere.cc:3018
G4double sinETheta
Definition: G4Sphere.hh:243
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Sphere.cc:216
G4double cPhi
Definition: G4Sphere.hh:238
G4VisExtent GetExtent() const
Definition: G4Sphere.cc:3171
G4double GetSurfaceArea()
Definition: G4Sphere.cc:3124
G4double kAngTolerance
Definition: G4Sphere.hh:229
void SetInnerRadius(G4double newRMin)
G4double GetSTheta() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4double cosEPhi
Definition: G4Sphere.hh:238
void Initialize()
double G4double
Definition: G4Types.hh:76
G4double GetCubicVolume()
G4double sinSTheta
Definition: G4Sphere.hh:243
G4double GetDeltaThetaAngle() const
G4double halfAngTolerance
Definition: G4Sphere.hh:252
G4double cosHDPhiIT
Definition: G4Sphere.hh:238
G4bool fFullThetaSphere
Definition: G4Sphere.hh:248
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Sphere.cc:3177
G4double cosCPhi
Definition: G4Sphere.hh:238