Geant4-11
G4Tet.hh
Go to the documentation of this file.
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 intellectual property of the *
19// * Vanderbilt University Free Electron Laser Center *
20// * Vanderbilt University, Nashville, TN, USA *
21// * Development supported by: *
22// * United States MFEL program under grant FA9550-04-1-0045 *
23// * and NASA under contract number NNG04CT05P. *
24// * Written by Marcus H. Mendenhall and Robert A. Weller. *
25// * *
26// * Contributed to the Geant4 Core, January, 2005. *
27// * *
28// ********************************************************************
29//
30// G4Tet
31//
32// Class description:
33//
34// A G4Tet is a tetrahedra solid.
35
36// 03.09.2004 - M.H.Mendenhall & R.A.Weller (Vanderbilt University, USA)
37// 08.01.2020 - E.Tcherniaev, complete revision, speed up
38// --------------------------------------------------------------------
39#ifndef G4TET_HH
40#define G4TET_HH
41
42#include "G4GeomTypes.hh"
43
44#if defined(G4GEOM_USE_USOLIDS)
45#define G4GEOM_USE_UTET 1
46#endif
47
48#if defined(G4GEOM_USE_UTET)
49 #define G4UTet G4Tet
50 #include "G4UTet.hh"
51#else
52
53#include "G4VSolid.hh"
54
55class G4Tet : public G4VSolid
56{
57
58 public: // with description
59
60 // Constructor
61 G4Tet(const G4String& pName,
62 const G4ThreeVector& anchor,
63 const G4ThreeVector& p1,
64 const G4ThreeVector& p2,
65 const G4ThreeVector& p3,
66 G4bool* degeneracyFlag = nullptr);
67
68 // Destructor
69 virtual ~G4Tet();
70
71 // Modifier
72 void SetVertices(const G4ThreeVector& anchor,
73 const G4ThreeVector& p1,
74 const G4ThreeVector& p2,
75 const G4ThreeVector& p3,
76 G4bool* degeneracyFlag = nullptr);
77
78 // Accessors, return the four vertices of the shape
79 void GetVertices(G4ThreeVector& anchor,
80 G4ThreeVector& p1,
81 G4ThreeVector& p2,
82 G4ThreeVector& p3) const;
83 std::vector<G4ThreeVector> GetVertices() const;
84
85 // Set warning flag - depricated (dummy)
87
88 // Return true if the tetrahedron is degenerate
90 const G4ThreeVector& p1,
91 const G4ThreeVector& p2,
92 const G4ThreeVector& p3) const;
93
94 // Standard methods
96 const G4int n,
97 const G4VPhysicalVolume* pRep);
98
101 G4bool CalculateExtent(const EAxis pAxis,
102 const G4VoxelLimits& pVoxelLimit,
103 const G4AffineTransform& pTransform,
104 G4double& pmin, G4double& pmax) const;
105
106 EInside Inside(const G4ThreeVector& p) const;
109 const G4ThreeVector& v) const;
110 G4double DistanceToIn(const G4ThreeVector& p) const;
112 const G4ThreeVector& v,
113 const G4bool calcNorm = false,
114 G4bool* validNorm = nullptr,
115 G4ThreeVector* n = nullptr) const;
116 G4double DistanceToOut(const G4ThreeVector& p) const;
117
119
120 G4VSolid* Clone() const;
121
122 std::ostream& StreamInfo(std::ostream& os) const;
123
126
128
129 // Methods for visualization
130 void DescribeYourselfTo (G4VGraphicsScene& scene) const;
131 G4VisExtent GetExtent () const;
133 G4Polyhedron* GetPolyhedron () const;
134
135 public: // without description
136
137 // Fake default constructor for usage restricted to direct object
138 // persistency for clients requiring preallocation of memory for
139 // persistifiable objects
140 G4Tet(__void__&);
141
142 // Copy constructor
143 G4Tet(const G4Tet& rhs);
144
145 // Assignment operator
146 G4Tet& operator=(const G4Tet& rhs);
147
148 private:
149
150 // Set data members
151 void Initialize(const G4ThreeVector& p0,
152 const G4ThreeVector& p1,
153 const G4ThreeVector& p2,
154 const G4ThreeVector& p3);
155
156 // Return normal to surface closest to p
158
159 private:
160
162 G4double fCubicVolume = 0; // Volume
163 G4double fSurfaceArea = 0; // Surface area
164 mutable G4bool fRebuildPolyhedron = false;
165 mutable G4Polyhedron* fpPolyhedron = nullptr;
166
167 G4ThreeVector fVertex[4]; // thetrahedron vertices
168 G4ThreeVector fNormal[4]; // normals to faces
169 G4double fDist[4] = {0}; // distances from origin to faces
170 G4double fArea[4] = {0}; // face areas
171 G4ThreeVector fBmin, fBmax; // bounding box
172};
173
174#endif
175
176#endif
static const G4double pMax
static const G4double pMin
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Definition: G4Tet.hh:56
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Tet.cc:488
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Tet.cc:313
G4ThreeVector fVertex[4]
Definition: G4Tet.hh:167
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Tet.cc:370
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
Definition: G4Tet.cc:528
G4Polyhedron * fpPolyhedron
Definition: G4Tet.hh:165
G4double fCubicVolume
Definition: G4Tet.hh:162
G4Tet & operator=(const G4Tet &rhs)
Definition: G4Tet.cc:140
G4ThreeVector fBmax
Definition: G4Tet.hh:171
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Tet.cc:360
virtual ~G4Tet()
Definition: G4Tet.cc:113
G4Polyhedron * GetPolyhedron() const
Definition: G4Tet.cc:719
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Tet.cc:434
G4GeometryType GetEntityType() const
Definition: G4Tet.cc:585
G4ThreeVector fNormal[4]
Definition: G4Tet.hh:168
void SetBoundingLimits(const G4ThreeVector &pMin, const G4ThreeVector &pMax)
Definition: G4Tet.cc:323
G4Tet(const G4String &pName, const G4ThreeVector &anchor, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, G4bool *degeneracyFlag=nullptr)
Definition: G4Tet.cc:66
G4ThreeVector GetPointOnSurface() const
Definition: G4Tet.cc:624
void PrintWarnings(G4bool)
Definition: G4Tet.hh:86
G4double GetSurfaceArea()
Definition: G4Tet.cc:658
G4double halfTolerance
Definition: G4Tet.hh:161
G4ThreeVector fBmin
Definition: G4Tet.hh:171
G4double fArea[4]
Definition: G4Tet.hh:170
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Tet.cc:603
void Initialize(const G4ThreeVector &p0, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3)
Definition: G4Tet.cc:202
G4bool fRebuildPolyhedron
Definition: G4Tet.hh:164
G4VSolid * Clone() const
Definition: G4Tet.cc:594
G4double GetCubicVolume()
Definition: G4Tet.cc:649
G4bool CheckDegeneracy(const G4ThreeVector &p0, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3) const
Definition: G4Tet.cc:173
G4Polyhedron * CreatePolyhedron() const
Definition: G4Tet.cc:687
G4double fDist[4]
Definition: G4Tet.hh:169
std::vector< G4ThreeVector > GetVertices() const
Definition: G4Tet.cc:301
G4double fSurfaceArea
Definition: G4Tet.hh:163
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition: G4Tet.cc:471
void SetVertices(const G4ThreeVector &anchor, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, G4bool *degeneracyFlag=nullptr)
Definition: G4Tet.cc:250
G4VisExtent GetExtent() const
Definition: G4Tet.cc:676
EInside Inside(const G4ThreeVector &p) const
Definition: G4Tet.cc:420
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Tet.cc:667
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:67