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 // G4EllipticalCone 27 // 28 // Class description: 29 // 30 // G4EllipticalCone is a full cone with elliptical base which can be cut in Z. 31 // 32 // Member Data: 33 // 34 // xSemiAxis semi-axis, x, without dimentions 35 // ySemiAxis semi-axis, y, without dimentions 36 // zheight height, z 37 // zTopCut upper cut plane level, z 38 // 39 // The height in Z corresponds to where the elliptical cone hits the 40 // Z-axis if it had no Z cut. Also the cone is centered at zero having a 41 // base at zTopCut and another at -zTopCut. The semi-major axes at the Z=0 42 // plane are given by xSemiAxis*zheight and ySemiAxis*zheight so that the 43 // curved surface of our cone satisfies the equation: 44 // 45 // *************************************************************************** 46 // * * 47 // * (x/xSemiAxis)^2 + (y/ySemiAxis)^2 = (zheight - z)^2 * 48 // * * 49 // *************************************************************************** 50 // 51 // In case you want to construct G4EllipticalCone from: 52 // 1. halflength in Z = zTopCut 53 // 2. Dx and Dy = halflength of ellipse axis at z = -zTopCut 54 // 3. dx and dy = halflength of ellipse axis at z = zTopCut 55 // ! Attention : dx/dy=Dx/Dy 56 // 57 // You need to find xSemiAxis,ySemiAxis and zheight: 58 // 59 // xSemiAxis = (Dx-dx)/(2*zTopCut) 60 // ySemiAxis = (Dy-dy)/(2*zTopCut) 61 // zheight = (Dx+dx)/(2*xSemiAxis) 62 63 // Author: Dionysios Anninos, 8.9.2005 64 // Revisions: 65 // Lukas Lindroos, Tatiana Nikitina, 20.08.2007 66 // Evgueni Tcherniaev, 20.07.2017 67 // -------------------------------------------------------------------- 68 #ifndef G4ELLIPTICALCONE_HH 69 #define G4ELLIPTICALCONE_HH 70 71 #include "G4GeomTypes.hh" 72 73 #if defined(G4GEOM_USE_USOLIDS) 74 #define G4GEOM_USE_UELLIPTICALCONE 1 75 #endif 76 77 #if (defined(G4GEOM_USE_UELLIPTICALCONE) && defined(G4GEOM_USE_SYS_USOLIDS)) 78 #define G4UEllipticalCone G4EllipticalCone 79 #include "G4UEllipticalCone.hh" 80 #else 81 82 #include <CLHEP/Units/PhysicalConstants.h> 83 84 #include "G4VSolid.hh" 85 #include "G4Polyhedron.hh" 86 87 class G4EllipticalCone : public G4VSolid 88 { 89 public: 90 91 G4EllipticalCone(const G4String& pName, 92 G4double pxSemiAxis, 93 G4double pySemiAxis, 94 G4double zMax, 95 G4double pzTopCut); 96 97 ~G4EllipticalCone() override; 98 99 // Access functions 100 // 101 inline G4double GetSemiAxisMin () const; 102 inline G4double GetSemiAxisMax () const; 103 inline G4double GetSemiAxisX () const; 104 inline G4double GetSemiAxisY () const; 105 inline G4double GetZMax() const; 106 inline G4double GetZTopCut() const; 107 inline void SetSemiAxis (G4double x, G4double y, G4double z); 108 inline void SetZCut (G4double newzTopCut); 109 110 G4double GetCubicVolume() override; 111 G4double GetSurfaceArea() override; 112 113 // Solid standard methods 114 // 115 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override; 116 117 G4bool CalculateExtent(const EAxis pAxis, 118 const G4VoxelLimits& pVoxelLimit, 119 const G4AffineTransform& pTransform, 120 G4double& pMin, G4double& pMax) const override; 121 122 EInside Inside(const G4ThreeVector& p) const override; 123 124 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override; 125 126 G4double DistanceToIn(const G4ThreeVector& p, 127 const G4ThreeVector& v) const override; 128 129 G4double DistanceToIn(const G4ThreeVector& p) const override; 130 131 G4double DistanceToOut(const G4ThreeVector& p, 132 const G4ThreeVector& v, 133 const G4bool calcNorm = false, 134 G4bool* validNorm = nullptr, 135 G4ThreeVector* n = nullptr) const override; 136 137 G4double DistanceToOut(const G4ThreeVector& p) const override; 138 139 G4GeometryType GetEntityType() const override; 140 141 G4VSolid* Clone() const override; 142 143 G4ThreeVector GetPointOnSurface() const override; 144 145 std::ostream& StreamInfo(std::ostream& os) const override; 146 147 // Visualisation functions 148 // 149 G4Polyhedron* GetPolyhedron () const override; 150 void DescribeYourselfTo(G4VGraphicsScene& scene) const override; 151 G4VisExtent GetExtent() const override; 152 G4Polyhedron* CreatePolyhedron() const override; 153 154 G4EllipticalCone(__void__&); 155 // Fake default constructor for usage restricted to direct object 156 // persistency for clients requiring preallocation of memory for 157 // persistifiable objects. 158 159 G4EllipticalCone(const G4EllipticalCone& rhs); 160 G4EllipticalCone& operator=(const G4EllipticalCone& rhs); 161 // Copy constructor and assignment operator. 162 163 protected: 164 165 mutable G4bool fRebuildPolyhedron = false; 166 mutable G4Polyhedron* fpPolyhedron = nullptr; 167 168 private: 169 170 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const; 171 // Algorithm for SurfaceNormal() following the original 172 // specification for points not on the surface 173 174 private: 175 176 G4double halfCarTol; 177 G4double fCubicVolume = 0.0; 178 G4double fSurfaceArea = 0.0; 179 G4double xSemiAxis, ySemiAxis, zheight, zTopCut; 180 G4double cosAxisMin, invXX, invYY; 181 }; 182 183 #include "G4EllipticalCone.icc" 184 185 #endif // defined(G4GEOM_USE_UELLIPTICALCONE) && defined(G4GEOM_USE_SYS_USOLIDS) 186 187 #endif // G4ELLIPTICALCONE_HH 188