G4Torus.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: G4Torus.hh 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 // 
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 // G4Torus
00034 //
00035 // Class description:
00036 //
00037 //   A torus or torus segment with curved sides parallel to the z-axis.
00038 //   The torus has a specified swept radius about which it is centered,
00039 //   and a given minimum and maximum radius. A minimum radius of 0
00040 //   signifies a filled torus.
00041 //   The torus segment is specified by starting and delta angles for phi,
00042 //   with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI
00043 //   signifies a complete, unsegmented torus/cylindr.
00044 //
00045 //   Member functions:
00046 //
00047 //   As inherited from G4CSGSolid+
00048 //
00049 //     G4Torus(const G4String      &pName
00050 //             G4double      pRmin
00051 //             G4double      pRmax
00052 //             G4double      pRtor
00053 //             G4double      pSPhi
00054 //             G4double      pDPhi )
00055 //
00056 //     - Construct a torus with the given name and dimensions.
00057 //       The angles are provided is radians. pRtor >= pRmax
00058 //
00059 //
00060 //   Protected:
00061 //
00062 //     G4ThreeVectorList*
00063 //     CreateRotatedVertices(const G4AffineTransform& pTransform) const
00064 //
00065 //     - Create the List of transformed vertices in the format required
00066 //       for G4VSolid:: ClipCrossSection and ClipBetweenSections.
00067 //   
00068 //   Member Data:
00069 //
00070 //  fRmin  Inside radius
00071 //  fRmax  Outside radius
00072 //  fRtor  swept radius of torus
00073 //
00074 //  fSPhi  The starting phi angle in radians,
00075 //         adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
00076 //
00077 //  fDPhi  Delta angle of the segment in radians
00078 //
00079 //   You could find very often in G4Torus functions values like 'pt' or
00080 //   'it'. These are the distances from p or i G4ThreeVector points in the
00081 //   plane (Z axis points p or i) to fRtor point in XY plane. This value is
00082 //   similar to rho for G4Tubs and is used for definiton of the point
00083 //   relative to fRmin and fRmax, i.e. for solution of inside/outside
00084 //   problems
00085  
00086 // History:
00087 // 30.10.96 V.Grichine: first version of G4Torus
00088 // 21.04.98 J.Apostolakis: added SetAllParameters() function
00089 // 26.05.00 V.Grichine: added new SolveBiQuadratic/Cubic() developed
00090 //                      by O.Cremonesi 
00091 // 31.08.00 E.Medernach: added SolveNumeric functions, migrated to
00092 //                       numeric solutions 
00093 // --------------------------------------------------------------------
00094 
00095 #ifndef G4Torus_HH
00096 #define G4Torus_HH
00097 
00098 #include <CLHEP/Units/PhysicalConstants.h>
00099 
00100 #include "G4CSGSolid.hh"
00101 
00102 class G4Torus : public G4CSGSolid
00103 {
00104 
00105   public:  // with description
00106 
00107     G4Torus(const G4String &pName,
00108                   G4double pRmin,
00109                   G4double pRmax,
00110                   G4double pRtor,
00111                   G4double pSPhi,
00112                   G4double pDPhi);
00113 
00114    ~G4Torus();
00115     
00116     // Accessors
00117 
00118     inline G4double GetRmin() const;
00119     inline G4double GetRmax() const;
00120     inline G4double GetRtor() const;
00121     inline G4double GetSPhi() const;
00122     inline G4double GetDPhi() const;
00123 
00124     // Methods of solid
00125 
00126     inline G4double GetCubicVolume();
00127     inline G4double GetSurfaceArea();
00128 
00129     EInside Inside(const G4ThreeVector& p) const;
00130     G4bool CalculateExtent(const EAxis pAxis,
00131                            const G4VoxelLimits& pVoxelLimit,
00132                            const G4AffineTransform& pTransform,
00133                                  G4double& pmin, G4double& pmax) const;
00134     void ComputeDimensions(      G4VPVParameterisation* p,
00135                            const G4int n,
00136                            const G4VPhysicalVolume* pRep);
00137     G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
00138     G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
00139     G4double DistanceToIn(const G4ThreeVector& p) const;
00140     G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
00141                            const G4bool calcNorm=G4bool(false),
00142                                  G4bool *validNorm=0,G4ThreeVector *n=0) const;
00143     G4double DistanceToOut(const G4ThreeVector& p) const;
00144 
00145     G4GeometryType GetEntityType() const;
00146 
00147     G4ThreeVector GetPointOnSurface() const;
00148 
00149     G4VSolid* Clone() const;
00150 
00151     std::ostream& StreamInfo(std::ostream& os) const;
00152 
00153     // Visualisation functions
00154 
00155     void                DescribeYourselfTo (G4VGraphicsScene& scene) const;
00156     G4Polyhedron*       CreatePolyhedron   () const;
00157     G4NURBS*            CreateNURBS        () const;
00158 
00159   public:  // without description
00160 
00161     void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
00162                           G4double pSPhi, G4double pDPhi);
00163  
00164     G4Torus(__void__&);
00165       // Fake default constructor for usage restricted to direct object
00166       // persistency for clients requiring preallocation of memory for
00167       // persistifiable objects.
00168 
00169     G4Torus(const G4Torus& rhs);
00170     G4Torus& operator=(const G4Torus& rhs); 
00171       // Copy constructor and assignment operator.
00172 
00173   private:
00174 
00175     void TorusRootsJT(const G4ThreeVector& p,
00176                       const G4ThreeVector& v,
00177                             G4double r,
00178                             std::vector<G4double>& roots) const ;
00179 
00180     G4double SolveNumericJT(const G4ThreeVector& p,
00181                             const G4ThreeVector& v,
00182                                   G4double r,
00183                                   G4bool IsDistanceToIn) const;
00184 
00185     G4ThreeVectorList*
00186     CreateRotatedVertices(const G4AffineTransform& pTransform,
00187                                 G4int& noPolygonVertices) const;
00188 
00189     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
00190       // Algorithm for SurfaceNormal() following the original
00191       // specification for points not on the surface
00192 
00193   private:
00194 
00195     G4double fRmin,fRmax,fRtor,fSPhi,fDPhi;
00196 
00197     // Used by distanceToOut
00198     enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi};
00199 
00200     // used by normal
00201     enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi};
00202     
00203     G4double fRminTolerance, fRmaxTolerance, kRadTolerance, kAngTolerance;
00204       // Radial and angular tolerances
00205 };
00206 
00207 #include "G4Torus.icc"
00208 
00209 #endif

Generated on Mon May 27 17:50:00 2013 for Geant4 by  doxygen 1.4.7