Geant4 Cross Reference |
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 // G4Ellipsoid 27 // 28 // Class description: 29 // 30 // A G4Ellipsoid is an ellipsoidal solid, optionally cut at a given z 31 // 32 // Member Data: 33 // 34 // xSemiAxis semi-axis, X 35 // ySemiAxis semi-axis, Y 36 // zSemiAxis semi-axis, Z 37 // zBottomCut lower cut in Z (solid lies above this plane) 38 // zTopCut upper cut in Z (solid lies below this plane) 39 40 // 10.11.1999 G.Horton-Smith (Caltech, USA) - First implementation 41 // 10.02.2005 G.Guerrieri (INFN Genova, Italy) - Revision 42 // 15.12.2019 E.Tcherniaev - Complete revision 43 // -------------------------------------------------------------------- 44 #ifndef G4ELLIPSOID_HH 45 #define G4ELLIPSOID_HH 46 47 #include "G4GeomTypes.hh" 48 49 #if defined(G4GEOM_USE_USOLIDS) 50 #define G4GEOM_USE_UELLIPSOID 1 51 #endif 52 53 #if (defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS)) 54 #define G4UEllipsoid G4Ellipsoid 55 #include "G4UEllipsoid.hh" 56 #else 57 58 #include <CLHEP/Units/PhysicalConstants.h> 59 60 #include "G4VSolid.hh" 61 #include "G4Polyhedron.hh" 62 63 class G4Ellipsoid : public G4VSolid 64 { 65 public: 66 67 G4Ellipsoid(const G4String& name, 68 G4double xSemiAxis, 69 G4double ySemiAxis, 70 G4double zSemiAxis, 71 G4double zBottomCut = 0., 72 G4double zTopCut = 0.); 73 74 ~G4Ellipsoid() override; 75 76 // Accessors 77 inline G4double GetDx() const; 78 inline G4double GetDy() const; 79 inline G4double GetDz() const; 80 inline G4double GetSemiAxisMax (G4int i) const; 81 inline G4double GetZBottomCut() const; 82 inline G4double GetZTopCut() const; 83 84 // Modifiers 85 inline void SetSemiAxis (G4double x, G4double y, G4double z); 86 inline void SetZCuts (G4double newzBottomCut, G4double newzTopCut); 87 88 // Standard methods 89 void ComputeDimensions(G4VPVParameterisation* p, 90 const G4int n, 91 const G4VPhysicalVolume* pRep) override; 92 93 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 94 G4bool CalculateExtent(const EAxis pAxis, 95 const G4VoxelLimits& pVoxelLimit, 96 const G4AffineTransform& pTransform, 97 G4double& pmin, G4double& pmax) const override; 98 99 EInside Inside(const G4ThreeVector& p) const override; 100 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override; 101 G4double DistanceToIn(const G4ThreeVector& p, 102 const G4ThreeVector& v) const override; 103 G4double DistanceToIn(const G4ThreeVector& p) const override; 104 G4double DistanceToOut(const G4ThreeVector& p, 105 const G4ThreeVector& v, 106 const G4bool calcNorm = false, 107 G4bool* validNorm = nullptr, 108 G4ThreeVector* n = nullptr) const override; 109 G4double DistanceToOut(const G4ThreeVector& p) const override; 110 111 G4GeometryType GetEntityType() const override; 112 113 G4VSolid* Clone() const override; 114 115 std::ostream& StreamInfo(std::ostream& os) const override; 116 117 G4double GetCubicVolume() override; 118 G4double GetSurfaceArea() override; 119 120 G4ThreeVector GetPointOnSurface() const override; 121 122 // Visualisation methods 123 void DescribeYourselfTo(G4VGraphicsScene& scene) const override; 124 G4VisExtent GetExtent() const override; 125 G4Polyhedron* CreatePolyhedron() const override; 126 G4Polyhedron* GetPolyhedron () const override; 127 128 // Fake default constructor for usage restricted to direct object 129 // persistency for clients requiring preallocation of memory for 130 // persistifiable objects 131 G4Ellipsoid(__void__&); 132 133 // Copy constructorassignment operator 134 G4Ellipsoid(const G4Ellipsoid& rhs); 135 136 // Assignment 137 G4Ellipsoid& operator=(const G4Ellipsoid& rhs); 138 139 private: 140 141 // Check parameters and set cached values 142 void CheckParameters(); 143 144 // Return normal to surface closest to p 145 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const; 146 147 // Calculate area of lateral surface 148 G4double LateralSurfaceArea() const; 149 150 private: 151 152 // Ellipsoid parameters 153 G4double fDx; // X semi-axis 154 G4double fDy; // Y semi-axis 155 G4double fDz; // Z semi-axis 156 G4double fZBottomCut; // Bottom cut in Z 157 G4double fZTopCut; // Top cut in Z 158 159 // Precalculated cached values 160 G4double halfTolerance; // Surface tolerance 161 G4double fXmax; // X extent 162 G4double fYmax; // Y extent 163 G4double fRsph; // Radius of bounding sphere 164 G4double fR; // Radius of sphere after scaling 165 G4double fSx; // X scale factor 166 G4double fSy; // Y scale factor 167 G4double fSz; // Z scale factor 168 G4double fZMidCut; // Middle position between cuts after scaling 169 G4double fZDimCut; // Half distance between cut after scaling 170 G4double fQ1; // 1st coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2 171 G4double fQ2; // 2nd coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2 172 173 G4double fCubicVolume = 0.0; // Volume 174 G4double fSurfaceArea = 0.0; // Surface area 175 mutable G4double fLateralArea = 0.0; // Lateral surface area 176 mutable G4bool fRebuildPolyhedron = false; 177 mutable G4Polyhedron* fpPolyhedron = nullptr; 178 }; 179 180 #include "G4Ellipsoid.icc" 181 182 #endif // defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS) 183 184 #endif // G4ELLIPSOID_HH 185