[831] | 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 | // |
---|
[921] | 27 | // $Id: G4Tubs.hh,v 1.21 2008/11/06 10:55:40 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-02-cand-01 $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class header file |
---|
| 33 | // |
---|
| 34 | // |
---|
| 35 | // G4Tubs |
---|
| 36 | // |
---|
| 37 | // Class description: |
---|
| 38 | // |
---|
| 39 | // A tube or tube segment with curved sides parallel to |
---|
| 40 | // the z-axis. The tube has a specified half-length along |
---|
[921] | 41 | // the z-axis, about which it is centered, and a given |
---|
[831] | 42 | // minimum and maximum radius. A minimum radius of 0 |
---|
[921] | 43 | // corresponds to filled tube /cylinder. The tube segment is |
---|
[831] | 44 | // specified by starting and delta angles for phi, with 0 |
---|
| 45 | // being the +x axis, PI/2 the +y axis. |
---|
| 46 | // A delta angle of 2PI signifies a complete, unsegmented |
---|
| 47 | // tube/cylinder. |
---|
| 48 | // |
---|
| 49 | // Member Data: |
---|
| 50 | // |
---|
| 51 | // fRMin Inner radius |
---|
| 52 | // fRMax Outer radius |
---|
| 53 | // fDz half length in z |
---|
| 54 | // |
---|
| 55 | // fSPhi The starting phi angle in radians, |
---|
| 56 | // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI |
---|
| 57 | // |
---|
| 58 | // fDPhi Delta angle of the segment. |
---|
[921] | 59 | // |
---|
| 60 | // fPhiFullTube Boolean variable used for indicate the Phi Section |
---|
[831] | 61 | |
---|
| 62 | // History: |
---|
| 63 | // 10.08.95 P.Kent: General cleanup, use G4VSolid extent helper functions |
---|
| 64 | // to CalculateExtent() |
---|
| 65 | // 23.01.94 P.Kent: Converted to `tolerant' geometry |
---|
| 66 | // 19.07.96 J.Allison: G4GraphicsScene - see G4Box |
---|
| 67 | // 22.07.96 J.Allison: Changed SendPolyhedronTo to CreatePolyhedron |
---|
| 68 | // -------------------------------------------------------------------- |
---|
| 69 | |
---|
| 70 | #ifndef G4TUBS_HH |
---|
| 71 | #define G4TUBS_HH |
---|
| 72 | |
---|
| 73 | #include "G4CSGSolid.hh" |
---|
| 74 | |
---|
| 75 | class G4Tubs : public G4CSGSolid |
---|
| 76 | { |
---|
| 77 | public: // with description |
---|
| 78 | |
---|
| 79 | G4Tubs( const G4String& pName, |
---|
| 80 | G4double pRMin, |
---|
| 81 | G4double pRMax, |
---|
| 82 | G4double pDz, |
---|
| 83 | G4double pSPhi, |
---|
| 84 | G4double pDPhi ); |
---|
| 85 | // |
---|
| 86 | // Constructs a tubs with the given name and dimensions |
---|
| 87 | |
---|
| 88 | virtual ~G4Tubs(); |
---|
| 89 | // |
---|
| 90 | // Destructor |
---|
| 91 | |
---|
| 92 | // Accessors |
---|
| 93 | |
---|
| 94 | inline G4double GetInnerRadius () const; |
---|
| 95 | inline G4double GetOuterRadius () const; |
---|
| 96 | inline G4double GetZHalfLength () const; |
---|
| 97 | inline G4double GetStartPhiAngle () const; |
---|
| 98 | inline G4double GetDeltaPhiAngle () const; |
---|
| 99 | |
---|
| 100 | // Modifiers |
---|
| 101 | |
---|
| 102 | inline void SetInnerRadius (G4double newRMin); |
---|
| 103 | inline void SetOuterRadius (G4double newRMax); |
---|
| 104 | inline void SetZHalfLength (G4double newDz); |
---|
| 105 | inline void SetStartPhiAngle (G4double newSPhi); |
---|
| 106 | inline void SetDeltaPhiAngle (G4double newDPhi); |
---|
[921] | 107 | |
---|
[831] | 108 | // Methods for solid |
---|
| 109 | |
---|
| 110 | inline G4double GetCubicVolume(); |
---|
| 111 | inline G4double GetSurfaceArea(); |
---|
| 112 | |
---|
| 113 | void ComputeDimensions( G4VPVParameterisation* p, |
---|
| 114 | const G4int n, |
---|
| 115 | const G4VPhysicalVolume* pRep ); |
---|
| 116 | |
---|
| 117 | G4bool CalculateExtent( const EAxis pAxis, |
---|
| 118 | const G4VoxelLimits& pVoxelLimit, |
---|
| 119 | const G4AffineTransform& pTransform, |
---|
| 120 | G4double& pmin, G4double& pmax ) const; |
---|
| 121 | |
---|
| 122 | EInside Inside( const G4ThreeVector& p ) const; |
---|
| 123 | |
---|
| 124 | G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const; |
---|
| 125 | |
---|
| 126 | G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const; |
---|
| 127 | G4double DistanceToIn(const G4ThreeVector& p) const; |
---|
| 128 | G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v, |
---|
| 129 | const G4bool calcNorm=G4bool(false), |
---|
| 130 | G4bool *validNorm=0, G4ThreeVector *n=0) const; |
---|
| 131 | G4double DistanceToOut(const G4ThreeVector& p) const; |
---|
| 132 | |
---|
| 133 | G4GeometryType GetEntityType() const; |
---|
| 134 | |
---|
| 135 | G4ThreeVector GetPointOnSurface() const; |
---|
| 136 | |
---|
| 137 | std::ostream& StreamInfo( std::ostream& os ) const; |
---|
| 138 | |
---|
| 139 | // Visualisation functions |
---|
| 140 | |
---|
| 141 | void DescribeYourselfTo ( G4VGraphicsScene& scene ) const; |
---|
| 142 | G4Polyhedron* CreatePolyhedron () const; |
---|
| 143 | G4NURBS* CreateNURBS () const; |
---|
| 144 | |
---|
| 145 | public: // without description |
---|
| 146 | |
---|
| 147 | G4Tubs(__void__&); |
---|
[921] | 148 | // |
---|
[831] | 149 | // Fake default constructor for usage restricted to direct object |
---|
| 150 | // persistency for clients requiring preallocation of memory for |
---|
| 151 | // persistifiable objects. |
---|
| 152 | |
---|
| 153 | // Older names for access functions |
---|
| 154 | |
---|
| 155 | inline G4double GetRMin() const; |
---|
| 156 | inline G4double GetRMax() const; |
---|
| 157 | inline G4double GetDz () const; |
---|
| 158 | inline G4double GetSPhi() const; |
---|
| 159 | inline G4double GetDPhi() const; |
---|
| 160 | |
---|
| 161 | protected: |
---|
| 162 | |
---|
| 163 | G4ThreeVectorList* |
---|
| 164 | CreateRotatedVertices( const G4AffineTransform& pTransform ) const; |
---|
| 165 | // |
---|
| 166 | // Creates the List of transformed vertices in the format required |
---|
| 167 | // for G4VSolid:: ClipCrossSection and ClipBetweenSections |
---|
| 168 | |
---|
[921] | 169 | G4double fRMin, fRMax, fDz, fSPhi, fDPhi; |
---|
| 170 | G4bool fPhiFullTube; |
---|
| 171 | |
---|
| 172 | // Used by distanceToOut |
---|
[831] | 173 | |
---|
| 174 | enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ}; |
---|
| 175 | |
---|
[921] | 176 | // Used by normal |
---|
[831] | 177 | |
---|
| 178 | enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ}; |
---|
| 179 | |
---|
| 180 | private: |
---|
| 181 | |
---|
[921] | 182 | inline void Initialize(); |
---|
| 183 | // |
---|
| 184 | // Reset relevant values to zero |
---|
| 185 | |
---|
| 186 | inline void InitializeTrigonometry(); |
---|
| 187 | // |
---|
| 188 | // Recompute relevant trigonometric values and cache them |
---|
| 189 | |
---|
[831] | 190 | G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const; |
---|
[921] | 191 | // |
---|
[831] | 192 | // Algorithm for SurfaceNormal() following the original |
---|
| 193 | // specification for points not on the surface |
---|
| 194 | |
---|
| 195 | private: |
---|
| 196 | |
---|
| 197 | G4double kRadTolerance, kAngTolerance; |
---|
[921] | 198 | // |
---|
[831] | 199 | // Radial and angular tolerances |
---|
[921] | 200 | |
---|
| 201 | G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT, |
---|
| 202 | sinSPhi, cosSPhi, sinEPhi, cosEPhi; |
---|
| 203 | // |
---|
| 204 | // Cached trigonometric values |
---|
[831] | 205 | }; |
---|
| 206 | |
---|
| 207 | #include "G4Tubs.icc" |
---|
| 208 | |
---|
| 209 | #endif |
---|