Geant4 Cross Reference |
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 // G4Tubs 27 // 28 // Class description: 29 // 30 // A tube or tube segment with curved sides parallel to 31 // the z-axis. The tube has a specified half-length along 32 // the z-axis, about which it is centered, and a given 33 // minimum and maximum radius. A minimum radius of 0 34 // corresponds to filled tube /cylinder. The tube segment is 35 // specified by starting and delta angles for phi, with 0 36 // being the +x axis, PI/2 the +y axis. 37 // A delta angle of 2PI signifies a complete, unsegmented 38 // tube/cylinder. 39 // 40 // Member Data: 41 // 42 // fRMin Inner radius 43 // fRMax Outer radius 44 // fDz half length in z 45 // 46 // fSPhi The starting phi angle in radians, 47 // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI 48 // 49 // fDPhi Delta angle of the segment. 50 // 51 // fPhiFullTube Boolean variable used for indicate the Phi Section 52 53 // 23.01.94 P.Kent: First version. Converted to `tolerant' geometry 54 // -------------------------------------------------------------------- 55 #ifndef G4TUBS_HH 56 #define G4TUBS_HH 57 58 #include "G4GeomTypes.hh" 59 60 #if defined(G4GEOM_USE_USOLIDS) 61 #define G4GEOM_USE_UTUBS 1 62 #endif 63 64 #if defined(G4GEOM_USE_UTUBS) 65 #define G4UTubs G4Tubs 66 #include "G4UTubs.hh" 67 #else 68 69 #include <CLHEP/Units/PhysicalConstants.h> 70 71 #include "G4CSGSolid.hh" 72 #include "G4Polyhedron.hh" 73 74 class G4Tubs : public G4CSGSolid 75 { 76 public: 77 78 G4Tubs( const G4String& pName, 79 G4double pRMin, 80 G4double pRMax, 81 G4double pDz, 82 G4double pSPhi, 83 G4double pDPhi ); 84 // 85 // Constructs a tubs with the given name and dimensions 86 87 ~G4Tubs() override; 88 // 89 // Destructor 90 91 // Accessors 92 93 inline G4double GetInnerRadius () const; 94 inline G4double GetOuterRadius () const; 95 inline G4double GetZHalfLength () const; 96 inline G4double GetStartPhiAngle () const; 97 inline G4double GetDeltaPhiAngle () const; 98 inline G4double GetSinStartPhi () const; 99 inline G4double GetCosStartPhi () const; 100 inline G4double GetSinEndPhi () const; 101 inline G4double GetCosEndPhi () const; 102 103 // Modifiers 104 105 inline void SetInnerRadius (G4double newRMin); 106 inline void SetOuterRadius (G4double newRMax); 107 inline void SetZHalfLength (G4double newDz); 108 inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true); 109 inline void SetDeltaPhiAngle (G4double newDPhi); 110 111 // Methods for solid 112 113 inline G4double GetCubicVolume() override; 114 inline G4double GetSurfaceArea() override; 115 116 void ComputeDimensions( G4VPVParameterisation* p, 117 const G4int n, 118 const G4VPhysicalVolume* pRep ) override; 119 120 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 121 122 G4bool CalculateExtent(const EAxis pAxis, 123 const G4VoxelLimits& pVoxelLimit, 124 const G4AffineTransform& pTransform, 125 G4double& pmin, G4double& pmax) const override; 126 127 EInside Inside( const G4ThreeVector& p ) const override; 128 129 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override; 130 131 G4double DistanceToIn(const G4ThreeVector& p, 132 const G4ThreeVector& v) const override; 133 G4double DistanceToIn(const G4ThreeVector& p) const override; 134 G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v, 135 const G4bool calcNorm = false, 136 G4bool* validNorm = nullptr, 137 G4ThreeVector* n = nullptr) const override; 138 G4double DistanceToOut(const G4ThreeVector& p) const override; 139 140 G4GeometryType GetEntityType() const override; 141 142 G4ThreeVector GetPointOnSurface() const override; 143 144 G4VSolid* Clone() const override; 145 146 std::ostream& StreamInfo( std::ostream& os ) const override; 147 148 // Visualisation functions 149 150 void DescribeYourselfTo (G4VGraphicsScene& scene) const override; 151 G4Polyhedron* CreatePolyhedron () const override; 152 153 G4Tubs(__void__&); 154 // 155 // Fake default constructor for usage restricted to direct object 156 // persistency for clients requiring preallocation of memory for 157 // persistifiable objects. 158 159 G4Tubs(const G4Tubs& rhs); 160 G4Tubs& operator=(const G4Tubs& rhs); 161 // Copy constructor and assignment operator. 162 163 protected: 164 165 inline void Initialize(); 166 // 167 // Reset relevant values to zero 168 169 inline void CheckSPhiAngle(G4double sPhi); 170 inline void CheckDPhiAngle(G4double dPhi); 171 inline void CheckPhiAngles(G4double sPhi, G4double dPhi); 172 // 173 // Reset relevant flags and angle values 174 175 inline void InitializeTrigonometry(); 176 // 177 // Recompute relevant trigonometric values and cache them 178 179 inline G4double FastInverseRxy( const G4ThreeVector& pos, G4double invRad, 180 G4double normalTolerance ) const; 181 // 182 // Compute fast inverse cylindrical (Rxy) radius for points expected to 183 // be on a cylindrical surface. Ensures that surface normal vector 184 // produced has magnitude with 'normalTolerance' of unit 185 186 virtual G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const; 187 // 188 // Algorithm for SurfaceNormal() following the original 189 // specification for points not on the surface 190 191 protected: 192 193 // Used by distanceToOut 194 // 195 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ}; 196 197 // Used by normal 198 // 199 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ}; 200 201 G4double kRadTolerance, kAngTolerance; 202 // 203 // Radial and angular tolerances 204 205 static constexpr G4double kNormTolerance = 1.0e-6; 206 // 207 // Tolerance of unity for surface normal 208 // (for speedup - use fInvRmax if possible ) 209 210 G4double fRMin, fRMax, fDz, fSPhi, fDPhi; 211 // 212 // Radial and angular dimensions 213 214 G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT, 215 sinSPhi, cosSPhi, sinEPhi, cosEPhi; 216 // 217 // Cached trigonometric values 218 219 G4bool fPhiFullTube; 220 // 221 // Flag for identification of section or full tube 222 223 G4double fInvRmax, fInvRmin; 224 // 225 // More cached values - inverse of Rmax, Rmin. 226 227 G4double halfCarTolerance, halfRadTolerance, halfAngTolerance; 228 // 229 // Cached half tolerance values 230 }; 231 232 #include "G4Tubs.icc" 233 234 #endif 235 236 #endif 237