44 #if !defined(G4GEOM_USE_UBOX)
72 std::ostringstream message;
73 message <<
"Dimensions too small for Solid: " <<
GetName() <<
"!" <<
G4endl
74 <<
" hX, hY, hZ = " << pX <<
", " << pY <<
", " << pZ;
85 :
G4CSGSolid(a), fDx(0.), fDy(0.), fDz(0.), delta(0.)
102 :
G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), delta(rhs.delta)
114 if (
this == &rhs) {
return *
this; }
140 std::ostringstream message;
141 message <<
"Dimension X too small for solid: " <<
GetName() <<
"!"
144 G4Exception(
"G4Box::SetXHalfLength()",
"GeomSolids0002",
160 std::ostringstream message;
161 message <<
"Dimension Y too small for solid: " <<
GetName() <<
"!"
164 G4Exception(
"G4Box::SetYHalfLength()",
"GeomSolids0002",
180 std::ostringstream message;
181 message <<
"Dimension Z too small for solid: " <<
GetName() <<
"!"
184 G4Exception(
"G4Box::SetZHalfLength()",
"GeomSolids0002",
224 xMin = xoffset -
fDx ;
225 xMax = xoffset +
fDx ;
238 yMin = yoffset -
fDy ;
239 yMax = yoffset +
fDy ;
252 zMin = zoffset -
fDz ;
253 zMax = zoffset +
fDz ;
289 G4bool existsAfterClip = false ;
302 if (pVoxelLimit.
IsLimited(pAxis) ==
false)
306 existsAfterClip = true ;
323 existsAfterClip = true ;
358 existsAfterClip = true ;
364 return existsAfterClip;
375 G4ThreeVector q(std::fabs(p.x()), std::fabs(p.y()), std::fabs(p.z()));
412 distx = std::fabs(std::fabs(p.x()) -
fDx) ;
413 disty = std::fabs(std::fabs(p.y()) -
fDy) ;
414 distz = std::fabs(std::fabs(p.z()) -
fDz) ;
426 G4ThreeVector normX(0.,0.,0.), normY(0.,0.,0.), normZ(0.,0.,0.);
433 if ( p.x() >= 0. ) { normX= nX ; }
441 if ( p.y() >= 0. ) { normY= nY; }
449 if ( p.z() >= 0. ) { normZ= nZ; }
454 static const G4double invSqrt2 = 1.0 / std::sqrt(2.0);
455 static const G4double invSqrt3 = 1.0 / std::sqrt(3.0);
459 if( noSurfaces == 1 )
466 if( noSurfaces == 2 )
469 norm = invSqrt2 * sumnorm;
474 norm = invSqrt3 * sumnorm;
482 "Point p is not on surface !?" );
502 distx = std::fabs(std::fabs(p.x()) -
fDx) ;
503 disty = std::fabs(std::fabs(p.y()) -
fDy) ;
504 distz = std::fabs(std::fabs(p.z()) -
fDz) ;
506 if ( distx <= disty )
508 if ( distx <= distz )
521 if ( disty <= distz )
565 safx = std::fabs(p.x()) -
fDx ;
566 safy = std::fabs(p.y()) -
fDy ;
567 safz = std::fabs(p.z()) -
fDz ;
574 if ( ((p.x()*v.x() >= 0.0) && (safx > -
delta))
575 || ((p.y()*v.y() >= 0.0) && (safy > -
delta))
576 || ((p.z()*v.z() >= 0.0) && (safz > -
delta)) )
586 stmp = 1.0/std::fabs(v.x()) ;
591 smax = (
fDx+std::fabs(p.x()))*stmp ;
595 if (v.x() < 0) { sOut = (
fDx + p.x())*stmp ; }
596 else { sOut = (
fDx - p.x())*stmp ; }
604 stmp = 1.0/std::fabs(v.y()) ;
609 smaxy = (
fDy+std::fabs(p.y()))*stmp ;
611 if (sminy > smin) { smin=sminy ; }
612 if (smaxy < smax) { smax=smaxy ; }
614 if (smin >= (smax-
delta))
621 if (v.y() < 0) { sOuty = (
fDy + p.y())*stmp ; }
622 else { sOuty = (
fDy - p.y())*stmp ; }
623 if( sOuty < sOut ) { sOut = sOuty ; }
631 stmp = 1.0/std::fabs(v.z()) ;
636 smaxz = (
fDz+std::fabs(p.z()))*stmp ;
638 if (sminz > smin) { smin = sminz ; }
639 if (smaxz < smax) { smax = smaxz ; }
641 if (smin >= (smax-
delta))
648 if (v.z() < 0) { sOutz = (
fDz + p.z())*stmp ; }
649 else { sOutz = (
fDz - p.z())*stmp ; }
650 if( sOutz < sOut ) { sOut = sOutz ; }
654 if (sOut <= (smin +
delta))
658 if (smin <
delta) { smin = 0.0 ; }
672 G4double safex, safey, safez, safe = 0.0 ;
674 safex = std::fabs(p.x()) -
fDx ;
675 safey = std::fabs(p.y()) -
fDy ;
676 safez = std::fabs(p.z()) -
fDz ;
678 if (safex > safe) { safe = safex ; }
679 if (safey > safe) { safe = safey ; }
680 if (safez > safe) { safe = safez ; }
700 if (calcNorm) { *validNorm = true ; }
704 pdist =
fDx - p.x() ;
719 pdist =
fDx + p.x() ;
723 snxt = -pdist/v.x() ;
755 pdist =
fDy + p.y() ;
840 std::ostringstream message;
841 G4int oldprc = message.precision(16);
842 message <<
"Undefined side for valid surface normal to solid."
844 <<
"Position:" << G4endl << G4endl
845 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
846 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
847 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
848 <<
"Direction:" << G4endl << G4endl
849 <<
"v.x() = " << v.x() << G4endl
850 <<
"v.y() = " << v.y() << G4endl
851 <<
"v.z() = " << v.z() << G4endl << G4endl
852 <<
"Proposed distance :" << G4endl << G4endl
853 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
854 message.precision(oldprc);
855 G4Exception(
"G4Box::DistanceToOut(p,v,..)",
"GeomSolids1002",
870 G4double safx1,safx2,safy1,safy2,safz1,safz2,safe=0.0;
882 G4cout.precision(oldprc) ;
883 G4Exception(
"G4Box::DistanceToOut(p)",
"GeomSolids1002",
888 safx1 =
fDx - p.x() ;
889 safx2 =
fDx + p.x() ;
890 safy1 =
fDy - p.y() ;
891 safy2 =
fDy + p.y() ;
892 safz1 =
fDz - p.z() ;
893 safz2 =
fDz + p.z() ;
897 if (safx2 < safx1) { safe = safx2; }
898 else { safe = safx1; }
899 if (safy1 < safe) { safe = safy1; }
900 if (safy2 < safe) { safe = safy2; }
901 if (safz1 < safe) { safe = safz1; }
902 if (safz2 < safe) { safe = safz2; }
904 if (safe < 0) { safe = 0 ; }
924 vertices->reserve(8);
948 "Error in allocation of vertices. Out of memory !");
968 G4int oldprc = os.precision(16);
969 os <<
"-----------------------------------------------------------\n"
970 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
971 <<
" ===================================================\n"
972 <<
" Solid type: G4Box\n"
974 <<
" half length X: " <<
fDx/
mm <<
" mm \n"
975 <<
" half length Y: " <<
fDy/
mm <<
" mm \n"
976 <<
" half length Z: " <<
fDz/
mm <<
" mm \n"
977 <<
"-----------------------------------------------------------\n";
978 os.precision(oldprc);
995 sumS = Sxy + Sxz + Syz;
1006 else if ( ( select - Sxy ) < Sxz )
1031 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
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