[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 | // |
---|
| 27 | // $Id: G4Torus.hh,v 1.27 2007/05/18 07:38:00 gcosmo Exp $ |
---|
[1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class header file |
---|
| 33 | // |
---|
| 34 | // G4Torus |
---|
| 35 | // |
---|
| 36 | // Class description: |
---|
| 37 | // |
---|
| 38 | // A torus or torus segment with curved sides parallel to the z-axis. |
---|
| 39 | // The torus has a specified swept radius about which it is centered, |
---|
| 40 | // and a given minimum and maximum radius. A minimum radius of 0 |
---|
| 41 | // signifies a filled torus. |
---|
| 42 | // The torus segment is specified by starting and delta angles for phi, |
---|
| 43 | // with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI |
---|
| 44 | // signifies a complete, unsegmented torus/cylindr. |
---|
| 45 | // |
---|
| 46 | // Member functions: |
---|
| 47 | // |
---|
| 48 | // As inherited from G4CSGSolid+ |
---|
| 49 | // |
---|
| 50 | // G4Torus(const G4String &pName |
---|
| 51 | // G4double pRmin |
---|
| 52 | // G4double pRmax |
---|
| 53 | // G4double pRtor |
---|
| 54 | // G4double pSPhi |
---|
| 55 | // G4double pDPhi ) |
---|
| 56 | // |
---|
| 57 | // - Construct a torus with the given name and dimensions. |
---|
| 58 | // The angles are provided is radians. pRtor >= pRmax |
---|
| 59 | // |
---|
| 60 | // |
---|
| 61 | // Protected: |
---|
| 62 | // |
---|
| 63 | // G4ThreeVectorList* |
---|
| 64 | // CreateRotatedVertices(const G4AffineTransform& pTransform) const |
---|
| 65 | // |
---|
| 66 | // - Create the List of transformed vertices in the format required |
---|
| 67 | // for G4VSolid:: ClipCrossSection and ClipBetweenSections. |
---|
| 68 | // |
---|
| 69 | // Member Data: |
---|
| 70 | // |
---|
| 71 | // fRmin Inside radius |
---|
| 72 | // fRmax Outside radius |
---|
| 73 | // fRtor swept radius of torus |
---|
| 74 | // |
---|
| 75 | // fSPhi The starting phi angle in radians, |
---|
| 76 | // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI |
---|
| 77 | // |
---|
| 78 | // fDPhi Delta angle of the segment in radians |
---|
| 79 | // |
---|
| 80 | // You could find very often in G4Torus functions values like 'pt' or |
---|
| 81 | // 'it'. These are the distances from p or i G4ThreeVector points in the |
---|
| 82 | // plane (Z axis points p or i) to fRtor point in XY plane. This value is |
---|
| 83 | // similar to rho for G4Tubs and is used for definiton of the point |
---|
| 84 | // relative to fRmin and fRmax, i.e. for solution of inside/outside |
---|
| 85 | // problems |
---|
| 86 | |
---|
| 87 | // History: |
---|
| 88 | // 30.10.96 V.Grichine: first version of G4Torus |
---|
| 89 | // 21.04.98 J.Apostolakis: added SetAllParameters() function |
---|
| 90 | // 26.05.00 V.Grichine: added new SolveBiQuadratic/Cubic() developed |
---|
| 91 | // by O.Cremonesi |
---|
| 92 | // 31.08.00 E.Medernach: added SolveNumeric functions, migrated to |
---|
| 93 | // numeric solutions |
---|
| 94 | // -------------------------------------------------------------------- |
---|
| 95 | |
---|
| 96 | #ifndef G4Torus_HH |
---|
| 97 | #define G4Torus_HH |
---|
| 98 | |
---|
| 99 | #include "G4CSGSolid.hh" |
---|
| 100 | |
---|
| 101 | class G4Torus : public G4CSGSolid |
---|
| 102 | { |
---|
| 103 | |
---|
| 104 | public: // with description |
---|
| 105 | |
---|
| 106 | G4Torus(const G4String &pName, |
---|
| 107 | G4double pRmin, |
---|
| 108 | G4double pRmax, |
---|
| 109 | G4double pRtor, |
---|
| 110 | G4double pSPhi, |
---|
| 111 | G4double pDPhi); |
---|
| 112 | |
---|
| 113 | virtual ~G4Torus(); |
---|
| 114 | |
---|
| 115 | // Accessors |
---|
| 116 | |
---|
| 117 | inline G4double GetRmin() const; |
---|
| 118 | inline G4double GetRmax() const; |
---|
| 119 | inline G4double GetRtor() const; |
---|
| 120 | inline G4double GetSPhi() const; |
---|
| 121 | inline G4double GetDPhi() const; |
---|
| 122 | |
---|
| 123 | // Methods of solid |
---|
| 124 | |
---|
| 125 | inline G4double GetCubicVolume(); |
---|
| 126 | inline G4double GetSurfaceArea(); |
---|
| 127 | |
---|
| 128 | EInside Inside(const G4ThreeVector& p) const; |
---|
| 129 | G4bool CalculateExtent(const EAxis pAxis, |
---|
| 130 | const G4VoxelLimits& pVoxelLimit, |
---|
| 131 | const G4AffineTransform& pTransform, |
---|
| 132 | G4double& pmin, G4double& pmax) const; |
---|
| 133 | void ComputeDimensions( G4VPVParameterisation* p, |
---|
| 134 | const G4int n, |
---|
| 135 | const G4VPhysicalVolume* pRep); |
---|
| 136 | G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const; |
---|
| 137 | G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const; |
---|
| 138 | G4double DistanceToIn(const G4ThreeVector& p) const; |
---|
| 139 | G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v, |
---|
| 140 | const G4bool calcNorm=G4bool(false), |
---|
| 141 | G4bool *validNorm=0,G4ThreeVector *n=0) const; |
---|
| 142 | G4double DistanceToOut(const G4ThreeVector& p) const; |
---|
| 143 | |
---|
| 144 | G4GeometryType GetEntityType() const; |
---|
| 145 | |
---|
| 146 | G4ThreeVector GetPointOnSurface() const; |
---|
| 147 | |
---|
| 148 | std::ostream& StreamInfo(std::ostream& os) const; |
---|
| 149 | |
---|
| 150 | // Visualisation functions |
---|
| 151 | |
---|
| 152 | void DescribeYourselfTo (G4VGraphicsScene& scene) const; |
---|
| 153 | G4Polyhedron* CreatePolyhedron () const; |
---|
| 154 | G4NURBS* CreateNURBS () const; |
---|
| 155 | |
---|
| 156 | public: // without description |
---|
| 157 | |
---|
| 158 | void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, |
---|
| 159 | G4double pSPhi, G4double pDPhi); |
---|
| 160 | |
---|
| 161 | G4Torus(__void__&); |
---|
| 162 | // Fake default constructor for usage restricted to direct object |
---|
| 163 | // persistency for clients requiring preallocation of memory for |
---|
| 164 | // persistifiable objects. |
---|
| 165 | |
---|
| 166 | protected: |
---|
| 167 | |
---|
| 168 | std::vector<G4double> TorusRootsJT(const G4ThreeVector& p, |
---|
| 169 | const G4ThreeVector& v, |
---|
| 170 | G4double r) const ; |
---|
| 171 | |
---|
| 172 | G4double SolveNumericJT(const G4ThreeVector& p, |
---|
| 173 | const G4ThreeVector& v, |
---|
| 174 | G4double r, |
---|
| 175 | G4bool IsDistanceToIn) const; |
---|
| 176 | |
---|
| 177 | G4ThreeVectorList* |
---|
| 178 | CreateRotatedVertices(const G4AffineTransform& pTransform, |
---|
| 179 | G4int& noPolygonVertices) const; |
---|
| 180 | |
---|
| 181 | protected: |
---|
| 182 | |
---|
| 183 | G4double fRmin,fRmax,fRtor,fSPhi,fDPhi; |
---|
| 184 | |
---|
| 185 | // Used by distanceToOut |
---|
| 186 | enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi}; |
---|
| 187 | |
---|
| 188 | // used by normal |
---|
| 189 | enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi}; |
---|
| 190 | |
---|
| 191 | private: |
---|
| 192 | |
---|
| 193 | G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const; |
---|
| 194 | // Algorithm for SurfaceNormal() following the original |
---|
| 195 | // specification for points not on the surface |
---|
| 196 | |
---|
| 197 | private: |
---|
| 198 | |
---|
| 199 | G4double kRadTolerance, kAngTolerance; |
---|
| 200 | // Radial and angular tolerances |
---|
| 201 | }; |
---|
| 202 | |
---|
| 203 | #include "G4Torus.icc" |
---|
| 204 | |
---|
| 205 | #endif |
---|