|
|
|||
File indexing completed on 2026-09-10 09:10:58
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 // G4Torus 0027 // 0028 // Class description: 0029 // 0030 // A torus or torus segment with curved sides parallel to the z-axis. 0031 // The torus has a specified swept radius about which it is centered, 0032 // and a given minimum and maximum radius. A minimum radius of 0 0033 // signifies a filled torus. 0034 // The torus segment is specified by starting and delta angles for phi, 0035 // with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI 0036 // signifies a complete, unsegmented torus/cylinder. 0037 // 0038 // Member functions: 0039 // 0040 // As inherited from G4CSGSolid+ 0041 // 0042 // G4Torus(const G4String &pName 0043 // G4double pRmin 0044 // G4double pRmax 0045 // G4double pRtor 0046 // G4double pSPhi 0047 // G4double pDPhi ) 0048 // 0049 // - Construct a torus with the given name and dimensions. 0050 // The angles are provided is radians. pRtor >= pRmax 0051 // 0052 // Member Data: 0053 // 0054 // fRmin Inside radius 0055 // fRmax Outside radius 0056 // fRtor swept radius of torus 0057 // 0058 // fSPhi The starting phi angle in radians, 0059 // adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI 0060 // 0061 // fDPhi Delta angle of the segment in radians 0062 // 0063 // You could find very often in G4Torus functions values like 'pt' or 0064 // 'it'. These are the distances from p or i G4ThreeVector points in the 0065 // plane (Z axis points p or i) to fRtor point in XY plane. This value is 0066 // similar to rho for G4Tubs and is used for definiton of the point 0067 // relative to fRmin and fRmax, i.e. for solution of inside/outside 0068 // problems 0069 0070 // Author: V.Grichine (CERN), 30.10.1996 - First version 0071 // E.Medernach (CERN), 31.08.2000 - Migrated to numeric solutions 0072 // -------------------------------------------------------------------- 0073 #ifndef G4TORUS_HH 0074 #define G4TORUS_HH 0075 0076 #include "G4GeomTypes.hh" 0077 0078 #if defined(G4GEOM_USE_USOLIDS) 0079 #define G4GEOM_USE_UTORUS 1 0080 #endif 0081 0082 #if (defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS)) 0083 #define G4UTorus G4Torus 0084 #include "G4UTorus.hh" 0085 #else 0086 0087 #include <CLHEP/Units/PhysicalConstants.h> 0088 0089 #include "G4CSGSolid.hh" 0090 0091 /** 0092 * @brief G4Torus represents a torus or torus segment with curved sides 0093 * parallel to the z-axis. The torus has a specified swept radius about which 0094 * it is centered, and a given minimum and maximum radius. A minimum radius 0095 * of 0 signifies a filled torus. 0096 * The torus segment is specified by starting and delta angles for phi, 0097 * with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI 0098 * signifies a complete, unsegmented torus/cylinder. 0099 */ 0100 0101 class G4Torus : public G4CSGSolid 0102 { 0103 0104 public: 0105 0106 /** 0107 * Constructs a torus or torus segment with the given name and dimensions. 0108 * @param[in] pName The name of the solid. 0109 * @param[in] pRmin Inner radius. 0110 * @param[in] pRmax Outer radius. 0111 * @param[in] pRtor Swept radius of torus. 0112 * @param[in] pSPhi Starting Phi angle in radians 0113 * adjusted such that fSPhi+fDPhi<=2PI, fSPhi>-2PI. 0114 * @param[in] pDPhi Delta angle of the segment in radians. 0115 */ 0116 G4Torus(const G4String& pName, 0117 G4double pRmin, 0118 G4double pRmax, 0119 G4double pRtor, 0120 G4double pSPhi, 0121 G4double pDPhi); 0122 0123 /** 0124 * Default destructor. 0125 */ 0126 ~G4Torus() override = default; 0127 0128 /** 0129 * Accessors. 0130 */ 0131 inline G4double GetRmin() const; 0132 inline G4double GetRmax() const; 0133 inline G4double GetRtor() const; 0134 inline G4double GetSPhi() const; 0135 inline G4double GetDPhi() const; 0136 inline G4double GetSinStartPhi () const; 0137 inline G4double GetCosStartPhi () const; 0138 inline G4double GetSinEndPhi () const; 0139 inline G4double GetCosEndPhi () const; 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,const G4ThreeVector& v, 0188 const G4bool calcNorm = false, 0189 G4bool* validNorm = nullptr, 0190 G4ThreeVector* n = nullptr) const override; 0191 G4double DistanceToOut(const G4ThreeVector& p) const override; 0192 0193 /** 0194 * Returns the type ID, "G4Torus" of the solid. 0195 */ 0196 G4GeometryType GetEntityType() const override; 0197 0198 /** 0199 * Returns a random point located and uniformly distributed on the 0200 * surface of the solid. 0201 */ 0202 G4ThreeVector GetPointOnSurface() const override; 0203 0204 /** 0205 * Makes a clone of the object for use in multi-treading. 0206 * @returns A pointer to the new cloned allocated solid. 0207 */ 0208 G4VSolid* Clone() const override; 0209 0210 /** 0211 * Streams the object contents to an output stream. 0212 */ 0213 std::ostream& StreamInfo(std::ostream& os) const override; 0214 0215 /** 0216 * Methods for creating graphical representations (i.e. for visualisation). 0217 */ 0218 void DescribeYourselfTo (G4VGraphicsScene& scene) const override; 0219 G4Polyhedron* CreatePolyhedron () const override; 0220 0221 /** 0222 * Checks and sets all the parameters given in input. Used in constructor. 0223 */ 0224 void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor, 0225 G4double pSPhi, G4double pDPhi); 0226 0227 /** 0228 * Fake default constructor for usage restricted to direct object 0229 * persistency for clients requiring preallocation of memory for 0230 * persistifiable objects. 0231 */ 0232 G4Torus(__void__&); 0233 0234 /** 0235 * Copy constructor and assignment operator. 0236 */ 0237 G4Torus(const G4Torus& rhs) = default; 0238 G4Torus& operator=(const G4Torus& rhs); 0239 0240 private: 0241 0242 /** 0243 * Calculates the real roots to the torus surface, using the 0244 * G4JTPolynomialSolver class. Returns negative solutions as well. 0245 */ 0246 void TorusRootsJT(const G4ThreeVector& p, 0247 const G4ThreeVector& v, 0248 G4double r, 0249 std::vector<G4double>& roots) const ; 0250 0251 /** 0252 * Interface method for DistanceToIn() and DistanceToOut(). 0253 * Calls TorusRootsJT() using the Jenkins-Traub algorithm for real 0254 * polynomial root finding. 0255 * @returns The smalles possible distance to the surface. 0256 */ 0257 G4double SolveNumericJT(const G4ThreeVector& p, 0258 const G4ThreeVector& v, 0259 G4double r, 0260 G4bool IsDistanceToIn) const; 0261 0262 /** 0263 * Algorithm for SurfaceNormal() following the original specification 0264 * for points not on the surface. 0265 */ 0266 G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const; 0267 0268 private: 0269 0270 /** The cached parameters, ensured within range. */ 0271 G4double fRmin, fRmax, fRtor, fSPhi, fDPhi; 0272 0273 /** Radial and angular tolerances. */ 0274 G4double fRminTolerance, fRmaxTolerance, kRadTolerance, kAngTolerance; 0275 0276 /** Cached half tolerance values. */ 0277 G4double halfCarTolerance, halfAngTolerance; 0278 }; 0279 0280 #include "G4Torus.icc" 0281 0282 #endif // defined(G4GEOM_USE_UTORUS) && defined(G4GEOM_USE_SYS_USOLIDS) 0283 0284 0285 #endif // G4TORUS_HH
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|