|
|
|||
File indexing completed on 2026-09-20 09:11:02
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 // G4Ellipsoid 0027 // 0028 // Class description: 0029 // 0030 // A G4Ellipsoid is an ellipsoidal solid, optionally cut at a given z. 0031 // 0032 // Member Data: 0033 // xSemiAxis semi-axis, X 0034 // ySemiAxis semi-axis, Y 0035 // zSemiAxis semi-axis, Z 0036 // zBottomCut lower cut in Z (solid lies above this plane) 0037 // zTopCut upper cut in Z (solid lies below this plane) 0038 0039 // Author: G.Horton-Smith (Caltech, USA), 10.11.1999 - First implementation 0040 // G.Guerrieri (INFN Genova, Italy), 10.02.2005 - Revision 0041 // E.Tcherniaev (CERN), 15.12.2019 - Complete revision 0042 // -------------------------------------------------------------------- 0043 #ifndef G4ELLIPSOID_HH 0044 #define G4ELLIPSOID_HH 0045 0046 #include "G4GeomTypes.hh" 0047 0048 #if defined(G4GEOM_USE_USOLIDS) 0049 #define G4GEOM_USE_UELLIPSOID 1 0050 #endif 0051 0052 #if (defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS)) 0053 #define G4UEllipsoid G4Ellipsoid 0054 #include "G4UEllipsoid.hh" 0055 #else 0056 0057 #include <CLHEP/Units/PhysicalConstants.h> 0058 0059 #include "G4VSolid.hh" 0060 #include "G4Polyhedron.hh" 0061 0062 /** 0063 * @brief G4Ellipsoid is an ellipsoidal solid, optionally cut at a given Z. 0064 */ 0065 0066 class G4Ellipsoid : public G4VSolid 0067 { 0068 public: 0069 0070 /** 0071 * Constructs an ellipsoid, given its input parameters. 0072 * @param[in] name The solid name. 0073 * @param[in] xSemiAxis Semiaxis in X. 0074 * @param[in] ySemiAxis Semiaxis in Y. 0075 * @param[in] zSemiAxis Semiaxis in Z. 0076 * @param[in] zBottomCut Optional lower cut plane level in Z. 0077 * @param[in] zTopCut Optional upper cut plane level in Z. 0078 */ 0079 G4Ellipsoid(const G4String& name, 0080 G4double xSemiAxis, 0081 G4double ySemiAxis, 0082 G4double zSemiAxis, 0083 G4double zBottomCut = 0., 0084 G4double zTopCut = 0.); 0085 0086 /** 0087 * Destructor. 0088 */ 0089 ~G4Ellipsoid() override; 0090 0091 /** 0092 * Accessors. 0093 */ 0094 inline G4double GetDx() const; 0095 inline G4double GetDy() const; 0096 inline G4double GetDz() const; 0097 inline G4double GetSemiAxisMax (G4int i) const; 0098 inline G4double GetZBottomCut() const; 0099 inline G4double GetZTopCut() const; 0100 0101 /** 0102 * Modifiers. 0103 */ 0104 inline void SetSemiAxis (G4double x, G4double y, G4double z); 0105 inline void SetZCuts (G4double newzBottomCut, G4double newzTopCut); 0106 0107 /** 0108 * Dispatch method for parameterisation replication mechanism and 0109 * dimension computation. 0110 */ 0111 void ComputeDimensions(G4VPVParameterisation* p, 0112 const G4int n, 0113 const G4VPhysicalVolume* pRep) override; 0114 0115 /** 0116 * Computes the bounding limits of the solid. 0117 * @param[out] pMin The minimum bounding limit point. 0118 * @param[out] pMax The maximum bounding limit point. 0119 */ 0120 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 0121 0122 /** 0123 * Calculates the minimum and maximum extent of the solid, when under the 0124 * specified transform, and within the specified limits. 0125 * @param[in] pAxis The axis along which compute the extent. 0126 * @param[in] pVoxelLimit The limiting space dictated by voxels. 0127 * @param[in] pTransform The internal transformation applied to the solid. 0128 * @param[out] pMin The minimum extent value. 0129 * @param[out] pMax The maximum extent value. 0130 * @returns True if the solid is intersected by the extent region. 0131 */ 0132 G4bool CalculateExtent(const EAxis pAxis, 0133 const G4VoxelLimits& pVoxelLimit, 0134 const G4AffineTransform& pTransform, 0135 G4double& pmin, G4double& pmax) const override; 0136 0137 /** 0138 * Concrete implementations of the expected query interfaces for 0139 * solids, as defined in the base class G4VSolid. 0140 */ 0141 EInside Inside(const G4ThreeVector& p) const override; 0142 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override; 0143 G4double DistanceToIn(const G4ThreeVector& p, 0144 const G4ThreeVector& v) const override; 0145 G4double DistanceToIn(const G4ThreeVector& p) const override; 0146 G4double DistanceToOut(const G4ThreeVector& p, 0147 const G4ThreeVector& v, 0148 const G4bool calcNorm = false, 0149 G4bool* validNorm = nullptr, 0150 G4ThreeVector* n = nullptr) const override; 0151 G4double DistanceToOut(const G4ThreeVector& p) const override; 0152 0153 /** 0154 * Returns the type ID, "G4Ellipsoid" of the solid. 0155 */ 0156 G4GeometryType GetEntityType() const override; 0157 0158 /** 0159 * Makes a clone of the object for use in multi-treading. 0160 * @returns A pointer to the new cloned allocated solid. 0161 */ 0162 G4VSolid* Clone() const override; 0163 0164 /** 0165 * Streams the object contents to an output stream. 0166 */ 0167 std::ostream& StreamInfo(std::ostream& os) const override; 0168 0169 /** 0170 * Returning an estimation of the solid volume (capacity) and 0171 * surface area, in internal units. 0172 */ 0173 G4double GetCubicVolume() override; 0174 G4double GetSurfaceArea() override; 0175 0176 /** 0177 * Returns a random point located and uniformly distributed on the 0178 * surface of the solid. 0179 */ 0180 G4ThreeVector GetPointOnSurface() const override; 0181 0182 /** 0183 * Methods for creating graphical representations (i.e. for visualisation). 0184 */ 0185 void DescribeYourselfTo(G4VGraphicsScene& scene) const override; 0186 G4VisExtent GetExtent() const override; 0187 G4Polyhedron* CreatePolyhedron() const override; 0188 G4Polyhedron* GetPolyhedron() const override; 0189 0190 /** 0191 * Fake default constructor for usage restricted to direct object 0192 * persistency for clients requiring preallocation of memory for 0193 * persistifiable objects. 0194 */ 0195 G4Ellipsoid(__void__&); 0196 0197 /** 0198 * Copy constructor and assignment operator. 0199 */ 0200 G4Ellipsoid(const G4Ellipsoid& rhs); 0201 G4Ellipsoid& operator=(const G4Ellipsoid& rhs); 0202 0203 private: 0204 0205 /** 0206 * Checks parameters and sets cached values. 0207 */ 0208 void CheckParameters(); 0209 0210 /** 0211 * Algorithm for SurfaceNormal() following the original specification 0212 * for points not on the surface. 0213 */ 0214 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const; 0215 0216 /** 0217 * Calculates the area of lateral surface. 0218 */ 0219 G4double LateralSurfaceArea() const; 0220 0221 private: 0222 0223 /** Ellipsoid parameters. */ 0224 G4double fDx; // X semi-axis 0225 G4double fDy; // Y semi-axis 0226 G4double fDz; // Z semi-axis 0227 G4double fZBottomCut; // Bottom cut in Z 0228 G4double fZTopCut; // Top cut in Z 0229 0230 /** Precalculated cached values. */ 0231 G4double halfTolerance; // Surface tolerance 0232 G4double fXmax; // X extent 0233 G4double fYmax; // Y extent 0234 G4double fRsph; // Radius of bounding sphere 0235 G4double fR; // Radius of sphere after scaling 0236 G4double fSx; // X scale factor 0237 G4double fSy; // Y scale factor 0238 G4double fSz; // Z scale factor 0239 G4double fZMidCut; // Middle position between cuts after scaling 0240 G4double fZDimCut; // Half distance between cut after scaling 0241 G4double fQ1; // 1st coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2 0242 G4double fQ2; // 2nd coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2 0243 0244 G4double fCubicVolume = 0.0; // Volume 0245 G4double fSurfaceArea = 0.0; // Surface area 0246 mutable G4double fLateralArea = 0.0; // Lateral surface area 0247 mutable G4bool fRebuildPolyhedron = false; 0248 mutable G4Polyhedron* fpPolyhedron = nullptr; 0249 }; 0250 0251 #include "G4Ellipsoid.icc" 0252 0253 #endif // defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS) 0254 0255 #endif // G4ELLIPSOID_HH
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|