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

#include <G4Tet.hh>

+ Inheritance diagram for G4Tet:

Public Member Functions

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

Definition at line 55 of file G4Tet.hh.

Constructor & Destructor Documentation

◆ G4Tet() [1/3]

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

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)
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)
Definition: G4Exception.cc:59
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
G4double kCarTolerance
Definition: G4VSolid.hh:299

◆ ~G4Tet()

G4Tet::~G4Tet ( )
virtual

Definition at line 113 of file G4Tet.cc.

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

◆ G4Tet() [2/3]

G4Tet::G4Tet ( __void__ &  a)

Definition at line 104 of file G4Tet.cc.

105 : G4VSolid(a)
106{
107}

◆ G4Tet() [3/3]

G4Tet::G4Tet ( const G4Tet rhs)

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
virtual

Reimplemented from G4VSolid.

Definition at line 360 of file G4Tet.cc.

361{
362 pMin = fBmin;
363 pMax = fBmax;
364}

Referenced by CalculateExtent().

◆ CalculateExtent()

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

Implements G4VSolid.

Definition at line 370 of file G4Tet.cc.

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

◆ CheckDegeneracy()

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

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) { if (ss[i] > ss[k]) k = i; }
193
194 // Check: vol^2 / s^2 <= hmin^2
195 return (vol*vol <= ss[k]*hmin*hmin);
196}
double G4double
Definition: G4Types.hh:83

Referenced by G4Tet(), and SetVertices().

◆ Clone()

G4VSolid * G4Tet::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 594 of file G4Tet.cc.

595{
596 return new G4Tet(*this);
597}
Definition: G4Tet.hh:56

◆ ComputeDimensions()

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

Reimplemented from G4VSolid.

Definition at line 313 of file G4Tet.cc.

316{
317}

◆ CreatePolyhedron()

G4Polyhedron * G4Tet::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 687 of file G4Tet.cc.

688{
689 // Check orientation of vertices
690 G4ThreeVector v1 = fVertex[1] - fVertex[0];
691 G4ThreeVector v2 = fVertex[2] - fVertex[0];
692 G4ThreeVector v3 = fVertex[3] - fVertex[0];
693 G4bool invert = v1.cross(v2).dot(v3) < 0.;
694 G4int k2 = (invert) ? 3 : 2;
695 G4int k3 = (invert) ? 2 : 3;
696
697 // Set coordinates of vertices
698 G4double xyz[4][3];
699 for (G4int i = 0; i < 3; ++i)
700 {
701 xyz[0][i] = fVertex[0][i];
702 xyz[1][i] = fVertex[1][i];
703 xyz[2][i] = fVertex[k2][i];
704 xyz[3][i] = fVertex[k3][i];
705 }
706
707 // Create polyhedron
708 G4int faces[4][4] = { {1,3,2,0}, {1,4,3,0}, {1,2,4,0}, {2,3,4,0} };
709 G4Polyhedron* ph = new G4Polyhedron;
710 ph->createPolyhedron(4,4,xyz,faces);
711
712 return ph;
713}
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])

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

◆ DescribeYourselfTo()

void G4Tet::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 667 of file G4Tet.cc.

668{
669 scene.AddSolid (*this);
670}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

G4double G4Tet::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 515 of file G4Tet.cc.

516{
517 G4double dd[4];
518 for (G4int i = 0; i < 4; ++i) { dd[i] = fNormal[i].dot(p) - fDist[i]; }
519
520 G4double dist = std::max(std::max(std::max(dd[0], dd[1]), dd[2]), dd[3]);
521 return (dist > 0.) ? dist : 0.;
522}

◆ DistanceToIn() [2/2]

G4double G4Tet::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 488 of file G4Tet.cc.

490{
491 G4double tin = -DBL_MAX, tout = DBL_MAX;
492 for (G4int i = 0; i < 4; ++i)
493 {
494 G4double cosa = fNormal[i].dot(v);
495 G4double dist = fNormal[i].dot(p) - fDist[i];
496 if (dist >= -halfTolerance)
497 {
498 if (cosa >= 0.) { return kInfinity; }
499 tin = std::max(tin, -dist/cosa);
500 }
501 else if (cosa > 0.)
502 {
503 tout = std::min(tout, -dist/cosa);
504 }
505 }
506
507 return (tout - tin <= halfTolerance) ?
508 kInfinity : ((tin < halfTolerance) ? 0. : tin);
509}
#define DBL_MAX
Definition: templates.hh:62

◆ DistanceToOut() [1/2]

G4double G4Tet::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 572 of file G4Tet.cc.

573{
574 G4double dd[4];
575 for (G4int i = 0; i < 4; ++i) { dd[i] = fDist[i] - fNormal[i].dot(p); }
576
577 G4double dist = std::min(std::min(std::min(dd[0], dd[1]), dd[2]), dd[3]);
578 return (dist > 0.) ? dist : 0.;
579}

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 528 of file G4Tet.cc.

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

◆ GetCubicVolume()

G4double G4Tet::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 649 of file G4Tet.cc.

650{
651 return fCubicVolume;
652}

◆ GetEntityType()

G4GeometryType G4Tet::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 585 of file G4Tet.cc.

586{
587 return G4String("G4Tet");
588}

Referenced by StreamInfo().

◆ GetExtent()

G4VisExtent G4Tet::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 676 of file G4Tet.cc.

677{
678 return G4VisExtent(fBmin.x(), fBmax.x(),
679 fBmin.y(), fBmax.y(),
680 fBmin.z(), fBmax.z());
681}
double z() const
double x() const
double y() const

◆ GetPointOnSurface()

G4ThreeVector G4Tet::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 624 of file G4Tet.cc.

625{
626 constexpr G4int iface[4][3] = { {0,1,2}, {0,2,3}, {0,3,1}, {1,2,3} };
627
628 // Select face
629 G4double select = fSurfaceArea*G4QuickRand();
630 G4int i = 0;
631 for ( ; i < 4; ++i) { if ((select -= fArea[i]) <= 0.) break; }
632
633 // Set selected triangle
634 G4ThreeVector p0 = fVertex[iface[i][0]];
635 G4ThreeVector e1 = fVertex[iface[i][1]] - p0;
636 G4ThreeVector e2 = fVertex[iface[i][2]] - p0;
637
638 // Return random point
639 G4double r1 = G4QuickRand();
640 G4double r2 = G4QuickRand();
641 return (r1 + r2 > 1.) ?
642 p0 + e1*(1. - r1) + e2*(1. - r2) : p0 + e1*r1 + e2*r2;
643}
G4double G4QuickRand()
Definition: G4QuickRand.hh:34

◆ GetPolyhedron()

G4Polyhedron * G4Tet::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 719 of file G4Tet.cc.

720{
721 if (fpPolyhedron == nullptr ||
722 fRebuildPolyhedron ||
724 fpPolyhedron->GetNumberOfRotationSteps())
725 {
726 G4AutoLock l(&polyhedronMutex);
727 delete fpPolyhedron;
728 fpPolyhedron = CreatePolyhedron();
729 fRebuildPolyhedron = false;
730 l.unlock();
731 }
732 return fpPolyhedron;
733}
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4Polyhedron * CreatePolyhedron() const
Definition: G4Tet.cc:687
static G4int GetNumberOfRotationSteps()

◆ GetSurfaceArea()

G4double G4Tet::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 658 of file G4Tet.cc.

659{
660 return fSurfaceArea;
661}

◆ GetVertices() [1/2]

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

Definition at line 301 of file G4Tet.cc.

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

Referenced by CalculateExtent().

◆ GetVertices() [2/2]

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

Definition at line 286 of file G4Tet.cc.

290{
291 p0 = fVertex[0];
292 p1 = fVertex[1];
293 p2 = fVertex[2];
294 p3 = fVertex[3];
295}

Referenced by G4GDMLWriteSolids::TetWrite().

◆ Inside()

EInside G4Tet::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 420 of file G4Tet.cc.

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

◆ 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:107

◆ PrintWarnings()

void G4Tet::PrintWarnings ( G4bool  )
inline

Definition at line 86 of file G4Tet.hh.

86{};

◆ SetBoundingLimits()

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

Definition at line 323 of file G4Tet.cc.

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

◆ SetVertices()

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

Definition at line 250 of file G4Tet.cc.

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

◆ StreamInfo()

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

Implements G4VSolid.

Definition at line 603 of file G4Tet.cc.

604{
605 G4long oldprc = os.precision(16);
606 os << "-----------------------------------------------------------\n"
607 << " *** Dump for solid - " << GetName() << " ***\n"
608 << " ===================================================\n"
609 << " Solid type: " << GetEntityType() << "\n"
610 << " Parameters: \n"
611 << " anchor: " << fVertex[0]/mm << " mm\n"
612 << " p1 : " << fVertex[1]/mm << " mm\n"
613 << " p2 : " << fVertex[2]/mm << " mm\n"
614 << " p3 : " << fVertex[3]/mm << " mm\n"
615 << "-----------------------------------------------------------\n";
616 os.precision(oldprc);
617 return os;
618}
long G4long
Definition: G4Types.hh:87
G4GeometryType GetEntityType() const
Definition: G4Tet.cc:585

◆ SurfaceNormal()

G4ThreeVector G4Tet::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 434 of file G4Tet.cc.

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

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