|
|
|||
File indexing completed on 2026-09-24 09:10:07
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 // G4Sphere 0027 // 0028 // Class description: 0029 // 0030 // A G4Sphere is, in the general case, a section of a spherical shell, 0031 // between specified phi and theta angles 0032 // 0033 // The phi and theta segments are described by a starting angle, 0034 // and the +ve delta angle for the shape. 0035 // If the delta angle is >=2*pi, or >=pi the shape is treated as 0036 // continuous in phi or theta respectively. 0037 // 0038 // Theta must lie between 0-pi (incl). 0039 // 0040 // Member Data: 0041 // 0042 // fRmin inner radius 0043 // fRmax outer radius 0044 // 0045 // fSPhi starting angle of the segment in radians 0046 // fDPhi delta angle of the segment in radians 0047 // 0048 // fSTheta starting angle of the segment in radians 0049 // fDTheta delta angle of the segment in radians 0050 // 0051 // 0052 // Note: 0053 // Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI, 0054 // and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be 0055 // made with (say) Phi of a point. 0056 0057 // Author: Paul Kent (CERN), 28.03.1994 - Code converted to tolerant geometry 0058 // -------------------------------------------------------------------- 0059 #ifndef G4SPHERE_HH 0060 #define G4SPHERE_HH 0061 0062 #include "G4GeomTypes.hh" 0063 0064 #if defined(G4GEOM_USE_USOLIDS) 0065 #define G4GEOM_USE_USPHERE 1 0066 #endif 0067 0068 #if defined(G4GEOM_USE_USPHERE) 0069 #define G4USphere G4Sphere 0070 #include "G4USphere.hh" 0071 #else 0072 0073 #include <CLHEP/Units/PhysicalConstants.h> 0074 #include "G4CSGSolid.hh" 0075 #include "G4Polyhedron.hh" 0076 0077 class G4VisExtent; 0078 0079 /** 0080 * @brief G4Sphere is, in the general case, a section of a spherical shell, 0081 * between specified phi and theta angles. 0082 * The phi and theta segments are described by a starting angle and the +ve 0083 * delta angle for the shape. If the delta angle is >=2*pi, or >=pi the shape 0084 * is treated as continuous in phi or theta respectively. 0085 * Theta must lie between [0..pi]. 0086 */ 0087 0088 class G4Sphere : public G4CSGSolid 0089 { 0090 public: 0091 0092 /** 0093 * Constructs a sphere or sphere shell section with the given 0094 * name and dimensions. 0095 * @param[in] pName The name of the solid. 0096 * @param[in] pRmin Inner radius. 0097 * @param[in] pRmax Outer radius. 0098 * @param[in] pSPhi Starting Phi angle of the segment in radians. 0099 * @param[in] pDPhi Delta Phi angle of the segment in radians. 0100 * @param[in] pSTheta Starting Theta angle of the segment in radians. 0101 * @param[in] pDTheta Delta Theta angle of the segment in radians. 0102 */ 0103 G4Sphere(const G4String& pName, 0104 G4double pRmin, G4double pRmax, 0105 G4double pSPhi, G4double pDPhi, 0106 G4double pSTheta, G4double pDTheta); 0107 0108 /** 0109 * Default destructor. 0110 */ 0111 ~G4Sphere() override = default; 0112 0113 /** 0114 * Accessors. 0115 */ 0116 inline G4double GetInnerRadius () const; 0117 inline G4double GetOuterRadius () const; 0118 inline G4double GetStartPhiAngle () const; 0119 inline G4double GetDeltaPhiAngle () const; 0120 inline G4double GetStartThetaAngle() const; 0121 inline G4double GetDeltaThetaAngle() const; 0122 inline G4double GetSinStartPhi () const; 0123 inline G4double GetCosStartPhi () const; 0124 inline G4double GetSinEndPhi () const; 0125 inline G4double GetCosEndPhi () const; 0126 inline G4double GetSinStartTheta () const; 0127 inline G4double GetCosStartTheta () const; 0128 inline G4double GetSinEndTheta () const; 0129 inline G4double GetCosEndTheta () const; 0130 0131 /** 0132 * Modifiers. 0133 */ 0134 inline void SetInnerRadius (G4double newRMin); 0135 inline void SetOuterRadius (G4double newRmax); 0136 inline void SetStartPhiAngle (G4double newSphi, G4bool trig = true); 0137 inline void SetDeltaPhiAngle (G4double newDphi); 0138 inline void SetStartThetaAngle(G4double newSTheta); 0139 inline void SetDeltaThetaAngle(G4double newDTheta); 0140 0141 /** 0142 * Returning an estimation of the solid volume (capacity) and 0143 * surface area, in internal units. 0144 */ 0145 G4double GetCubicVolume() override; 0146 G4double GetSurfaceArea() override; 0147 0148 /** 0149 * Dispatch method for parameterisation replication mechanism and 0150 * dimension computation. 0151 */ 0152 void ComputeDimensions(G4VPVParameterisation* p, 0153 const G4int n, 0154 const G4VPhysicalVolume* pRep) override; 0155 0156 /** 0157 * Computes the bounding limits of the solid. 0158 * @param[out] pMin The minimum bounding limit point. 0159 * @param[out] pMax The maximum bounding limit point. 0160 */ 0161 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 0162 0163 /** 0164 * Calculates the minimum and maximum extent of the solid, when under the 0165 * specified transform, and within the specified limits. 0166 * @param[in] pAxis The axis along which compute the extent. 0167 * @param[in] pVoxelLimit The limiting space dictated by voxels. 0168 * @param[in] pTransform The internal transformation applied to the solid. 0169 * @param[out] pMin The minimum extent value. 0170 * @param[out] pMax The maximum extent value. 0171 * @returns True if the solid is intersected by the extent region. 0172 */ 0173 G4bool CalculateExtent(const EAxis pAxis, 0174 const G4VoxelLimits& pVoxelLimit, 0175 const G4AffineTransform& pTransform, 0176 G4double& pmin, G4double& pmax) const override; 0177 0178 /** 0179 * Concrete implementations of the expected query interfaces for 0180 * solids, as defined in the base class G4VSolid. 0181 */ 0182 EInside Inside(const G4ThreeVector& p) const override; 0183 G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override; 0184 G4double DistanceToIn(const G4ThreeVector& p, 0185 const G4ThreeVector& v) const override; 0186 G4double DistanceToIn(const G4ThreeVector& p) const override; 0187 G4double DistanceToOut(const G4ThreeVector& p, 0188 const G4ThreeVector& v, 0189 const G4bool calcNorm = false, 0190 G4bool* validNorm = nullptr, 0191 G4ThreeVector* n = nullptr) const override; 0192 G4double DistanceToOut(const G4ThreeVector& p) const override; 0193 0194 /** 0195 * Returns the type ID, "G4Sphere" of the solid. 0196 */ 0197 G4GeometryType GetEntityType() const override; 0198 0199 /** 0200 * Returns a random point located and uniformly distributed on the 0201 * surface of the solid. 0202 */ 0203 G4ThreeVector GetPointOnSurface() const override; 0204 0205 /** 0206 * Makes a clone of the object for use in multi-treading. 0207 * @returns A pointer to the new cloned allocated solid. 0208 */ 0209 G4VSolid* Clone() const override; 0210 0211 /** 0212 * Streams the object contents to an output stream. 0213 */ 0214 std::ostream& StreamInfo(std::ostream& os) const override; 0215 0216 /** 0217 * Methods for creating graphical representations (i.e. for visualisation). 0218 */ 0219 G4VisExtent GetExtent() const override; 0220 void DescribeYourselfTo(G4VGraphicsScene& scene) const override; 0221 G4Polyhedron* CreatePolyhedron() const override; 0222 0223 /** 0224 * Fake default constructor for usage restricted to direct object 0225 * persistency for clients requiring preallocation of memory for 0226 * persistifiable objects. 0227 */ 0228 G4Sphere(__void__&); 0229 0230 /** 0231 * Copy constructor and assignment operator. 0232 */ 0233 G4Sphere(const G4Sphere& rhs) = default; 0234 G4Sphere& operator=(const G4Sphere& rhs); 0235 0236 private: 0237 0238 /** 0239 * Resets relevant values to zero. 0240 */ 0241 inline void Initialize(); 0242 0243 /** 0244 * Reset relevant flags and angle values. 0245 */ 0246 inline void CheckThetaAngles(G4double sTheta, G4double dTheta); 0247 inline void CheckSPhiAngle(G4double sPhi); 0248 inline void CheckDPhiAngle(G4double dPhi); 0249 inline void CheckPhiAngles(G4double sPhi, G4double dPhi); 0250 0251 /** 0252 * Recompute relevant trigonometric values and cache them. 0253 */ 0254 inline void InitializePhiTrigonometry(); 0255 inline void InitializeThetaTrigonometry(); 0256 0257 /** 0258 * Algorithm for SurfaceNormal() following the original specification 0259 * for points not on the surface. 0260 */ 0261 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const; 0262 0263 private: 0264 0265 /** Radial and angular tolerances. */ 0266 G4double fRminTolerance, fRmaxTolerance, kAngTolerance, 0267 kRadTolerance, fEpsilon = 2.e-11; 0268 0269 /** Radial and angular dimensions. */ 0270 G4double fRmin, fRmax, fSPhi, fDPhi, fSTheta, fDTheta; 0271 0272 /** Cached trigonometric values for Phi angle. */ 0273 G4double sinCPhi, cosCPhi, cosHDPhi, cosHDPhiOT, cosHDPhiIT, 0274 sinSPhi, cosSPhi, sinEPhi, cosEPhi, hDPhi, cPhi, ePhi; 0275 0276 /** Cached trigonometric values for Theta angle. */ 0277 G4double sinSTheta, cosSTheta, sinETheta, cosETheta, 0278 tanSTheta, tanSTheta2, tanETheta, tanETheta2, eTheta; 0279 0280 /** Flags for identification of section, shell or full sphere. */ 0281 G4bool fFullPhiSphere=false, fFullThetaSphere=false, fFullSphere=true; 0282 0283 /** Cached half tolerance values. */ 0284 G4double halfCarTolerance, halfAngTolerance; 0285 }; 0286 0287 #include "G4Sphere.icc" 0288 0289 #endif 0290 0291 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|