Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Tet Class Reference

G4Tet is a tetrahedra solid, defined by 4 points in space. More...

#include <G4Tet.hh>

Inheritance diagram for G4Tet:

Public Member Functions

 G4Tet (const G4String &pName, const G4ThreeVector &anchor, const G4ThreeVector &p2, const G4ThreeVector &p3, const G4ThreeVector &p4, G4bool *degeneracyFlag=nullptr)
 ~G4Tet () override
void SetVertices (const G4ThreeVector &anchor, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, G4bool *degeneracyFlag=nullptr)
void GetVertices (G4ThreeVector &anchor, G4ThreeVector &p1, G4ThreeVector &p2, G4ThreeVector &p3) const
std::vector< G4ThreeVectorGetVertices () const
G4bool CheckDegeneracy (const G4ThreeVector &p0, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3) const
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
void SetBoundingLimits (const G4ThreeVector &pMin, const G4ThreeVector &pMax)
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
EInside Inside (const G4ThreeVector &p) const override
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const override
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double DistanceToIn (const G4ThreeVector &p) const override
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double DistanceToOut (const G4ThreeVector &p) const override
G4GeometryType GetEntityType () const override
G4bool IsFaceted () const override
G4VSolidClone () const override
std::ostream & StreamInfo (std::ostream &os) const override
G4double GetCubicVolume () override
G4double GetSurfaceArea () override
G4ThreeVector GetPointOnSurface () const override
void DescribeYourselfTo (G4VGraphicsScene &scene) const override
G4VisExtent GetExtent () const override
G4PolyhedronCreatePolyhedron () const override
G4PolyhedronGetPolyhedron () const override
 G4Tet (__void__ &)
 G4Tet (const G4Tet &rhs)
G4Tetoperator= (const G4Tet &rhs)
Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
virtual ~G4VSolid ()
 G4VSolid (const G4VSolid &rhs)
G4VSolidoperator= (const G4VSolid &rhs)
G4bool operator== (const G4VSolid &s) const
G4String GetName () const
void SetName (const G4String &name)
G4double GetTolerance () const
virtual G4int GetNumOfConstituents () const
void DumpInfo () const
virtual const G4VSolidGetConstituentSolid (G4int no) const
virtual G4VSolidGetConstituentSolid (G4int no)
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 G4VSolid (__void__ &)
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
G4double EstimateSurfaceArea (G4int nStat, G4double epsilon) const

Additional Inherited Members

Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
Protected Attributes inherited from G4VSolid
G4double kCarTolerance

Detailed Description

G4Tet is a tetrahedra solid, defined by 4 points in space.

Definition at line 59 of file G4Tet.hh.

Constructor & Destructor Documentation

◆ G4Tet() [1/3]

G4Tet::G4Tet ( const G4String & pName,
const G4ThreeVector & anchor,
const G4ThreeVector & p2,
const G4ThreeVector & p3,
const G4ThreeVector & p4,
G4bool * degeneracyFlag = nullptr )

Constructs a tetrahedra, given its parameters.

Parameters
[in]pNameThe solid name.
[in]anchorThe anchor point.
[in]p2Point 2.
[in]p3Point 3.
[in]p4Point 4.
[in]degeneracyFlagFlag indicating degeneracy of points.

Definition at line 66 of file G4Tet.cc.

71 : G4VSolid(pName)
72{
73 // Check for degeneracy
74 G4bool degenerate = CheckDegeneracy(p0, p1, p2, p3);
75 if (degeneracyFlag != nullptr)
76 {
77 *degeneracyFlag = degenerate;
78 }
79 else if (degenerate)
80 {
81 std::ostringstream message;
82 message << "Degenerate tetrahedron: " << GetName() << " !\n"
83 << " anchor: " << p0 << "\n"
84 << " p1 : " << p1 << "\n"
85 << " p2 : " << p2 << "\n"
86 << " p3 : " << p3 << "\n"
87 << " volume: "
88 << std::abs((p1 - p0).cross(p2 - p0).dot(p3 - p0))/6.;
89 G4Exception("G4Tet::G4Tet()", "GeomSolids0002", FatalException, message);
90 }
91
92 // Define surface thickness
93 halfTolerance = 0.5 * kCarTolerance;
94
95 // Set data members
96 Initialize(p0, p1, p2, p3);
97}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
bool G4bool
Definition G4Types.hh:86
G4bool CheckDegeneracy(const G4ThreeVector &p0, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3) const
Definition G4Tet.cc:173
G4String GetName() const
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59
G4double kCarTolerance
Definition G4VSolid.hh:418

Referenced by Clone(), G4Tet(), and operator=().

◆ ~G4Tet()

G4Tet::~G4Tet ( )
override

Destructor.

Definition at line 113 of file G4Tet.cc.

114{
115 delete fpPolyhedron; fpPolyhedron = nullptr;
116}

◆ G4Tet() [2/3]

G4Tet::G4Tet ( __void__ & a)

Fake default constructor for usage restricted to direct object persistency for clients requiring preallocation of memory for persistifiable objects.

Definition at line 104 of file G4Tet.cc.

105 : G4VSolid(a)
106{
107}

◆ G4Tet() [3/3]

G4Tet::G4Tet ( const G4Tet & rhs)

Copy constructor and assignment operator.

Definition at line 122 of file G4Tet.cc.

123 : G4VSolid(rhs)
124{
125 halfTolerance = rhs.halfTolerance;
126 fCubicVolume = rhs.fCubicVolume;
127 fSurfaceArea = rhs.fSurfaceArea;
128 for (G4int i = 0; i < 4; ++i) { fVertex[i] = rhs.fVertex[i]; }
129 for (G4int i = 0; i < 4; ++i) { fNormal[i] = rhs.fNormal[i]; }
130 for (G4int i = 0; i < 4; ++i) { fDist[i] = rhs.fDist[i]; }
131 for (G4int i = 0; i < 4; ++i) { fArea[i] = rhs.fArea[i]; }
132 fBmin = rhs.fBmin;
133 fBmax = rhs.fBmax;
134}
int G4int
Definition G4Types.hh:85

Member Function Documentation

◆ BoundingLimits()

void G4Tet::BoundingLimits ( G4ThreeVector & pMin,
G4ThreeVector & pMax ) const
overridevirtual

Computes the bounding limits of the solid.

Parameters
[out]pMinThe minimum bounding limit point.
[out]pMaxThe maximum bounding limit point.

Reimplemented from G4VSolid.

Definition at line 363 of file G4Tet.cc.

364{
365 pMin = fBmin;
366 pMax = fBmax;
367}

Referenced by CalculateExtent().

◆ CalculateExtent()

G4bool G4Tet::CalculateExtent ( const EAxis pAxis,
const G4VoxelLimits & pVoxelLimit,
const G4AffineTransform & pTransform,
G4double & pmin,
G4double & pmax ) const
overridevirtual

Calculates the minimum and maximum extent of the solid, when under the specified transform, and within the specified limits.

Parameters
[in]pAxisThe axis along which compute the extent.
[in]pVoxelLimitThe limiting space dictated by voxels.
[in]pTransformThe internal transformation applied to the solid.
[out]pMinThe minimum extent value.
[out]pMaxThe maximum extent value.
Returns
True if the solid is intersected by the extent region.

Implements G4VSolid.

Definition at line 373 of file G4Tet.cc.

377{
378 G4ThreeVector bmin, bmax;
379
380 // Check bounding box (bbox)
381 //
382 BoundingLimits(bmin,bmax);
383 G4BoundingEnvelope bbox(bmin,bmax);
384
385 // Use simple bounding-box to help in the case of complex 3D meshes
386 //
387 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
388
389#if 0
390 // Precise extent computation (disabled by default for this shape)
391 //
392 G4bool exist;
393 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
394 {
395 return exist = (pMin < pMax) ? true : false;
396 }
397
398 // Set bounding envelope (benv) and calculate extent
399 //
400 std::vector<G4ThreeVector> vec = GetVertices();
401
402 G4ThreeVectorList anchor(1);
403 anchor[0].set(vec[0].x(),vec[0].y(),vec[0].z());
404
405 G4ThreeVectorList base(3);
406 base[0].set(vec[1].x(),vec[1].y(),vec[1].z());
407 base[1].set(vec[2].x(),vec[2].y(),vec[2].z());
408 base[2].set(vec[3].x(),vec[3].y(),vec[3].z());
409
410 std::vector<const G4ThreeVectorList *> polygons(2);
411 polygons[0] = &anchor;
412 polygons[1] = &base;
413
414 G4BoundingEnvelope benv(bmin,bmax,polygons);
415 return exists = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
416#endif
417}
std::vector< G4ThreeVector > G4ThreeVectorList
CLHEP::Hep3Vector G4ThreeVector
std::vector< G4ThreeVector > GetVertices() const
Definition G4Tet.cc:304
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
Definition G4Tet.cc:363
bool exists(std::string const &a_path)
Definition LUPI_file.cc:129

◆ CheckDegeneracy()

G4bool G4Tet::CheckDegeneracy ( const G4ThreeVector & p0,
const G4ThreeVector & p1,
const G4ThreeVector & p2,
const G4ThreeVector & p3 ) const

Checks if the tetrahedron is degenerate. A tetrahedron is considered as degenerate in case its minimal height is less than the degeneracy tolerance

Returns
true if the tetrahedron is degenerate.

Definition at line 173 of file G4Tet.cc.

177{
178 G4double hmin = 4. * kCarTolerance; // degeneracy tolerance
179
180 // Calculate volume
181 G4double vol = std::abs((p1 - p0).cross(p2 - p0).dot(p3 - p0));
182
183 // Calculate face areas squared
184 G4double ss[4];
185 ss[0] = ((p1 - p0).cross(p2 - p0)).mag2();
186 ss[1] = ((p2 - p0).cross(p3 - p0)).mag2();
187 ss[2] = ((p3 - p0).cross(p1 - p0)).mag2();
188 ss[3] = ((p2 - p1).cross(p3 - p1)).mag2();
189
190 // Find face with max area
191 G4int k = 0;
192 for (G4int i = 1; i < 4; ++i)
193 {
194 if (ss[i] > ss[k]) { k = i; }
195 }
196
197 // Check: vol^2 / s^2 <= hmin^2
198 return (vol*vol <= ss[k]*hmin*hmin);
199}
double G4double
Definition G4Types.hh:83

Referenced by G4Tet(), and SetVertices().

◆ Clone()

G4VSolid * G4Tet::Clone ( ) const
overridevirtual

Makes a clone of the object for use in multi-treading.

Returns
A pointer to the new cloned allocated solid.

Reimplemented from G4VSolid.

Definition at line 611 of file G4Tet.cc.

612{
613 return new G4Tet(*this);
614}
G4Tet(const G4String &pName, const G4ThreeVector &anchor, const G4ThreeVector &p2, const G4ThreeVector &p3, const G4ThreeVector &p4, G4bool *degeneracyFlag=nullptr)
Definition G4Tet.cc:66

◆ ComputeDimensions()

void G4Tet::ComputeDimensions ( G4VPVParameterisation * p,
const G4int n,
const G4VPhysicalVolume * pRep )
overridevirtual

Dispatch method for parameterisation replication mechanism and dimension computation.

Reimplemented from G4VSolid.

Definition at line 316 of file G4Tet.cc.

319{
320}

◆ CreatePolyhedron()

G4Polyhedron * G4Tet::CreatePolyhedron ( ) const
overridevirtual

Creates a Polyhedron used for Visualisation. It is the caller's responsibility to delete it. A null pointer means "not created".

Reimplemented from G4VSolid.

Definition at line 706 of file G4Tet.cc.

707{
708 // Check orientation of vertices
709 G4ThreeVector v1 = fVertex[1] - fVertex[0];
710 G4ThreeVector v2 = fVertex[2] - fVertex[0];
711 G4ThreeVector v3 = fVertex[3] - fVertex[0];
712 G4bool invert = v1.cross(v2).dot(v3) < 0.;
713 G4int k2 = (invert) ? 3 : 2;
714 G4int k3 = (invert) ? 2 : 3;
715
716 // Set coordinates of vertices
717 G4double xyz[4][3];
718 for (G4int i = 0; i < 3; ++i)
719 {
720 xyz[0][i] = fVertex[0][i];
721 xyz[1][i] = fVertex[1][i];
722 xyz[2][i] = fVertex[k2][i];
723 xyz[3][i] = fVertex[k3][i];
724 }
725
726 // Create polyhedron
727 G4int faces[4][4] = { {1,3,2,0}, {1,4,3,0}, {1,2,4,0}, {2,3,4,0} };
728 auto ph = new G4Polyhedron;
729 ph->createPolyhedron(4,4,xyz,faces);
730
731 return ph;
732}
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const

Referenced by G4ArrowModel::G4ArrowModel(), and GetPolyhedron().

◆ DescribeYourselfTo()

void G4Tet::DescribeYourselfTo ( G4VGraphicsScene & scene) const
overridevirtual

Methods for creating graphical representations (i.e. for visualisation).

Implements G4VSolid.

Definition at line 686 of file G4Tet.cc.

687{
688 scene.AddSolid (*this);
689}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

G4double G4Tet::DistanceToIn ( const G4ThreeVector & p) const
overridevirtual

Calculates the distance to the nearest surface of a shape from an outside point. The distance can be an underestimate.

Parameters
[in]pThe point at offset p.
Returns
The safety distance to enter the shape.

Implements G4VSolid.

Definition at line 523 of file G4Tet.cc.

524{
525 G4double dd[4];
526 for (G4int i = 0; i < 4; ++i) { dd[i] = fNormal[i].dot(p) - fDist[i]; }
527
528 G4double dist = std::max(std::max(std::max(dd[0], dd[1]), dd[2]), dd[3]);
529 return (dist > 0.) ? dist : 0.;
530}

◆ DistanceToIn() [2/2]

G4double G4Tet::DistanceToIn ( const G4ThreeVector & p,
const G4ThreeVector & v ) const
overridevirtual

Returns the distance along the normalised vector 'v' to the shape, from the point at offset 'p'. If there is no intersection, returns kInfinity. The first intersection resulting from 'leaving' a surface/volume is discarded. Hence, it is tolerant of points on the surface of the shape.

Parameters
[in]pThe point at offset p.
[in]vThe normalised direction vector.
Returns
The distance to enter the shape.

Implements G4VSolid.

Definition at line 496 of file G4Tet.cc.

498{
499 G4double tin = -DBL_MAX, tout = DBL_MAX;
500 for (G4int i = 0; i < 4; ++i)
501 {
502 G4double cosa = fNormal[i].dot(v);
503 G4double dist = fNormal[i].dot(p) - fDist[i];
504 if (dist >= -halfTolerance)
505 {
506 if (cosa >= 0.) { return kInfinity; }
507 tin = std::max(tin, -dist/cosa);
508 }
509 else if (cosa > 0.)
510 {
511 tout = std::min(tout, -dist/cosa);
512 }
513 }
514
515 return (tout - tin <= halfTolerance) ?
516 kInfinity : ((tin < halfTolerance) ? 0. : tin);
517}
#define DBL_MAX
Definition templates.hh:62

◆ DistanceToOut() [1/2]

G4double G4Tet::DistanceToOut ( const G4ThreeVector & p) const
overridevirtual

Calculates the distance to the nearest surface of a shape from an inside point 'p'. The distance can be an underestimate.

Parameters
[in]pThe point at offset p.
Returns
The safety distance to exit the shape.

Implements G4VSolid.

Definition at line 580 of file G4Tet.cc.

581{
582 G4double dd[4];
583 for (G4int i = 0; i < 4; ++i) { dd[i] = fDist[i] - fNormal[i].dot(p); }
584
585 G4double dist = std::min(std::min(std::min(dd[0], dd[1]), dd[2]), dd[3]);
586 return (dist > 0.) ? dist : 0.;
587}

◆ DistanceToOut() [2/2]

G4double G4Tet::DistanceToOut ( const G4ThreeVector & p,
const G4ThreeVector & v,
const G4bool calcNorm = false,
G4bool * validNorm = nullptr,
G4ThreeVector * n = nullptr ) const
overridevirtual

Returns the distance along the normalised vector 'v' to the shape, from a point at an offset 'p' inside or on the surface of the shape. Intersections with surfaces, when the point is less than Tolerance/2 from a surface must be ignored.

Parameters
[in]pThe point at offset p.
[in]vThe normalised direction vector.
[in]calcNormFlag to indicate if to calculate the normal or not.
[out]validNormFlag set to true if the solid lies entirely behind or on the exiting surface. It is set false if the solid does not lie entirely behind or on the exiting surface. 'calcNorm' must be true, otherwise it is unused.
[out]nThe exiting outwards normal vector (undefined Magnitude). 'calcNorm' must be true, otherwise it is unused.
Returns
The distance to exit the shape.

Implements G4VSolid.

Definition at line 536 of file G4Tet.cc.

541{
542 // Calculate distances and cosines
543 G4double cosa[4], dist[4];
544 G4int ind[4] = {0}, nside = 0;
545 for (G4int i = 0; i < 4; ++i)
546 {
547 G4double tmp = fNormal[i].dot(v);
548 cosa[i] = tmp;
549 ind[nside] = (G4int)(tmp > 0) * i;
550 nside += (G4int)(tmp > 0);
551 dist[i] = fNormal[i].dot(p) - fDist[i];
552 }
553
554 // Find intersection (in most of cases nside == 1)
555 G4double tout = DBL_MAX;
556 G4int iside = 0;
557 for (G4int i = 0; i < nside; ++i)
558 {
559 G4int k = ind[i];
560 // Check: leaving the surface
561 if (dist[k] >= -halfTolerance) { tout = 0.; iside = k; break; }
562 // Compute distance to intersection
563 G4double tmp = -dist[k]/cosa[k];
564 if (tmp < tout) { tout = tmp; iside = k; }
565 }
566
567 // Set normal, if required, and return distance to out
568 if (calcNorm)
569 {
570 *validNorm = true;
571 *n = fNormal[iside];
572 }
573 return tout;
574}

◆ GetCubicVolume()

G4double G4Tet::GetCubicVolume ( )
overridevirtual

Returning an estimation of the solid volume (capacity) and surface area, in internal units.

Reimplemented from G4VSolid.

Definition at line 668 of file G4Tet.cc.

669{
670 return fCubicVolume;
671}

◆ GetEntityType()

G4GeometryType G4Tet::GetEntityType ( ) const
overridevirtual

Returns the type ID, "G4Tet" of the solid.

Implements G4VSolid.

Definition at line 593 of file G4Tet.cc.

594{
595 return {"G4Tet"};
596}

Referenced by StreamInfo().

◆ GetExtent()

G4VisExtent G4Tet::GetExtent ( ) const
overridevirtual

Provides extent (bounding box) as possible hint to the graphics view.

Reimplemented from G4VSolid.

Definition at line 695 of file G4Tet.cc.

696{
697 return { fBmin.x(), fBmax.x(),
698 fBmin.y(), fBmax.y(),
699 fBmin.z(), fBmax.z() };
700}

◆ GetPointOnSurface()

G4ThreeVector G4Tet::GetPointOnSurface ( ) const
overridevirtual

Returns a random point located and uniformly distributed on the surface of the solid.

Reimplemented from G4VSolid.

Definition at line 641 of file G4Tet.cc.

642{
643 constexpr G4int iface[4][3] = { {0,1,2}, {0,2,3}, {0,3,1}, {1,2,3} };
644
645 // Select face
646 G4double select = fSurfaceArea*G4QuickRand();
647 G4int i = 0;
648 i += (G4int)(select > fArea[0]);
649 i += (G4int)(select > fArea[0] + fArea[1]);
650 i += (G4int)(select > fArea[0] + fArea[1] + fArea[2]);
651
652 // Set selected triangle
653 G4ThreeVector p0 = fVertex[iface[i][0]];
654 G4ThreeVector e1 = fVertex[iface[i][1]] - p0;
655 G4ThreeVector e2 = fVertex[iface[i][2]] - p0;
656
657 // Return random point
658 G4double r1 = G4QuickRand();
659 G4double r2 = G4QuickRand();
660 return (r1 + r2 > 1.) ?
661 p0 + e1*(1. - r1) + e2*(1. - r2) : p0 + e1*r1 + e2*r2;
662}
G4double G4QuickRand(uint32_t seed=0)

◆ GetPolyhedron()

G4Polyhedron * G4Tet::GetPolyhedron ( ) const
overridevirtual

Smart access function - creates on request and stores for future access. A null pointer means "not available".

Reimplemented from G4VSolid.

Definition at line 738 of file G4Tet.cc.

739{
740 if (fpPolyhedron == nullptr ||
741 fRebuildPolyhedron ||
742 fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
743 fpPolyhedron->GetNumberOfRotationSteps())
744 {
745 G4AutoLock l(&polyhedronMutex);
746 delete fpPolyhedron;
747 fpPolyhedron = CreatePolyhedron();
748 fRebuildPolyhedron = false;
749 l.unlock();
750 }
751 return fpPolyhedron;
752}
G4TemplateAutoLock< G4Mutex > G4AutoLock
G4Polyhedron * CreatePolyhedron() const override
Definition G4Tet.cc:706

◆ GetSurfaceArea()

G4double G4Tet::GetSurfaceArea ( )
overridevirtual

Returns an estimation of the solid surface area in internal units. This method may be overloaded by derived classes to compute the exact geometrical quantity for solids where this is possible, or anyway to cache the computed value. Note: the computed value is NOT cached.

Reimplemented from G4VSolid.

Definition at line 677 of file G4Tet.cc.

678{
679 return fSurfaceArea;
680}

◆ GetVertices() [1/2]

std::vector< G4ThreeVector > G4Tet::GetVertices ( ) const

Definition at line 304 of file G4Tet.cc.

305{
306 std::vector<G4ThreeVector> vertices(4);
307 for (G4int i = 0; i < 4; ++i) { vertices[i] = fVertex[i]; }
308 return vertices;
309}

Referenced by CalculateExtent().

◆ GetVertices() [2/2]

void G4Tet::GetVertices ( G4ThreeVector & anchor,
G4ThreeVector & p1,
G4ThreeVector & p2,
G4ThreeVector & p3 ) const

Definition at line 289 of file G4Tet.cc.

293{
294 p0 = fVertex[0];
295 p1 = fVertex[1];
296 p2 = fVertex[2];
297 p3 = fVertex[3];
298}

Referenced by G4GDMLWriteSolids::TetWrite().

◆ Inside()

EInside G4Tet::Inside ( const G4ThreeVector & p) const
overridevirtual

Concrete implementations of the expected query interfaces for solids, as defined in the base class G4VSolid.

Implements G4VSolid.

Definition at line 423 of file G4Tet.cc.

424{
425 G4double dd[4];
426 for (G4int i = 0; i < 4; ++i) { dd[i] = fNormal[i].dot(p) - fDist[i]; }
427
428 G4double dist = std::max(std::max(std::max(dd[0], dd[1]), dd[2]), dd[3]);
429 return (dist <= -halfTolerance) ?
430 kInside : ((dist <= halfTolerance) ? kSurface : kOutside);
431}
@ kInside
Definition geomdefs.hh:70
@ kOutside
Definition geomdefs.hh:68
@ kSurface
Definition geomdefs.hh:69

◆ IsFaceted()

G4bool G4Tet::IsFaceted ( ) const
overridevirtual

Returns true as the solid has only planar faces.

Reimplemented from G4VSolid.

Definition at line 602 of file G4Tet.cc.

603{
604 return true;
605}

◆ operator=()

G4Tet & G4Tet::operator= ( const G4Tet & rhs)

Definition at line 140 of file G4Tet.cc.

141{
142 // Check assignment to self
143 //
144 if (this == &rhs) { return *this; }
145
146 // Copy base class data
147 //
149
150 // Copy data
151 //
152 halfTolerance = rhs.halfTolerance;
153 fCubicVolume = rhs.fCubicVolume;
154 fSurfaceArea = rhs.fSurfaceArea;
155 for (G4int i = 0; i < 4; ++i) { fVertex[i] = rhs.fVertex[i]; }
156 for (G4int i = 0; i < 4; ++i) { fNormal[i] = rhs.fNormal[i]; }
157 for (G4int i = 0; i < 4; ++i) { fDist[i] = rhs.fDist[i]; }
158 for (G4int i = 0; i < 4; ++i) { fArea[i] = rhs.fArea[i]; }
159 fBmin = rhs.fBmin;
160 fBmax = rhs.fBmax;
161 fRebuildPolyhedron = false;
162 delete fpPolyhedron; fpPolyhedron = nullptr;
163
164 return *this;
165}
G4VSolid & operator=(const G4VSolid &rhs)
Definition G4VSolid.cc:108

◆ SetBoundingLimits()

void G4Tet::SetBoundingLimits ( const G4ThreeVector & pMin,
const G4ThreeVector & pMax )

Computes the bounding limits of the solid.

Parameters
[out]pMinThe minimum bounding limit point.
[out]pMaxThe maximum bounding limit point.

Definition at line 326 of file G4Tet.cc.

328{
329 G4int iout[4] = { 0, 0, 0, 0 };
330 for (G4int i = 0; i < 4; ++i)
331 {
332 iout[i] = (G4int)(fVertex[i].x() < pMin.x() ||
333 fVertex[i].y() < pMin.y() ||
334 fVertex[i].z() < pMin.z() ||
335 fVertex[i].x() > pMax.x() ||
336 fVertex[i].y() > pMax.y() ||
337 fVertex[i].z() > pMax.z());
338 }
339 if (iout[0] + iout[1] + iout[2] + iout[3] != 0)
340 {
341 std::ostringstream message;
342 message << "Attempt to set bounding box that does not encapsulate solid: "
343 << GetName() << " !\n"
344 << " Specified bounding box limits:\n"
345 << " pmin: " << pMin << "\n"
346 << " pmax: " << pMax << "\n"
347 << " Tetrahedron vertices:\n"
348 << " anchor " << fVertex[0] << ((iout[0]) != 0 ? " is outside\n" : "\n")
349 << " p1 " << fVertex[1] << ((iout[1]) != 0 ? " is outside\n" : "\n")
350 << " p2 " << fVertex[2] << ((iout[2]) != 0 ? " is outside\n" : "\n")
351 << " p3 " << fVertex[3] << ((iout[3]) != 0 ? " is outside" : "");
352 G4Exception("G4Tet::SetBoundingLimits()", "GeomSolids0002",
353 FatalException, message);
354 }
355 fBmin = pMin;
356 fBmax = pMax;
357}
double z() const
double x() const
double y() const

◆ SetVertices()

void G4Tet::SetVertices ( const G4ThreeVector & anchor,
const G4ThreeVector & p1,
const G4ThreeVector & p2,
const G4ThreeVector & p3,
G4bool * degeneracyFlag = nullptr )

Modifier and accessors, for the four vertices of the shape.

Definition at line 253 of file G4Tet.cc.

257{
258 // Check for degeneracy
259 G4bool degenerate = CheckDegeneracy(p0, p1, p2, p3);
260 if (degeneracyFlag != nullptr)
261 {
262 *degeneracyFlag = degenerate;
263 }
264 else if (degenerate)
265 {
266 std::ostringstream message;
267 message << "Degenerate tetrahedron is not permitted: " << GetName() << " !\n"
268 << " anchor: " << p0 << "\n"
269 << " p1 : " << p1 << "\n"
270 << " p2 : " << p2 << "\n"
271 << " p3 : " << p3 << "\n"
272 << " volume: "
273 << std::abs((p1 - p0).cross(p2 - p0).dot(p3 - p0))/6.;
274 G4Exception("G4Tet::SetVertices()", "GeomSolids0002",
275 FatalException, message);
276 }
277
278 // Set data members
279 Initialize(p0, p1, p2, p3);
280
281 // Set flag to rebuild polyhedron
282 fRebuildPolyhedron = true;
283}

◆ StreamInfo()

std::ostream & G4Tet::StreamInfo ( std::ostream & os) const
overridevirtual

Streams the object contents to an output stream.

Implements G4VSolid.

Definition at line 620 of file G4Tet.cc.

621{
622 G4long oldprc = os.precision(16);
623 os << "-----------------------------------------------------------\n"
624 << " *** Dump for solid - " << GetName() << " ***\n"
625 << " ===================================================\n"
626 << " Solid type: " << GetEntityType() << "\n"
627 << " Parameters: \n"
628 << " anchor: " << fVertex[0]/mm << " mm\n"
629 << " p1 : " << fVertex[1]/mm << " mm\n"
630 << " p2 : " << fVertex[2]/mm << " mm\n"
631 << " p3 : " << fVertex[3]/mm << " mm\n"
632 << "-----------------------------------------------------------\n";
633 os.precision(oldprc);
634 return os;
635}
long G4long
Definition G4Types.hh:87
G4GeometryType GetEntityType() const override
Definition G4Tet.cc:593

◆ SurfaceNormal()

G4ThreeVector G4Tet::SurfaceNormal ( const G4ThreeVector & p) const
overridevirtual

Returns the outwards pointing unit normal of the shape for the surface closest to the point at offset 'p'.

Parameters
[in]pThe point at offset p.
Returns
The outwards pointing unit normal.

Implements G4VSolid.

Definition at line 437 of file G4Tet.cc.

438{
439 G4double k[4];
440 for (G4int i = 0; i < 4; ++i)
441 {
442 k[i] = (G4double)(std::abs(fNormal[i].dot(p) - fDist[i]) <= halfTolerance);
443 }
444 G4double nsurf = k[0] + k[1] + k[2] + k[3];
445 G4ThreeVector norm =
446 k[0]*fNormal[0] + k[1]*fNormal[1] + k[2]*fNormal[2] + k[3]*fNormal[3];
447
448 if (nsurf == 1.)
449 {
450 return norm;
451 }
452 if (nsurf > 1.)
453 {
454 return norm.unit(); // edge or vertex
455 }
456
457#ifdef G4SPECSDEBUG
458 std::ostringstream message;
459 G4long oldprc = message.precision(16);
460 message << "Point p is not on surface (!?) of solid: "
461 << GetName() << "\n";
462 message << "Position:\n";
463 message << " p.x() = " << p.x()/mm << " mm\n";
464 message << " p.y() = " << p.y()/mm << " mm\n";
465 message << " p.z() = " << p.z()/mm << " mm";
466 G4cout.precision(oldprc);
467 G4Exception("G4Tet::SurfaceNormal(p)", "GeomSolids1002",
468 JustWarning, message );
469 DumpInfo();
470#endif
471 return ApproxSurfaceNormal(p);
472}
@ JustWarning
G4GLOB_DLL std::ostream G4cout
Hep3Vector unit() const
void DumpInfo() const

The documentation for this class was generated from the following files: