Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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, defined by 4 points in space.
35
36// Author: M.H.Mendenhall & R.A.Weller (Vanderbilt University, USA), 03.09.2004
37// E.Tcherniaev (CERN), 08.01.2020 - 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
55/**
56 * @brief G4Tet is a tetrahedra solid, defined by 4 points in space.
57 */
58
59class G4Tet : public G4VSolid
60{
61 public:
62
63 /**
64 * Constructs a tetrahedra, given its parameters.
65 * @param[in] pName The solid name.
66 * @param[in] anchor The anchor point.
67 * @param[in] p2 Point 2.
68 * @param[in] p3 Point 3.
69 * @param[in] p4 Point 4.
70 * @param[in] degeneracyFlag Flag indicating degeneracy of points.
71 */
72 G4Tet(const G4String& pName,
73 const G4ThreeVector& anchor,
74 const G4ThreeVector& p2,
75 const G4ThreeVector& p3,
76 const G4ThreeVector& p4,
77 G4bool* degeneracyFlag = nullptr);
78
79 /**
80 * Destructor.
81 */
82 ~G4Tet() override;
83
84 /**
85 * Modifier and accessors, for the four vertices of the shape.
86 */
87 void SetVertices(const G4ThreeVector& anchor,
88 const G4ThreeVector& p1,
89 const G4ThreeVector& p2,
90 const G4ThreeVector& p3,
91 G4bool* degeneracyFlag = nullptr);
92 void GetVertices(G4ThreeVector& anchor,
93 G4ThreeVector& p1,
94 G4ThreeVector& p2,
95 G4ThreeVector& p3) const;
96 std::vector<G4ThreeVector> GetVertices() const;
97
98 /**
99 * Checks if the tetrahedron is degenerate. A tetrahedron is considered
100 * as degenerate in case its minimal height is less than the degeneracy
101 * tolerance
102 * @returns true if the tetrahedron is degenerate.
103 */
105 const G4ThreeVector& p1,
106 const G4ThreeVector& p2,
107 const G4ThreeVector& p3) const;
108
109 /**
110 * Dispatch method for parameterisation replication mechanism and
111 * dimension computation.
112 */
114 const G4int n,
115 const G4VPhysicalVolume* pRep) override;
116
117 /**
118 * Computes the bounding limits of the solid.
119 * @param[out] pMin The minimum bounding limit point.
120 * @param[out] pMax The maximum bounding limit point.
121 */
122 void SetBoundingLimits(const G4ThreeVector& pMin, const G4ThreeVector& pMax);
123 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
124
125 /**
126 * Calculates the minimum and maximum extent of the solid, when under the
127 * specified transform, and within the specified limits.
128 * @param[in] pAxis The axis along which compute the extent.
129 * @param[in] pVoxelLimit The limiting space dictated by voxels.
130 * @param[in] pTransform The internal transformation applied to the solid.
131 * @param[out] pMin The minimum extent value.
132 * @param[out] pMax The maximum extent value.
133 * @returns True if the solid is intersected by the extent region.
134 */
135 G4bool CalculateExtent(const EAxis pAxis,
136 const G4VoxelLimits& pVoxelLimit,
137 const G4AffineTransform& pTransform,
138 G4double& pmin, G4double& pmax) const override;
139
140 /**
141 * Concrete implementations of the expected query interfaces for
142 * solids, as defined in the base class G4VSolid.
143 */
144 EInside Inside(const G4ThreeVector& p) const override;
145 G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
147 const G4ThreeVector& v) const override;
148 G4double DistanceToIn(const G4ThreeVector& p) const override;
150 const G4ThreeVector& v,
151 const G4bool calcNorm = false,
152 G4bool* validNorm = nullptr,
153 G4ThreeVector* n = nullptr) const override;
154 G4double DistanceToOut(const G4ThreeVector& p) const override;
155
156 /**
157 * Returns the type ID, "G4Tet" of the solid.
158 */
159 G4GeometryType GetEntityType() const override;
160
161 /**
162 * Returns true as the solid has only planar faces.
163 */
164 G4bool IsFaceted () const override;
165
166 /**
167 * Makes a clone of the object for use in multi-treading.
168 * @returns A pointer to the new cloned allocated solid.
169 */
170 G4VSolid* Clone() const override;
171
172 /**
173 * Streams the object contents to an output stream.
174 */
175 std::ostream& StreamInfo(std::ostream& os) const override;
176
177 /**
178 * Returning an estimation of the solid volume (capacity) and
179 * surface area, in internal units.
180 */
181 G4double GetCubicVolume() override;
182 G4double GetSurfaceArea() override;
183
184 /**
185 * Returns a random point located and uniformly distributed on the
186 * surface of the solid.
187 */
188 G4ThreeVector GetPointOnSurface() const override;
189
190 /**
191 * Methods for creating graphical representations (i.e. for visualisation).
192 */
193 void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
194 G4VisExtent GetExtent () const override;
195 G4Polyhedron* CreatePolyhedron () const override;
196 G4Polyhedron* GetPolyhedron () const override;
197
198 /**
199 * Fake default constructor for usage restricted to direct object
200 * persistency for clients requiring preallocation of memory for
201 * persistifiable objects.
202 */
203 G4Tet(__void__&);
204
205 /**
206 * Copy constructor and assignment operator.
207 */
208 G4Tet(const G4Tet& rhs);
209 G4Tet& operator=(const G4Tet& rhs);
210
211 private:
212
213 /**
214 * Initialises the data members.
215 */
216 void Initialize(const G4ThreeVector& p0,
217 const G4ThreeVector& p1,
218 const G4ThreeVector& p2,
219 const G4ThreeVector& p3);
220
221 /**
222 * Algorithm for SurfaceNormal() following the original specification
223 * for points not on the surface.
224 */
225 G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
226
227 private:
228
229 G4double halfTolerance = 0;
230 G4double fCubicVolume = 0; // Volume
231 G4double fSurfaceArea = 0; // Surface area
232 mutable G4bool fRebuildPolyhedron = false;
233 mutable G4Polyhedron* fpPolyhedron = nullptr;
234
235 G4ThreeVector fVertex[4]; // thetrahedron vertices
236 G4ThreeVector fNormal[4]; // normals to faces
237 G4double fDist[4] = {0}; // distances from origin to faces
238 G4double fArea[4] = {0}; // face areas
239 G4ThreeVector fBmin, fBmax; // bounding box
240};
241
242#endif
243
244#endif
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4String G4GeometryType
Definition G4VSolid.hh:70
G4AffineTransform is a class for geometric affine transformations. It supports efficient arbitrary ro...
G4Polyhedron * CreatePolyhedron() const override
Definition G4Tet.cc:706
G4VSolid * Clone() const override
Definition G4Tet.cc:611
G4Polyhedron * GetPolyhedron() const override
Definition G4Tet.cc:738
G4bool IsFaceted() const override
Definition G4Tet.cc:602
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
Definition G4Tet.cc:373
G4GeometryType GetEntityType() const override
Definition G4Tet.cc:593
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
Definition G4Tet.cc:686
G4Tet & operator=(const G4Tet &rhs)
Definition G4Tet.cc:140
G4ThreeVector GetPointOnSurface() const override
Definition G4Tet.cc:641
G4double GetSurfaceArea() override
Definition G4Tet.cc:677
void SetBoundingLimits(const G4ThreeVector &pMin, const G4ThreeVector &pMax)
Definition G4Tet.cc:326
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
Definition G4Tet.cc:536
std::ostream & StreamInfo(std::ostream &os) const override
Definition G4Tet.cc:620
G4double GetCubicVolume() override
Definition G4Tet.cc:668
G4Tet(const G4String &pName, const G4ThreeVector &anchor, const G4ThreeVector &p2, const G4ThreeVector &p3, const G4ThreeVector &p4, G4bool *degeneracyFlag=nullptr)
Definition G4Tet.cc:66
G4VisExtent GetExtent() const override
Definition G4Tet.cc:695
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
Definition G4Tet.cc:437
G4bool CheckDegeneracy(const G4ThreeVector &p0, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3) const
Definition G4Tet.cc:173
std::vector< G4ThreeVector > GetVertices() const
Definition G4Tet.cc:304
~G4Tet() override
Definition G4Tet.cc:113
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
Definition G4Tet.cc:316
EInside Inside(const G4ThreeVector &p) const override
Definition G4Tet.cc:423
void SetVertices(const G4ThreeVector &anchor, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, G4bool *degeneracyFlag=nullptr)
Definition G4Tet.cc:253
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Tet.cc:363
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
Definition G4Tet.cc:496
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...
EAxis
Definition geomdefs.hh:54
EInside
Definition geomdefs.hh:67