Geant4-11
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4Hype Class Reference

#include <G4Hype.hh>

Inheritance diagram for G4Hype:
G4VSolid

Public Member Functions

void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
G4VSolidClone () const
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
G4PolyhedronCreatePolyhedron () const
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
 
void DumpInfo () const
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 
 G4Hype (__void__ &)
 
 G4Hype (const G4Hype &rhs)
 
 G4Hype (const G4String &pName, G4double newInnerRadius, G4double newOuterRadius, G4double newInnerStereo, G4double newOuterStereo, G4double newHalfLenZ)
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
G4double GetCubicVolume ()
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
G4GeometryType GetEntityType () const
 
G4VisExtent GetExtent () const
 
G4double GetInnerRadius () const
 
G4double GetInnerStereo () const
 
G4String GetName () const
 
G4double GetOuterRadius () const
 
G4double GetOuterStereo () const
 
G4ThreeVector GetPointOnSurface () const
 
G4PolyhedronGetPolyhedron () const
 
G4double GetSurfaceArea ()
 
G4double GetTolerance () const
 
G4double GetZHalfLength () const
 
EInside Inside (const G4ThreeVector &p) const
 
G4Hypeoperator= (const G4Hype &rhs)
 
G4bool operator== (const G4VSolid &s) const
 
void SetInnerRadius (G4double newIRad)
 
void SetInnerStereo (G4double newISte)
 
void SetName (const G4String &name)
 
void SetOuterRadius (G4double newORad)
 
void SetOuterStereo (G4double newOSte)
 
void SetZHalfLength (G4double newHLZ)
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
virtual ~G4Hype ()
 

Protected Types

enum  ESide { outerFace , innerFace , leftCap , rightCap }
 

Protected Member Functions

void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, 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 ClipCrossSection (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
 
G4double HypeInnerRadius2 (G4double zVal) const
 
G4double HypeOuterRadius2 (G4double zVal) const
 
G4bool InnerSurfaceExists () const
 

Static Protected Member Functions

static G4double ApproxDistInside (G4double pr, G4double pz, G4double r0, G4double tan2Phi)
 
static G4double ApproxDistOutside (G4double pr, G4double pz, G4double r0, G4double tanPhi)
 
static G4int IntersectHype (const G4ThreeVector &p, const G4ThreeVector &v, G4double r2, G4double tan2Phi, G4double s[2])
 

Protected Attributes

G4double endInnerRadius
 
G4double endInnerRadius2
 
G4double endOuterRadius
 
G4double endOuterRadius2
 
G4double halfLenZ
 
G4double innerRadius
 
G4double innerRadius2
 
G4double innerStereo
 
G4double kCarTolerance
 
G4double outerRadius
 
G4double outerRadius2
 
G4double outerStereo
 
G4double tanInnerStereo
 
G4double tanInnerStereo2
 
G4double tanOuterStereo
 
G4double tanOuterStereo2
 

Private Member Functions

G4double asinh (G4double arg)
 
void ClipPolygonToSimpleLimits (G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit) const
 

Private Attributes

G4double fCubicVolume = 0.0
 
G4double fHalfTol
 
G4PolyhedronfpPolyhedron = nullptr
 
G4bool fRebuildPolyhedron = false
 
G4String fshapeName
 
G4double fSurfaceArea = 0.0
 

Detailed Description

Definition at line 68 of file G4Hype.hh.

Member Enumeration Documentation

◆ ESide

enum G4Hype::ESide
protected
Enumerator
outerFace 
innerFace 
leftCap 
rightCap 

Definition at line 185 of file G4Hype.hh.

@ innerFace
Definition: G4Hype.hh:185
@ leftCap
Definition: G4Hype.hh:185
@ rightCap
Definition: G4Hype.hh:185
@ outerFace
Definition: G4Hype.hh:185

Constructor & Destructor Documentation

◆ G4Hype() [1/3]

G4Hype::G4Hype ( const G4String pName,
G4double  newInnerRadius,
G4double  newOuterRadius,
G4double  newInnerStereo,
G4double  newOuterStereo,
G4double  newHalfLenZ 
)

Definition at line 65 of file G4Hype.cc.

71 : G4VSolid(pName)
72{
74
75 // Check z-len
76 //
77 if (newHalfLenZ<=0)
78 {
79 std::ostringstream message;
80 message << "Invalid Z half-length - " << GetName() << G4endl
81 << " Invalid Z half-length: "
82 << newHalfLenZ/mm << " mm";
83 G4Exception("G4Hype::G4Hype()", "GeomSolids0002",
84 FatalErrorInArgument, message);
85 }
86 halfLenZ=newHalfLenZ;
87
88 // Check radii
89 //
90 if (newInnerRadius<0 || newOuterRadius<0)
91 {
92 std::ostringstream message;
93 message << "Invalid radii - " << GetName() << G4endl
94 << " Invalid radii ! Inner radius: "
95 << newInnerRadius/mm << " mm" << G4endl
96 << " Outer radius: "
97 << newOuterRadius/mm << " mm";
98 G4Exception("G4Hype::G4Hype()", "GeomSolids0002",
99 FatalErrorInArgument, message);
100 }
101 if (newInnerRadius >= newOuterRadius)
102 {
103 std::ostringstream message;
104 message << "Outer > inner radius - " << GetName() << G4endl
105 << " Invalid radii ! Inner radius: "
106 << newInnerRadius/mm << " mm" << G4endl
107 << " Outer radius: "
108 << newOuterRadius/mm << " mm";
109 G4Exception("G4Hype::G4Hype()", "GeomSolids0002",
110 FatalErrorInArgument, message);
111 }
112
113 innerRadius=newInnerRadius;
114 outerRadius=newOuterRadius;
115
118
119 SetInnerStereo( newInnerStereo );
120 SetOuterStereo( newOuterStereo );
121}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
static constexpr double mm
Definition: G4SIunits.hh:95
#define G4endl
Definition: G4ios.hh:57
G4double fHalfTol
Definition: G4Hype.hh:196
G4double halfLenZ
Definition: G4Hype.hh:166
G4double innerRadius2
Definition: G4Hype.hh:176
void SetOuterStereo(G4double newOSte)
G4double outerRadius
Definition: G4Hype.hh:165
G4double outerRadius2
Definition: G4Hype.hh:177
G4double innerRadius
Definition: G4Hype.hh:164
void SetInnerStereo(G4double newISte)
G4String GetName() const
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:57
G4double kCarTolerance
Definition: G4VSolid.hh:299

References FatalErrorInArgument, fHalfTol, G4endl, G4Exception(), G4VSolid::GetName(), halfLenZ, innerRadius, innerRadius2, G4VSolid::kCarTolerance, mm, outerRadius, outerRadius2, SetInnerStereo(), and SetOuterStereo().

Referenced by Clone().

◆ ~G4Hype()

G4Hype::~G4Hype ( )
virtual

Definition at line 136 of file G4Hype.cc.

137{
138 delete fpPolyhedron; fpPolyhedron = 0;
139}
G4Polyhedron * fpPolyhedron
Definition: G4Hype.hh:199

References fpPolyhedron.

◆ G4Hype() [2/3]

G4Hype::G4Hype ( __void__ &  a)

Definition at line 126 of file G4Hype.cc.

127 : G4VSolid(a), innerRadius(0.), outerRadius(0.), halfLenZ(0.), innerStereo(0.),
131{
132}
G4double endInnerRadius
Definition: G4Hype.hh:180
G4double tanOuterStereo
Definition: G4Hype.hh:173
G4double tanOuterStereo2
Definition: G4Hype.hh:175
G4double tanInnerStereo2
Definition: G4Hype.hh:174
G4double endInnerRadius2
Definition: G4Hype.hh:178
G4double endOuterRadius
Definition: G4Hype.hh:181
G4double outerStereo
Definition: G4Hype.hh:168
G4double tanInnerStereo
Definition: G4Hype.hh:172
G4double endOuterRadius2
Definition: G4Hype.hh:179
G4double innerStereo
Definition: G4Hype.hh:167

◆ G4Hype() [3/3]

G4Hype::G4Hype ( const G4Hype rhs)

Member Function Documentation

◆ ApproxDistInside()

G4double G4Hype::ApproxDistInside ( G4double  pr,
G4double  pz,
G4double  r0,
G4double  tan2Phi 
)
staticprotected

Definition at line 1043 of file G4Hype.cc.

1045{
1046 if (tan2Phi < DBL_MIN) return r0 - pr;
1047
1048 //
1049 // Corresponding position and normal on hyperbolic
1050 //
1051 G4double rh = std::sqrt( r0*r0 + pz*pz*tan2Phi );
1052
1053 G4double dr = -rh;
1054 G4double dz = pz*tan2Phi;
1055 G4double len = std::sqrt(dr*dr + dz*dz);
1056
1057 //
1058 // Answer
1059 //
1060 return std::fabs((pr-rh)*dr)/len;
1061}
double G4double
Definition: G4Types.hh:83
#define DBL_MIN
Definition: templates.hh:54

References DBL_MIN.

Referenced by DistanceToIn(), and DistanceToOut().

◆ ApproxDistOutside()

G4double G4Hype::ApproxDistOutside ( G4double  pr,
G4double  pz,
G4double  r0,
G4double  tanPhi 
)
staticprotected

Definition at line 986 of file G4Hype.cc.

988{
989 if (tanPhi < DBL_MIN) return pr-r0;
990
991 G4double tan2Phi = tanPhi*tanPhi;
992
993 //
994 // First point
995 //
996 G4double z1 = pz;
997 G4double r1 = std::sqrt( r0*r0 + z1*z1*tan2Phi );
998
999 //
1000 // Second point
1001 //
1002 G4double z2 = (pr*tanPhi + pz)/(1 + tan2Phi);
1003 G4double r2 = std::sqrt( r0*r0 + z2*z2*tan2Phi );
1004
1005 //
1006 // Line between them
1007 //
1008 G4double dr = r2-r1;
1009 G4double dz = z2-z1;
1010
1011 G4double len = std::sqrt(dr*dr + dz*dz);
1012 if (len < DBL_MIN)
1013 {
1014 //
1015 // The two points are the same?? I guess we
1016 // must have really bracketed the normal
1017 //
1018 dr = pr-r1;
1019 dz = pz-z1;
1020 return std::sqrt( dr*dr + dz*dz );
1021 }
1022
1023 //
1024 // Distance
1025 //
1026 return std::fabs((pr-r1)*dz - (pz-z1)*dr)/len;
1027}

References DBL_MIN.

Referenced by DistanceToIn(), and DistanceToOut().

◆ asinh()

G4double G4Hype::asinh ( G4double  arg)
private

Definition at line 1267 of file G4Hype.cc.

1268{
1269 return std::log(arg+std::sqrt(sqr(arg)+1));
1270}
T sqr(const T &x)
Definition: templates.hh:128

References sqr().

◆ BoundingLimits()

void G4Hype::BoundingLimits ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 199 of file G4Hype.cc.

200{
203
204 // Check correctness of the bounding box
205 //
206 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
207 {
208 std::ostringstream message;
209 message << "Bad bounding box (min >= max) for solid: "
210 << GetName() << " !"
211 << "\npMin = " << pMin
212 << "\npMax = " << pMax;
213 G4Exception("G4Hype::BoundingLimits()", "GeomMgt0001",
214 JustWarning, message);
215 DumpInfo();
216 }
217}
@ JustWarning
static const G4double pMax
static const G4double pMin
void DumpInfo() const

References G4VSolid::DumpInfo(), endOuterRadius, G4Exception(), G4VSolid::GetName(), halfLenZ, JustWarning, pMax, and pMin.

Referenced by CalculateExtent().

◆ CalculateClippedPolygonExtent()

void G4VSolid::CalculateClippedPolygonExtent ( G4ThreeVectorList pPolygon,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 489 of file G4VSolid.cc.

494{
495 G4int noLeft,i;
496 G4double component;
497
498 ClipPolygon(pPolygon,pVoxelLimit,pAxis);
499 noLeft = pPolygon.size();
500
501 if ( noLeft )
502 {
503 for (i=0; i<noLeft; ++i)
504 {
505 component = pPolygon[i].operator()(pAxis);
506
507 if (component < pMin)
508 {
509 pMin = component;
510 }
511 if (component > pMax)
512 {
513 pMax = component;
514 }
515 }
516 }
517}
int G4int
Definition: G4Types.hh:85
void ClipPolygon(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
Definition: G4VSolid.cc:539

References G4VSolid::ClipPolygon(), pMax, and pMin.

Referenced by G4VSolid::ClipBetweenSections(), and G4VSolid::ClipCrossSection().

◆ CalculateExtent()

G4bool G4Hype::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pMin,
G4double pMax 
) const
virtual

Implements G4VSolid.

Definition at line 221 of file G4Hype.cc.

225{
226 G4ThreeVector bmin, bmax;
227
228 // Get bounding box
229 BoundingLimits(bmin,bmax);
230
231 // Find extent
232 G4BoundingEnvelope bbox(bmin,bmax);
233 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
234}
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Hype.cc:199

References BoundingLimits(), G4BoundingEnvelope::CalculateExtent(), pMax, and pMin.

◆ ClipBetweenSections()

void G4VSolid::ClipBetweenSections ( G4ThreeVectorList pVertices,
const G4int  pSectionIndex,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 444 of file G4VSolid.cc.

449{
450 G4ThreeVectorList polygon;
451 polygon.reserve(4);
452 polygon.push_back((*pVertices)[pSectionIndex]);
453 polygon.push_back((*pVertices)[pSectionIndex+4]);
454 polygon.push_back((*pVertices)[pSectionIndex+5]);
455 polygon.push_back((*pVertices)[pSectionIndex+1]);
456 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
457 polygon.clear();
458
459 polygon.push_back((*pVertices)[pSectionIndex+1]);
460 polygon.push_back((*pVertices)[pSectionIndex+5]);
461 polygon.push_back((*pVertices)[pSectionIndex+6]);
462 polygon.push_back((*pVertices)[pSectionIndex+2]);
463 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
464 polygon.clear();
465
466 polygon.push_back((*pVertices)[pSectionIndex+2]);
467 polygon.push_back((*pVertices)[pSectionIndex+6]);
468 polygon.push_back((*pVertices)[pSectionIndex+7]);
469 polygon.push_back((*pVertices)[pSectionIndex+3]);
470 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
471 polygon.clear();
472
473 polygon.push_back((*pVertices)[pSectionIndex+3]);
474 polygon.push_back((*pVertices)[pSectionIndex+7]);
475 polygon.push_back((*pVertices)[pSectionIndex+4]);
476 polygon.push_back((*pVertices)[pSectionIndex]);
477 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
478 return;
479}
std::vector< G4ThreeVector > G4ThreeVectorList
void CalculateClippedPolygonExtent(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
Definition: G4VSolid.cc:489

References G4VSolid::CalculateClippedPolygonExtent(), pMax, and pMin.

◆ ClipCrossSection()

void G4VSolid::ClipCrossSection ( G4ThreeVectorList pVertices,
const G4int  pSectionIndex,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 414 of file G4VSolid.cc.

419{
420
421 G4ThreeVectorList polygon;
422 polygon.reserve(4);
423 polygon.push_back((*pVertices)[pSectionIndex]);
424 polygon.push_back((*pVertices)[pSectionIndex+1]);
425 polygon.push_back((*pVertices)[pSectionIndex+2]);
426 polygon.push_back((*pVertices)[pSectionIndex+3]);
427 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
428 return;
429}

References G4VSolid::CalculateClippedPolygonExtent(), pMax, and pMin.

◆ ClipPolygon()

void G4VSolid::ClipPolygon ( G4ThreeVectorList pPolygon,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis 
) const
protectedinherited

Definition at line 539 of file G4VSolid.cc.

542{
543 G4ThreeVectorList outputPolygon;
544
545 if ( pVoxelLimit.IsLimited() )
546 {
547 if (pVoxelLimit.IsXLimited() ) // && pAxis != kXAxis)
548 {
549 G4VoxelLimits simpleLimit1;
550 simpleLimit1.AddLimit(kXAxis,pVoxelLimit.GetMinXExtent(),kInfinity);
551 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
552
553 pPolygon.clear();
554
555 if ( !outputPolygon.size() ) return;
556
557 G4VoxelLimits simpleLimit2;
558 simpleLimit2.AddLimit(kXAxis,-kInfinity,pVoxelLimit.GetMaxXExtent());
559 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
560
561 if ( !pPolygon.size() ) return;
562 else outputPolygon.clear();
563 }
564 if ( pVoxelLimit.IsYLimited() ) // && pAxis != kYAxis)
565 {
566 G4VoxelLimits simpleLimit1;
567 simpleLimit1.AddLimit(kYAxis,pVoxelLimit.GetMinYExtent(),kInfinity);
568 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
569
570 // Must always clear pPolygon - for clip to simpleLimit2 and in case of
571 // early exit
572
573 pPolygon.clear();
574
575 if ( !outputPolygon.size() ) return;
576
577 G4VoxelLimits simpleLimit2;
578 simpleLimit2.AddLimit(kYAxis,-kInfinity,pVoxelLimit.GetMaxYExtent());
579 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
580
581 if ( !pPolygon.size() ) return;
582 else outputPolygon.clear();
583 }
584 if ( pVoxelLimit.IsZLimited() ) // && pAxis != kZAxis)
585 {
586 G4VoxelLimits simpleLimit1;
587 simpleLimit1.AddLimit(kZAxis,pVoxelLimit.GetMinZExtent(),kInfinity);
588 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
589
590 // Must always clear pPolygon - for clip to simpleLimit2 and in case of
591 // early exit
592
593 pPolygon.clear();
594
595 if ( !outputPolygon.size() ) return;
596
597 G4VoxelLimits simpleLimit2;
598 simpleLimit2.AddLimit(kZAxis,-kInfinity,pVoxelLimit.GetMaxZExtent());
599 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
600
601 // Return after final clip - no cleanup
602 }
603 }
604}
void ClipPolygonToSimpleLimits(G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit) const
Definition: G4VSolid.cc:612
G4bool IsYLimited() const
G4double GetMinZExtent() const
void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax)
G4bool IsXLimited() const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4bool IsLimited() const
G4double GetMaxXExtent() const
@ kYAxis
Definition: geomdefs.hh:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57
static const G4double kInfinity
Definition: geomdefs.hh:41

References G4VoxelLimits::AddLimit(), G4VSolid::ClipPolygonToSimpleLimits(), G4VoxelLimits::GetMaxXExtent(), G4VoxelLimits::GetMaxYExtent(), G4VoxelLimits::GetMaxZExtent(), G4VoxelLimits::GetMinXExtent(), G4VoxelLimits::GetMinYExtent(), G4VoxelLimits::GetMinZExtent(), G4VoxelLimits::IsLimited(), G4VoxelLimits::IsXLimited(), G4VoxelLimits::IsYLimited(), G4VoxelLimits::IsZLimited(), kInfinity, kXAxis, kYAxis, and kZAxis.

Referenced by G4VSolid::CalculateClippedPolygonExtent().

◆ ClipPolygonToSimpleLimits()

void G4VSolid::ClipPolygonToSimpleLimits ( G4ThreeVectorList pPolygon,
G4ThreeVectorList outputPolygon,
const G4VoxelLimits pVoxelLimit 
) const
privateinherited

Definition at line 612 of file G4VSolid.cc.

615{
616 G4int i;
617 G4int noVertices=pPolygon.size();
618 G4ThreeVector vEnd,vStart;
619
620 for (i = 0 ; i < noVertices ; ++i )
621 {
622 vStart = pPolygon[i];
623 if ( i == noVertices-1 ) vEnd = pPolygon[0];
624 else vEnd = pPolygon[i+1];
625
626 if ( pVoxelLimit.Inside(vStart) )
627 {
628 if (pVoxelLimit.Inside(vEnd))
629 {
630 // vStart and vEnd inside -> output end point
631 //
632 outputPolygon.push_back(vEnd);
633 }
634 else
635 {
636 // vStart inside, vEnd outside -> output crossing point
637 //
638 pVoxelLimit.ClipToLimits(vStart,vEnd);
639 outputPolygon.push_back(vEnd);
640 }
641 }
642 else
643 {
644 if (pVoxelLimit.Inside(vEnd))
645 {
646 // vStart outside, vEnd inside -> output inside section
647 //
648 pVoxelLimit.ClipToLimits(vStart,vEnd);
649 outputPolygon.push_back(vStart);
650 outputPolygon.push_back(vEnd);
651 }
652 else // Both point outside -> no output
653 {
654 // outputPolygon.push_back(vStart);
655 // outputPolygon.push_back(vEnd);
656 }
657 }
658 }
659}
G4bool ClipToLimits(G4ThreeVector &pStart, G4ThreeVector &pEnd) const
G4bool Inside(const G4ThreeVector &pVec) const

References G4VoxelLimits::ClipToLimits(), and G4VoxelLimits::Inside().

Referenced by G4VSolid::ClipPolygon().

◆ Clone()

G4VSolid * G4Hype::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1072 of file G4Hype.cc.

1073{
1074 return new G4Hype(*this);
1075}
G4Hype(const G4String &pName, G4double newInnerRadius, G4double newOuterRadius, G4double newInnerStereo, G4double newOuterStereo, G4double newHalfLenZ)
Definition: G4Hype.cc:65

References G4Hype().

◆ ComputeDimensions()

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

Reimplemented from G4VSolid.

Definition at line 190 of file G4Hype.cc.

193{
194 p->ComputeDimensions(*this,n,pRep);
195}
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const

References G4VPVParameterisation::ComputeDimensions(), and CLHEP::detail::n.

◆ CreatePolyhedron()

G4Polyhedron * G4Hype::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1241 of file G4Hype.cc.

References halfLenZ, innerRadius, outerRadius, tanInnerStereo2, and tanOuterStereo2.

Referenced by GetPolyhedron().

◆ DescribeYourselfTo()

void G4Hype::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 1223 of file G4Hype.cc.

1224{
1225 scene.AddSolid (*this);
1226}
virtual void AddSolid(const G4Box &)=0

References G4VGraphicsScene::AddSolid().

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 614 of file G4Hype.cc.

615{
616 G4double absZ(std::fabs(p.z()));
617
618 //
619 // Check region
620 //
621 G4double r2 = p.x()*p.x() + p.y()*p.y();
622 G4double r = std::sqrt(r2);
623
624 G4double sigz = absZ - halfLenZ;
625
626 if (r < endOuterRadius)
627 {
628 if (sigz > -fHalfTol)
629 {
630 if (InnerSurfaceExists())
631 {
632 if (r > endInnerRadius)
633 return sigz < fHalfTol ? 0 : sigz; // Region 1
634
635 G4double dr = endInnerRadius - r;
636 if (sigz > dr*tanInnerStereo2)
637 {
638 //
639 // In region 5
640 //
641 G4double answer = std::sqrt( dr*dr + sigz*sigz );
642 return answer < fHalfTol ? 0 : answer;
643 }
644 }
645 else
646 {
647 //
648 // In region 1 (no inner surface)
649 //
650 return sigz < fHalfTol ? 0 : sigz;
651 }
652 }
653 }
654 else
655 {
656 G4double dr = r - endOuterRadius;
657 if (sigz > -dr*tanOuterStereo2)
658 {
659 //
660 // In region 2
661 //
662 G4double answer = std::sqrt( dr*dr + sigz*sigz );
663 return answer < fHalfTol ? 0 : answer;
664 }
665 }
666
667 if (InnerSurfaceExists())
668 {
670 {
671 //
672 // In region 4
673 //
675 return answer < fHalfTol ? 0 : answer;
676 }
677 }
678
679 //
680 // We are left by elimination with region 3
681 //
683 return answer < fHalfTol ? 0 : answer;
684}
double z() const
double x() const
double y() const
static G4double ApproxDistOutside(G4double pr, G4double pz, G4double r0, G4double tanPhi)
Definition: G4Hype.cc:986
G4bool InnerSurfaceExists() const
static G4double ApproxDistInside(G4double pr, G4double pz, G4double r0, G4double tan2Phi)
Definition: G4Hype.cc:1043
G4double HypeInnerRadius2(G4double zVal) const

References ApproxDistInside(), ApproxDistOutside(), endInnerRadius, endOuterRadius, fHalfTol, halfLenZ, HypeInnerRadius2(), innerRadius, InnerSurfaceExists(), G4VSolid::kCarTolerance, outerRadius, tanInnerStereo2, tanOuterStereo, tanOuterStereo2, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DistanceToIn() [2/2]

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

Implements G4VSolid.

Definition at line 323 of file G4Hype.cc.

325{
326 //
327 // Quick test. Beware! This assumes v is a unit vector!
328 //
329 if (std::fabs(p.x()*v.y() - p.y()*v.x()) > endOuterRadius+kCarTolerance)
330 return kInfinity;
331
332 //
333 // Take advantage of z symmetry, and reflect throught the
334 // z=0 plane so that pz is always positive
335 //
336 G4double pz(p.z()), vz(v.z());
337 if (pz < 0)
338 {
339 pz = -pz;
340 vz = -vz;
341 }
342
343 //
344 // We must be very careful if we don't want to
345 // create subtle leaks at the edges where the
346 // hyperbolic surfaces connect to the endplate.
347 // The only reliable way to do so is to make sure
348 // that the decision as to when a track passes
349 // over the edge of one surface is exactly the
350 // same decision as to when a track passes into the
351 // other surface. By "exact", we don't mean algebraicly
352 // exact, but we mean the same machine instructions
353 // should be used.
354 //
355 G4bool couldMissOuter(true),
356 couldMissInner(true),
357 cantMissInnerCylinder(false);
358
359 //
360 // Check endplate intersection
361 //
362 G4double sigz = pz-halfLenZ;
363
364 if (sigz > -fHalfTol) // equivalent to: if (pz > halfLenZ - fHalfTol)
365 {
366 //
367 // We start in front of the endplate (within roundoff)
368 // Correct direction to intersect endplate?
369 //
370 if (vz >= 0)
371 {
372 //
373 // Nope. As long as we are far enough away, we
374 // can't intersect anything
375 //
376 if (sigz > 0) return kInfinity;
377
378 //
379 // Otherwise, we may still hit a hyperbolic surface
380 // if the point is on the hyperbolic surface (within tolerance)
381 //
382 G4double pr2 = p.x()*p.x() + p.y()*p.y();
384 return kInfinity;
385
386 if (InnerSurfaceExists())
387 {
389 return kInfinity;
392 return kInfinity;
393 }
394 else
395 {
397 return kInfinity;
398 }
399 }
400 else
401 {
402 //
403 // Where do we intersect at z = halfLenZ?
404 //
405 G4double q = -sigz/vz;
406 G4double xi = p.x() + q*v.x(),
407 yi = p.y() + q*v.y();
408
409 //
410 // Is this on the endplate? If so, return s, unless
411 // we are on the tolerant surface, in which case return 0
412 //
413 G4double pr2 = xi*xi + yi*yi;
414 if (pr2 <= endOuterRadius2)
415 {
416 if (InnerSurfaceExists())
417 {
418 if (pr2 >= endInnerRadius2) return (sigz < fHalfTol) ? 0 : q;
419 //
420 // This test is sufficient to ensure that the
421 // trajectory cannot miss the inner hyperbolic surface
422 // for z > 0, if the normal is correct.
423 //
424 G4double dot1 = (xi*v.x() + yi*v.y())*endInnerRadius/std::sqrt(pr2);
425 couldMissInner = (dot1 - halfLenZ*tanInnerStereo2*vz <= 0);
426
427 if (pr2 > endInnerRadius2*(1 - 2*DBL_EPSILON) )
428 {
429 //
430 // There is a potential leak if the inner
431 // surface is a cylinder
432 //
433 if ( (innerStereo < DBL_MIN)
434 && ((std::fabs(v.x()) > DBL_MIN) || (std::fabs(v.y()) > DBL_MIN)))
435 cantMissInnerCylinder = true;
436 }
437 }
438 else
439 {
440 return (sigz < fHalfTol) ? 0 : q;
441 }
442 }
443 else
444 {
445 G4double dotR( xi*v.x() + yi*v.y() );
446 if (dotR >= 0)
447 {
448 //
449 // Otherwise, if we are traveling outwards, we know
450 // we must miss the hyperbolic surfaces also, so
451 // we need not bother checking
452 //
453 return kInfinity;
454 }
455 else
456 {
457 //
458 // This test is sufficient to ensure that the
459 // trajectory cannot miss the outer hyperbolic surface
460 // for z > 0, if the normal is correct.
461 //
462 G4double dot1 = dotR*endOuterRadius/std::sqrt(pr2);
463 couldMissOuter = (dot1 - halfLenZ*tanOuterStereo2*vz>= 0);
464 }
465 }
466 }
467 }
468
469 //
470 // Check intersection with outer hyperbolic surface, save
471 // distance to valid intersection into "best".
472 //
473 G4double best = kInfinity;
474
475 G4double q[2];
477
478 if (n > 0)
479 {
480 //
481 // Potential intersection: is p on this surface?
482 //
483 if (pz < halfLenZ+fHalfTol)
484 {
485 G4double dr2 = p.x()*p.x() + p.y()*p.y() - HypeOuterRadius2(pz);
486 if (std::fabs(dr2) < kCarTolerance*endOuterRadius)
487 {
488 //
489 // Sure, but make sure we're traveling inwards at
490 // this point
491 //
492 if (p.x()*v.x() + p.y()*v.y() - pz*tanOuterStereo2*vz < 0)
493 return 0;
494 }
495 }
496
497 //
498 // We are now certain that p is not on the tolerant surface.
499 // Accept only position distance q
500 //
501 for( G4int i=0; i<n; ++i )
502 {
503 if (q[i] >= 0)
504 {
505 //
506 // Check to make sure this intersection point is
507 // on the surface, but only do so if we haven't
508 // checked the endplate intersection already
509 //
510 G4double zi = pz + q[i]*vz;
511
512 if (zi < -halfLenZ) continue;
513 if (zi > +halfLenZ && couldMissOuter) continue;
514
515 //
516 // Check normal
517 //
518 G4double xi = p.x() + q[i]*v.x(),
519 yi = p.y() + q[i]*v.y();
520
521 if (xi*v.x() + yi*v.y() - zi*tanOuterStereo2*vz > 0) continue;
522
523 best = q[i];
524 break;
525 }
526 }
527 }
528
529 if (!InnerSurfaceExists()) return best;
530
531 //
532 // Check intersection with inner hyperbolic surface
533 //
535 if (n == 0)
536 {
537 if (cantMissInnerCylinder) return (sigz < fHalfTol) ? 0 : -sigz/vz;
538
539 return best;
540 }
541
542 //
543 // P on this surface?
544 //
545 if (pz < halfLenZ+fHalfTol)
546 {
547 G4double dr2 = p.x()*p.x() + p.y()*p.y() - HypeInnerRadius2(pz);
548 if (std::fabs(dr2) < kCarTolerance*endInnerRadius)
549 {
550 //
551 // Sure, but make sure we're traveling outwards at
552 // this point
553 //
554 if (p.x()*v.x() + p.y()*v.y() - pz*tanInnerStereo2*vz > 0) return 0;
555 }
556 }
557
558 //
559 // No, so only positive q is valid. Search for a valid intersection
560 // that is closer than the outer intersection (if it exists)
561 //
562 for( G4int i=0; i<n; ++i )
563 {
564 if (q[i] > best) break;
565 if (q[i] >= 0)
566 {
567 //
568 // Check to make sure this intersection point is
569 // on the surface, but only do so if we haven't
570 // checked the endplate intersection already
571 //
572 G4double zi = pz + q[i]*vz;
573
574 if (zi < -halfLenZ) continue;
575 if (zi > +halfLenZ && couldMissInner) continue;
576
577 //
578 // Check normal
579 //
580 G4double xi = p.x() + q[i]*v.x(),
581 yi = p.y() + q[i]*v.y();
582
583 if (xi*v.x() + yi*v.y() - zi*tanOuterStereo2*vz < 0) continue;
584
585 best = q[i];
586 break;
587 }
588 }
589
590 //
591 // Done
592 //
593 return best;
594}
bool G4bool
Definition: G4Types.hh:86
static G4int IntersectHype(const G4ThreeVector &p, const G4ThreeVector &v, G4double r2, G4double tan2Phi, G4double s[2])
Definition: G4Hype.cc:921
G4double HypeOuterRadius2(G4double zVal) const
#define DBL_EPSILON
Definition: templates.hh:66

References DBL_EPSILON, DBL_MIN, endInnerRadius, endInnerRadius2, endOuterRadius, endOuterRadius2, fHalfTol, halfLenZ, HypeInnerRadius2(), HypeOuterRadius2(), innerRadius2, innerStereo, InnerSurfaceExists(), IntersectHype(), G4VSolid::kCarTolerance, kInfinity, CLHEP::detail::n, outerRadius2, tanInnerStereo2, tanOuterStereo2, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Definition at line 860 of file G4Hype.cc.

861{
862 //
863 // Try each surface and remember the closest
864 //
865 G4double absZ(std::fabs(p.z()));
866 G4double r(p.perp());
867
868 G4double sBest = halfLenZ - absZ;
869
871 if (tryOuter < sBest)
872 sBest = tryOuter;
873
874 if (InnerSurfaceExists())
875 {
877 if (tryInner < sBest) sBest = tryInner;
878 }
879
880 return sBest < 0.5*kCarTolerance ? 0 : sBest;
881}
double perp() const

References ApproxDistInside(), ApproxDistOutside(), halfLenZ, innerRadius, InnerSurfaceExists(), G4VSolid::kCarTolerance, outerRadius, CLHEP::Hep3Vector::perp(), tanInnerStereo, tanOuterStereo2, and CLHEP::Hep3Vector::z().

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 693 of file G4Hype.cc.

696{
697 static const G4ThreeVector normEnd1(0.0,0.0,+1.0);
698 static const G4ThreeVector normEnd2(0.0,0.0,-1.0);
699
700 //
701 // Keep track of closest surface
702 //
703 G4double sBest; // distance to
704 const G4ThreeVector* nBest; // normal vector
705 G4bool vBest; // whether "valid"
706
707 //
708 // Check endplate, taking advantage of symmetry.
709 // Note that the endcap is the only surface which
710 // has a "valid" normal, i.e. is a surface of which
711 // the entire solid is behind.
712 //
713 G4double pz(p.z()), vz(v.z());
714 if (vz < 0)
715 {
716 pz = -pz;
717 vz = -vz;
718 nBest = &normEnd2;
719 }
720 else
721 nBest = &normEnd1;
722
723 //
724 // Possible intercept. Are we on the surface?
725 //
726 if (pz > halfLenZ-fHalfTol)
727 {
728 if (calcNorm) { *norm = *nBest; *validNorm = true; }
729 return 0;
730 }
731
732 //
733 // Nope. Get distance. Beware of zero vz.
734 //
735 sBest = (vz > DBL_MIN) ? (halfLenZ - pz)/vz : kInfinity;
736 vBest = true;
737
738 //
739 // Check outer surface
740 //
741 G4double r2 = p.x()*p.x() + p.y()*p.y();
742
743 G4double q[2];
745
746 G4ThreeVector norm1, norm2;
747
748 if (n > 0)
749 {
750 //
751 // We hit somewhere. Are we on the surface?
752 //
753 G4double dr2 = r2 - HypeOuterRadius2(pz);
754 if (std::fabs(dr2) < endOuterRadius*kCarTolerance)
755 {
756 G4ThreeVector normHere( p.x(), p.y(), -p.z()*tanOuterStereo2 );
757 //
758 // Sure. But are we going the right way?
759 //
760 if (normHere.dot(v) > 0)
761 {
762 if (calcNorm) { *norm = normHere.unit(); *validNorm = false; }
763 return 0;
764 }
765 }
766
767 //
768 // Nope. Check closest positive intercept.
769 //
770 for( G4int i=0; i<n; ++i )
771 {
772 if (q[i] > sBest) break;
773 if (q[i] > 0)
774 {
775 //
776 // Make sure normal is correct (that this
777 // solution is an outgoing solution)
778 //
779 G4ThreeVector pk(p+q[i]*v);
780 norm1 = G4ThreeVector( pk.x(), pk.y(), -pk.z()*tanOuterStereo2 );
781 if (norm1.dot(v) > 0)
782 {
783 sBest = q[i];
784 nBest = &norm1;
785 vBest = false;
786 break;
787 }
788 }
789 }
790 }
791
792 if (InnerSurfaceExists())
793 {
794 //
795 // Check inner surface
796 //
798 if (n > 0)
799 {
800 //
801 // On surface?
802 //
803 G4double dr2 = r2 - HypeInnerRadius2(pz);
804 if (std::fabs(dr2) < endInnerRadius*kCarTolerance)
805 {
806 G4ThreeVector normHere( -p.x(), -p.y(), p.z()*tanInnerStereo2 );
807 if (normHere.dot(v) > 0)
808 {
809 if (calcNorm)
810 {
811 *norm = normHere.unit();
812 *validNorm = false;
813 }
814 return 0;
815 }
816 }
817
818 //
819 // Check closest positive
820 //
821 for( G4int i=0; i<n; ++i )
822 {
823 if (q[i] > sBest) break;
824 if (q[i] > 0)
825 {
826 G4ThreeVector pk(p+q[i]*v);
827 norm2 = G4ThreeVector( -pk.x(), -pk.y(), pk.z()*tanInnerStereo2 );
828 if (norm2.dot(v) > 0)
829 {
830 sBest = q[i];
831 nBest = &norm2;
832 vBest = false;
833 break;
834 }
835 }
836 }
837 }
838 }
839
840 //
841 // Done!
842 //
843 if (calcNorm)
844 {
845 *validNorm = vBest;
846
847 if (nBest == &norm1 || nBest == &norm2)
848 *norm = nBest->unit();
849 else
850 *norm = *nBest;
851 }
852
853 return sBest;
854}
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector unit() const
double dot(const Hep3Vector &) const

References DBL_MIN, CLHEP::Hep3Vector::dot(), endInnerRadius, endOuterRadius, fHalfTol, halfLenZ, HypeInnerRadius2(), HypeOuterRadius2(), innerRadius2, InnerSurfaceExists(), IntersectHype(), G4VSolid::kCarTolerance, kInfinity, CLHEP::detail::n, outerRadius2, tanInnerStereo2, tanOuterStereo2, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DumpInfo()

void G4VSolid::DumpInfo ( ) const
inlineinherited

Referenced by G4Cons::ApproxSurfaceNormal(), G4CutTubs::ApproxSurfaceNormal(), G4Sphere::ApproxSurfaceNormal(), G4Torus::ApproxSurfaceNormal(), G4Tubs::ApproxSurfaceNormal(), G4ReflectedSolid::BoundingLimits(), G4DisplacedSolid::BoundingLimits(), G4IntersectionSolid::BoundingLimits(), G4ScaledSolid::BoundingLimits(), G4SubtractionSolid::BoundingLimits(), G4UnionSolid::BoundingLimits(), G4Box::BoundingLimits(), G4Cons::BoundingLimits(), G4CutTubs::BoundingLimits(), G4Orb::BoundingLimits(), G4Para::BoundingLimits(), G4Sphere::BoundingLimits(), G4Torus::BoundingLimits(), G4Trap::BoundingLimits(), G4Trd::BoundingLimits(), G4Tubs::BoundingLimits(), G4EllipticalCone::BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), BoundingLimits(), G4Paraboloid::BoundingLimits(), G4Polycone::BoundingLimits(), G4Polyhedra::BoundingLimits(), G4TessellatedSolid::BoundingLimits(), G4TwistedTubs::BoundingLimits(), G4ParameterisationBoxX::ComputeDimensions(), G4ParameterisationBoxY::ComputeDimensions(), G4ParameterisationBoxZ::ComputeDimensions(), G4ParameterisationConsRho::ComputeDimensions(), G4ParameterisationConsPhi::ComputeDimensions(), G4ParameterisationConsZ::ComputeDimensions(), G4ParameterisationParaX::ComputeDimensions(), G4ParameterisationParaY::ComputeDimensions(), G4ParameterisationParaZ::ComputeDimensions(), G4ParameterisationPolyconeRho::ComputeDimensions(), G4ParameterisationPolyconePhi::ComputeDimensions(), G4ParameterisationPolyconeZ::ComputeDimensions(), G4ParameterisationPolyhedraRho::ComputeDimensions(), G4ParameterisationPolyhedraPhi::ComputeDimensions(), G4ParameterisationPolyhedraZ::ComputeDimensions(), G4ParameterisationTrdX::ComputeDimensions(), G4ParameterisationTrdY::ComputeDimensions(), G4ParameterisationTrdZ::ComputeDimensions(), G4ParameterisationTubsRho::ComputeDimensions(), G4ParameterisationTubsPhi::ComputeDimensions(), G4ParameterisationTubsZ::ComputeDimensions(), G4ReflectedSolid::ComputeDimensions(), G4DisplacedSolid::ComputeDimensions(), G4ScaledSolid::ComputeDimensions(), G4ParameterisedNavigation::ComputeStep(), G4ReplicaNavigation::ComputeStep(), G4DisplacedSolid::CreatePolyhedron(), G4ScaledSolid::CreatePolyhedron(), G4SubtractionSolid::DistanceToIn(), G4Box::DistanceToOut(), G4Orb::DistanceToOut(), G4Para::DistanceToOut(), G4Trap::DistanceToOut(), G4Trd::DistanceToOut(), G4Paraboloid::DistanceToOut(), G4VTwistedFaceted::DistanceToOut(), G4Cons::DistanceToOut(), G4CutTubs::DistanceToOut(), G4Sphere::DistanceToOut(), G4Torus::DistanceToOut(), G4Tubs::DistanceToOut(), G4Ellipsoid::DistanceToOut(), G4EllipticalCone::DistanceToOut(), G4EllipticalTube::DistanceToOut(), G4GenericTrap::DistanceToOut(), export_G4VSolid(), G4Polycone::G4Polycone(), G4Polyhedra::G4Polyhedra(), G4BooleanSolid::GetConstituentSolid(), G4NavigationLogger::PostComputeStepLog(), G4Box::SurfaceNormal(), G4Para::SurfaceNormal(), G4Trap::SurfaceNormal(), G4Trd::SurfaceNormal(), G4Ellipsoid::SurfaceNormal(), G4EllipticalCone::SurfaceNormal(), G4EllipticalTube::SurfaceNormal(), G4ExtrudedSolid::SurfaceNormal(), and G4Tet::SurfaceNormal().

◆ EstimateCubicVolume()

G4double G4VSolid::EstimateCubicVolume ( G4int  nStat,
G4double  epsilon 
) const
inherited

Definition at line 203 of file G4VSolid.cc.

204{
205 G4int iInside=0;
206 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,volume,halfepsilon;
208 EInside in;
209
210 // values needed for CalculateExtent signature
211
212 G4VoxelLimits limit; // Unlimited
213 G4AffineTransform origin;
214
215 // min max extents of pSolid along X,Y,Z
216
217 CalculateExtent(kXAxis,limit,origin,minX,maxX);
218 CalculateExtent(kYAxis,limit,origin,minY,maxY);
219 CalculateExtent(kZAxis,limit,origin,minZ,maxZ);
220
221 // limits
222
223 if(nStat < 100) nStat = 100;
224 if(epsilon > 0.01) epsilon = 0.01;
225 halfepsilon = 0.5*epsilon;
226
227 for(auto i = 0; i < nStat; ++i )
228 {
229 px = minX-halfepsilon+(maxX-minX+epsilon)*G4QuickRand();
230 py = minY-halfepsilon+(maxY-minY+epsilon)*G4QuickRand();
231 pz = minZ-halfepsilon+(maxZ-minZ+epsilon)*G4QuickRand();
232 p = G4ThreeVector(px,py,pz);
233 in = Inside(p);
234 if(in != kOutside) ++iInside;
235 }
236 volume = (maxX-minX+epsilon)*(maxY-minY+epsilon)
237 * (maxZ-minZ+epsilon)*iInside/nStat;
238 return volume;
239}
G4double epsilon(G4double density, G4double temperature)
static const G4int maxZ
G4double G4QuickRand()
Definition: G4QuickRand.hh:34
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
EInside
Definition: geomdefs.hh:67
@ kOutside
Definition: geomdefs.hh:68

References G4VSolid::CalculateExtent(), epsilon(), G4QuickRand(), G4VSolid::Inside(), kOutside, kXAxis, kYAxis, kZAxis, and maxZ.

Referenced by G4VSolid::GetCubicVolume(), G4BooleanSolid::GetCubicVolume(), and G4VCSGfaceted::GetCubicVolume().

◆ EstimateSurfaceArea()

G4double G4VSolid::EstimateSurfaceArea ( G4int  nStat,
G4double  ell 
) const
inherited

Definition at line 265 of file G4VSolid.cc.

266{
267 static const G4double s2 = 1./std::sqrt(2.);
268 static const G4double s3 = 1./std::sqrt(3.);
269 static const G4ThreeVector directions[64] =
270 {
271 G4ThreeVector( 0, 0, 0), G4ThreeVector( -1, 0, 0), // ( , , ) ( -, , )
272 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +, , ) (-+, , )
273 G4ThreeVector( 0, -1, 0), G4ThreeVector(-s2,-s2, 0), // ( , -, ) ( -, -, )
274 G4ThreeVector( s2, -s2, 0), G4ThreeVector( 0, -1, 0), // ( +, -, ) (-+, -, )
275
276 G4ThreeVector( 0, 1, 0), G4ThreeVector( -s2, s2, 0), // ( , +, ) ( -, +, )
277 G4ThreeVector( s2, s2, 0), G4ThreeVector( 0, 1, 0), // ( +, +, ) (-+, +, )
278 G4ThreeVector( 0, -1, 0), G4ThreeVector( -1, 0, 0), // ( ,-+, ) ( -,-+, )
279 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +,-+, ) (-+,-+, )
280
281 G4ThreeVector( 0, 0, -1), G4ThreeVector(-s2, 0,-s2), // ( , , -) ( -, , -)
282 G4ThreeVector( s2, 0,-s2), G4ThreeVector( 0, 0, -1), // ( +, , -) (-+, , -)
283 G4ThreeVector( 0,-s2,-s2), G4ThreeVector(-s3,-s3,-s3), // ( , -, -) ( -, -, -)
284 G4ThreeVector( s3,-s3,-s3), G4ThreeVector( 0,-s2,-s2), // ( +, -, -) (-+, -, -)
285
286 G4ThreeVector( 0, s2,-s2), G4ThreeVector(-s3, s3,-s3), // ( , +, -) ( -, +, -)
287 G4ThreeVector( s3, s3,-s3), G4ThreeVector( 0, s2,-s2), // ( +, +, -) (-+, +, -)
288 G4ThreeVector( 0, 0, -1), G4ThreeVector(-s2, 0,-s2), // ( ,-+, -) ( -,-+, -)
289 G4ThreeVector( s2, 0,-s2), G4ThreeVector( 0, 0, -1), // ( +,-+, -) (-+,-+, -)
290
291 G4ThreeVector( 0, 0, 1), G4ThreeVector(-s2, 0, s2), // ( , , +) ( -, , +)
292 G4ThreeVector( s2, 0, s2), G4ThreeVector( 0, 0, 1), // ( +, , +) (-+, , +)
293 G4ThreeVector( 0,-s2, s2), G4ThreeVector(-s3,-s3, s3), // ( , -, +) ( -, -, +)
294 G4ThreeVector( s3,-s3, s3), G4ThreeVector( 0,-s2, s2), // ( +, -, +) (-+, -, +)
295
296 G4ThreeVector( 0, s2, s2), G4ThreeVector(-s3, s3, s3), // ( , +, +) ( -, +, +)
297 G4ThreeVector( s3, s3, s3), G4ThreeVector( 0, s2, s2), // ( +, +, +) (-+, +, +)
298 G4ThreeVector( 0, 0, 1), G4ThreeVector(-s2, 0, s2), // ( ,-+, +) ( -,-+, +)
299 G4ThreeVector( s2, 0, s2), G4ThreeVector( 0, 0, 1), // ( +,-+, +) (-+,-+, +)
300
301 G4ThreeVector( 0, 0, -1), G4ThreeVector( -1, 0, 0), // ( , ,-+) ( -, ,-+)
302 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +, ,-+) (-+, ,-+)
303 G4ThreeVector( 0, -1, 0), G4ThreeVector(-s2,-s2, 0), // ( , -,-+) ( -, -,-+)
304 G4ThreeVector( s2, -s2, 0), G4ThreeVector( 0, -1, 0), // ( +, -,-+) (-+, -,-+)
305
306 G4ThreeVector( 0, 1, 0), G4ThreeVector( -s2, s2, 0), // ( , +,-+) ( -, +,-+)
307 G4ThreeVector( s2, s2, 0), G4ThreeVector( 0, 1, 0), // ( +, +,-+) (-+, +,-+)
308 G4ThreeVector( 0, -1, 0), G4ThreeVector( -1, 0, 0), // ( ,-+,-+) ( -,-+,-+)
309 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +,-+,-+) (-+,-+,-+)
310 };
311
312 G4ThreeVector bmin, bmax;
313 BoundingLimits(bmin, bmax);
314
315 G4double dX = bmax.x() - bmin.x();
316 G4double dY = bmax.y() - bmin.y();
317 G4double dZ = bmax.z() - bmin.z();
318
319 // Define statistics and shell thickness
320 //
321 G4int npoints = (nstat < 1000) ? 1000 : nstat;
322 G4double coeff = 0.5 / std::cbrt(G4double(npoints));
323 G4double eps = (ell > 0) ? ell : coeff * std::min(std::min(dX, dY), dZ);
324 G4double del = 1.8 * eps; // shold be more than sqrt(3.)
325
326 G4double minX = bmin.x() - eps;
327 G4double minY = bmin.y() - eps;
328 G4double minZ = bmin.z() - eps;
329
330 G4double dd = 2. * eps;
331 dX += dd;
332 dY += dd;
333 dZ += dd;
334
335 // Calculate surface area
336 //
337 G4int icount = 0;
338 for(auto i = 0; i < npoints; ++i)
339 {
340 G4double px = minX + dX*G4QuickRand();
341 G4double py = minY + dY*G4QuickRand();
342 G4double pz = minZ + dZ*G4QuickRand();
343 G4ThreeVector p = G4ThreeVector(px, py, pz);
344 EInside in = Inside(p);
345 G4double dist = 0;
346 if (in == kInside)
347 {
348 if (DistanceToOut(p) >= eps) continue;
349 G4int icase = 0;
350 if (Inside(G4ThreeVector(px-del, py, pz)) != kInside) icase += 1;
351 if (Inside(G4ThreeVector(px+del, py, pz)) != kInside) icase += 2;
352 if (Inside(G4ThreeVector(px, py-del, pz)) != kInside) icase += 4;
353 if (Inside(G4ThreeVector(px, py+del, pz)) != kInside) icase += 8;
354 if (Inside(G4ThreeVector(px, py, pz-del)) != kInside) icase += 16;
355 if (Inside(G4ThreeVector(px, py, pz+del)) != kInside) icase += 32;
356 if (icase == 0) continue;
357 G4ThreeVector v = directions[icase];
358 dist = DistanceToOut(p, v);
359 G4ThreeVector n = SurfaceNormal(p + v*dist);
360 dist *= v.dot(n);
361 }
362 else if (in == kOutside)
363 {
364 if (DistanceToIn(p) >= eps) continue;
365 G4int icase = 0;
366 if (Inside(G4ThreeVector(px-del, py, pz)) != kOutside) icase += 1;
367 if (Inside(G4ThreeVector(px+del, py, pz)) != kOutside) icase += 2;
368 if (Inside(G4ThreeVector(px, py-del, pz)) != kOutside) icase += 4;
369 if (Inside(G4ThreeVector(px, py+del, pz)) != kOutside) icase += 8;
370 if (Inside(G4ThreeVector(px, py, pz-del)) != kOutside) icase += 16;
371 if (Inside(G4ThreeVector(px, py, pz+del)) != kOutside) icase += 32;
372 if (icase == 0) continue;
373 G4ThreeVector v = directions[icase];
374 dist = DistanceToIn(p, v);
375 if (dist == kInfinity) continue;
376 G4ThreeVector n = SurfaceNormal(p + v*dist);
377 dist *= -(v.dot(n));
378 }
379 if (dist < eps) ++icount;
380 }
381 return dX*dY*dZ*icount/npoints/dd;
382}
static const G4double eps
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4VSolid.cc:665
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
@ kInside
Definition: geomdefs.hh:70
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References G4VSolid::BoundingLimits(), G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), CLHEP::Hep3Vector::dot(), eps, G4QuickRand(), G4VSolid::Inside(), kInfinity, kInside, kOutside, G4INCL::Math::min(), CLHEP::detail::n, G4VSolid::SurfaceNormal(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4VSolid::GetSurfaceArea(), G4MultiUnion::GetSurfaceArea(), and G4VCSGfaceted::GetSurfaceArea().

◆ GetConstituentSolid() [1/2]

G4VSolid * G4VSolid::GetConstituentSolid ( G4int  no)
virtualinherited

Reimplemented in G4BooleanSolid.

Definition at line 170 of file G4VSolid.cc.

171{ return nullptr; }

◆ GetConstituentSolid() [2/2]

const G4VSolid * G4VSolid::GetConstituentSolid ( G4int  no) const
virtualinherited

Reimplemented in G4BooleanSolid.

Definition at line 167 of file G4VSolid.cc.

168{ return nullptr; }

Referenced by G4BooleanSolid::StackPolyhedron().

◆ GetCubicVolume()

G4double G4Hype::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1081 of file G4Hype.cc.

1082{
1083 if(fCubicVolume != 0.) {;}
1085 return fCubicVolume;
1086}
virtual G4double GetCubicVolume()
Definition: G4VSolid.cc:188

References fCubicVolume, and G4VSolid::GetCubicVolume().

◆ GetDisplacedSolidPtr() [1/2]

G4DisplacedSolid * G4VSolid::GetDisplacedSolidPtr ( )
virtualinherited

Reimplemented in G4DisplacedSolid.

Definition at line 176 of file G4VSolid.cc.

177{ return nullptr; }

◆ GetDisplacedSolidPtr() [2/2]

const G4DisplacedSolid * G4VSolid::GetDisplacedSolidPtr ( ) const
virtualinherited

Reimplemented in G4DisplacedSolid.

Definition at line 173 of file G4VSolid.cc.

174{ return nullptr; }

◆ GetEntityType()

G4GeometryType G4Hype::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 1065 of file G4Hype.cc.

1066{
1067 return G4String("G4Hype");
1068}

◆ GetExtent()

G4VisExtent G4Hype::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1230 of file G4Hype.cc.

1231{
1232 // Define the sides of the box into which the G4Tubs instance would fit.
1233 //
1236 -halfLenZ, halfLenZ );
1237}

References endOuterRadius, and halfLenZ.

◆ GetInnerRadius()

G4double G4Hype::GetInnerRadius ( ) const
inline

◆ GetInnerStereo()

G4double G4Hype::GetInnerStereo ( ) const
inline

◆ GetName()

G4String G4VSolid::GetName ( ) const
inlineinherited

Referenced by G4GMocrenFileSceneHandler::AddDetector(), G4HepRepFileSceneHandler::AddHepRepInstance(), G4GMocrenFileSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), G4VtkSceneHandler::AddSolid(), G4GDMLWriteSolids::AddSolid(), G4NavigationLogger::AlongComputeStepLog(), G4GDMLWriteSolids::BooleanWrite(), G4ReflectedSolid::BoundingLimits(), G4DisplacedSolid::BoundingLimits(), G4IntersectionSolid::BoundingLimits(), G4ScaledSolid::BoundingLimits(), G4SubtractionSolid::BoundingLimits(), G4UnionSolid::BoundingLimits(), G4Box::BoundingLimits(), G4Cons::BoundingLimits(), G4CutTubs::BoundingLimits(), G4Orb::BoundingLimits(), G4Para::BoundingLimits(), G4Sphere::BoundingLimits(), G4Torus::BoundingLimits(), G4Trap::BoundingLimits(), G4Trd::BoundingLimits(), G4Tubs::BoundingLimits(), G4EllipticalCone::BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), BoundingLimits(), G4Paraboloid::BoundingLimits(), G4Polycone::BoundingLimits(), G4Polyhedra::BoundingLimits(), G4TessellatedSolid::BoundingLimits(), G4TwistedTubs::BoundingLimits(), G4GDMLWriteSolids::BoxWrite(), G4ExtrudedSolid::CalculateExtent(), G4GenericPolycone::CalculateExtent(), G4Polycone::CalculateExtent(), G4Polyhedra::CalculateExtent(), G4NavigationLogger::CheckDaughterEntryPoint(), G4VDivisionParameterisation::CheckNDivAndWidth(), G4VDivisionParameterisation::CheckOffset(), G4GenericTrap::CheckOrder(), G4Para::CheckParameters(), G4Trap::CheckParameters(), G4Trd::CheckParameters(), G4Ellipsoid::CheckParameters(), G4EllipticalTube::CheckParameters(), G4ParameterisationPolyconeRho::CheckParametersValidity(), G4ParameterisationPolyconeZ::CheckParametersValidity(), G4ParameterisationPolyhedraRho::CheckParametersValidity(), G4ParameterisationPolyhedraPhi::CheckParametersValidity(), G4ParameterisationPolyhedraZ::CheckParametersValidity(), G4PhantomParameterisation::CheckVoxelsFillContainer(), G4GenericTrap::ComputeIsTwisted(), G4VoxelNavigation::ComputeSafety(), G4VoxelSafety::ComputeSafety(), G4NavigationLogger::ComputeSafetyLog(), G4ParameterisedNavigation::ComputeStep(), G4ReplicaNavigation::ComputeStep(), G4GDMLWriteSolids::ConeWrite(), G4Polyhedra::Create(), G4GenericPolycone::Create(), G4Polycone::Create(), G4PhysicalVolumeModel::CreateCurrentAttValues(), G4ReflectedSolid::CreatePolyhedron(), G4ReflectionFactory::CreateReflectedLV(), G4GenericTrap::CreateTessellatedSolid(), G4GDMLWriteSolids::CutTubeWrite(), G4SolidStore::DeRegister(), G4PhysicalVolumeModel::DescribeSolid(), G4SubtractionSolid::DistanceToIn(), G4Paraboloid::DistanceToIn(), G4TessellatedSolid::DistanceToIn(), G4Box::DistanceToOut(), G4Orb::DistanceToOut(), G4Para::DistanceToOut(), G4Trap::DistanceToOut(), G4Trd::DistanceToOut(), G4EllipticalCone::DistanceToOut(), G4TessellatedSolid::DistanceToOut(), G4Ellipsoid::DistanceToOut(), G4EllipticalTube::DistanceToOut(), G4tgbGeometryDumper::DumpMultiUnionVolume(), G4tgbGeometryDumper::DumpScaledVolume(), G4tgbGeometryDumper::DumpSolid(), G4GDMLWriteSolids::ElconeWrite(), G4GDMLWriteSolids::EllipsoidWrite(), G4GDMLWriteSolids::EltubeWrite(), G4PVDivision::ErrorInAxis(), G4ReplicatedSlice::ErrorInAxis(), export_G4VSolid(), G4Box::G4Box(), G4Cons::G4Cons(), G4CutTubs::G4CutTubs(), G4EllipticalCone::G4EllipticalCone(), G4Hype(), G4Para::G4Para(), G4Paraboloid::G4Paraboloid(), G4Polycone::G4Polycone(), G4Polyhedra::G4Polyhedra(), G4Sphere::G4Sphere(), G4Tet::G4Tet(), G4Trap::G4Trap(), G4Tubs::G4Tubs(), G4VParameterisationCons::G4VParameterisationCons(), G4VParameterisationPara::G4VParameterisationPara(), G4VParameterisationPolycone::G4VParameterisationPolycone(), G4VParameterisationPolyhedra::G4VParameterisationPolyhedra(), G4VParameterisationTrd::G4VParameterisationTrd(), G4VTwistedFaceted::G4VTwistedFaceted(), G4GDMLWriteSolids::GenericPolyconeWrite(), G4GDMLWriteSolids::GenTrapWrite(), G4Navigator::GetGlobalExitNormal(), G4Navigator::GetLocalExitNormal(), G4ITNavigator1::GetLocalExitNormal(), G4ITNavigator2::GetLocalExitNormal(), G4BooleanSolid::GetPointOnSurface(), G4PhantomParameterisation::GetReplicaNo(), G4GDMLWriteSolids::HypeWrite(), G4TessellatedSolid::InsideNoVoxels(), G4TessellatedSolid::InsideVoxels(), G4ITNavigator1::LocateGlobalPointAndSetup(), G4ITNavigator2::LocateGlobalPointAndSetup(), G4Navigator::LocateGlobalPointAndSetup(), G4GenericTrap::MakeDownFacet(), G4Trap::MakePlanes(), G4GenericTrap::MakeUpFacet(), G4GDMLWriteSolids::MultiUnionWrite(), G4GDMLWriteSolids::OrbWrite(), G4GDMLWriteSolids::ParaboloidWrite(), G4GDMLWriteParamvol::ParametersWrite(), G4GDMLWriteSolids::ParaWrite(), G4GDMLWriteSolids::PolyconeWrite(), G4GDMLWriteSolids::PolyhedraWrite(), G4NavigationLogger::PostComputeStepLog(), G4NavigationLogger::PreComputeStepLog(), G4NavigationLogger::PrintDaughterLog(), G4PseudoScene::ProcessVolume(), G4SolidStore::Register(), G4tgbVolumeMgr::RegisterMe(), G4NavigationLogger::ReportOutsideMother(), G4ASCIITreeSceneHandler::RequestPrimitives(), G4VSceneHandler::RequestPrimitives(), G4GenericPolycone::Reset(), G4Polyhedra::Reset(), G4VoxelSafety::SafetyForVoxelNode(), G4GDMLWriteSolids::ScaledWrite(), G4Torus::SetAllParameters(), G4Tet::SetBoundingLimits(), G4Polycone::SetOriginalParameters(), G4Polyhedra::SetOriginalParameters(), G4TessellatedSolid::SetSolidClosed(), G4Tet::SetVertices(), G4Box::SetXHalfLength(), G4Box::SetYHalfLength(), G4Box::SetZHalfLength(), G4GDMLWriteSolids::SphereWrite(), G4BooleanSolid::StackPolyhedron(), G4ReflectedSolid::StreamInfo(), G4BooleanSolid::StreamInfo(), G4DisplacedSolid::StreamInfo(), G4MultiUnion::StreamInfo(), G4ScaledSolid::StreamInfo(), G4Box::StreamInfo(), G4Cons::StreamInfo(), G4CSGSolid::StreamInfo(), G4CutTubs::StreamInfo(), G4Orb::StreamInfo(), G4Para::StreamInfo(), G4Sphere::StreamInfo(), G4Torus::StreamInfo(), G4Trap::StreamInfo(), G4Trd::StreamInfo(), G4Tubs::StreamInfo(), G4Ellipsoid::StreamInfo(), G4EllipticalCone::StreamInfo(), G4EllipticalTube::StreamInfo(), G4ExtrudedSolid::StreamInfo(), G4GenericPolycone::StreamInfo(), G4GenericTrap::StreamInfo(), StreamInfo(), G4Paraboloid::StreamInfo(), G4Polycone::StreamInfo(), G4Polyhedra::StreamInfo(), G4TessellatedSolid::StreamInfo(), G4Tet::StreamInfo(), G4TwistedBox::StreamInfo(), G4TwistedTrap::StreamInfo(), G4TwistedTrd::StreamInfo(), G4TwistedTubs::StreamInfo(), G4VCSGfaceted::StreamInfo(), G4VTwistedFaceted::StreamInfo(), G4GDMLRead::StripNames(), SubstractSolids(), G4UnionSolid::SurfaceNormal(), G4Box::SurfaceNormal(), G4Para::SurfaceNormal(), G4Trap::SurfaceNormal(), G4Trd::SurfaceNormal(), G4Ellipsoid::SurfaceNormal(), G4EllipticalCone::SurfaceNormal(), G4EllipticalTube::SurfaceNormal(), G4ExtrudedSolid::SurfaceNormal(), G4Tet::SurfaceNormal(), G4GDMLWriteSolids::TessellatedWrite(), G4GDMLWriteSolids::TetWrite(), G4GDMLWriteSolids::TorusWrite(), G4GDMLWriteSolids::TrapWrite(), G4GDMLWriteStructure::TraverseVolumeTree(), G4GDMLWriteSolids::TrdWrite(), G4GDMLWriteSolids::TubeWrite(), G4GDMLWriteSolids::TwistedboxWrite(), G4GDMLWriteSolids::TwistedtrapWrite(), G4GDMLWriteSolids::TwistedtrdWrite(), G4GDMLWriteSolids::TwistedtubsWrite(), G4PhysicalVolumeModel::VisitGeometryAndGetVisReps(), and G4GDMLWriteSolids::XtruWrite().

◆ GetOuterRadius()

G4double G4Hype::GetOuterRadius ( ) const
inline

◆ GetOuterStereo()

G4double G4Hype::GetOuterStereo ( ) const
inline

◆ GetPointOnSurface()

G4ThreeVector G4Hype::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1120 of file G4Hype.cc.

1121{
1122 G4double xRand, yRand, zRand, r2 , aOne, aTwo, aThree, chose, sinhu;
1123 G4double phi, cosphi, sinphi, rBar2Out, rBar2In, alpha, t, rOut, rIn2, rOut2;
1124
1125 // we use the formula of the area of a surface of revolution to compute
1126 // the areas, using the equation of the hyperbola:
1127 // x^2 + y^2 = (z*tanphi)^2 + r^2
1128
1129 rBar2Out = outerRadius2;
1130 alpha = 2.*pi*rBar2Out*std::cos(outerStereo)/tanOuterStereo;
1132 t = std::log(t+std::sqrt(sqr(t)+1));
1133 aOne = std::fabs(2.*alpha*(std::sinh(2.*t)/4.+t/2.));
1134
1135
1136 rBar2In = innerRadius2;
1137 alpha = 2.*pi*rBar2In*std::cos(innerStereo)/tanInnerStereo;
1139 t = std::log(t+std::sqrt(sqr(t)+1));
1140 aTwo = std::fabs(2.*alpha*(std::sinh(2.*t)/4.+t/2.));
1141
1144
1145 if(outerStereo == 0.) {aOne = std::fabs(2.*pi*outerRadius*2.*halfLenZ);}
1146 if(innerStereo == 0.) {aTwo = std::fabs(2.*pi*innerRadius*2.*halfLenZ);}
1147
1148 phi = G4RandFlat::shoot(0.,2.*pi);
1149 cosphi = std::cos(phi);
1150 sinphi = std::sin(phi);
1153
1154 chose = G4RandFlat::shoot(0.,aOne+aTwo+2.*aThree);
1155 if(chose>=0. && chose < aOne)
1156 {
1157 if(outerStereo != 0.)
1158 {
1159 zRand = outerRadius*sinhu/tanOuterStereo;
1160 xRand = std::sqrt(sqr(sinhu)+1)*outerRadius*cosphi;
1161 yRand = std::sqrt(sqr(sinhu)+1)*outerRadius*sinphi;
1162 return G4ThreeVector (xRand, yRand, zRand);
1163 }
1164 else
1165 {
1166 return G4ThreeVector(outerRadius*cosphi,outerRadius*sinphi,
1168 }
1169 }
1170 else if(chose>=aOne && chose<aOne+aTwo)
1171 {
1172 if(innerStereo != 0.)
1173 {
1176 zRand = innerRadius*sinhu/tanInnerStereo;
1177 xRand = std::sqrt(sqr(sinhu)+1)*innerRadius*cosphi;
1178 yRand = std::sqrt(sqr(sinhu)+1)*innerRadius*sinphi;
1179 return G4ThreeVector (xRand, yRand, zRand);
1180 }
1181 else
1182 {
1183 return G4ThreeVector(innerRadius*cosphi,innerRadius*sinphi,
1185 }
1186 }
1187 else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
1188 {
1191 rOut = std::sqrt(rOut2) ;
1192
1193 do // Loop checking, 13.08.2015, G.Cosmo
1194 {
1195 xRand = G4RandFlat::shoot(-rOut,rOut) ;
1196 yRand = G4RandFlat::shoot(-rOut,rOut) ;
1197 r2 = xRand*xRand + yRand*yRand ;
1198 } while ( ! ( r2 >= rIn2 && r2 <= rOut2 ) ) ;
1199
1200 zRand = halfLenZ;
1201 return G4ThreeVector (xRand, yRand, zRand);
1202 }
1203 else
1204 {
1207 rOut = std::sqrt(rOut2) ;
1208
1209 do // Loop checking, 13.08.2015, G.Cosmo
1210 {
1211 xRand = G4RandFlat::shoot(-rOut,rOut) ;
1212 yRand = G4RandFlat::shoot(-rOut,rOut) ;
1213 r2 = xRand*xRand + yRand*yRand ;
1214 } while ( ! ( r2 >= rIn2 && r2 <= rOut2 ) ) ;
1215
1216 zRand = -1.*halfLenZ;
1217 return G4ThreeVector (xRand, yRand, zRand);
1218 }
1219}
static const G4double alpha
static constexpr double pi
Definition: G4SIunits.hh:55
ThreeVector shoot(const G4int Ap, const G4int Af)

References alpha, halfLenZ, innerRadius, innerRadius2, innerStereo, outerRadius, outerRadius2, outerStereo, pi, G4INCL::DeJongSpin::shoot(), sqr(), tanInnerStereo, tanInnerStereo2, tanOuterStereo, and tanOuterStereo2.

◆ GetPolyhedron()

G4Polyhedron * G4Hype::GetPolyhedron ( ) const
virtual

◆ GetSurfaceArea()

G4double G4Hype::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1090 of file G4Hype.cc.

1091{
1092 if(fSurfaceArea != 0.) {;}
1094 return fSurfaceArea;
1095}
virtual G4double GetSurfaceArea()
Definition: G4VSolid.cc:250

References fSurfaceArea, and G4VSolid::GetSurfaceArea().

◆ GetTolerance()

G4double G4VSolid::GetTolerance ( ) const
inlineinherited

◆ GetZHalfLength()

G4double G4Hype::GetZHalfLength ( ) const
inline

◆ HypeInnerRadius2()

G4double G4Hype::HypeInnerRadius2 ( G4double  zVal) const
inlineprotected

◆ HypeOuterRadius2()

G4double G4Hype::HypeOuterRadius2 ( G4double  zVal) const
inlineprotected

◆ InnerSurfaceExists()

G4bool G4Hype::InnerSurfaceExists ( ) const
inlineprotected

◆ Inside()

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

Implements G4VSolid.

Definition at line 238 of file G4Hype.cc.

239{
240 //
241 // Check z extents: are we outside?
242 //
243 const G4double absZ(std::fabs(p.z()));
244 if (absZ > halfLenZ + fHalfTol) return kOutside;
245
246 //
247 // Check outer radius
248 //
249 const G4double oRad2(HypeOuterRadius2(absZ));
250 const G4double xR2( p.x()*p.x()+p.y()*p.y() );
251
252 if (xR2 > oRad2 + kCarTolerance*endOuterRadius) return kOutside;
253
254 if (xR2 > oRad2 - kCarTolerance*endOuterRadius) return kSurface;
255
256 if (InnerSurfaceExists())
257 {
258 //
259 // Check inner radius
260 //
261 const G4double iRad2(HypeInnerRadius2(absZ));
262
263 if (xR2 < iRad2 - kCarTolerance*endInnerRadius) return kOutside;
264
265 if (xR2 < iRad2 + kCarTolerance*endInnerRadius) return kSurface;
266 }
267
268 //
269 // We are inside in radius, now check endplate surface
270 //
271 if (absZ > halfLenZ - fHalfTol) return kSurface;
272
273 return kInside;
274}
@ kSurface
Definition: geomdefs.hh:69

References endInnerRadius, endOuterRadius, fHalfTol, halfLenZ, HypeInnerRadius2(), HypeOuterRadius2(), InnerSurfaceExists(), G4VSolid::kCarTolerance, kInside, kOutside, kSurface, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ IntersectHype()

G4int G4Hype::IntersectHype ( const G4ThreeVector p,
const G4ThreeVector v,
G4double  r2,
G4double  tan2Phi,
G4double  s[2] 
)
staticprotected

Definition at line 921 of file G4Hype.cc.

923{
924 G4double x0 = p.x(), y0 = p.y(), z0 = p.z();
925 G4double tx = v.x(), ty = v.y(), tz = v.z();
926
927 G4double a = tx*tx + ty*ty - tz*tz*tan2Phi;
928 G4double b = 2*( x0*tx + y0*ty - z0*tz*tan2Phi );
929 G4double c = x0*x0 + y0*y0 - r2 - z0*z0*tan2Phi;
930
931 if (std::fabs(a) < DBL_MIN)
932 {
933 //
934 // The trajectory is parallel to the asympotic limit of
935 // the surface: single solution
936 //
937 if (std::fabs(b) < DBL_MIN) return 0;
938 // Unless we travel through exact center
939
940 ss[0] = c/b;
941 return 1;
942 }
943
944 G4double radical = b*b - 4*a*c;
945
946 if (radical < -DBL_MIN) return 0; // No solution
947
948 if (radical < DBL_MIN)
949 {
950 //
951 // Grazes surface
952 //
953 ss[0] = -b/a/2.0;
954 return 1;
955 }
956
957 radical = std::sqrt(radical);
958
959 G4double q = -0.5*( b + (b < 0 ? -radical : +radical) );
960 G4double sa = q/a;
961 G4double sb = c/q;
962 if (sa < sb) { ss[0] = sa; ss[1] = sb; } else { ss[0] = sb; ss[1] = sa; }
963 return 2;
964}

References DBL_MIN, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep3Vector::z(), and G4InuclParticleNames::z0.

Referenced by DistanceToIn(), and DistanceToOut().

◆ operator=()

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

Definition at line 159 of file G4Hype.cc.

160{
161 // Check assignment to self
162 //
163 if (this == &rhs) { return *this; }
164
165 // Copy base class data
166 //
168
169 // Copy data
170 //
172 halfLenZ = rhs.halfLenZ;
180 fHalfTol = rhs.fHalfTol;
181 fRebuildPolyhedron = false;
182 delete fpPolyhedron; fpPolyhedron = nullptr;
183
184 return *this;
185}
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:107

References endInnerRadius, endInnerRadius2, endOuterRadius, endOuterRadius2, fCubicVolume, fHalfTol, fpPolyhedron, fRebuildPolyhedron, fSurfaceArea, halfLenZ, innerRadius, innerRadius2, innerStereo, G4VSolid::operator=(), outerRadius, outerRadius2, outerStereo, tanInnerStereo, tanInnerStereo2, tanOuterStereo, and tanOuterStereo2.

◆ operator==()

G4bool G4VSolid::operator== ( const G4VSolid s) const
inlineinherited

◆ SetInnerRadius()

void G4Hype::SetInnerRadius ( G4double  newIRad)
inline

◆ SetInnerStereo()

void G4Hype::SetInnerStereo ( G4double  newISte)
inline

◆ SetName()

void G4VSolid::SetName ( const G4String name)
inherited

Definition at line 127 of file G4VSolid.cc.

128{
131}
void SetMapValid(G4bool val)
Definition: G4SolidStore.hh:76
static G4SolidStore * GetInstance()
G4String fshapeName
Definition: G4VSolid.hh:312
const char * name(G4int ptype)

References G4VSolid::fshapeName, G4SolidStore::GetInstance(), G4InuclParticleNames::name(), and G4SolidStore::SetMapValid().

Referenced by export_G4VSolid(), G4MultiUnion::G4MultiUnion(), and G4GDMLRead::StripNames().

◆ SetOuterRadius()

void G4Hype::SetOuterRadius ( G4double  newORad)
inline

◆ SetOuterStereo()

void G4Hype::SetOuterStereo ( G4double  newOSte)
inline

◆ SetZHalfLength()

void G4Hype::SetZHalfLength ( G4double  newHLZ)
inline

◆ StreamInfo()

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

Implements G4VSolid.

Definition at line 1099 of file G4Hype.cc.

1100{
1101 G4int oldprc = os.precision(16);
1102 os << "-----------------------------------------------------------\n"
1103 << " *** Dump for solid - " << GetName() << " ***\n"
1104 << " ===================================================\n"
1105 << " Solid type: G4Hype\n"
1106 << " Parameters: \n"
1107 << " half length Z: " << halfLenZ/mm << " mm \n"
1108 << " inner radius : " << innerRadius/mm << " mm \n"
1109 << " outer radius : " << outerRadius/mm << " mm \n"
1110 << " inner stereo angle : " << innerStereo/degree << " degrees \n"
1111 << " outer stereo angle : " << outerStereo/degree << " degrees \n"
1112 << "-----------------------------------------------------------\n";
1113 os.precision(oldprc);
1114
1115 return os;
1116}
static constexpr double degree
Definition: G4SIunits.hh:124

References degree, G4VSolid::GetName(), halfLenZ, innerRadius, innerStereo, mm, outerRadius, and outerStereo.

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 279 of file G4Hype.cc.

280{
281 //
282 // Which of the three or four surfaces are we closest to?
283 //
284 const G4double absZ(std::fabs(p.z()));
285 const G4double distZ(absZ - halfLenZ);
286 const G4double dist2Z(distZ*distZ);
287
288 const G4double xR2( p.x()*p.x()+p.y()*p.y() );
289 const G4double dist2Outer( std::fabs(xR2 - HypeOuterRadius2(absZ)) );
290
291 if (InnerSurfaceExists())
292 {
293 //
294 // Has inner surface: is this closest?
295 //
296 const G4double dist2Inner( std::fabs(xR2 - HypeInnerRadius2(absZ)) );
297 if (dist2Inner < dist2Z && dist2Inner < dist2Outer)
298 return G4ThreeVector( -p.x(), -p.y(), p.z()*tanInnerStereo2 ).unit();
299 }
300
301 //
302 // Do the "endcaps" win?
303 //
304 if (dist2Z < dist2Outer)
305 return G4ThreeVector( 0.0, 0.0, p.z() < 0 ? -1.0 : 1.0 );
306
307
308 //
309 // Outer surface wins
310 //
311 return G4ThreeVector( p.x(), p.y(), -p.z()*tanOuterStereo2 ).unit();
312}

References halfLenZ, HypeInnerRadius2(), HypeOuterRadius2(), InnerSurfaceExists(), tanInnerStereo2, tanOuterStereo2, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Field Documentation

◆ endInnerRadius

G4double G4Hype::endInnerRadius
protected

Definition at line 180 of file G4Hype.hh.

Referenced by DistanceToIn(), DistanceToOut(), Inside(), and operator=().

◆ endInnerRadius2

G4double G4Hype::endInnerRadius2
protected

Definition at line 178 of file G4Hype.hh.

Referenced by DistanceToIn(), and operator=().

◆ endOuterRadius

G4double G4Hype::endOuterRadius
protected

Definition at line 181 of file G4Hype.hh.

Referenced by BoundingLimits(), DistanceToIn(), DistanceToOut(), GetExtent(), Inside(), and operator=().

◆ endOuterRadius2

G4double G4Hype::endOuterRadius2
protected

Definition at line 179 of file G4Hype.hh.

Referenced by DistanceToIn(), and operator=().

◆ fCubicVolume

G4double G4Hype::fCubicVolume = 0.0
private

Definition at line 193 of file G4Hype.hh.

Referenced by GetCubicVolume(), and operator=().

◆ fHalfTol

G4double G4Hype::fHalfTol
private

Definition at line 196 of file G4Hype.hh.

Referenced by DistanceToIn(), DistanceToOut(), G4Hype(), Inside(), and operator=().

◆ fpPolyhedron

G4Polyhedron* G4Hype::fpPolyhedron = nullptr
mutableprivate

Definition at line 199 of file G4Hype.hh.

Referenced by GetPolyhedron(), operator=(), and ~G4Hype().

◆ fRebuildPolyhedron

G4bool G4Hype::fRebuildPolyhedron = false
mutableprivate

Definition at line 198 of file G4Hype.hh.

Referenced by GetPolyhedron(), and operator=().

◆ fshapeName

G4String G4VSolid::fshapeName
privateinherited

Definition at line 312 of file G4VSolid.hh.

Referenced by G4VSolid::operator=(), and G4VSolid::SetName().

◆ fSurfaceArea

G4double G4Hype::fSurfaceArea = 0.0
private

Definition at line 194 of file G4Hype.hh.

Referenced by GetSurfaceArea(), and operator=().

◆ halfLenZ

G4double G4Hype::halfLenZ
protected

◆ innerRadius

G4double G4Hype::innerRadius
protected

◆ innerRadius2

G4double G4Hype::innerRadius2
protected

Definition at line 176 of file G4Hype.hh.

Referenced by DistanceToIn(), DistanceToOut(), G4Hype(), GetPointOnSurface(), and operator=().

◆ innerStereo

G4double G4Hype::innerStereo
protected

Definition at line 167 of file G4Hype.hh.

Referenced by DistanceToIn(), GetPointOnSurface(), operator=(), and StreamInfo().

◆ kCarTolerance

G4double G4VSolid::kCarTolerance
protectedinherited

Definition at line 299 of file G4VSolid.hh.

Referenced by G4TessellatedSolid::AddFacet(), G4Polycone::CalculateExtent(), G4Polyhedra::CalculateExtent(), G4Tet::CheckDegeneracy(), G4Para::CheckParameters(), G4Trd::CheckParameters(), G4Ellipsoid::CheckParameters(), G4EllipticalTube::CheckParameters(), G4GenericTrap::ComputeIsTwisted(), G4Polyhedra::Create(), G4GenericPolycone::Create(), G4Polycone::Create(), G4CutTubs::CreatePolyhedron(), G4TessellatedSolid::CreateVertexList(), G4VCSGfaceted::DistanceTo(), G4Sphere::DistanceToIn(), G4Ellipsoid::DistanceToIn(), DistanceToIn(), G4Paraboloid::DistanceToIn(), G4VCSGfaceted::DistanceToIn(), G4TessellatedSolid::DistanceToInCore(), G4Cons::DistanceToOut(), G4CutTubs::DistanceToOut(), G4Sphere::DistanceToOut(), G4Torus::DistanceToOut(), G4Tubs::DistanceToOut(), G4GenericTrap::DistanceToOut(), DistanceToOut(), G4Paraboloid::DistanceToOut(), G4VCSGfaceted::DistanceToOut(), G4TessellatedSolid::DistanceToOutCandidates(), G4TessellatedSolid::DistanceToOutCore(), G4TessellatedSolid::DistanceToOutNoVoxels(), G4GenericTrap::DistToPlane(), G4GenericTrap::DistToTriangle(), G4Box::G4Box(), G4Cons::G4Cons(), G4CutTubs::G4CutTubs(), G4EllipticalCone::G4EllipticalCone(), G4ExtrudedSolid::G4ExtrudedSolid(), G4GenericTrap::G4GenericTrap(), G4Hype(), G4Para::G4Para(), G4Sphere::G4Sphere(), G4Tet::G4Tet(), G4Trap::G4Trap(), G4Tubs::G4Tubs(), G4UnionSolid::G4UnionSolid(), G4VSolid::G4VSolid(), G4VTwistedFaceted::G4VTwistedFaceted(), G4GenericPolycone::GetPointOnSurface(), G4Polycone::GetPointOnSurface(), G4UnionSolid::Init(), G4Orb::Initialize(), G4TessellatedSolid::Initialize(), G4SubtractionSolid::Inside(), Inside(), G4Paraboloid::Inside(), G4VCSGfaceted::Inside(), G4VTwistedFaceted::Inside(), G4TessellatedSolid::InsideNoVoxels(), G4GenericTrap::InsidePolygone(), G4TessellatedSolid::InsideVoxels(), G4CutTubs::IsCrossingCutPlanes(), G4GenericTrap::IsSegCrossingZ(), G4Trap::MakePlane(), G4GenericTrap::NormalToPlane(), G4VSolid::operator=(), G4TessellatedSolid::SafetyFromInside(), G4TessellatedSolid::SafetyFromOutside(), G4Torus::SetAllParameters(), G4Polycone::SetOriginalParameters(), G4Polyhedra::SetOriginalParameters(), G4Box::SetXHalfLength(), G4Box::SetYHalfLength(), G4Box::SetZHalfLength(), G4Torus::SurfaceNormal(), G4GenericTrap::SurfaceNormal(), and G4Paraboloid::SurfaceNormal().

◆ outerRadius

G4double G4Hype::outerRadius
protected

◆ outerRadius2

G4double G4Hype::outerRadius2
protected

Definition at line 177 of file G4Hype.hh.

Referenced by DistanceToIn(), DistanceToOut(), G4Hype(), GetPointOnSurface(), and operator=().

◆ outerStereo

G4double G4Hype::outerStereo
protected

Definition at line 168 of file G4Hype.hh.

Referenced by GetPointOnSurface(), operator=(), and StreamInfo().

◆ tanInnerStereo

G4double G4Hype::tanInnerStereo
protected

Definition at line 172 of file G4Hype.hh.

Referenced by DistanceToOut(), GetPointOnSurface(), and operator=().

◆ tanInnerStereo2

G4double G4Hype::tanInnerStereo2
protected

◆ tanOuterStereo

G4double G4Hype::tanOuterStereo
protected

Definition at line 173 of file G4Hype.hh.

Referenced by DistanceToIn(), GetPointOnSurface(), and operator=().

◆ tanOuterStereo2

G4double G4Hype::tanOuterStereo2
protected

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