102 if (
this == &rhs) {
return *
this; }
107 fshapeName = rhs.fshapeName;
129 std::ostringstream message;
130 message <<
"Illegal call to G4VSolid::ComputeDimensions()" <<
G4endl
131 <<
"Method not overloaded by derived class !";
132 G4Exception(
"G4VSolid::ComputeDimensions()",
"GeomMgt0003",
142 std::ostringstream message;
143 message <<
"Not implemented for solid: "
145 <<
"Returning origin.";
146 G4Exception(
"G4VSolid::GetPointOnSurface()",
"GeomMgt1001",
178 G4int cubVolStatistics = 1000000;
194 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,volume,halfepsilon;
211 if(nStat < 100) nStat = 100;
215 for(
auto i = 0; i < nStat; ++i )
225 * (maxZ-minZ+
epsilon)*iInside/nStat;
240 G4int stat = 1000000;
255 static const G4double s2 = 1./std::sqrt(2.);
256 static const G4double s3 = 1./std::sqrt(3.);
309 G4int npoints = (nstat < 1000) ? 1000 : nstat;
311 G4double eps = (ell > 0) ? ell : coeff * std::min(std::min(dX, dY), dZ);
326 for(
auto i = 0; i < npoints; ++i)
344 if (icase == 0)
continue;
360 if (icase == 0)
continue;
363 if (dist == kInfinity)
continue;
367 if (dist < eps) ++icount;
369 return dX*dY*dZ*icount/npoints/dd;
381 std::ostringstream message;
382 message <<
"Clone() method not implemented for type: "
384 <<
"Returning NULL pointer!";
403 const G4int pSectionIndex,
411 polygon.push_back((*pVertices)[pSectionIndex]);
412 polygon.push_back((*pVertices)[pSectionIndex+1]);
413 polygon.push_back((*pVertices)[pSectionIndex+2]);
414 polygon.push_back((*pVertices)[pSectionIndex+3]);
433 const G4int pSectionIndex,
440 polygon.push_back((*pVertices)[pSectionIndex]);
441 polygon.push_back((*pVertices)[pSectionIndex+4]);
442 polygon.push_back((*pVertices)[pSectionIndex+5]);
443 polygon.push_back((*pVertices)[pSectionIndex+1]);
447 polygon.push_back((*pVertices)[pSectionIndex+1]);
448 polygon.push_back((*pVertices)[pSectionIndex+5]);
449 polygon.push_back((*pVertices)[pSectionIndex+6]);
450 polygon.push_back((*pVertices)[pSectionIndex+2]);
454 polygon.push_back((*pVertices)[pSectionIndex+2]);
455 polygon.push_back((*pVertices)[pSectionIndex+6]);
456 polygon.push_back((*pVertices)[pSectionIndex+7]);
457 polygon.push_back((*pVertices)[pSectionIndex+3]);
461 polygon.push_back((*pVertices)[pSectionIndex+3]);
462 polygon.push_back((*pVertices)[pSectionIndex+7]);
463 polygon.push_back((*pVertices)[pSectionIndex+4]);
464 polygon.push_back((*pVertices)[pSectionIndex]);
487 noLeft = pPolygon.size();
491 for (i=0; i<noLeft; ++i)
493 component = pPolygon[i].operator()(pAxis);
495 if (component < pMin)
499 if (component > pMax)
539 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
543 if ( !outputPolygon.size() )
return;
547 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
549 if ( !pPolygon.size() )
return;
550 else outputPolygon.clear();
556 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
563 if ( !outputPolygon.size() )
return;
567 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
569 if ( !pPolygon.size() )
return;
570 else outputPolygon.clear();
576 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
583 if ( !outputPolygon.size() )
return;
587 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
605 G4int noVertices=pPolygon.size();
608 for (i = 0 ; i < noVertices ; ++i )
610 vStart = pPolygon[i];
611 if ( i == noVertices-1 ) vEnd = pPolygon[0];
612 else vEnd = pPolygon[i+1];
614 if ( pVoxelLimit.
Inside(vStart) )
616 if (pVoxelLimit.
Inside(vEnd))
620 outputPolygon.push_back(vEnd);
627 outputPolygon.push_back(vEnd);
632 if (pVoxelLimit.
Inside(vEnd))
637 outputPolygon.push_back(vStart);
638 outputPolygon.push_back(vEnd);
655 std::ostringstream message;
656 message <<
"Not implemented for solid: "
658 <<
"\nReturning infinite boundinx box.";
659 G4Exception(
"G4VSolid::BoundingLimits()",
"GeomMgt1001",
662 pMin.
set(-kInfinity,-kInfinity,-kInfinity);
663 pMax.
set( kInfinity, kInfinity, kInfinity);
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
double epsilon(double density, double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
std::ostream & operator<<(std::ostream &os, const G4VSolid &e)
std::vector< G4ThreeVector > G4ThreeVectorList
double dot(const Hep3Vector &) const
void set(double x, double y, double z)
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
static void Register(G4VSolid *pSolid)
static void DeRegister(G4VSolid *pSolid)
static G4SolidStore * GetInstance()
G4double EstimateSurfaceArea(G4int nStat, G4double ell) const
virtual G4VSolid * Clone() const
virtual const G4VSolid * GetConstituentSolid(G4int no) const
virtual std::ostream & StreamInfo(std::ostream &os) const =0
void ClipBetweenSections(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
G4double EstimateCubicVolume(G4int nStat, G4double epsilon) const
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
virtual G4VisExtent GetExtent() const
G4VSolid(const G4String &name)
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4ThreeVector GetPointOnSurface() const
void ClipPolygon(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4Polyhedron * GetPolyhedron() const
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
virtual G4Polyhedron * CreatePolyhedron() const
G4VSolid & operator=(const G4VSolid &rhs)
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
virtual const G4DisplacedSolid * GetDisplacedSolidPtr() const
virtual G4double GetCubicVolume()
void ClipCrossSection(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
virtual G4double GetSurfaceArea()
void CalculateClippedPolygonExtent(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
virtual G4GeometryType GetEntityType() const =0
void SetYmin(G4double ymin)
void SetYmax(G4double ymax)
void SetXmax(G4double xmax)
void SetXmin(G4double xmin)
void SetZmax(G4double zmax)
void SetZmin(G4double zmin)
G4bool IsYLimited() const
G4bool ClipToLimits(G4ThreeVector &pStart, G4ThreeVector &pEnd) const
G4double GetMinZExtent() const
void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax)
G4bool IsXLimited() const
G4double GetMaxYExtent() const
G4bool Inside(const G4ThreeVector &pVec) const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4double GetMaxXExtent() const