Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4EllipticalCone Class Reference

#include <G4EllipticalCone.hh>

Inheritance diagram for G4EllipticalCone:
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
 
virtual 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
 
 G4EllipticalCone (__void__ &)
 
 G4EllipticalCone (const G4EllipticalCone &rhs)
 
 G4EllipticalCone (const G4String &pName, G4double pxSemiAxis, G4double pySemiAxis, G4double zMax, G4double pzTopCut)
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
G4double GetCubicVolume ()
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
G4GeometryType GetEntityType () const
 
G4VisExtent GetExtent () const
 
G4String GetName () const
 
G4ThreeVector GetPointOnSurface () const
 
G4PolyhedronGetPolyhedron () const
 
G4double GetSemiAxisMax () const
 
G4double GetSemiAxisMin () const
 
G4double GetSemiAxisX () const
 
G4double GetSemiAxisY () const
 
G4double GetSurfaceArea ()
 
G4double GetTolerance () const
 
G4double GetZMax () const
 
G4double GetZTopCut () const
 
EInside Inside (const G4ThreeVector &p) const
 
G4EllipticalConeoperator= (const G4EllipticalCone &rhs)
 
G4bool operator== (const G4VSolid &s) const
 
void SetName (const G4String &name)
 
void SetSemiAxis (G4double x, G4double y, G4double z)
 
void SetZCut (G4double newzTopCut)
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
virtual ~G4EllipticalCone ()
 

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
 

Protected Attributes

G4PolyhedronfpPolyhedron = nullptr
 
G4bool fRebuildPolyhedron = false
 
G4double kCarTolerance
 

Private Member Functions

G4ThreeVector ApproxSurfaceNormal (const G4ThreeVector &p) const
 
void ClipPolygonToSimpleLimits (G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit) const
 

Private Attributes

G4double cosAxisMin
 
G4double fCubicVolume = 0.0
 
G4String fshapeName
 
G4double fSurfaceArea = 0.0
 
G4double halfCarTol
 
G4double invXX
 
G4double invYY
 
G4double xSemiAxis
 
G4double ySemiAxis
 
G4double zheight
 
G4double zTopCut
 

Detailed Description

Definition at line 87 of file G4EllipticalCone.hh.

Constructor & Destructor Documentation

◆ G4EllipticalCone() [1/3]

G4EllipticalCone::G4EllipticalCone ( const G4String pName,
G4double  pxSemiAxis,
G4double  pySemiAxis,
G4double  zMax,
G4double  pzTopCut 
)

Definition at line 72 of file G4EllipticalCone.cc.

77 : G4VSolid(pName), zTopCut(0.)
78{
80
81 // Check Semi-Axis & Z-cut
82 //
83 if ( (pxSemiAxis <= 0.) || (pySemiAxis <= 0.) || (pzMax <= 0.) )
84 {
85 std::ostringstream message;
86 message << "Invalid semi-axis or height for solid: " << GetName()
87 << "\n X semi-axis, Y semi-axis, height = "
88 << pxSemiAxis << ", " << pySemiAxis << ", " << pzMax;
89 G4Exception("G4EllipticalCone::G4EllipticalCone()", "GeomSolids0002",
90 FatalErrorInArgument, message);
91 }
92
93 if ( pzTopCut <= 0 )
94 {
95 std::ostringstream message;
96 message << "Invalid z-coordinate for cutting plane for solid: " << GetName()
97 << "\n Z top cut = " << pzTopCut;
98 G4Exception("G4EllipticalCone::G4EllipticalCone()", "GeomSolids0002",
99 FatalErrorInArgument, message);
100 }
101
102 SetSemiAxis( pxSemiAxis, pySemiAxis, pzMax );
103 SetZCut(pzTopCut);
104}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
void SetSemiAxis(G4double x, G4double y, G4double z)
void SetZCut(G4double newzTopCut)
G4String GetName() const
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:57
G4double kCarTolerance
Definition: G4VSolid.hh:299

References FatalErrorInArgument, G4Exception(), G4VSolid::GetName(), halfCarTol, G4VSolid::kCarTolerance, SetSemiAxis(), and SetZCut().

Referenced by Clone().

◆ ~G4EllipticalCone()

G4EllipticalCone::~G4EllipticalCone ( )
virtual

Definition at line 122 of file G4EllipticalCone.cc.

123{
124 delete fpPolyhedron; fpPolyhedron = nullptr;
125}
G4Polyhedron * fpPolyhedron

References fpPolyhedron.

◆ G4EllipticalCone() [2/3]

G4EllipticalCone::G4EllipticalCone ( __void__ &  a)

Definition at line 111 of file G4EllipticalCone.cc.

112 : G4VSolid(a), halfCarTol(0.),
113 xSemiAxis(0.), ySemiAxis(0.), zheight(0.), zTopCut(0.),
114 cosAxisMin(0.), invXX(0.), invYY(0.)
115{
116}

◆ G4EllipticalCone() [3/3]

G4EllipticalCone::G4EllipticalCone ( const G4EllipticalCone rhs)

Definition at line 131 of file G4EllipticalCone.cc.

Member Function Documentation

◆ ApproxSurfaceNormal()

G4ThreeVector G4EllipticalCone::ApproxSurfaceNormal ( const G4ThreeVector p) const
private

Definition at line 330 of file G4EllipticalCone.cc.

331{
332 G4double hp = std::sqrt(p.x()*p.x()*invXX + p.y()*p.y()*invYY) + p.z();
333 G4double ds = (hp - zheight)*cosAxisMin;
334 G4double dz = std::abs(p.z()) - zTopCut;
335 if (ds > dz && std::abs(hp - p.z()) > halfCarTol)
336 return G4ThreeVector(p.x()*invXX, p.y()*invYY, hp - p.z()).unit();
337 else
338 return G4ThreeVector(0., 0.,(p.z() < 0) ? -1. : 1.);
339}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
double z() const
Hep3Vector unit() const
double x() const
double y() const

References cosAxisMin, anonymous_namespace{G4QuasiElRatios.cc}::ds, halfCarTol, invXX, invYY, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep3Vector::z(), zheight, and zTopCut.

Referenced by SurfaceNormal().

◆ BoundingLimits()

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

Reimplemented from G4VSolid.

Definition at line 172 of file G4EllipticalCone.cc.

174{
175 G4double zcut = GetZTopCut();
176 G4double height = GetZMax();
177 G4double xmax = GetSemiAxisX()*(height+zcut);
178 G4double ymax = GetSemiAxisY()*(height+zcut);
179 pMin.set(-xmax,-ymax,-zcut);
180 pMax.set( xmax, ymax, zcut);
181
182 // Check correctness of the bounding box
183 //
184 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
185 {
186 std::ostringstream message;
187 message << "Bad bounding box (min >= max) for solid: "
188 << GetName() << " !"
189 << "\npMin = " << pMin
190 << "\npMax = " << pMax;
191 G4Exception("G4EllipticalCone::BoundingLimits()", "GeomMgt0001",
192 JustWarning, message);
193 DumpInfo();
194 }
195}
@ JustWarning
static const G4double pMax
static const G4double pMin
G4double GetSemiAxisX() const
G4double GetSemiAxisY() const
G4double GetZMax() const
G4double GetZTopCut() const
void DumpInfo() const

References G4VSolid::DumpInfo(), G4Exception(), G4VSolid::GetName(), GetSemiAxisX(), GetSemiAxisY(), GetZMax(), GetZTopCut(), JustWarning, pMax, and pMin.

Referenced by CalculateExtent(), and GetExtent().

◆ 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 G4EllipticalCone::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pMin,
G4double pMax 
) const
virtual

Implements G4VSolid.

Definition at line 202 of file G4EllipticalCone.cc.

206{
207 G4ThreeVector bmin,bmax;
208 G4bool exist;
209
210 // Check bounding box (bbox)
211 //
212 BoundingLimits(bmin,bmax);
213 G4BoundingEnvelope bbox(bmin,bmax);
214#ifdef G4BBOX_EXTENT
215 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
216#endif
217 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
218 {
219 return exist = (pMin < pMax) ? true : false;
220 }
221
222 // Set bounding envelope (benv) and calculate extent
223 //
224 static const G4int NSTEPS = 48; // number of steps for whole circle
225 static const G4double ang = twopi/NSTEPS;
226 static const G4double sinHalf = std::sin(0.5*ang);
227 static const G4double cosHalf = std::cos(0.5*ang);
228 static const G4double sinStep = 2.*sinHalf*cosHalf;
229 static const G4double cosStep = 1. - 2.*sinHalf*sinHalf;
230 G4double zcut = bmax.z();
231 G4double height = GetZMax();
232 G4double sxmin = GetSemiAxisX()*(height-zcut)/cosHalf;
233 G4double symin = GetSemiAxisY()*(height-zcut)/cosHalf;
234 G4double sxmax = bmax.x()/cosHalf;
235 G4double symax = bmax.y()/cosHalf;
236
237 G4double sinCur = sinHalf;
238 G4double cosCur = cosHalf;
239 G4ThreeVectorList baseA(NSTEPS),baseB(NSTEPS);
240 for (G4int k=0; k<NSTEPS; ++k)
241 {
242 baseA[k].set(sxmax*cosCur,symax*sinCur,-zcut);
243 baseB[k].set(sxmin*cosCur,symin*sinCur, zcut);
244
245 G4double sinTmp = sinCur;
246 sinCur = sinCur*cosStep + cosCur*sinStep;
247 cosCur = cosCur*cosStep - sinTmp*sinStep;
248 }
249
250 std::vector<const G4ThreeVectorList *> polygons(2);
251 polygons[0] = &baseA;
252 polygons[1] = &baseB;
253 G4BoundingEnvelope benv(bmin,bmax,polygons);
254 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
255 return exist;
256}
std::vector< G4ThreeVector > G4ThreeVectorList
static constexpr double twopi
Definition: G4SIunits.hh:56
bool G4bool
Definition: G4Types.hh:86
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const

References G4BoundingEnvelope::BoundingBoxVsVoxelLimits(), BoundingLimits(), G4BoundingEnvelope::CalculateExtent(), GetSemiAxisX(), GetSemiAxisY(), GetZMax(), pMax, pMin, twopi, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ 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}
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 * G4EllipticalCone::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 809 of file G4EllipticalCone.cc.

810{
811 return new G4EllipticalCone(*this);
812}
G4EllipticalCone(const G4String &pName, G4double pxSemiAxis, G4double pySemiAxis, G4double zMax, G4double pzTopCut)

References G4EllipticalCone().

◆ ComputeDimensions()

void G4VSolid::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtualinherited

Reimplemented in G4TwistedTubs, G4VTwistedFaceted, G4ReflectedSolid, G4DisplacedSolid, G4IntersectionSolid, G4ScaledSolid, G4SubtractionSolid, G4UnionSolid, G4Box, G4Cons, G4Orb, G4Para, G4Sphere, G4Torus, G4Trap, G4Trd, G4Tubs, G4Ellipsoid, G4Hype, G4Polycone, G4Polyhedra, and G4Tet.

Definition at line 137 of file G4VSolid.cc.

140{
141 std::ostringstream message;
142 message << "Illegal call to G4VSolid::ComputeDimensions()" << G4endl
143 << "Method not overloaded by derived class !";
144 G4Exception("G4VSolid::ComputeDimensions()", "GeomMgt0003",
145 FatalException, message);
146}
@ FatalException
#define G4endl
Definition: G4ios.hh:57

References FatalException, G4endl, and G4Exception().

Referenced by G4SmartVoxelHeader::BuildNodes(), G4PVParameterised::CheckOverlaps(), G4VPrimitiveScorer::ComputeSolid(), G4ScoreSplittingProcess::CreateTouchableForSubStep(), G4LogicalVolumeModel::DescribeYourselfTo(), G4VFieldModel::DescribeYourselfTo(), G4LogicalVolume::GetMass(), G4Navigator::GetMotherToDaughterTransform(), G4ITNavigator1::GetMotherToDaughterTransform(), G4ITNavigator2::GetMotherToDaughterTransform(), G4ITNavigator1::LocateGlobalPointAndSetup(), G4ITNavigator2::LocateGlobalPointAndSetup(), G4Navigator::LocateGlobalPointAndSetup(), G4PSFlatSurfaceCurrent::ProcessHits(), G4PSFlatSurfaceFlux::ProcessHits(), G4PSSphereSurfaceFlux::ProcessHits(), G4PSVolumeFlux::ProcessHits(), G4Navigator::SetupHierarchy(), G4ITNavigator1::SetupHierarchy(), and G4ITNavigator2::SetupHierarchy().

◆ CreatePolyhedron()

G4Polyhedron * G4EllipticalCone::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 973 of file G4EllipticalCone.cc.

References xSemiAxis, ySemiAxis, zheight, and zTopCut.

Referenced by GetPolyhedron().

◆ DescribeYourselfTo()

void G4EllipticalCone::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 957 of file G4EllipticalCone.cc.

958{
959 scene.AddSolid(*this);
960}
virtual void AddSolid(const G4Box &)=0

References G4VGraphicsScene::AddSolid().

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 595 of file G4EllipticalCone.cc.

596{
597 G4double hp = std::sqrt(p.x()*p.x()*invXX + p.y()*p.y()*invYY) + p.z();
598 G4double ds = (hp - zheight)*cosAxisMin;
599 G4double dz = std::abs(p.z()) - zTopCut;
600 G4double dist = std::max(ds,dz);
601 return (dist > 0) ? dist : 0.;
602}
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References cosAxisMin, anonymous_namespace{G4QuasiElRatios.cc}::ds, invXX, invYY, G4INCL::Math::max(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep3Vector::z(), zheight, and zTopCut.

◆ DistanceToIn() [2/2]

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

Implements G4VSolid.

Definition at line 346 of file G4EllipticalCone.cc.

348{
349 G4double distMin = kInfinity;
350
351 // code from EllipticalTube
352
353 G4double sigz = p.z()+zTopCut;
354
355 //
356 // Check z = -dz planer surface
357 //
358
359 if (sigz < halfCarTol)
360 {
361 //
362 // We are "behind" the shape in z, and so can
363 // potentially hit the rear face. Correct direction?
364 //
365 if (v.z() <= 0)
366 {
367 //
368 // As long as we are far enough away, we know we
369 // can't intersect
370 //
371 if (sigz < 0) return kInfinity;
372
373 //
374 // Otherwise, we don't intersect unless we are
375 // on the surface of the ellipse
376 //
377
378 if ( sqr(p.x()/( xSemiAxis - halfCarTol ))
379 + sqr(p.y()/( ySemiAxis - halfCarTol )) <= sqr( zheight + zTopCut ) )
380 return kInfinity;
381
382 }
383 else
384 {
385 //
386 // How far?
387 //
388 G4double q = -sigz/v.z();
389
390 //
391 // Where does that place us?
392 //
393 G4double xi = p.x() + q*v.x(),
394 yi = p.y() + q*v.y();
395
396 //
397 // Is this on the surface (within ellipse)?
398 //
399 if ( sqr(xi/xSemiAxis) + sqr(yi/ySemiAxis) <= sqr( zheight + zTopCut ) )
400 {
401 //
402 // Yup. Return q, unless we are on the surface
403 //
404 return (sigz < -halfCarTol) ? q : 0;
405 }
406 else if (xi/(xSemiAxis*xSemiAxis)*v.x()
407 + yi/(ySemiAxis*ySemiAxis)*v.y() >= 0)
408 {
409 //
410 // Else, if we are traveling outwards, we know
411 // we must miss
412 //
413 // return kInfinity;
414 }
415 }
416 }
417
418 //
419 // Check z = +dz planer surface
420 //
421 sigz = p.z() - zTopCut;
422
423 if (sigz > -halfCarTol)
424 {
425 if (v.z() >= 0)
426 {
427
428 if (sigz > 0) return kInfinity;
429
430 if ( sqr(p.x()/( xSemiAxis - halfCarTol ))
431 + sqr(p.y()/( ySemiAxis - halfCarTol )) <= sqr( zheight-zTopCut ) )
432 return kInfinity;
433
434 }
435 else {
436 G4double q = -sigz/v.z();
437
438 G4double xi = p.x() + q*v.x(),
439 yi = p.y() + q*v.y();
440
441 if ( sqr(xi/xSemiAxis) + sqr(yi/ySemiAxis) <= sqr( zheight - zTopCut ) )
442 {
443 return (sigz > -halfCarTol) ? q : 0;
444 }
445 else if (xi/(xSemiAxis*xSemiAxis)*v.x()
446 + yi/(ySemiAxis*ySemiAxis)*v.y() >= 0)
447 {
448 // return kInfinity;
449 }
450 }
451 }
452
453
454#if 0
455
456 // check to see if Z plane is relevant
457 //
458 if (p.z() < -zTopCut - halfCarTol)
459 {
460 if (v.z() <= 0.0)
461 return distMin;
462
463 G4double lambda = (-zTopCut - p.z())/v.z();
464
465 if ( sqr((lambda*v.x()+p.x())/xSemiAxis) +
466 sqr((lambda*v.y()+p.y())/ySemiAxis) <=
468 {
469 return distMin = std::fabs(lambda);
470 }
471 }
472
473 if (p.z() > zTopCut + halfCarTol)
474 {
475 if (v.z() >= 0.0)
476 { return distMin; }
477
478 G4double lambda = (zTopCut - p.z()) / v.z();
479
480 if ( sqr((lambda*v.x() + p.x())/xSemiAxis) +
481 sqr((lambda*v.y() + p.y())/ySemiAxis) <=
483 {
484 return distMin = std::fabs(lambda);
485 }
486 }
487
488 if (p.z() > zTopCut - halfCarTol
489 && p.z() < zTopCut + halfCarTol )
490 {
491 if (v.z() > 0.)
492 { return kInfinity; }
493
494 return distMin = 0.;
495 }
496
497 if (p.z() < -zTopCut + halfCarTol
498 && p.z() > -zTopCut - halfCarTol)
499 {
500 if (v.z() < 0.)
501 { return distMin = kInfinity; }
502
503 return distMin = 0.;
504 }
505
506#endif
507
508 // if we are here then it either intersects or grazes the curved surface
509 // or it does not intersect at all
510 //
511 G4double A = sqr(v.x()/xSemiAxis) + sqr(v.y()/ySemiAxis) - sqr(v.z());
512 G4double B = 2*(v.x()*p.x()/sqr(xSemiAxis) +
513 v.y()*p.y()/sqr(ySemiAxis) + v.z()*(zheight-p.z()));
514 G4double C = sqr(p.x()/xSemiAxis) + sqr(p.y()/ySemiAxis) -
515 sqr(zheight - p.z());
516
517 G4double discr = B*B - 4.*A*C;
518
519 // if the discriminant is negative it never hits the curved object
520 //
521 if ( discr < -halfCarTol )
522 { return distMin; }
523
524 // case below is when it hits or grazes the surface
525 //
526 if ( (discr >= -halfCarTol ) && (discr < halfCarTol ) )
527 {
528 return distMin = std::fabs(-B/(2.*A));
529 }
530
531 G4double plus = (-B+std::sqrt(discr))/(2.*A);
532 G4double minus = (-B-std::sqrt(discr))/(2.*A);
533
534 // Special case::Point on Surface, Check norm.dot(v)
535
536 if ( ( std::fabs(plus) < halfCarTol )||( std::fabs(minus) < halfCarTol ) )
537 {
538 G4ThreeVector truenorm(p.x()/(xSemiAxis*xSemiAxis),
539 p.y()/(ySemiAxis*ySemiAxis),
540 -( p.z() - zheight ));
541 if ( truenorm*v >= 0) // going outside the solid from surface
542 {
543 return kInfinity;
544 }
545 else
546 {
547 return 0;
548 }
549 }
550
551 // G4double lambda = std::fabs(plus) < std::fabs(minus) ? plus : minus;
552 G4double lambda = 0;
553
554 if ( minus > halfCarTol && minus < distMin )
555 {
556 lambda = minus ;
557 // check normal vector n * v < 0
558 G4ThreeVector pin = p + lambda*v;
559 if(std::fabs(pin.z())< zTopCut + halfCarTol)
560 {
561 G4ThreeVector truenorm(pin.x()/(xSemiAxis*xSemiAxis),
562 pin.y()/(ySemiAxis*ySemiAxis),
563 - ( pin.z() - zheight ));
564 if ( truenorm*v < 0)
565 { // yes, going inside the solid
566 distMin = lambda;
567 }
568 }
569 }
570 if ( plus > halfCarTol && plus < distMin )
571 {
572 lambda = plus ;
573 // check normal vector n * v < 0
574 G4ThreeVector pin = p + lambda*v;
575 if(std::fabs(pin.z()) < zTopCut + halfCarTol)
576 {
577 G4ThreeVector truenorm(pin.x()/(xSemiAxis*xSemiAxis),
578 pin.y()/(ySemiAxis*ySemiAxis),
579 - ( pin.z() - zheight ) );
580 if ( truenorm*v < 0)
581 { // yes, going inside the solid
582 distMin = lambda;
583 }
584 }
585 }
586 if (distMin < halfCarTol) distMin=0.;
587 return distMin ;
588}
G4double C(G4double temp)
G4double B(G4double temperature)
const G4double A[17]
T sqr(const T &x)
Definition: templates.hh:128

References A, B(), C(), halfCarTol, kInfinity, G4InuclParticleNames::lambda, sqr(), CLHEP::Hep3Vector::x(), xSemiAxis, CLHEP::Hep3Vector::y(), ySemiAxis, CLHEP::Hep3Vector::z(), zheight, and zTopCut.

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Definition at line 771 of file G4EllipticalCone.cc.

772{
773#ifdef G4SPECSDEBUG
774 if( Inside(p) == kOutside )
775 {
776 std::ostringstream message;
777 G4int oldprc = message.precision(16);
778 message << "Point p is outside (!?) of solid: " << GetName() << "\n"
779 << "Position:\n"
780 << " p.x() = " << p.x()/mm << " mm\n"
781 << " p.y() = " << p.y()/mm << " mm\n"
782 << " p.z() = " << p.z()/mm << " mm";
783 message.precision(oldprc) ;
784 G4Exception("G4Ellipsoid::DistanceToOut(p)", "GeomSolids1002",
785 JustWarning, message);
786 DumpInfo();
787 }
788#endif
789 G4double hp = std::sqrt(p.x()*p.x()*invXX + p.y()*p.y()*invYY) + p.z();
790 G4double ds = (zheight - hp)*cosAxisMin;
791 G4double dz = zTopCut - std::abs(p.z());
792 G4double dist = std::min(ds,dz);
793 return (dist > 0) ? dist : 0.;
794}
static constexpr double mm
Definition: G4SIunits.hh:95
EInside Inside(const G4ThreeVector &p) const
@ kOutside
Definition: geomdefs.hh:68
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References cosAxisMin, anonymous_namespace{G4QuasiElRatios.cc}::ds, G4VSolid::DumpInfo(), G4Exception(), G4VSolid::GetName(), Inside(), invXX, invYY, JustWarning, kOutside, G4INCL::Math::min(), mm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep3Vector::z(), zheight, and zTopCut.

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 609 of file G4EllipticalCone.cc.

614{
615 G4double distMin, lambda;
616 enum surface_e {kPlaneSurf, kCurvedSurf, kNoSurf} surface;
617
618 distMin = kInfinity;
619 surface = kNoSurf;
620
621 if (v.z() < 0.0)
622 {
623 lambda = (-p.z() - zTopCut)/v.z();
624
625 if ( (sqr((p.x() + lambda*v.x())/xSemiAxis) +
626 sqr((p.y() + lambda*v.y())/ySemiAxis)) <
628 {
629 distMin = std::fabs(lambda);
630
631 if (!calcNorm) { return distMin; }
632 }
633 distMin = std::fabs(lambda);
634 surface = kPlaneSurf;
635 }
636
637 if (v.z() > 0.0)
638 {
639 lambda = (zTopCut - p.z()) / v.z();
640
641 if ( (sqr((p.x() + lambda*v.x())/xSemiAxis)
642 + sqr((p.y() + lambda*v.y())/ySemiAxis) )
643 < (sqr(zheight - zTopCut + halfCarTol)) )
644 {
645 distMin = std::fabs(lambda);
646 if (!calcNorm) { return distMin; }
647 }
648 distMin = std::fabs(lambda);
649 surface = kPlaneSurf;
650 }
651
652 // if we are here then it either intersects or grazes the
653 // curved surface...
654 //
655 G4double A = sqr(v.x()/xSemiAxis) + sqr(v.y()/ySemiAxis) - sqr(v.z());
656 G4double B = 2.*(v.x()*p.x()/sqr(xSemiAxis) +
657 v.y()*p.y()/sqr(ySemiAxis) + v.z()*(zheight-p.z()));
658 G4double C = sqr(p.x()/xSemiAxis) + sqr(p.y()/ySemiAxis)
659 - sqr(zheight - p.z());
660
661 G4double discr = B*B - 4.*A*C;
662
663 if ( discr >= - halfCarTol && discr < halfCarTol )
664 {
665 if(!calcNorm) { return distMin = std::fabs(-B/(2.*A)); }
666 }
667
668 else if ( discr > halfCarTol )
669 {
670 G4double plus = (-B+std::sqrt(discr))/(2.*A);
671 G4double minus = (-B-std::sqrt(discr))/(2.*A);
672
673 if ( plus > halfCarTol && minus > halfCarTol )
674 {
675 // take the shorter distance
676 //
677 lambda = std::fabs(plus) < std::fabs(minus) ? plus : minus;
678 }
679 else
680 {
681 // at least one solution is close to zero or negative
682 // so, take small positive solution or zero
683 //
684 lambda = plus > -halfCarTol ? plus : 0;
685 }
686
687 if ( std::fabs(lambda) < distMin )
688 {
689 if( std::fabs(lambda) > halfCarTol)
690 {
691 distMin = std::fabs(lambda);
692 surface = kCurvedSurf;
693 }
694 else // Point is On the Surface, Check Normal
695 {
696 G4ThreeVector truenorm(p.x()/(xSemiAxis*xSemiAxis),
697 p.y()/(ySemiAxis*ySemiAxis),
698 -( p.z() - zheight ));
699 if( truenorm.dot(v) > 0 )
700 {
701 distMin = 0.0;
702 surface = kCurvedSurf;
703 }
704 }
705 }
706 }
707
708 // set normal if requested
709 //
710 if (calcNorm)
711 {
712 if (surface == kNoSurf)
713 {
714 *validNorm = false;
715 }
716 else
717 {
718 *validNorm = true;
719 switch (surface)
720 {
721 case kPlaneSurf:
722 {
723 *n = G4ThreeVector(0.,0.,(v.z() > 0.0 ? 1. : -1.));
724 }
725 break;
726
727 case kCurvedSurf:
728 {
729 G4ThreeVector pexit = p + distMin*v;
730 G4ThreeVector truenorm( pexit.x()/(xSemiAxis*xSemiAxis),
731 pexit.y()/(ySemiAxis*ySemiAxis),
732 -( pexit.z() - zheight ) );
733 truenorm /= truenorm.mag();
734 *n= truenorm;
735 }
736 break;
737
738 default: // Should never reach this case ...
739 DumpInfo();
740 std::ostringstream message;
741 G4int oldprc = message.precision(16);
742 message << "Undefined side for valid surface normal to solid."
743 << G4endl
744 << "Position:" << G4endl
745 << " p.x() = " << p.x()/mm << " mm" << G4endl
746 << " p.y() = " << p.y()/mm << " mm" << G4endl
747 << " p.z() = " << p.z()/mm << " mm" << G4endl
748 << "Direction:" << G4endl
749 << " v.x() = " << v.x() << G4endl
750 << " v.y() = " << v.y() << G4endl
751 << " v.z() = " << v.z() << G4endl
752 << "Proposed distance :" << G4endl
753 << " distMin = " << distMin/mm << " mm";
754 message.precision(oldprc);
755 G4Exception("G4EllipticalCone::DistanceToOut(p,v,..)",
756 "GeomSolids1002", JustWarning, message);
757 break;
758 }
759 }
760 }
761
762 if (distMin < halfCarTol) { distMin=0; }
763
764 return distMin;
765}

References A, B(), C(), CLHEP::Hep3Vector::dot(), G4VSolid::DumpInfo(), G4endl, G4Exception(), halfCarTol, JustWarning, kInfinity, G4InuclParticleNames::lambda, CLHEP::Hep3Vector::mag(), mm, CLHEP::detail::n, sqr(), CLHEP::Hep3Vector::x(), xSemiAxis, CLHEP::Hep3Vector::y(), ySemiAxis, CLHEP::Hep3Vector::z(), zheight, and zTopCut.

◆ 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(), BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), G4Hype::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(), 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(), 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

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
double dot(const Hep3Vector &) const
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

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 G4EllipticalCone::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 920 of file G4EllipticalCone.cc.

921{
922 if (fCubicVolume == 0.0)
923 {
924 G4double x0 = xSemiAxis*zheight; // x semi axis at z=0
925 G4double y0 = ySemiAxis*zheight; // y semi axis at z=0
926 G4double v0 = CLHEP::pi*x0*y0*zheight/3.;
927 G4double kmin = (zTopCut >= zheight ) ? 0. : (zheight - zTopCut)/zheight;
928 G4double kmax = (zTopCut >= zheight ) ? 2. : (zheight + zTopCut)/zheight;
929 fCubicVolume = (kmax - kmin)*(kmax*kmax + kmax*kmin + kmin*kmin)*v0;
930 }
931 return fCubicVolume;
932}
static constexpr double pi
Definition: SystemOfUnits.h:55

References fCubicVolume, CLHEP::pi, xSemiAxis, ySemiAxis, zheight, and zTopCut.

◆ 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 G4EllipticalCone::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 800 of file G4EllipticalCone.cc.

801{
802 return G4String("G4EllipticalCone");
803}

◆ GetExtent()

G4VisExtent G4EllipticalCone::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 962 of file G4EllipticalCone.cc.

963{
964 // Define the sides of the box into which the solid instance would fit.
965 //
966 G4ThreeVector pmin,pmax;
967 BoundingLimits(pmin,pmax);
968 return G4VisExtent(pmin.x(),pmax.x(),
969 pmin.y(),pmax.y(),
970 pmin.z(),pmax.z());
971}

References BoundingLimits(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ 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(), BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), G4Hype::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(), 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(), G4Hype::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(), StreamInfo(), G4EllipticalTube::StreamInfo(), G4ExtrudedSolid::StreamInfo(), G4GenericPolycone::StreamInfo(), G4GenericTrap::StreamInfo(), G4Hype::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(), 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().

◆ GetPointOnSurface()

G4ThreeVector G4EllipticalCone::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 841 of file G4EllipticalCone.cc.

842{
843 G4double x0 = xSemiAxis*zheight; // x semi axis at z=0
844 G4double y0 = ySemiAxis*zheight; // y semi axis at z=0
846 G4double kmin = (zTopCut >= zheight ) ? 0. : (zheight - zTopCut)/zheight;
847 G4double kmax = (zTopCut >= zheight ) ? 2. : (zheight + zTopCut)/zheight;
848
849 // Set areas (base at -Z, side surface, base at +Z)
850 //
851 G4double szmin = pi*x0*y0*kmax*kmax;
852 G4double szmax = pi*x0*y0*kmin*kmin;
853 G4double sside = s0*(kmax*kmax - kmin*kmin);
854 G4double ssurf[3] = { szmin, sside, szmax };
855 for (auto i=1; i<3; ++i) { ssurf[i] += ssurf[i-1]; }
856
857 // Select surface
858 //
859 G4double select = ssurf[2]*G4UniformRand();
860 G4int k = 2;
861 if (select <= ssurf[1]) k = 1;
862 if (select <= ssurf[0]) k = 0;
863
864 // Pick random point on selected surface
865 //
867 switch(k)
868 {
869 case 0: // base at -Z, uniform distribution, rejection sampling
870 {
871 G4double zh = zheight + zTopCut;
873 p.set(rho.x(),rho.y(),-zTopCut);
874 break;
875 }
876 case 1: // side surface, uniform distribution, rejection sampling
877 {
879 G4double a = x0;
880 G4double b = y0;
881
883 G4double aa = a*a;
884 G4double bb = b*b;
885 G4double R = std::max(a,b);
886 G4double mu_max = R*std::sqrt(hh + R*R);
887
888 G4double x,y;
889 for (auto i=0; i<1000; ++i)
890 {
892 x = std::cos(phi);
893 y = std::sin(phi);
894 G4double xx = x*x;
895 G4double yy = y*y;
896 G4double E = hh + aa*xx + bb*yy;
897 G4double F = (aa-bb)*x*y;
898 G4double G = aa*yy + bb*xx;
899 G4double mu = std::sqrt(E*G - F*F);
900 if (mu_max*G4UniformRand() <= mu) break;
901 }
902 p.set(zh*xSemiAxis*x,zh*ySemiAxis*y,zheight-zh);
903 break;
904 }
905 case 2: // base at +Z, uniform distribution, rejection sampling
906 {
907 G4double zh = zheight - zTopCut;
909 p.set(rho.x(),rho.y(),zTopCut);
910 break;
911 }
912 }
913 return p;
914}
G4double G4RandomRadiusInRing(G4double rmin, G4double rmax)
G4TwoVector G4RandomPointInEllipse(G4double a, G4double b)
static constexpr double pi
Definition: G4SIunits.hh:55
#define G4UniformRand()
Definition: Randomize.hh:52
double x() const
double y() const
void set(double x, double y, double z)
static G4double EllipticConeLateralArea(G4double a, G4double b, G4double h)
Definition: G4GeomTools.cc:546
static constexpr double twopi
Definition: SystemOfUnits.h:56

References G4GeomTools::EllipticConeLateralArea(), G4RandomPointInEllipse(), G4RandomRadiusInRing(), G4UniformRand, G4INCL::Math::max(), pi, G4InuclParticleNames::s0, CLHEP::Hep3Vector::set(), CLHEP::twopi, CLHEP::Hep2Vector::x(), xSemiAxis, CLHEP::Hep2Vector::y(), ySemiAxis, zheight, and zTopCut.

◆ GetPolyhedron()

G4Polyhedron * G4EllipticalCone::GetPolyhedron ( ) const
virtual

◆ GetSemiAxisMax()

G4double G4EllipticalCone::GetSemiAxisMax ( ) const
inline

Referenced by export_G4EllipticalCone().

◆ GetSemiAxisMin()

G4double G4EllipticalCone::GetSemiAxisMin ( ) const
inline

◆ GetSemiAxisX()

G4double G4EllipticalCone::GetSemiAxisX ( ) const
inline

◆ GetSemiAxisY()

G4double G4EllipticalCone::GetSemiAxisY ( ) const
inline

◆ GetSurfaceArea()

G4double G4EllipticalCone::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 938 of file G4EllipticalCone.cc.

939{
940 if (fSurfaceArea == 0.0)
941 {
942 G4double x0 = xSemiAxis*zheight; // x semi axis at z=0
943 G4double y0 = ySemiAxis*zheight; // y semi axis at z=0
945 G4double kmin = (zTopCut >= zheight ) ? 0. : (zheight - zTopCut)/zheight;
946 G4double kmax = (zTopCut >= zheight ) ? 2. : (zheight + zTopCut)/zheight;
947 fSurfaceArea = (kmax - kmin)*(kmax + kmin)*s0
948 + CLHEP::pi*x0*y0*(kmin*kmin + kmax*kmax);
949 }
950 return fSurfaceArea;
951}

References G4GeomTools::EllipticConeLateralArea(), fSurfaceArea, CLHEP::pi, G4InuclParticleNames::s0, xSemiAxis, ySemiAxis, zheight, and zTopCut.

◆ GetTolerance()

G4double G4VSolid::GetTolerance ( ) const
inlineinherited

◆ GetZMax()

G4double G4EllipticalCone::GetZMax ( ) const
inline

◆ GetZTopCut()

G4double G4EllipticalCone::GetZTopCut ( ) const
inline

◆ Inside()

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

Implements G4VSolid.

Definition at line 262 of file G4EllipticalCone.cc.

263{
264 G4double hp = std::sqrt(p.x()*p.x()*invXX + p.y()*p.y()*invYY) + p.z();
265 G4double ds = (hp - zheight)*cosAxisMin;
266 G4double dz = std::abs(p.z()) - zTopCut;
267 G4double dist = std::max(ds,dz);
268
269 if (dist > halfCarTol) return kOutside;
270 return (dist > -halfCarTol) ? kSurface : kInside;
271}
@ kSurface
Definition: geomdefs.hh:69

References cosAxisMin, anonymous_namespace{G4QuasiElRatios.cc}::ds, halfCarTol, invXX, invYY, kInside, kOutside, kSurface, G4INCL::Math::max(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep3Vector::z(), zheight, and zTopCut.

Referenced by DistanceToOut().

◆ operator=()

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

Definition at line 144 of file G4EllipticalCone.cc.

145{
146 // Check assignment to self
147 //
148 if (this == &rhs) { return *this; }
149
150 // Copy base class data
151 //
153
154 // Copy data
155 //
159 zheight = rhs.zheight; zTopCut = rhs.zTopCut;
160 cosAxisMin = rhs.cosAxisMin; invXX = rhs.invXX; invYY = rhs.invYY;
161
162 fRebuildPolyhedron = false;
163 delete fpPolyhedron; fpPolyhedron = nullptr;
164
165 return *this;
166}
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:107

References cosAxisMin, fCubicVolume, fpPolyhedron, fRebuildPolyhedron, fSurfaceArea, halfCarTol, invXX, invYY, G4VSolid::operator=(), xSemiAxis, ySemiAxis, zheight, and zTopCut.

◆ operator==()

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

◆ 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().

◆ SetSemiAxis()

void G4EllipticalCone::SetSemiAxis ( G4double  x,
G4double  y,
G4double  z 
)
inline

◆ SetZCut()

void G4EllipticalCone::SetZCut ( G4double  newzTopCut)
inline

◆ StreamInfo()

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

Implements G4VSolid.

Definition at line 818 of file G4EllipticalCone.cc.

819{
820 G4int oldprc = os.precision(16);
821 os << "-----------------------------------------------------------\n"
822 << " *** Dump for solid - " << GetName() << " ***\n"
823 << " ===================================================\n"
824 << " Solid type: G4EllipticalCone\n"
825 << " Parameters: \n"
826
827 << " semi-axis x: " << xSemiAxis/mm << " mm \n"
828 << " semi-axis y: " << ySemiAxis/mm << " mm \n"
829 << " height z: " << zheight/mm << " mm \n"
830 << " half length in z: " << zTopCut/mm << " mm \n"
831 << "-----------------------------------------------------------\n";
832 os.precision(oldprc);
833
834 return os;
835}

References G4VSolid::GetName(), mm, xSemiAxis, ySemiAxis, zheight, and zTopCut.

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 277 of file G4EllipticalCone.cc.

278{
279 G4ThreeVector norm(0,0,0);
280 G4int nsurf = 0; // number of surfaces where p is placed
281
282 G4double hp = std::sqrt(p.x()*p.x()*invXX + p.y()*p.y()*invYY) + p.z();
283 G4double ds = (hp - zheight)*cosAxisMin;
284 if (std::abs(ds) <= halfCarTol)
285 {
286 norm = G4ThreeVector(p.x()*invXX, p.y()*invYY, hp - p.z());
287 G4double mag = norm.mag();
288 if (mag == 0) return G4ThreeVector(0,0,1); // apex
289 norm *= (1/mag);
290 ++nsurf;
291 }
292 G4double dz = std::abs(p.z()) - zTopCut;
293 if (std::abs(dz) <= halfCarTol)
294 {
295 norm += G4ThreeVector(0., 0.,(p.z() < 0) ? -1. : 1.);
296 ++nsurf;
297 }
298
299 if (nsurf == 1) return norm;
300 else if (nsurf > 1) return norm.unit(); // elliptic edge
301 else
302 {
303 // Point is not on the surface
304 //
305#ifdef G4CSGDEBUG
306 std::ostringstream message;
307 G4int oldprc = message.precision(16);
308 message << "Point p is not on surface (!?) of solid: "
309 << GetName() << G4endl;
310 message << "Position:\n";
311 message << " p.x() = " << p.x()/mm << " mm\n";
312 message << " p.y() = " << p.y()/mm << " mm\n";
313 message << " p.z() = " << p.z()/mm << " mm";
314 G4cout.precision(oldprc);
315 G4Exception("G4EllipticalCone::SurfaceNormal(p)", "GeomSolids1002",
316 JustWarning, message );
317 DumpInfo();
318#endif
319 return ApproxSurfaceNormal(p);
320 }
321}
G4GLOB_DLL std::ostream G4cout
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const

References ApproxSurfaceNormal(), cosAxisMin, anonymous_namespace{G4QuasiElRatios.cc}::ds, G4VSolid::DumpInfo(), G4cout, G4endl, G4Exception(), G4VSolid::GetName(), halfCarTol, invXX, invYY, JustWarning, CLHEP::Hep3Vector::mag(), mm, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep3Vector::z(), zheight, and zTopCut.

Field Documentation

◆ cosAxisMin

G4double G4EllipticalCone::cosAxisMin
private

◆ fCubicVolume

G4double G4EllipticalCone::fCubicVolume = 0.0
private

Definition at line 179 of file G4EllipticalCone.hh.

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

◆ fpPolyhedron

G4Polyhedron* G4EllipticalCone::fpPolyhedron = nullptr
mutableprotected

Definition at line 168 of file G4EllipticalCone.hh.

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

◆ fRebuildPolyhedron

G4bool G4EllipticalCone::fRebuildPolyhedron = false
mutableprotected

Definition at line 167 of file G4EllipticalCone.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 G4EllipticalCone::fSurfaceArea = 0.0
private

Definition at line 180 of file G4EllipticalCone.hh.

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

◆ halfCarTol

G4double G4EllipticalCone::halfCarTol
private

◆ invXX

G4double G4EllipticalCone::invXX
private

◆ invYY

G4double G4EllipticalCone::invYY
private

◆ 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(), G4Hype::DistanceToIn(), G4Paraboloid::DistanceToIn(), G4VCSGfaceted::DistanceToIn(), G4TessellatedSolid::DistanceToInCore(), G4Cons::DistanceToOut(), G4CutTubs::DistanceToOut(), G4Sphere::DistanceToOut(), G4Torus::DistanceToOut(), G4Tubs::DistanceToOut(), G4GenericTrap::DistanceToOut(), G4Hype::DistanceToOut(), G4Paraboloid::DistanceToOut(), G4VCSGfaceted::DistanceToOut(), G4TessellatedSolid::DistanceToOutCandidates(), G4TessellatedSolid::DistanceToOutCore(), G4TessellatedSolid::DistanceToOutNoVoxels(), G4GenericTrap::DistToPlane(), G4GenericTrap::DistToTriangle(), G4Box::G4Box(), G4Cons::G4Cons(), G4CutTubs::G4CutTubs(), G4EllipticalCone(), G4ExtrudedSolid::G4ExtrudedSolid(), G4GenericTrap::G4GenericTrap(), G4Hype::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(), G4Hype::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().

◆ xSemiAxis

G4double G4EllipticalCone::xSemiAxis
private

◆ ySemiAxis

G4double G4EllipticalCone::ySemiAxis
private

◆ zheight

G4double G4EllipticalCone::zheight
private

◆ zTopCut

G4double G4EllipticalCone::zTopCut
private

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