ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Ellipsoid.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Ellipsoid.hh
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 
59 
60 #include "G4VSolid.hh"
61 #include "G4Polyhedron.hh"
62 
63 class G4Ellipsoid : public G4VSolid
64 {
65  public:
66 
67  // Constructor
68  G4Ellipsoid(const G4String& name,
69  G4double xSemiAxis,
70  G4double ySemiAxis,
71  G4double zSemiAxis,
72  G4double zBottomCut = 0.,
73  G4double zTopCut = 0.);
74 
75  // Destructor
76  virtual ~G4Ellipsoid();
77 
78  // Accessors
79  inline G4double GetDx() const;
80  inline G4double GetDy() const;
81  inline G4double GetDz() const;
82  inline G4double GetSemiAxisMax (G4int i) const;
83  inline G4double GetZBottomCut() const;
84  inline G4double GetZTopCut() const;
85 
86  // Modifiers
87  inline void SetSemiAxis (G4double x, G4double y, G4double z);
88  inline void SetZCuts (G4double newzBottomCut, G4double newzTopCut);
89 
90  // Standard methods
92  const G4int n,
93  const G4VPhysicalVolume* pRep);
94 
96  G4bool CalculateExtent(const EAxis pAxis,
97  const G4VoxelLimits& pVoxelLimit,
98  const G4AffineTransform& pTransform,
99  G4double& pmin, G4double& pmax) const;
100 
101  EInside Inside(const G4ThreeVector& p) const;
102  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
104  const G4ThreeVector& v) const;
105  G4double DistanceToIn(const G4ThreeVector& p) const;
107  const G4ThreeVector& v,
108  const G4bool calcNorm = false,
109  G4bool* validNorm = nullptr,
110  G4ThreeVector* n = nullptr) const;
111  G4double DistanceToOut(const G4ThreeVector& p) const;
112 
114 
115  G4VSolid* Clone() const;
116 
117  std::ostream& StreamInfo(std::ostream& os) const;
118 
121 
123 
124  // Visualisation methods
125  void DescribeYourselfTo(G4VGraphicsScene& scene) const;
126  G4VisExtent GetExtent() const;
128  G4Polyhedron* GetPolyhedron () const;
129 
130  public:
131 
132  // Fake default constructor for usage restricted to direct object
133  // persistency for clients requiring preallocation of memory for
134  // persistifiable objects
135  G4Ellipsoid(__void__&);
136 
137  // Copy constructorassignment operator
138  G4Ellipsoid(const G4Ellipsoid& rhs);
139 
140  // Assignment
141  G4Ellipsoid& operator=(const G4Ellipsoid& rhs);
142 
143  private:
144 
145  // Check parameters and set cached values
146  void CheckParameters();
147 
148  // Return normal to surface closest to p
150 
151  // Calculate area of lateral surface
153 
154  private:
155 
156  // Ellipsoid parameters
157  G4double fDx; // X semi-axis
158  G4double fDy; // Y semi-axis
159  G4double fDz; // Z semi-axis
160  G4double fZBottomCut; // Bottom cut in Z
161  G4double fZTopCut; // Top cut in Z
162 
163  // Precalculated cached values
164  G4double halfTolerance; // Surface tolerance
165  G4double fXmax; // X extent
166  G4double fYmax; // Y extent
167  G4double fRsph; // Radius of bounding sphere
168  G4double fR; // Radius of sphere after scaling
169  G4double fSx; // X scale factor
170  G4double fSy; // Y scale factor
171  G4double fSz; // Z scale factor
172  G4double fZMidCut; // Middle position between cuts after scaling
173  G4double fZDimCut; // Half distance between cut after scaling
174  G4double fQ1; // 1st coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2
175  G4double fQ2; // 2nd coefficient in approximation of dist = Q1*(x^2+y^2+z^2) - Q2
176 
177  G4double fCubicVolume = 0.0; // Volume
178  G4double fSurfaceArea = 0.0; // Surface area
179  mutable G4double fLateralArea = 0.0; // Lateral surface area
180  mutable G4bool fRebuildPolyhedron = false;
181  mutable G4Polyhedron* fpPolyhedron = nullptr;
182 };
183 
184 #include "G4Ellipsoid.icc"
185 
186 #endif // defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS)
187 
188 #endif // G4ELLIPSOID_HH