G4Tubs.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: G4Tubs.hh 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 // 
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 // 
00034 // G4Tubs
00035 //
00036 // Class description:
00037 //
00038 //   A tube or tube segment with curved sides parallel to
00039 //   the z-axis. The tube has a specified half-length along
00040 //   the z-axis, about which it is centered, and a given
00041 //   minimum and maximum radius. A minimum radius of 0
00042 //   corresponds to filled tube /cylinder. The tube segment is
00043 //   specified by starting and delta angles for phi, with 0
00044 //   being the +x axis, PI/2 the +y axis.
00045 //   A delta angle of 2PI signifies a complete, unsegmented
00046 //   tube/cylinder.
00047 //
00048 //   Member Data:
00049 //
00050 //   fRMin  Inner radius
00051 //   fRMax  Outer radius
00052 //   fDz  half length in z
00053 //
00054 //   fSPhi  The starting phi angle in radians,
00055 //          adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI
00056 //
00057 //   fDPhi  Delta angle of the segment.
00058 //
00059 //   fPhiFullTube   Boolean variable used for indicate the Phi Section
00060 
00061 // History:
00062 // 10.08.95 P.Kent: General cleanup, use G4VSolid extent helper functions
00063 //                  to CalculateExtent()
00064 // 23.01.94 P.Kent: Converted to `tolerant' geometry
00065 // 19.07.96 J.Allison: G4GraphicsScene - see G4Box
00066 // 22.07.96 J.Allison: Changed SendPolyhedronTo to CreatePolyhedron
00067 // --------------------------------------------------------------------
00068 
00069 #ifndef G4TUBS_HH
00070 #define G4TUBS_HH
00071 
00072 #include <CLHEP/Units/PhysicalConstants.h>
00073 
00074 #include "G4CSGSolid.hh"
00075 
00076 class G4Tubs : public G4CSGSolid
00077 {
00078   public:  // with description
00079 
00080     G4Tubs( const G4String& pName,
00081                   G4double pRMin,
00082                   G4double pRMax,
00083                   G4double pDz,
00084                   G4double pSPhi,
00085                   G4double pDPhi );
00086       //
00087       // Constructs a tubs with the given name and dimensions
00088 
00089     virtual ~G4Tubs();
00090       //
00091       // Destructor
00092 
00093     // Accessors
00094     
00095     inline G4double GetInnerRadius   () const;
00096     inline G4double GetOuterRadius   () const;
00097     inline G4double GetZHalfLength   () const;
00098     inline G4double GetStartPhiAngle () const;
00099     inline G4double GetDeltaPhiAngle () const;
00100 
00101     // Modifiers
00102 
00103     inline void SetInnerRadius   (G4double newRMin);
00104     inline void SetOuterRadius   (G4double newRMax);
00105     inline void SetZHalfLength   (G4double newDz);
00106     inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
00107     inline void SetDeltaPhiAngle (G4double newDPhi);
00108     
00109     // Methods for solid
00110 
00111     inline G4double GetCubicVolume();
00112     inline G4double GetSurfaceArea();
00113 
00114     void ComputeDimensions(       G4VPVParameterisation* p,
00115                             const G4int n,
00116                             const G4VPhysicalVolume* pRep );
00117 
00118     G4bool CalculateExtent( const EAxis pAxis,
00119                             const G4VoxelLimits& pVoxelLimit,
00120                             const G4AffineTransform& pTransform,
00121                                   G4double& pmin, G4double& pmax ) const;
00122 
00123     EInside Inside( const G4ThreeVector& p ) const;
00124 
00125     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
00126 
00127     G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
00128     G4double DistanceToIn(const G4ThreeVector& p) const;
00129     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
00130                            const G4bool calcNorm=G4bool(false),
00131                                  G4bool *validNorm=0, G4ThreeVector *n=0) const;
00132     G4double DistanceToOut(const G4ThreeVector& p) const;
00133 
00134     G4GeometryType GetEntityType() const;
00135 
00136     G4ThreeVector GetPointOnSurface() const;
00137 
00138     G4VSolid* Clone() const;
00139 
00140     std::ostream& StreamInfo( std::ostream& os ) const;
00141 
00142     // Visualisation functions
00143 
00144     void                DescribeYourselfTo ( G4VGraphicsScene& scene ) const;
00145     G4Polyhedron*       CreatePolyhedron   () const;
00146     G4NURBS*            CreateNURBS        () const;
00147 
00148   public:  // without description
00149 
00150     G4Tubs(__void__&);
00151       //
00152       // Fake default constructor for usage restricted to direct object
00153       // persistency for clients requiring preallocation of memory for
00154       // persistifiable objects.
00155 
00156     G4Tubs(const G4Tubs& rhs);
00157     G4Tubs& operator=(const G4Tubs& rhs); 
00158       // Copy constructor and assignment operator.
00159 
00160     //  Older names for access functions
00161 
00162     inline G4double GetRMin() const;
00163     inline G4double GetRMax() const;
00164     inline G4double GetDz  () const;
00165     inline G4double GetSPhi() const;
00166     inline G4double GetDPhi() const;
00167 
00168   protected:
00169 
00170     G4ThreeVectorList*
00171     CreateRotatedVertices( const G4AffineTransform& pTransform ) const;
00172       //
00173       // Creates the List of transformed vertices in the format required
00174       // for G4VSolid:: ClipCrossSection and ClipBetweenSections
00175 
00176     inline void Initialize();
00177       //
00178       // Reset relevant values to zero
00179 
00180     inline void CheckSPhiAngle(G4double sPhi);
00181     inline void CheckDPhiAngle(G4double dPhi);
00182     inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
00183       //
00184       // Reset relevant flags and angle values
00185 
00186     inline void InitializeTrigonometry();
00187       //
00188       // Recompute relevant trigonometric values and cache them
00189 
00190     virtual G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
00191       //
00192       // Algorithm for SurfaceNormal() following the original
00193       // specification for points not on the surface
00194 
00195   protected:
00196 
00197     // Used by distanceToOut
00198     //
00199     enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
00200 
00201     // Used by normal
00202     //
00203     enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
00204 
00205     G4double kRadTolerance, kAngTolerance;
00206       //
00207       // Radial and angular tolerances
00208 
00209     G4double fRMin, fRMax, fDz, fSPhi, fDPhi;
00210       //
00211       // Radial and angular dimensions
00212 
00213     G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
00214              sinSPhi, cosSPhi, sinEPhi, cosEPhi;
00215       //
00216       // Cached trigonometric values
00217 
00218     G4bool fPhiFullTube;
00219       //
00220       // Flag for identification of section or full tube
00221 };
00222 
00223 #include "G4Tubs.icc"
00224 
00225 #endif

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