[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 | // |
---|
[1228] | 27 | // $Id: G4Cons.hh,v 1.22 2009/03/31 09:56:24 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class header file |
---|
| 33 | // |
---|
| 34 | // G4Cons |
---|
| 35 | // |
---|
| 36 | // Class description: |
---|
| 37 | // |
---|
| 38 | // A G4Cons is, in the general case, a Phi segment of a cone, with |
---|
| 39 | // half-length fDz, inner and outer radii specified at -fDz and +fDz. |
---|
| 40 | // The Phi segment is described by a starting fSPhi angle, and the |
---|
| 41 | // +fDPhi delta angle for the shape. |
---|
| 42 | // If the delta angle is >=2*pi, the shape is treated as continuous |
---|
| 43 | // in Phi |
---|
| 44 | // |
---|
| 45 | // Member Data: |
---|
| 46 | // |
---|
| 47 | // fRmin1 inside radius at -fDz |
---|
| 48 | // fRmin2 inside radius at +fDz |
---|
| 49 | // fRmax1 outside radius at -fDz |
---|
| 50 | // fRmax2 outside radius at +fDz |
---|
| 51 | // fDz half length in z |
---|
| 52 | // |
---|
| 53 | // fSPhi starting angle of the segment in radians |
---|
| 54 | // fDPhi delta angle of the segment in radians |
---|
| 55 | // |
---|
[921] | 56 | // fPhiFullCone Boolean variable used for indicate the Phi Section |
---|
| 57 | // |
---|
[831] | 58 | // Note: |
---|
| 59 | // Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI, |
---|
| 60 | // and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be |
---|
| 61 | // made with (say) Phi of a point. |
---|
| 62 | |
---|
| 63 | // History: |
---|
| 64 | // 19.3.94 P.Kent: Old C++ code converted to tolerant geometry |
---|
| 65 | // 13.9.96 V.Grichine: Final modifications to commit |
---|
| 66 | // -------------------------------------------------------------------- |
---|
| 67 | |
---|
| 68 | #ifndef G4Cons_HH |
---|
| 69 | #define G4Cons_HH |
---|
| 70 | |
---|
| 71 | #include "G4CSGSolid.hh" |
---|
| 72 | |
---|
| 73 | class G4Cons : public G4CSGSolid |
---|
| 74 | { |
---|
| 75 | public: // with description |
---|
| 76 | |
---|
[921] | 77 | G4Cons(const G4String& pName, |
---|
| 78 | G4double pRmin1, G4double pRmax1, |
---|
| 79 | G4double pRmin2, G4double pRmax2, |
---|
| 80 | G4double pDz, |
---|
| 81 | G4double pSPhi, G4double pDPhi); |
---|
[1228] | 82 | // |
---|
| 83 | // Constructs a cone with the given name and dimensions |
---|
[831] | 84 | |
---|
[1228] | 85 | ~G4Cons() ; |
---|
| 86 | // |
---|
| 87 | // Destructor |
---|
| 88 | |
---|
[921] | 89 | // Accessors |
---|
[831] | 90 | |
---|
[1228] | 91 | inline G4double GetInnerRadiusMinusZ() const; |
---|
| 92 | inline G4double GetOuterRadiusMinusZ() const; |
---|
| 93 | inline G4double GetInnerRadiusPlusZ() const; |
---|
| 94 | inline G4double GetOuterRadiusPlusZ() const; |
---|
| 95 | inline G4double GetZHalfLength() const; |
---|
| 96 | inline G4double GetStartPhiAngle() const; |
---|
| 97 | inline G4double GetDeltaPhiAngle() const; |
---|
[831] | 98 | |
---|
[921] | 99 | // Modifiers |
---|
[831] | 100 | |
---|
[1228] | 101 | inline void SetInnerRadiusMinusZ (G4double Rmin1 ); |
---|
| 102 | inline void SetOuterRadiusMinusZ (G4double Rmax1 ); |
---|
| 103 | inline void SetInnerRadiusPlusZ (G4double Rmin2 ); |
---|
| 104 | inline void SetOuterRadiusPlusZ (G4double Rmax2 ); |
---|
| 105 | inline void SetZHalfLength (G4double newDz ); |
---|
| 106 | inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true); |
---|
| 107 | inline void SetDeltaPhiAngle (G4double newDPhi); |
---|
[831] | 108 | |
---|
[921] | 109 | // Other methods for solid |
---|
[831] | 110 | |
---|
[1228] | 111 | inline G4double GetCubicVolume(); |
---|
| 112 | inline G4double GetSurfaceArea(); |
---|
[831] | 113 | |
---|
[1228] | 114 | void ComputeDimensions( G4VPVParameterisation* p, |
---|
| 115 | const G4int n, |
---|
| 116 | const G4VPhysicalVolume* pRep ); |
---|
[831] | 117 | |
---|
[1228] | 118 | G4bool CalculateExtent( const EAxis pAxis, |
---|
| 119 | const G4VoxelLimits& pVoxelLimit, |
---|
| 120 | const G4AffineTransform& pTransform, |
---|
| 121 | G4double& pmin, G4double& pmax ) const; |
---|
[831] | 122 | |
---|
[1228] | 123 | EInside Inside( const G4ThreeVector& p ) const; |
---|
[831] | 124 | |
---|
[1228] | 125 | G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const; |
---|
[831] | 126 | |
---|
[921] | 127 | G4double DistanceToIn (const G4ThreeVector& p, |
---|
| 128 | const G4ThreeVector& v) const; |
---|
| 129 | G4double DistanceToIn (const G4ThreeVector& p) const; |
---|
| 130 | G4double DistanceToOut(const G4ThreeVector& p, |
---|
| 131 | const G4ThreeVector& v, |
---|
| 132 | const G4bool calcNorm=G4bool(false), |
---|
| 133 | G4bool *validNorm=0, |
---|
| 134 | G4ThreeVector *n=0) const; |
---|
| 135 | G4double DistanceToOut(const G4ThreeVector& p) const; |
---|
[831] | 136 | |
---|
[1228] | 137 | G4GeometryType GetEntityType() const; |
---|
[831] | 138 | |
---|
[921] | 139 | G4ThreeVector GetPointOnSurface() const; |
---|
[831] | 140 | |
---|
[921] | 141 | std::ostream& StreamInfo(std::ostream& os) const; |
---|
[831] | 142 | |
---|
[921] | 143 | // Visualisation functions |
---|
[831] | 144 | |
---|
[921] | 145 | void DescribeYourselfTo( G4VGraphicsScene& scene ) const; |
---|
| 146 | G4Polyhedron* CreatePolyhedron() const; |
---|
| 147 | G4NURBS* CreateNURBS() const; |
---|
[831] | 148 | |
---|
| 149 | public: // without description |
---|
| 150 | |
---|
[921] | 151 | G4Cons(__void__&); |
---|
| 152 | // |
---|
| 153 | // Fake default constructor for usage restricted to direct object |
---|
| 154 | // persistency for clients requiring preallocation of memory for |
---|
| 155 | // persistifiable objects. |
---|
[831] | 156 | |
---|
[921] | 157 | // Old access functions |
---|
[831] | 158 | |
---|
[921] | 159 | inline G4double GetRmin1() const; |
---|
| 160 | inline G4double GetRmax1() const; |
---|
| 161 | inline G4double GetRmin2() const; |
---|
| 162 | inline G4double GetRmax2() const; |
---|
| 163 | inline G4double GetDz() const; |
---|
| 164 | inline G4double GetSPhi() const; |
---|
| 165 | inline G4double GetDPhi() const; |
---|
[831] | 166 | |
---|
[1228] | 167 | private: |
---|
[831] | 168 | |
---|
[921] | 169 | G4ThreeVectorList* |
---|
| 170 | CreateRotatedVertices(const G4AffineTransform& pTransform) const; |
---|
[831] | 171 | |
---|
[1228] | 172 | inline void Initialize(); |
---|
| 173 | // |
---|
| 174 | // Reset relevant values to zero |
---|
[921] | 175 | |
---|
[1228] | 176 | inline void CheckSPhiAngle(G4double sPhi); |
---|
| 177 | inline void CheckDPhiAngle(G4double dPhi); |
---|
| 178 | inline void CheckPhiAngles(G4double sPhi, G4double dPhi); |
---|
| 179 | // |
---|
| 180 | // Reset relevant flags and angle values |
---|
[831] | 181 | |
---|
[921] | 182 | inline void InitializeTrigonometry(); |
---|
| 183 | // |
---|
| 184 | // Recompute relevant trigonometric values and cache them |
---|
| 185 | |
---|
| 186 | G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const; |
---|
| 187 | // |
---|
| 188 | // Algorithm for SurfaceNormal() following the original |
---|
| 189 | // specification for points not on the surface |
---|
| 190 | |
---|
[831] | 191 | private: |
---|
| 192 | |
---|
[1228] | 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 | |
---|
[921] | 201 | G4double kRadTolerance, kAngTolerance; |
---|
| 202 | // |
---|
| 203 | // Radial and angular tolerances |
---|
[831] | 204 | |
---|
[1228] | 205 | G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi; |
---|
| 206 | // |
---|
| 207 | // Radial and angular dimensions |
---|
| 208 | |
---|
[921] | 209 | G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT, |
---|
| 210 | sinSPhi, cosSPhi, sinEPhi, cosEPhi; |
---|
| 211 | // |
---|
| 212 | // Cached trigonometric values |
---|
[1228] | 213 | |
---|
| 214 | G4bool fPhiFullCone; |
---|
| 215 | // |
---|
| 216 | // Flag for identification of section or full cone |
---|
[831] | 217 | }; |
---|
| 218 | |
---|
| 219 | #include "G4Cons.icc" |
---|
| 220 | |
---|
| 221 | #endif |
---|