G4Cons.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: G4Cons.hh 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 //
00030 // --------------------------------------------------------------------
00031 // GEANT 4 class header file
00032 //
00033 // G4Cons
00034 //
00035 // Class description:
00036 //
00037 //   A G4Cons is, in the general case, a Phi segment of a cone, with
00038 //   half-length fDz, inner and outer radii specified at -fDz and +fDz.
00039 //   The Phi segment is described by a starting fSPhi angle, and the
00040 //   +fDPhi delta angle for the shape.
00041 //   If the delta angle is >=2*pi, the shape is treated as continuous
00042 //   in Phi
00043 //
00044 //   Member Data:
00045 //
00046 //  fRmin1  inside radius at  -fDz
00047 //  fRmin2  inside radius at  +fDz
00048 //  fRmax1  outside radius at -fDz
00049 //  fRmax2  outside radius at +fDz
00050 //  fDz  half length in z
00051 //
00052 //  fSPhi  starting angle of the segment in radians
00053 //  fDPhi  delta angle of the segment in radians
00054 //
00055 //  fPhiFullCone   Boolean variable used for indicate the Phi Section
00056 //
00057 //   Note:
00058 //      Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
00059 //      and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
00060 //      made with (say) Phi of a point.
00061 
00062 // History:
00063 // 19.3.94 P.Kent: Old C++ code converted to tolerant geometry
00064 // 13.9.96 V.Grichine: Final modifications to commit
00065 // --------------------------------------------------------------------
00066 
00067 #ifndef G4Cons_HH
00068 #define G4Cons_HH
00069 
00070 #include <CLHEP/Units/PhysicalConstants.h>
00071 
00072 #include "G4CSGSolid.hh"
00073 
00074 class G4Cons : public G4CSGSolid
00075 {
00076   public:  // with description
00077 
00078     G4Cons(const G4String& pName,
00079                  G4double pRmin1, G4double pRmax1,
00080                  G4double pRmin2, G4double pRmax2,
00081                  G4double pDz,
00082                  G4double pSPhi, G4double pDPhi);
00083       //
00084       // Constructs a cone with the given name and dimensions
00085 
00086    ~G4Cons() ;
00087       //
00088       // Destructor
00089 
00090     // Accessors
00091 
00092     inline G4double GetInnerRadiusMinusZ() const;
00093     inline G4double GetOuterRadiusMinusZ() const;
00094     inline G4double GetInnerRadiusPlusZ()  const;
00095     inline G4double GetOuterRadiusPlusZ()  const;
00096     inline G4double GetZHalfLength()       const;
00097     inline G4double GetStartPhiAngle()     const;
00098     inline G4double GetDeltaPhiAngle()     const;
00099   
00100     // Modifiers
00101 
00102     inline void SetInnerRadiusMinusZ (G4double Rmin1 );
00103     inline void SetOuterRadiusMinusZ (G4double Rmax1 );
00104     inline void SetInnerRadiusPlusZ  (G4double Rmin2 );
00105     inline void SetOuterRadiusPlusZ  (G4double Rmax2 );
00106     inline void SetZHalfLength       (G4double newDz );
00107     inline void SetStartPhiAngle     (G4double newSPhi, G4bool trig=true);
00108     inline void SetDeltaPhiAngle     (G4double newDPhi);
00109 
00110     // Other methods for solid
00111 
00112     inline G4double GetCubicVolume();
00113     inline G4double GetSurfaceArea();
00114 
00115     void ComputeDimensions(       G4VPVParameterisation* p,
00116                             const G4int n,
00117                             const G4VPhysicalVolume* pRep );
00118 
00119     G4bool CalculateExtent( const EAxis pAxis,
00120                             const G4VoxelLimits& pVoxelLimit,
00121                             const G4AffineTransform& pTransform,
00122                                   G4double& pmin, G4double& pmax ) const;         
00123 
00124     EInside Inside( const G4ThreeVector& p ) const;
00125 
00126     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
00127 
00128     G4double DistanceToIn (const G4ThreeVector& p,
00129                            const G4ThreeVector& v) const;
00130     G4double DistanceToIn (const G4ThreeVector& p) const;
00131     G4double DistanceToOut(const G4ThreeVector& p,
00132                            const G4ThreeVector& v,
00133                            const G4bool calcNorm=G4bool(false),
00134                                  G4bool *validNorm=0,
00135                                  G4ThreeVector *n=0) const;             
00136     G4double DistanceToOut(const G4ThreeVector& p) const;
00137 
00138     G4GeometryType GetEntityType() const;
00139         
00140     G4ThreeVector GetPointOnSurface() const; 
00141         
00142     G4VSolid* Clone() const;
00143 
00144     std::ostream& StreamInfo(std::ostream& os) const;
00145 
00146     // Visualisation functions
00147 
00148     void          DescribeYourselfTo( G4VGraphicsScene& scene ) const;
00149     G4Polyhedron* CreatePolyhedron() const;
00150     G4NURBS*      CreateNURBS() const;
00151 
00152   public:  // without description
00153        
00154     G4Cons(__void__&);
00155       //
00156       // Fake default constructor for usage restricted to direct object
00157       // persistency for clients requiring preallocation of memory for
00158       // persistifiable objects.
00159 
00160     G4Cons(const G4Cons& rhs);
00161     G4Cons& operator=(const G4Cons& rhs); 
00162       // Copy constructor and assignment operator.
00163 
00164     //  Old access functions
00165 
00166     inline G4double    GetRmin1() const;
00167     inline G4double    GetRmax1() const;
00168     inline G4double    GetRmin2() const;
00169     inline G4double    GetRmax2() const;
00170     inline G4double    GetDz()    const;
00171     inline G4double    GetSPhi() const;
00172     inline G4double    GetDPhi() const;
00173 
00174   private:
00175  
00176     G4ThreeVectorList*
00177     CreateRotatedVertices(const G4AffineTransform& pTransform) const;
00178   
00179     inline void Initialize();
00180       //
00181       // Reset relevant values to zero
00182 
00183     inline void CheckSPhiAngle(G4double sPhi);
00184     inline void CheckDPhiAngle(G4double dPhi);
00185     inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
00186       //
00187       // Reset relevant flags and angle values
00188 
00189     inline void InitializeTrigonometry();
00190       //
00191       // Recompute relevant trigonometric values and cache them
00192 
00193     G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
00194       //
00195       // Algorithm for SurfaceNormal() following the original
00196       // specification for points not on the surface
00197 
00198   private:
00199 
00200     // Used by distanceToOut
00201     //
00202     enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
00203   
00204     // used by normal
00205     //
00206     enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
00207 
00208     G4double kRadTolerance, kAngTolerance;
00209       //
00210       // Radial and angular tolerances
00211 
00212     G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi;
00213       //
00214       // Radial and angular dimensions
00215 
00216     G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
00217              sinSPhi, cosSPhi, sinEPhi, cosEPhi;
00218       //
00219       // Cached trigonometric values
00220 
00221     G4bool fPhiFullCone;
00222       //
00223       // Flag for identification of section or full cone
00224 };
00225 
00226 #include "G4Cons.icc"
00227 
00228 #endif

Generated on Mon May 27 17:47:57 2013 for Geant4 by  doxygen 1.4.7