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

G4GenericPolycone is a Polycone shape where the composing Z planes positions, in their order of definition, may not be monotically increasing, i.e. may also decrease. More...

#include <G4GenericPolycone.hh>

Inheritance diagram for G4GenericPolycone:

Public Member Functions

 G4GenericPolycone (const G4String &name, G4double phiStart, G4double phiTotal, G4int numRZ, const G4double r[], const G4double z[])
 ~G4GenericPolycone () override
G4double GetStartPhi () const
G4double GetEndPhi () const
G4double GetSinStartPhi () const
G4double GetCosStartPhi () const
G4double GetSinEndPhi () const
G4double GetCosEndPhi () const
G4bool IsOpen () const
G4int GetNumRZCorner () const
G4PolyconeSideRZ GetCorner (G4int index) const
EInside Inside (const G4ThreeVector &p) const override
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double DistanceToIn (const G4ThreeVector &p) const override
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
G4double GetCubicVolume () override
G4double GetSurfaceArea () override
G4ThreeVector GetPointOnSurface () const override
G4GeometryType GetEntityType () const override
G4VSolidClone () const override
std::ostream & StreamInfo (std::ostream &os) const override
G4PolyhedronCreatePolyhedron () const override
G4bool Reset ()
 G4GenericPolycone (__void__ &)
 G4GenericPolycone (const G4GenericPolycone &source)
G4GenericPolyconeoperator= (const G4GenericPolycone &source)
Public Member Functions inherited from G4VCSGfaceted
 G4VCSGfaceted (const G4String &name)
 ~G4VCSGfaceted () override
 G4VCSGfaceted (const G4VCSGfaceted &source)
G4VCSGfacetedoperator= (const G4VCSGfaceted &source)
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
EInside Inside (const G4ThreeVector &p) const override
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const override
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double DistanceToIn (const G4ThreeVector &p) const override
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double DistanceToOut (const G4ThreeVector &p) const override
G4GeometryType GetEntityType () const override
std::ostream & StreamInfo (std::ostream &os) const override
void DescribeYourselfTo (G4VGraphicsScene &scene) const override
G4VisExtent GetExtent () const override
G4PolyhedronGetPolyhedron () const override
G4int GetCubVolStatistics () const
G4double GetCubVolEpsilon () const
void SetCubVolStatistics (G4int st)
void SetCubVolEpsilon (G4double ep)
G4int GetAreaStatistics () const
G4double GetAreaAccuracy () const
void SetAreaStatistics (G4int st)
void SetAreaAccuracy (G4double ep)
G4double GetCubicVolume () override
G4double GetSurfaceArea () override
 G4VCSGfaceted (__void__ &)
Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
virtual ~G4VSolid ()
 G4VSolid (const G4VSolid &rhs)
G4VSolidoperator= (const G4VSolid &rhs)
G4bool operator== (const G4VSolid &s) const
G4String GetName () const
void SetName (const G4String &name)
G4double GetTolerance () const
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
virtual G4int GetNumOfConstituents () const
virtual G4bool IsFaceted () const
void DumpInfo () const
virtual const G4VSolidGetConstituentSolid (G4int no) const
virtual G4VSolidGetConstituentSolid (G4int no)
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 G4VSolid (__void__ &)
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
G4double EstimateSurfaceArea (G4int nStat, G4double epsilon) const

Additional Inherited Members

Protected Member Functions inherited from G4VCSGfaceted
virtual G4double DistanceTo (const G4ThreeVector &p, const G4bool outgoing) const
G4ThreeVector GetPointOnSurfaceGeneric () const
void CopyStuff (const G4VCSGfaceted &source)
void DeleteStuff ()
Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
Protected Attributes inherited from G4VCSGfaceted
G4int numFace = 0
G4VCSGface ** faces = nullptr
G4double fCubicVolume = 0.0
G4double fSurfaceArea = 0.0
G4bool fRebuildPolyhedron = false
G4PolyhedronfpPolyhedron = nullptr
Protected Attributes inherited from G4VSolid
G4double kCarTolerance

Detailed Description

G4GenericPolycone is a Polycone shape where the composing Z planes positions, in their order of definition, may not be monotically increasing, i.e. may also decrease.

Definition at line 69 of file G4GenericPolycone.hh.

Constructor & Destructor Documentation

◆ G4GenericPolycone() [1/3]

G4GenericPolycone::G4GenericPolycone ( const G4String & name,
G4double phiStart,
G4double phiTotal,
G4int numRZ,
const G4double r[],
const G4double z[] )

Constructs a generic polycone shape, given its parameters.

Parameters
[in]nameThe solid name.
[in]phiStartThe initial Phi starting angle.
[in]phiTotalThe total Phi angle.
[in]numRZNumber of corners in r,Z space.
[in]rVector of r coordinate of corners.
[in]zVector of Z coordinate of corners.

Definition at line 60 of file G4GenericPolycone.cc.

66 : G4VCSGfaceted( name )
67{
68
69 auto rz = new G4ReduciblePolygon( r, z, numRZ );
70
71 Create( phiStart, phiTotal, rz );
72
73 // Set original_parameters struct for consistency
74 //
75 //SetOriginalParameters(rz);
76
77 delete rz;
78}
G4VCSGfaceted(const G4String &name)

Referenced by Clone(), G4GenericPolycone(), GetCorner(), and operator=().

◆ ~G4GenericPolycone()

G4GenericPolycone::~G4GenericPolycone ( )
override

Destructor.

Definition at line 263 of file G4GenericPolycone.cc.

264{
265 delete [] corners;
266 delete enclosingCylinder;
267 delete fElements;
268 delete fpPolyhedron;
269 corners = nullptr;
270 enclosingCylinder = nullptr;
271 fElements = nullptr;
272 fpPolyhedron = nullptr;
273}
G4Polyhedron * fpPolyhedron

◆ G4GenericPolycone() [2/3]

G4GenericPolycone::G4GenericPolycone ( __void__ & a)

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

Definition at line 256 of file G4GenericPolycone.cc.

257 : G4VCSGfaceted(a), startPhi(0.), endPhi(0.), numCorner(0)
258{
259}

◆ G4GenericPolycone() [3/3]

G4GenericPolycone::G4GenericPolycone ( const G4GenericPolycone & source)

Copy constructor and assignment operator.

Definition at line 277 of file G4GenericPolycone.cc.

278 : G4VCSGfaceted( source )
279{
280 CopyStuff( source );
281}

Member Function Documentation

◆ BoundingLimits()

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

Computes the bounding limits of the solid.

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

Reimplemented from G4VSolid.

Definition at line 406 of file G4GenericPolycone.cc.

408{
409 G4double rmin = kInfinity, rmax = -kInfinity;
410 G4double zmin = kInfinity, zmax = -kInfinity;
411
412 for (G4int i=0; i<GetNumRZCorner(); ++i)
413 {
414 G4PolyconeSideRZ corner = GetCorner(i);
415 if (corner.r < rmin) { rmin = corner.r; }
416 if (corner.r > rmax) { rmax = corner.r; }
417 if (corner.z < zmin) { zmin = corner.z; }
418 if (corner.z > zmax) { zmax = corner.z; }
419 }
420
421 if (IsOpen())
422 {
423 G4TwoVector vmin,vmax;
424 G4GeomTools::DiskExtent(rmin,rmax,
427 vmin,vmax);
428 pMin.set(vmin.x(),vmin.y(),zmin);
429 pMax.set(vmax.x(),vmax.y(),zmax);
430 }
431 else
432 {
433 pMin.set(-rmax,-rmax, zmin);
434 pMax.set( rmax, rmax, zmax);
435 }
436
437 // Check correctness of the bounding box
438 //
439 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
440 {
441 std::ostringstream message;
442 message << "Bad bounding box (min >= max) for solid: "
443 << GetName() << " !"
444 << "\npMin = " << pMin
445 << "\npMax = " << pMax;
446 G4Exception("GenericG4Polycone::BoundingLimits()", "GeomMgt0001",
447 JustWarning, message);
448 DumpInfo();
449 }
450}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep2Vector G4TwoVector
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
double x() const
double y() const
double z() const
double x() const
double y() const
void set(double x, double y, double z)
G4bool IsOpen() const
G4int GetNumRZCorner() const
G4double GetCosEndPhi() const
G4double GetSinStartPhi() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4double GetSinEndPhi() const
G4double GetCosStartPhi() const
static G4bool DiskExtent(G4double rmin, G4double rmax, G4double startPhi, G4double delPhi, G4TwoVector &pmin, G4TwoVector &pmax)
G4String GetName() const
void DumpInfo() const

Referenced by CalculateExtent().

◆ CalculateExtent()

G4bool G4GenericPolycone::CalculateExtent ( const EAxis pAxis,
const G4VoxelLimits & pVoxelLimit,
const G4AffineTransform & pTransform,
G4double & pMin,
G4double & pMax ) const
overridevirtual

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

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

Implements G4VSolid.

Definition at line 457 of file G4GenericPolycone.cc.

461{
462 G4ThreeVector bmin, bmax;
463 G4bool exist;
464
465 // Check bounding box (bbox)
466 //
467 BoundingLimits(bmin,bmax);
468 G4BoundingEnvelope bbox(bmin,bmax);
469#ifdef G4BBOX_EXTENT
470 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
471#endif
472 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
473 {
474 return exist = pMin < pMax;
475 }
476
477 // To find the extent, RZ contour of the polycone is subdivided
478 // in triangles. The extent is calculated as cumulative extent of
479 // all sub-polycones formed by rotation of triangles around Z
480 //
481 G4TwoVectorList contourRZ;
482 G4TwoVectorList triangles;
483 G4double eminlim = pVoxelLimit.GetMinExtent(pAxis);
484 G4double emaxlim = pVoxelLimit.GetMaxExtent(pAxis);
485
486 // get RZ contour, ensure anticlockwise order of corners
487 for (G4int i=0; i<GetNumRZCorner(); ++i)
488 {
489 G4PolyconeSideRZ corner = GetCorner(i);
490 contourRZ.emplace_back(corner.r,corner.z);
491 }
492 G4double area = G4GeomTools::PolygonArea(contourRZ);
493 if (area < 0.) { std::reverse(contourRZ.begin(),contourRZ.end()); }
494
495 // triangulate RZ countour
496 if (!G4GeomTools::TriangulatePolygon(contourRZ,triangles))
497 {
498 std::ostringstream message;
499 message << "Triangulation of RZ contour has failed for solid: "
500 << GetName() << " !"
501 << "\nExtent has been calculated using boundary box";
502 G4Exception("G4GenericPolycone::CalculateExtent()",
503 "GeomMgt1002", JustWarning, message);
504 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
505 }
506
507 // set trigonometric values
508 const G4int NSTEPS = 24; // number of steps for whole circle
509 G4double astep = twopi/NSTEPS; // max angle for one step
510
511 G4double sphi = GetStartPhi();
512 G4double ephi = GetEndPhi();
513 G4double dphi = IsOpen() ? ephi-sphi : twopi;
514 G4int ksteps = (dphi <= astep) ? 1 : (G4int)((dphi-deg)/astep) + 1;
515 G4double ang = dphi/ksteps;
516
517 G4double sinHalf = std::sin(0.5*ang);
518 G4double cosHalf = std::cos(0.5*ang);
519 G4double sinStep = 2.*sinHalf*cosHalf;
520 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
521
522 G4double sinStart = GetSinStartPhi();
523 G4double cosStart = GetCosStartPhi();
524 G4double sinEnd = GetSinEndPhi();
525 G4double cosEnd = GetCosEndPhi();
526
527 // define vectors and arrays
528 std::vector<const G4ThreeVectorList *> polygons;
529 polygons.resize(ksteps+2);
530 G4ThreeVectorList pols[NSTEPS+2];
531 for (G4int k=0; k<ksteps+2; ++k)
532 {
533 pols[k].resize(6);
534 }
535 for (G4int k=0; k<ksteps+2; ++k)
536 {
537 polygons[k] = &pols[k];
538 }
539 G4double r0[6],z0[6]; // contour with original edges of triangle
540 G4double r1[6]; // shifted radii of external edges of triangle
541
542 // main loop along triangles
543 pMin = kInfinity;
544 pMax =-kInfinity;
545 G4int ntria = (G4int)triangles.size()/3;
546 for (G4int i=0; i<ntria; ++i)
547 {
548 G4int i3 = i*3;
549 for (G4int k=0; k<3; ++k)
550 {
551 G4int e0 = i3+k, e1 = (k<2) ? e0+1 : i3;
552 G4int k2 = k*2;
553 // set contour with original edges of triangle
554 r0[k2+0] = triangles[e0].x(); z0[k2+0] = triangles[e0].y();
555 r0[k2+1] = triangles[e1].x(); z0[k2+1] = triangles[e1].y();
556 // set shifted radii
557 r1[k2+0] = r0[k2+0];
558 r1[k2+1] = r0[k2+1];
559 if (z0[k2+1] - z0[k2+0] <= 0) { continue; }
560 r1[k2+0] /= cosHalf;
561 r1[k2+1] /= cosHalf;
562 }
563
564 // rotate countour, set sequence of 6-sided polygons
565 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
566 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
567 for (G4int j=0; j<6; ++j)
568 {
569 pols[0][j].set(r0[j]*cosStart,r0[j]*sinStart,z0[j]);
570 }
571 for (G4int k=1; k<ksteps+1; ++k)
572 {
573 for (G4int j=0; j<6; ++j)
574 {
575 pols[k][j].set(r1[j]*cosCur,r1[j]*sinCur,z0[j]);
576 }
577 G4double sinTmp = sinCur;
578 sinCur = sinCur*cosStep + cosCur*sinStep;
579 cosCur = cosCur*cosStep - sinTmp*sinStep;
580 }
581 for (G4int j=0; j<6; ++j)
582 {
583 pols[ksteps+1][j].set(r0[j]*cosEnd,r0[j]*sinEnd,z0[j]);
584 }
585
586 // set sub-envelope and adjust extent
587 G4double emin,emax;
588 G4BoundingEnvelope benv(polygons);
589 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
590 {
591 continue;
592 }
593 if (emin < pMin) { pMin = emin; }
594 if (emax > pMax) { pMax = emax; }
595 if (eminlim > pMin && emaxlim < pMax) { return true; } // max possible extent
596 }
597 return (pMin < pMax);
598}
std::vector< G4ThreeVector > G4ThreeVectorList
std::vector< G4TwoVector > G4TwoVectorList
CLHEP::Hep3Vector G4ThreeVector
bool G4bool
Definition G4Types.hh:86
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4double GetStartPhi() const
G4double GetEndPhi() const
static G4double PolygonArea(const G4TwoVectorList &polygon)
static G4bool TriangulatePolygon(const G4TwoVectorList &polygon, std::vector< G4int > &result)
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const

◆ Clone()

G4VSolid * G4GenericPolycone::Clone ( ) const
overridevirtual

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

Returns
A pointer to the new cloned allocated solid.

Reimplemented from G4VSolid.

Definition at line 611 of file G4GenericPolycone.cc.

612{
613 return new G4GenericPolycone(*this);
614}
G4GenericPolycone(const G4String &name, G4double phiStart, G4double phiTotal, G4int numRZ, const G4double r[], const G4double z[])

◆ CreatePolyhedron()

G4Polyhedron * G4GenericPolycone::CreatePolyhedron ( ) const
overridevirtual

Returns a pointer to a polyhedron for use in visualisation.

Implements G4VCSGfaceted.

Definition at line 842 of file G4GenericPolycone.cc.

843{
844 std::vector<G4TwoVector> rz(numCorner);
845 for (G4int i = 0; i < numCorner; ++i)
846 {
847 rz[i].set(corners[i].r, corners[i].z);
848 }
849 return new G4PolyhedronPcon(startPhi, endPhi - startPhi, rz);
850}

◆ DistanceToIn() [1/2]

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

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

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

Implements G4VSolid.

Definition at line 396 of file G4GenericPolycone.cc.

397{
399}
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override

◆ DistanceToIn() [2/2]

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

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

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

Implements G4VSolid.

Definition at line 380 of file G4GenericPolycone.cc.

382{
383 //
384 // Quick test
385 //
386 if (enclosingCylinder->ShouldMiss(p,v)) { return kInfinity; }
387
388 //
389 // Long answer
390 //
391 return G4VCSGfaceted::DistanceToIn( p, v );
392}

◆ GetCorner()

◆ GetCosEndPhi()

G4double G4GenericPolycone::GetCosEndPhi ( ) const
inline

Referenced by BoundingLimits(), and CalculateExtent().

◆ GetCosStartPhi()

G4double G4GenericPolycone::GetCosStartPhi ( ) const
inline

Referenced by BoundingLimits(), and CalculateExtent().

◆ GetCubicVolume()

G4double G4GenericPolycone::GetCubicVolume ( )
overridevirtual

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

Reimplemented from G4VSolid.

Definition at line 649 of file G4GenericPolycone.cc.

650{
651 if (fCubicVolume == 0)
652 {
653 G4AutoLock l(&genpolyMutex);
654 G4double total = 0.;
655 G4int nrz = GetNumRZCorner();
656 G4PolyconeSideRZ a = GetCorner(nrz - 1);
657 for (G4int i=0; i<nrz; ++i)
658 {
659 G4PolyconeSideRZ b = GetCorner(i);
660 total += (b.r*b.r + b.r*a.r + a.r*a.r)*(b.z - a.z);
661 a = b;
662 }
663 fCubicVolume = std::abs(total)*(GetEndPhi() - GetStartPhi())/6.;
664 l.unlock();
665 }
666 return fCubicVolume;
667}
G4TemplateAutoLock< G4Mutex > G4AutoLock
G4double fCubicVolume
G4double total(Particle const *const p1, Particle const *const p2)

◆ GetEndPhi()

◆ GetEntityType()

G4GeometryType G4GenericPolycone::GetEntityType ( ) const
overridevirtual

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

Implements G4VSolid.

Definition at line 602 of file G4GenericPolycone.cc.

603{
604 return {"G4GenericPolycone"};
605}

◆ GetNumRZCorner()

◆ GetPointOnSurface()

G4ThreeVector G4GenericPolycone::GetPointOnSurface ( ) const
overridevirtual

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

Reimplemented from G4VSolid.

Definition at line 777 of file G4GenericPolycone.cc.

778{
779 // Set surface elements
780 if (fElements == nullptr)
781 {
782 G4AutoLock l(&surface_elementsMutex);
783 SetSurfaceElements();
784 l.unlock();
785 }
786
787 // Select surface element
788 G4GenericPolycone::surface_element selem;
789 selem = fElements->back();
790 G4double select = selem.area*G4QuickRand();
791 auto it = std::lower_bound(fElements->begin(), fElements->end(), select,
792 [](const G4GenericPolycone::surface_element& x, G4double val)
793 -> G4bool { return x.area < val; });
794
795 // Generate random point
796 G4double r = 0, z = 0, phi = 0;
797 G4double u = G4QuickRand();
798 G4double v = G4QuickRand();
799 G4int i0 = (*it).i0;
800 G4int i1 = (*it).i1;
801 G4int i2 = (*it).i2;
802 if (i2 < 0) // lateral surface
803 {
804 G4PolyconeSideRZ p0 = GetCorner(i0);
805 G4PolyconeSideRZ p1 = GetCorner(i1);
806 if (p1.r < p0.r)
807 {
808 p0 = GetCorner(i1);
809 p1 = GetCorner(i0);
810 }
811 if (p1.r - p0.r < kCarTolerance) // cylindrical surface
812 {
813 r = (p1.r - p0.r)*u + p0.r;
814 z = (p1.z - p0.z)*u + p0.z;
815 }
816 else // conical surface
817 {
818 r = std::sqrt(p1.r*p1.r*u + p0.r*p0.r*(1. - u));
819 z = p0.z + (p1.z - p0.z)*(r - p0.r)/(p1.r - p0.r);
820 }
821 phi = (GetEndPhi() - GetStartPhi())*v + GetStartPhi();
822 }
823 else // phi cut
824 {
825 G4int nrz = GetNumRZCorner();
826 phi = (i0 < nrz) ? GetStartPhi() : GetEndPhi();
827 if (i0 >= nrz) { i0 -= nrz; }
828 G4PolyconeSideRZ p0 = GetCorner(i0);
829 G4PolyconeSideRZ p1 = GetCorner(i1);
830 G4PolyconeSideRZ p2 = GetCorner(i2);
831 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
832 r = (p1.r - p0.r)*u + (p2.r - p0.r)*v + p0.r;
833 z = (p1.z - p0.z)*u + (p2.z - p0.z)*v + p0.z;
834 }
835 return {r*std::cos(phi), r*std::sin(phi), z};
836}
G4double G4QuickRand(uint32_t seed=0)
G4double kCarTolerance
Definition G4VSolid.hh:418

◆ GetSinEndPhi()

G4double G4GenericPolycone::GetSinEndPhi ( ) const
inline

Referenced by BoundingLimits(), and CalculateExtent().

◆ GetSinStartPhi()

G4double G4GenericPolycone::GetSinStartPhi ( ) const
inline

Referenced by BoundingLimits(), and CalculateExtent().

◆ GetStartPhi()

◆ GetSurfaceArea()

G4double G4GenericPolycone::GetSurfaceArea ( )
overridevirtual

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

Reimplemented from G4VSolid.

Definition at line 673 of file G4GenericPolycone.cc.

674{
675 if (fSurfaceArea == 0)
676 {
677 G4AutoLock l(&genpolyMutex);
678 // phi cut area
679 G4int nrz = GetNumRZCorner();
680 G4double scut = 0.;
681 if (IsOpen())
682 {
683 G4PolyconeSideRZ a = GetCorner(nrz - 1);
684 for (G4int i=0; i<nrz; ++i)
685 {
686 G4PolyconeSideRZ b = GetCorner(i);
687 scut += a.r*b.z - a.z*b.r;
688 a = b;
689 }
690 scut = std::abs(scut);
691 }
692 // lateral surface area
693 G4double slat = 0;
694 G4PolyconeSideRZ a = GetCorner(nrz - 1);
695 for (G4int i=0; i<nrz; ++i)
696 {
697 G4PolyconeSideRZ b = GetCorner(i);
698 G4double h = std::sqrt((b.r - a.r)*(b.r - a.r) + (b.z - a.z)*(b.z - a.z));
699 slat += (b.r + a.r)*h;
700 a = b;
701 }
702 slat *= (GetEndPhi() - GetStartPhi())/2.;
703 fSurfaceArea = scut + slat;
704 l.unlock();
705 }
706 return fSurfaceArea;
707}
G4double fSurfaceArea

◆ Inside()

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

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

Implements G4VSolid.

Definition at line 361 of file G4GenericPolycone.cc.

362{
363 //
364 // Quick test
365 //
366 if (enclosingCylinder->MustBeOutside(p)) { return kOutside;
367}
368
369 //
370 // Long answer
371 //
372 return G4VCSGfaceted::Inside(p);
373}
EInside Inside(const G4ThreeVector &p) const override
@ kOutside
Definition geomdefs.hh:68

◆ IsOpen()

G4bool G4GenericPolycone::IsOpen ( ) const
inline

◆ operator=()

G4GenericPolycone & G4GenericPolycone::operator= ( const G4GenericPolycone & source)

Definition at line 286 of file G4GenericPolycone.cc.

287{
288 if (this == &source) { return *this; }
289
290 G4VCSGfaceted::operator=( source );
291
292 delete [] corners;
293 // if (original_parameters) delete original_parameters;
294
295 delete enclosingCylinder;
296
297 CopyStuff( source );
298
299 return *this;
300}
G4VCSGfaceted & operator=(const G4VCSGfaceted &source)

◆ Reset()

G4bool G4GenericPolycone::Reset ( )

Does nothing. Reset of parameters (for use in divisions) is not allowed for a generic polycone. Issues a warning and just returns true.

Definition at line 346 of file G4GenericPolycone.cc.

347{
348 std::ostringstream message;
349 message << "Solid " << GetName() << " built using generic construct."
350 << G4endl << "Not applicable to the generic construct !";
351 G4Exception("G4GenericPolycone::Reset()", "GeomSolids1001",
352 JustWarning, message, "Parameters NOT resetted.");
353 return true;
354}
#define G4endl
Definition G4ios.hh:67

◆ StreamInfo()

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

Streams the object contents to an output stream.

Implements G4VSolid.

Definition at line 620 of file G4GenericPolycone.cc.

621{
622 G4long oldprc = os.precision(16);
623 os << "-----------------------------------------------------------\n"
624 << " *** Dump for solid - " << GetName() << " ***\n"
625 << " ===================================================\n"
626 << " Solid type: G4GenericPolycone\n"
627 << " Parameters: \n"
628 << " starting phi angle : " << startPhi/degree << " degrees \n"
629 << " ending phi angle : " << endPhi/degree << " degrees \n";
630 G4int i=0;
631
632 os << " number of RZ points: " << numCorner << "\n"
633 << " RZ values (corners): \n";
634 for (i=0; i<numCorner; ++i)
635 {
636 os << " "
637 << corners[i].r << ", " << corners[i].z << "\n";
638 }
639 os << "-----------------------------------------------------------\n";
640 os.precision(oldprc);
641
642 return os;
643}
long G4long
Definition G4Types.hh:87

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