G4Sphere.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4Sphere.hh 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 //
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 // G4Sphere
00034 //
00035 // Class description:
00036 //
00037 //   A G4Sphere is, in the general case, a section of a spherical shell,
00038 //   between specified phi and theta angles
00039 //
00040 //   The phi and theta segments are described by a starting angle,
00041 //   and the +ve delta angle for the shape.
00042 //   If the delta angle is >=2*pi, or >=pi the shape is treated as
00043 //   continuous in phi or theta respectively.
00044 //
00045 //   Theta must lie between 0-pi (incl).
00046 //
00047 //   Member Data:
00048 //
00049 //   fRmin  inner radius
00050 //   fRmax  outer radius
00051 //
00052 //   fSPhi  starting angle of the segment in radians
00053 //   fDPhi  delta angle of the segment in radians
00054 //
00055 //   fSTheta  starting angle of the segment in radians
00056 //   fDTheta  delta angle of the segment in radians
00057 //
00058 //     
00059 //   Note:
00060 //      Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
00061 //      and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
00062 //      made with (say) Phi of a point.
00063 
00064 // History:
00065 // 28.3.94 P.Kent: old C++ code converted to tolerant geometry
00066 // 17.9.96 V.Grichine: final modifications to commit
00067 // --------------------------------------------------------------------
00068 
00069 #ifndef G4Sphere_HH
00070 #define G4Sphere_HH
00071 
00072 #include <CLHEP/Units/PhysicalConstants.h>
00073 #include "G4CSGSolid.hh"
00074 
00075 class G4VisExtent;
00076 
00077 class G4Sphere : public G4CSGSolid
00078 {
00079   public:  // with description
00080 
00081     G4Sphere(const G4String& pName,
00082                    G4double pRmin, G4double pRmax,
00083                    G4double pSPhi, G4double pDPhi,
00084                    G4double pSTheta, G4double pDTheta);
00085       //
00086       // Constructs a sphere or sphere shell section
00087       // with the given name and dimensions
00088        
00089    ~G4Sphere();
00090       //
00091       // Destructor
00092 
00093     // Accessors
00094        
00095     inline G4double GetInnerRadius    () const;
00096     inline G4double GetOuterRadius    () const;
00097     inline G4double GetStartPhiAngle  () const;
00098     inline G4double GetDeltaPhiAngle  () const;
00099     inline G4double GetStartThetaAngle() const;
00100     inline G4double GetDeltaThetaAngle() const;
00101 
00102     // Modifiers
00103 
00104     inline void SetInnerRadius    (G4double newRMin);
00105     inline void SetOuterRadius    (G4double newRmax);
00106     inline void SetStartPhiAngle  (G4double newSphi, G4bool trig=true);
00107     inline void SetDeltaPhiAngle  (G4double newDphi);
00108     inline void SetStartThetaAngle(G4double newSTheta);
00109     inline void SetDeltaThetaAngle(G4double newDTheta);
00110 
00111     // Methods for solid
00112 
00113     inline G4double GetCubicVolume();
00114     G4double GetSurfaceArea();
00115 
00116     void ComputeDimensions(      G4VPVParameterisation* p,
00117                            const G4int n,
00118                            const G4VPhysicalVolume* pRep);
00119 
00120     G4bool CalculateExtent(const EAxis pAxis,
00121                            const G4VoxelLimits& pVoxelLimit,
00122                            const G4AffineTransform& pTransform,
00123                                  G4double& pmin, G4double& pmax) const;
00124          
00125     EInside Inside(const G4ThreeVector& p) const;
00126 
00127     G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
00128 
00129     G4double DistanceToIn(const G4ThreeVector& p,
00130                           const G4ThreeVector& v) const;
00131     
00132     G4double DistanceToIn(const G4ThreeVector& p) const;
00133     
00134     G4double DistanceToOut(const G4ThreeVector& p,
00135                            const G4ThreeVector& v,
00136                            const G4bool calcNorm=G4bool(false),
00137                                  G4bool *validNorm=0,
00138                                  G4ThreeVector *n=0) const;
00139          
00140     G4double DistanceToOut(const G4ThreeVector& p) const;
00141 
00142     G4GeometryType GetEntityType() const;
00143  
00144     G4ThreeVector GetPointOnSurface() const;
00145 
00146     G4VSolid* Clone() const;
00147 
00148     std::ostream& StreamInfo(std::ostream& os) const;
00149 
00150     // Visualisation functions
00151 
00152     G4VisExtent   GetExtent          () const;    
00153     void          DescribeYourselfTo(G4VGraphicsScene& scene) const;
00154     G4Polyhedron* CreatePolyhedron() const;
00155     G4NURBS*      CreateNURBS() const;
00156   
00157   public:  // without description
00158    
00159     G4Sphere(__void__&);
00160       //
00161       // Fake default constructor for usage restricted to direct object
00162       // persistency for clients requiring preallocation of memory for
00163       // persistifiable objects.
00164 
00165     G4Sphere(const G4Sphere& rhs);
00166     G4Sphere& operator=(const G4Sphere& rhs); 
00167       // Copy constructor and assignment operator.
00168 
00169     // Old access functions
00170 
00171     inline G4double  GetRmin()   const;
00172     inline G4double  GetRmax()   const;
00173     inline G4double  GetSPhi()   const;
00174     inline G4double  GetDPhi()   const;
00175     inline G4double  GetSTheta() const;
00176     inline G4double  GetDTheta() const;
00177     inline G4double  GetInsideRadius() const;
00178     inline void SetInsideRadius(G4double newRmin);
00179 
00180   private:
00181  
00182     G4ThreeVectorList*
00183     CreateRotatedVertices(const G4AffineTransform& pTransform,
00184                                 G4int& noPolygonVertices) const;
00185       //
00186       // Creates the List of transformed vertices in the format required
00187       // for G4VSolid:: ClipCrossSection and ClipBetweenSections
00188 
00189     inline void Initialize();
00190       //
00191       // Reset relevant values to zero
00192 
00193     inline void CheckThetaAngles(G4double sTheta, G4double dTheta);
00194     inline void CheckSPhiAngle(G4double sPhi);
00195     inline void CheckDPhiAngle(G4double dPhi);
00196     inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
00197       //
00198       // Reset relevant flags and angle values
00199 
00200     inline void InitializePhiTrigonometry();
00201     inline void InitializeThetaTrigonometry();
00202       //
00203       // Recompute relevant trigonometric values and cache them
00204 
00205     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
00206       //
00207       // Algorithm for SurfaceNormal() following the original
00208       // specification for points not on the surface
00209 
00210   private:
00211 
00212     // Used by distanceToOut
00213     //
00214     enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kSTheta,kETheta};
00215   
00216     // used by normal
00217     //
00218     enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNSTheta,kNETheta};
00219 
00220     G4double fRminTolerance, fRmaxTolerance, kAngTolerance,
00221              kRadTolerance, fEpsilon;
00222       //
00223       // Radial and angular tolerances
00224 
00225     G4double fRmin, fRmax, fSPhi, fDPhi, fSTheta, fDTheta;
00226       //
00227       // Radial and angular dimensions
00228 
00229     G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
00230              sinSPhi, cosSPhi, sinEPhi, cosEPhi, hDPhi, cPhi, ePhi;
00231       //
00232       // Cached trigonometric values for Phi angle
00233 
00234     G4double sinSTheta, cosSTheta, sinETheta, cosETheta,
00235              tanSTheta, tanSTheta2, tanETheta, tanETheta2, eTheta;
00236       //
00237       // Cached trigonometric values for Theta angle
00238 
00239     G4bool fFullPhiSphere, fFullThetaSphere, fFullSphere;
00240       //
00241       // Flags for identification of section, shell or full sphere
00242 };
00243 
00244 #include "G4Sphere.icc"
00245 
00246 #endif

Generated on Mon May 27 17:49:52 2013 for Geant4 by  doxygen 1.4.7