|
|
|||
File indexing completed on 2026-08-02 09:17:28
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4Tubs 0027 // 0028 // Class description: 0029 // 0030 // A tube or tube segment with curved sides parallel to 0031 // the z-axis. The tube has a specified half-length along 0032 // the z-axis, about which it is centered, and a given 0033 // minimum and maximum radius. A minimum radius of 0 0034 // corresponds to filled tube /cylinder. The tube segment is 0035 // specified by starting and delta angles for phi, with 0 0036 // being the +x axis, PI/2 the +y axis. 0037 // A delta angle of 2PI signifies a complete, unsegmented 0038 // tube/cylinder. 0039 // 0040 // Member Data: 0041 // 0042 // fRMin Inner radius 0043 // fRMax Outer radius 0044 // fDz half length in z 0045 // 0046 // fSPhi The starting phi angle in radians, 0047 // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI 0048 // 0049 // fDPhi Delta angle of the segment. 0050 // 0051 // fPhiFullTube Boolean variable used for indicate the Phi Section 0052 0053 // Author: Paul Kent (CERN), 23.01.1994 - First version 0054 // -------------------------------------------------------------------- 0055 #ifndef G4TUBS_HH 0056 #define G4TUBS_HH 0057 0058 #include "G4GeomTypes.hh" 0059 0060 #if defined(G4GEOM_USE_USOLIDS) 0061 #define G4GEOM_USE_UTUBS 1 0062 #endif 0063 0064 #if defined(G4GEOM_USE_UTUBS) 0065 #define G4UTubs G4Tubs 0066 #include "G4UTubs.hh" 0067 #else 0068 0069 #include <CLHEP/Units/PhysicalConstants.h> 0070 0071 #include "G4CSGSolid.hh" 0072 #include "G4Polyhedron.hh" 0073 0074 /** 0075 * @brief G4Tubs is a tube or tube segment with curved sides parallel to 0076 * the Z-axis. The tube has a specified half-length along the Z-axis, about 0077 * which it is centered, and a given minimum and maximum radius. A minimum 0078 * radius of 0 corresponds to filled tube/cylinder. The tube segment is 0079 * specified by starting and delta angles for phi, with 0 being the +x axis, 0080 * PI/2 the +y axis. A delta angle of 2PI signifies a complete, unsegmented 0081 * tube/cylinder. 0082 */ 0083 0084 class G4Tubs : public G4CSGSolid 0085 { 0086 public: 0087 0088 /** 0089 * Constructs a tubs with the given name and dimensions. 0090 * It checks the input parameters, converting angles so 0<sphi+dpshi<=2_PI 0091 * if pdphi>2PI then reset it to 2PI. 0092 * @param[in] pName The name of the solid. 0093 * @param[in] pRMin Inner radius. 0094 * @param[in] pRMax Outer radius. 0095 * @param[in] pDz Half length in Z. 0096 * @param[in] pSPhi Starting phi angle in radians. 0097 * @param[in] pDPhi Angle of the segment in radians. 0098 */ 0099 G4Tubs( const G4String& pName, 0100 G4double pRMin, 0101 G4double pRMax, 0102 G4double pDz, 0103 G4double pSPhi, 0104 G4double pDPhi ); 0105 0106 /** 0107 * Default destructor. 0108 */ 0109 ~G4Tubs() override = default; 0110 0111 /** 0112 * Accessors. 0113 */ 0114 inline G4double GetInnerRadius () const; 0115 inline G4double GetOuterRadius () const; 0116 inline G4double GetZHalfLength () const; 0117 inline G4double GetStartPhiAngle () const; 0118 inline G4double GetDeltaPhiAngle () const; 0119 inline G4double GetSinStartPhi () const; 0120 inline G4double GetCosStartPhi () const; 0121 inline G4double GetSinEndPhi () const; 0122 inline G4double GetCosEndPhi () const; 0123 0124 /** 0125 * Modifiers. 0126 */ 0127 inline void SetInnerRadius (G4double newRMin); 0128 inline void SetOuterRadius (G4double newRMax); 0129 inline void SetZHalfLength (G4double newDz); 0130 inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true); 0131 inline void SetDeltaPhiAngle (G4double newDPhi); 0132 0133 /** 0134 * Returning an estimation of the solid volume (capacity) and 0135 * surface area, in internal units. 0136 */ 0137 G4double GetCubicVolume() override; 0138 G4double GetSurfaceArea() override; 0139 0140 /** 0141 * Dispatch method for parameterisation replication mechanism and 0142 * dimension computation. 0143 */ 0144 void ComputeDimensions( G4VPVParameterisation* p, 0145 const G4int n, 0146 const G4VPhysicalVolume* pRep ) override; 0147 0148 /** 0149 * Computes the bounding limits of the solid. 0150 * @param[out] pMin The minimum bounding limit point. 0151 * @param[out] pMax The maximum bounding limit point. 0152 */ 0153 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 0154 0155 /** 0156 * Calculates the minimum and maximum extent of the solid, when under the 0157 * specified transform, and within the specified limits. 0158 * @param[in] pAxis The axis along which compute the extent. 0159 * @param[in] pVoxelLimit The limiting space dictated by voxels. 0160 * @param[in] pTransform The internal transformation applied to the solid. 0161 * @param[out] pMin The minimum extent value. 0162 * @param[out] pMax The maximum extent value. 0163 * @returns True if the solid is intersected by the extent region. 0164 */ 0165 G4bool CalculateExtent(const EAxis pAxis, 0166 const G4VoxelLimits& pVoxelLimit, 0167 const G4AffineTransform& pTransform, 0168 G4double& pmin, G4double& pmax) const override; 0169 0170 /** 0171 * Concrete implementations of the expected query interfaces for 0172 * solids, as defined in the base class G4VSolid. 0173 */ 0174 EInside Inside( const G4ThreeVector& p ) const override; 0175 G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override; 0176 G4double DistanceToIn(const G4ThreeVector& p, 0177 const G4ThreeVector& v) const override; 0178 G4double DistanceToIn(const G4ThreeVector& p) const override; 0179 G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v, 0180 const G4bool calcNorm = false, 0181 G4bool* validNorm = nullptr, 0182 G4ThreeVector* n = nullptr) const override; 0183 G4double DistanceToOut(const G4ThreeVector& p) const override; 0184 0185 /** 0186 * Returns the type ID, "G4Tubs" of the solid. 0187 */ 0188 G4GeometryType GetEntityType() const override; 0189 0190 /** 0191 * Returns a random point located and uniformly distributed on the 0192 * surface of the solid. 0193 */ 0194 G4ThreeVector GetPointOnSurface() const override; 0195 0196 /** 0197 * Makes a clone of the object for use in multi-treading. 0198 * @returns A pointer to the new cloned allocated solid. 0199 */ 0200 G4VSolid* Clone() const override; 0201 0202 /** 0203 * Streams the object contents to an output stream. 0204 */ 0205 std::ostream& StreamInfo( std::ostream& os ) const override; 0206 0207 /** 0208 * Methods for creating graphical representations (i.e. for visualisation). 0209 */ 0210 void DescribeYourselfTo (G4VGraphicsScene& scene) const override; 0211 G4Polyhedron* CreatePolyhedron () const override; 0212 0213 /** 0214 * Fake default constructor for usage restricted to direct object 0215 * persistency for clients requiring preallocation of memory for 0216 * persistifiable objects. 0217 */ 0218 G4Tubs(__void__&); 0219 0220 /** 0221 * Copy constructor and assignment operator. 0222 */ 0223 G4Tubs(const G4Tubs& rhs) = default; 0224 G4Tubs& operator=(const G4Tubs& rhs); 0225 0226 protected: 0227 0228 /** 0229 * Resets the relevant values to zero. 0230 */ 0231 inline void Initialize(); 0232 0233 /** 0234 * Methods resetting relevant flags and angle values. 0235 */ 0236 inline void CheckSPhiAngle(G4double sPhi); 0237 inline void CheckDPhiAngle(G4double dPhi); 0238 inline void CheckPhiAngles(G4double sPhi, G4double dPhi); 0239 0240 /** 0241 * Recomputes relevant trigonometric values and caches them. 0242 */ 0243 inline void InitializeTrigonometry(); 0244 0245 /** 0246 * Computes fast inverse cylindrical (Rxy) radius for points expected to 0247 * be on a cylindrical surface. Ensures that surface normal vector 0248 * produced has magnitude with 'normalTolerance' of unit. 0249 */ 0250 inline G4double FastInverseRxy( const G4ThreeVector& pos, G4double invRad, 0251 G4double normalTolerance ) const; 0252 0253 /** 0254 * Algorithm for SurfaceNormal() following the original specification 0255 * for points not on the surface. 0256 */ 0257 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const; 0258 0259 protected: 0260 0261 /** Radial and angular tolerances. */ 0262 G4double kRadTolerance, kAngTolerance; 0263 0264 /** Tolerance of unity for surface normal. */ 0265 static constexpr G4double kNormTolerance = 1.0e-6; 0266 0267 /** Radial and angular dimensions. */ 0268 G4double fRMin, fRMax, fDz, fSPhi, fDPhi; 0269 0270 /** Cached trigonometric values. */ 0271 G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT, 0272 sinSPhi, cosSPhi, sinEPhi, cosEPhi; 0273 0274 /** Flag for identification of section or full tube. */ 0275 G4bool fPhiFullTube; 0276 0277 /** More cached values - inverse of Rmax, Rmin. */ 0278 G4double fInvRmax, fInvRmin; 0279 0280 /** Cached half tolerance values. */ 0281 G4double halfCarTolerance, halfRadTolerance, halfAngTolerance; 0282 }; 0283 0284 #include "G4Tubs.icc" 0285 0286 #endif 0287 0288 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|