46 #if !defined(G4GEOM_USE_UBOX)
74 std::ostringstream message;
75 message <<
"Dimensions too small for Solid: " <<
GetName() <<
"!" <<
G4endl
76 <<
" hX, hY, hZ = " << pX <<
", " << pY <<
", " << pZ;
87 :
G4CSGSolid(a), fDx(0.), fDy(0.), fDz(0.), delta(0.)
104 :
G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), delta(rhs.delta)
116 if (
this == &rhs) {
return *
this; }
142 std::ostringstream message;
143 message <<
"Dimension X too small for solid: " <<
GetName() <<
"!"
146 G4Exception(
"G4Box::SetXHalfLength()",
"GeomSolids0002",
162 std::ostringstream message;
163 message <<
"Dimension Y too small for solid: " <<
GetName() <<
"!"
166 G4Exception(
"G4Box::SetYHalfLength()",
"GeomSolids0002",
182 std::ostringstream message;
183 message <<
"Dimension Z too small for solid: " <<
GetName() <<
"!"
186 G4Exception(
"G4Box::SetZHalfLength()",
"GeomSolids0002",
217 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
219 std::ostringstream message;
220 message <<
"Bad bounding box (min >= max) for solid: "
222 <<
"\npMin = " << pMin
223 <<
"\npMax = " << pMax;
255 G4ThreeVector q(std::fabs(p.x()), std::fabs(p.y()), std::fabs(p.z()));
292 distx = std::fabs(std::fabs(p.x()) -
fDx) ;
293 disty = std::fabs(std::fabs(p.y()) -
fDy) ;
294 distz = std::fabs(std::fabs(p.z()) -
fDz) ;
306 G4ThreeVector normX(0.,0.,0.), normY(0.,0.,0.), normZ(0.,0.,0.);
313 if ( p.x() >= 0. ) { normX= nX ; }
321 if ( p.y() >= 0. ) { normY= nY; }
329 if ( p.z() >= 0. ) { normZ= nZ; }
334 static const G4double invSqrt2 = 1.0 / std::sqrt(2.0);
335 static const G4double invSqrt3 = 1.0 / std::sqrt(3.0);
339 if( noSurfaces == 1 )
346 if( noSurfaces == 2 )
349 norm = invSqrt2 * sumnorm;
354 norm = invSqrt3 * sumnorm;
362 "Point p is not on surface !?" );
382 distx = std::fabs(std::fabs(p.x()) -
fDx) ;
383 disty = std::fabs(std::fabs(p.y()) -
fDy) ;
384 distz = std::fabs(std::fabs(p.z()) -
fDz) ;
386 if ( distx <= disty )
388 if ( distx <= distz )
401 if ( disty <= distz )
445 safx = std::fabs(p.x()) -
fDx ;
446 safy = std::fabs(p.y()) -
fDy ;
447 safz = std::fabs(p.z()) -
fDz ;
454 if ( ((p.x()*v.x() >= 0.0) && (safx > -
delta))
455 || ((p.y()*v.y() >= 0.0) && (safy > -
delta))
456 || ((p.z()*v.z() >= 0.0) && (safz > -
delta)) )
466 stmp = 1.0/std::fabs(v.x()) ;
471 smax = (
fDx+std::fabs(p.x()))*stmp ;
475 if (v.x() < 0) { sOut = (
fDx + p.x())*stmp ; }
476 else { sOut = (
fDx - p.x())*stmp ; }
484 stmp = 1.0/std::fabs(v.y()) ;
489 smaxy = (
fDy+std::fabs(p.y()))*stmp ;
491 if (sminy > smin) { smin=sminy ; }
492 if (smaxy < smax) { smax=smaxy ; }
494 if (smin >= (smax-
delta))
501 if (v.y() < 0) { sOuty = (
fDy + p.y())*stmp ; }
502 else { sOuty = (
fDy - p.y())*stmp ; }
503 if( sOuty < sOut ) { sOut = sOuty ; }
511 stmp = 1.0/std::fabs(v.z()) ;
516 smaxz = (
fDz+std::fabs(p.z()))*stmp ;
518 if (sminz > smin) { smin = sminz ; }
519 if (smaxz < smax) { smax = smaxz ; }
521 if (smin >= (smax-
delta))
528 if (v.z() < 0) { sOutz = (
fDz + p.z())*stmp ; }
529 else { sOutz = (
fDz - p.z())*stmp ; }
530 if( sOutz < sOut ) { sOut = sOutz ; }
534 if (sOut <= (smin +
delta))
538 if (smin <
delta) { smin = 0.0 ; }
552 G4double safex, safey, safez, safe = 0.0 ;
554 safex = std::fabs(p.x()) -
fDx ;
555 safey = std::fabs(p.y()) -
fDy ;
556 safez = std::fabs(p.z()) -
fDz ;
558 if (safex > safe) { safe = safex ; }
559 if (safey > safe) { safe = safey ; }
560 if (safez > safe) { safe = safez ; }
580 if (calcNorm) { *validNorm = true ; }
584 pdist =
fDx - p.x() ;
599 pdist =
fDx + p.x() ;
603 snxt = -pdist/v.x() ;
635 pdist =
fDy + p.y() ;
720 std::ostringstream message;
721 G4int oldprc = message.precision(16);
722 message <<
"Undefined side for valid surface normal to solid."
724 <<
"Position:" << G4endl << G4endl
725 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
726 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
727 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
728 <<
"Direction:" << G4endl << G4endl
729 <<
"v.x() = " << v.x() << G4endl
730 <<
"v.y() = " << v.y() << G4endl
731 <<
"v.z() = " << v.z() << G4endl << G4endl
732 <<
"Proposed distance :" << G4endl << G4endl
733 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
734 message.precision(oldprc);
735 G4Exception(
"G4Box::DistanceToOut(p,v,..)",
"GeomSolids1002",
750 G4double safx1,safx2,safy1,safy2,safz1,safz2,safe=0.0;
762 G4cout.precision(oldprc) ;
763 G4Exception(
"G4Box::DistanceToOut(p)",
"GeomSolids1002",
768 safx1 =
fDx - p.x() ;
769 safx2 =
fDx + p.x() ;
770 safy1 =
fDy - p.y() ;
771 safy2 =
fDy + p.y() ;
772 safz1 =
fDz - p.z() ;
773 safz2 =
fDz + p.z() ;
777 if (safx2 < safx1) { safe = safx2; }
778 else { safe = safx1; }
779 if (safy1 < safe) { safe = safy1; }
780 if (safy2 < safe) { safe = safy2; }
781 if (safz1 < safe) { safe = safz1; }
782 if (safz2 < safe) { safe = safz2; }
784 if (safe < 0) { safe = 0 ; }
803 G4int oldprc = os.precision(16);
804 os <<
"-----------------------------------------------------------\n"
805 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
806 <<
" ===================================================\n"
807 <<
" Solid type: G4Box\n"
809 <<
" half length X: " <<
fDx/
mm <<
" mm \n"
810 <<
" half length Y: " <<
fDy/
mm <<
" mm \n"
811 <<
" half length Z: " <<
fDz/
mm <<
" mm \n"
812 <<
"-----------------------------------------------------------\n";
813 os.precision(oldprc);
830 sumS = Sxy + Sxz + Syz;
841 else if ( ( select - Sxy ) < Sxz )
866 return new G4Box(*
this);
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4ThreeVector GetPointOnSurface() const
void SetZHalfLength(G4double dz)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
static constexpr double mm
static const G4double kInfinity
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
CLHEP::Hep3Vector G4ThreeVector
G4Box & operator=(const G4Box &rhs)
G4bool fRebuildPolyhedron
std::vector< ExP01TrackerHit * > a
G4GeometryType GetEntityType() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
G4VisExtent GetExtent() const
virtual void AddSolid(const G4Box &)=0
G4Polyhedron * CreatePolyhedron() const
std::ostream & StreamInfo(std::ostream &os) const
G4GLOB_DLL std::ostream G4cout
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) 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 DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
EInside Inside(const G4ThreeVector &p) const
void SetYHalfLength(G4double dy)
void SetXHalfLength(G4double dx)
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const