44 #if !defined(G4GEOM_USE_UBOX)
71 std::ostringstream message;
72 message <<
"Dimensions too small for Solid: " <<
GetName() <<
"!" <<
G4endl
73 <<
" hX, hY, hZ = " << pX <<
", " << pY <<
", " << pZ;
84 :
G4CSGSolid(a), fDx(0.), fDy(0.), fDz(0.), delta(0.)
101 :
G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), delta(rhs.delta)
114 if (
this == &rhs) {
return *
this; }
141 std::ostringstream message;
142 message <<
"Dimension X too small for solid: " <<
GetName() <<
"!"
145 G4Exception(
"G4Box::SetXHalfLength()",
"GeomSolids0002",
161 std::ostringstream message;
162 message <<
"Dimension Y too small for solid: " <<
GetName() <<
"!"
165 G4Exception(
"G4Box::SetYHalfLength()",
"GeomSolids0002",
181 std::ostringstream message;
182 message <<
"Dimension Z too small for solid: " <<
GetName() <<
"!"
185 G4Exception(
"G4Box::SetZHalfLength()",
"GeomSolids0002",
225 xMin = xoffset -
fDx ;
226 xMax = xoffset +
fDx ;
239 yMin = yoffset -
fDy ;
240 yMax = yoffset +
fDy ;
253 zMin = zoffset -
fDz ;
254 zMax = zoffset +
fDz ;
290 G4bool existsAfterClip = false ;
303 if (pVoxelLimit.
IsLimited(pAxis) ==
false)
307 existsAfterClip = true ;
324 existsAfterClip = true ;
359 existsAfterClip = true ;
365 return existsAfterClip;
376 G4ThreeVector q(std::fabs(p.x()), std::fabs(p.y()), std::fabs(p.z()));
413 distx = std::fabs(std::fabs(p.x()) -
fDx) ;
414 disty = std::fabs(std::fabs(p.y()) -
fDy) ;
415 distz = std::fabs(std::fabs(p.z()) -
fDz) ;
427 G4ThreeVector normX(0.,0.,0.), normY(0.,0.,0.), normZ(0.,0.,0.);
434 if ( p.x() >= 0. ) { normX= nX ; }
442 if ( p.y() >= 0. ) { normY= nY; }
450 if ( p.z() >= 0. ) { normZ= nZ; }
455 static const G4double invSqrt2 = 1.0 / std::sqrt(2.0);
456 static const G4double invSqrt3 = 1.0 / std::sqrt(3.0);
460 if( noSurfaces == 1 )
467 if( noSurfaces == 2 )
470 norm = invSqrt2 * sumnorm;
475 norm = invSqrt3 * sumnorm;
483 "Point p is not on surface !?" );
503 distx = std::fabs(std::fabs(p.x()) -
fDx) ;
504 disty = std::fabs(std::fabs(p.y()) -
fDy) ;
505 distz = std::fabs(std::fabs(p.z()) -
fDz) ;
507 if ( distx <= disty )
509 if ( distx <= distz )
522 if ( disty <= distz )
566 safx = std::fabs(p.x()) -
fDx ;
567 safy = std::fabs(p.y()) -
fDy ;
568 safz = std::fabs(p.z()) -
fDz ;
575 if ( ((p.x()*v.x() >= 0.0) && (safx > -
delta))
576 || ((p.y()*v.y() >= 0.0) && (safy > -
delta))
577 || ((p.z()*v.z() >= 0.0) && (safz > -
delta)) )
587 stmp = 1.0/std::fabs(v.x()) ;
592 smax = (
fDx+std::fabs(p.x()))*stmp ;
596 if (v.x() < 0) { sOut = (
fDx + p.x())*stmp ; }
597 else { sOut = (
fDx - p.x())*stmp ; }
605 stmp = 1.0/std::fabs(v.y()) ;
610 smaxy = (
fDy+std::fabs(p.y()))*stmp ;
612 if (sminy > smin) { smin=sminy ; }
613 if (smaxy < smax) { smax=smaxy ; }
615 if (smin >= (smax-
delta))
622 if (v.y() < 0) { sOuty = (
fDy + p.y())*stmp ; }
623 else { sOuty = (
fDy - p.y())*stmp ; }
624 if( sOuty < sOut ) { sOut = sOuty ; }
632 stmp = 1.0/std::fabs(v.z()) ;
637 smaxz = (
fDz+std::fabs(p.z()))*stmp ;
639 if (sminz > smin) { smin = sminz ; }
640 if (smaxz < smax) { smax = smaxz ; }
642 if (smin >= (smax-
delta))
649 if (v.z() < 0) { sOutz = (
fDz + p.z())*stmp ; }
650 else { sOutz = (
fDz - p.z())*stmp ; }
651 if( sOutz < sOut ) { sOut = sOutz ; }
655 if (sOut <= (smin +
delta))
659 if (smin <
delta) { smin = 0.0 ; }
673 G4double safex, safey, safez, safe = 0.0 ;
675 safex = std::fabs(p.x()) -
fDx ;
676 safey = std::fabs(p.y()) -
fDy ;
677 safez = std::fabs(p.z()) -
fDz ;
679 if (safex > safe) { safe = safex ; }
680 if (safey > safe) { safe = safey ; }
681 if (safez > safe) { safe = safez ; }
701 if (calcNorm) { *validNorm = true ; }
705 pdist =
fDx - p.x() ;
720 pdist =
fDx + p.x() ;
724 snxt = -pdist/v.x() ;
756 pdist =
fDy + p.y() ;
841 std::ostringstream message;
842 G4int oldprc = message.precision(16);
843 message <<
"Undefined side for valid surface normal to solid."
845 <<
"Position:" << G4endl << G4endl
846 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
847 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
848 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
849 <<
"Direction:" << G4endl << G4endl
850 <<
"v.x() = " << v.x() << G4endl
851 <<
"v.y() = " << v.y() << G4endl
852 <<
"v.z() = " << v.z() << G4endl << G4endl
853 <<
"Proposed distance :" << G4endl << G4endl
854 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
855 message.precision(oldprc);
856 G4Exception(
"G4Box::DistanceToOut(p,v,..)",
"GeomSolids1002",
871 G4double safx1,safx2,safy1,safy2,safz1,safz2,safe=0.0;
883 G4cout.precision(oldprc) ;
884 G4Exception(
"G4Box::DistanceToOut(p)",
"GeomSolids1002",
889 safx1 =
fDx - p.x() ;
890 safx2 =
fDx + p.x() ;
891 safy1 =
fDy - p.y() ;
892 safy2 =
fDy + p.y() ;
893 safz1 =
fDz - p.z() ;
894 safz2 =
fDz + p.z() ;
898 if (safx2 < safx1) { safe = safx2; }
899 else { safe = safx1; }
900 if (safy1 < safe) { safe = safy1; }
901 if (safy2 < safe) { safe = safy2; }
902 if (safz1 < safe) { safe = safz1; }
903 if (safz2 < safe) { safe = safz2; }
905 if (safe < 0) { safe = 0 ; }
925 vertices->reserve(8);
949 "Error in allocation of vertices. Out of memory !");
969 G4int oldprc = os.precision(16);
970 os <<
"-----------------------------------------------------------\n"
971 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
972 <<
" ===================================================\n"
973 <<
" Solid type: G4Box\n"
975 <<
" half length X: " <<
fDx/
mm <<
" mm \n"
976 <<
" half length Y: " <<
fDy/
mm <<
" mm \n"
977 <<
" half length Z: " <<
fDz/
mm <<
" mm \n"
978 <<
"-----------------------------------------------------------\n";
979 os.precision(oldprc);
996 sumS = Sxy + Sxz + Syz;
1007 else if ( ( select - Sxy ) < Sxz )
1032 return new G4Box(*
this);
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4ThreeVector GetPointOnSurface() const
void ClipCrossSection(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void SetZHalfLength(G4double dz)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
static const G4double kInfinity
G4double GetMinYExtent() const
CLHEP::Hep3Vector G4ThreeVector
G4Box & operator=(const G4Box &rhs)
G4bool IsYLimited() const
G4GeometryType GetEntityType() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
G4bool IsXLimited() const
G4VisExtent GetExtent() const
virtual void AddSolid(const G4Box &)=0
G4Polyhedron * CreatePolyhedron() const
std::ostream & StreamInfo(std::ostream &os) const
G4double GetMaxXExtent() const
G4double GetMinZExtent() const
G4GLOB_DLL std::ostream G4cout
G4Polyhedron * fpPolyhedron
virtual G4Polyhedron * GetPolyhedron() const
std::vector< G4ThreeVector > G4ThreeVectorList
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4double GetMinXExtent() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
EInside Inside(const G4ThreeVector &p) const
G4double GetMaxZExtent() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void SetYHalfLength(G4double dy)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void SetXHalfLength(G4double dx)
G4double GetMaxYExtent() const
G4double GetMaxExtent(const EAxis pAxis) const
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4bool IsZLimited() const
void ClipBetweenSections(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
G4double GetMinExtent(const EAxis pAxis) const
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const