71 std::ostringstream message;
72 message <<
"Dimensions too small for Solid: " <<
GetName() <<
"!" <<
G4endl
73 <<
" hX, hY, hZ = " << pX <<
", " << pY <<
", " << pZ;
101 :
G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz)
113 if (
this == &rhs) {
return *
this; }
138 std::ostringstream message;
139 message <<
"Dimension X too small for solid: " <<
GetName() <<
"!"
142 G4Exception(
"G4Box::SetXHalfLength()",
"GeomSolids0002",
158 std::ostringstream message;
159 message <<
"Dimension Y too small for solid: " <<
GetName() <<
"!"
162 G4Exception(
"G4Box::SetYHalfLength()",
"GeomSolids0002",
178 std::ostringstream message;
179 message <<
"Dimension Z too small for solid: " <<
GetName() <<
"!"
182 G4Exception(
"G4Box::SetZHalfLength()",
"GeomSolids0002",
222 xMin = xoffset - fDx ;
223 xMax = xoffset + fDx ;
236 yMin = yoffset - fDy ;
237 yMax = yoffset + fDy ;
250 zMin = zoffset - fDz ;
251 zMax = zoffset + fDz ;
287 G4bool existsAfterClip = false ;
300 if (pVoxelLimit.
IsLimited(pAxis) ==
false)
302 if ( (pMin != kInfinity) || (pMax != -kInfinity) )
304 existsAfterClip = true ;
319 if ( (pMin != kInfinity) || (pMax != -kInfinity) )
321 existsAfterClip = true ;
356 existsAfterClip = true ;
362 return existsAfterClip;
376 if ( q.
x() <= (fDx - delta) )
378 if (q.
y() <= (fDy - delta) )
380 if ( q.
z() <= (fDz - delta) ) { in =
kInside ; }
381 else if ( q.
z() <= (fDz + delta) ) { in =
kSurface ; }
383 else if ( q.
y() <= (fDy + delta) )
385 if ( q.
z() <= (fDz + delta) ) { in =
kSurface ; }
388 else if ( q.
x() <= (fDx + delta) )
390 if ( q.
y() <= (fDy + delta) )
392 if ( q.
z() <= (fDz + delta) ) { in =
kSurface ; }
411 distx = std::fabs(std::fabs(p.
x()) - fDx) ;
412 disty = std::fabs(std::fabs(p.
y()) - fDy) ;
413 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 !?" );
484 norm = ApproxSurfaceNormal(p);
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 )
561 G4double smax=kInfinity, smaxy, smaxz ;
563 G4double sOut=kInfinity, sOuty=kInfinity, sOutz=kInfinity ;
567 safx = std::fabs(p.
x()) - fDx ;
568 safy = std::fabs(p.
y()) - fDy ;
569 safz = std::fabs(p.
z()) - fDz ;
576 if ( ((p.
x()*v.
x() >= 0.0) && (safx > -delta))
577 || ((p.
y()*v.
y() >= 0.0) && (safy > -delta))
578 || ((p.
z()*v.
z() >= 0.0) && (safz > -delta)) )
588 stmp = 1.0/std::fabs(v.
x()) ;
593 smax = (fDx+std::fabs(p.
x()))*stmp ;
597 if (v.
x() < 0) { sOut = (fDx + p.
x())*stmp ; }
598 else { sOut = (fDx - p.
x())*stmp ; }
606 stmp = 1.0/std::fabs(v.
y()) ;
611 smaxy = (fDy+std::fabs(p.
y()))*stmp ;
613 if (sminy > smin) { smin=sminy ; }
614 if (smaxy < smax) { smax=smaxy ; }
616 if (smin >= (smax-delta))
623 if (v.
y() < 0) { sOuty = (fDy + p.
y())*stmp ; }
624 else { sOuty = (fDy - p.
y())*stmp ; }
625 if( sOuty < sOut ) { sOut = sOuty ; }
633 stmp = 1.0/std::fabs(v.
z()) ;
638 smaxz = (fDz+std::fabs(p.
z()))*stmp ;
640 if (sminz > smin) { smin = sminz ; }
641 if (smaxz < smax) { smax = smaxz ; }
643 if (smin >= (smax-delta))
650 if (v.
z() < 0) { sOutz = (fDz + p.
z())*stmp ; }
651 else { sOutz = (fDz - p.
z())*stmp ; }
652 if( sOutz < sOut ) { sOut = sOutz ; }
656 if (sOut <= (smin + delta))
660 if (smin < delta) { smin = 0.0 ; }
674 G4double safex, safey, safez, safe = 0.0 ;
676 safex = std::fabs(p.
x()) - fDx ;
677 safey = std::fabs(p.
y()) - fDy ;
678 safez = std::fabs(p.
z()) - fDz ;
680 if (safex > safe) { safe = safex ; }
681 if (safey > safe) { safe = safey ; }
682 if (safez > safe) { safe = safez ; }
704 if (calcNorm) { *validNorm = true ; }
708 pdist = fDx - p.
x() ;
723 pdist = fDx + p.
x() ;
727 snxt = -pdist/v.
x() ;
759 pdist = fDy + p.
y() ;
844 std::ostringstream message;
845 G4int oldprc = message.precision(16);
846 message <<
"Undefined side for valid surface normal to solid."
849 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
850 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
853 <<
"v.x() = " << v.
x() <<
G4endl
854 <<
"v.y() = " << v.
y() <<
G4endl
857 <<
"snxt = " << snxt/mm <<
" mm" <<
G4endl;
858 message.precision(oldprc);
859 G4Exception(
"G4Box::DistanceToOut(p,v,..)",
"GeomSolids1002",
874 G4double safx1,safx2,safy1,safy2,safz1,safz2,safe=0.0;
886 G4cout.precision(oldprc) ;
887 G4Exception(
"G4Box::DistanceToOut(p)",
"GeomSolids1002",
892 safx1 = fDx - p.
x() ;
893 safx2 = fDx + p.
x() ;
894 safy1 = fDy - p.
y() ;
895 safy2 = fDy + p.
y() ;
896 safz1 = fDz - p.
z() ;
897 safz2 = fDz + p.
z() ;
901 if (safx2 < safx1) { safe = safx2; }
902 else { safe = safx1; }
903 if (safy1 < safe) { safe = safy1; }
904 if (safy2 < safe) { safe = safy2; }
905 if (safz1 < safe) { safe = safz1; }
906 if (safz2 < safe) { safe = safz2; }
908 if (safe < 0) { safe = 0 ; }
928 vertices->reserve(8);
952 "Error in allocation of vertices. Out of memory !");
972 G4int oldprc = os.precision(16);
973 os <<
"-----------------------------------------------------------\n"
974 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
975 <<
" ===================================================\n"
976 <<
" Solid type: G4Box\n"
978 <<
" half length X: " << fDx/mm <<
" mm \n"
979 <<
" half length Y: " << fDy/mm <<
" mm \n"
980 <<
" half length Z: " << fDz/mm <<
" mm \n"
981 <<
"-----------------------------------------------------------\n";
982 os.precision(oldprc);
997 G4double Sxy = fDx*fDy, Sxz = fDx*fDz, Syz = fDy*fDz;
999 sumS = Sxy + Sxz + Syz;
1010 else if ( ( select - Sxy ) < Sxz )
1035 return new G4Box(*
this);
1049 return G4VisExtent (-fDx, fDx, -fDy, fDy, -fDz, fDz);
CLHEP::Hep3Vector G4ThreeVector
std::vector< G4ThreeVector > G4ThreeVectorList
G4DLLIMPORT std::ostream G4cout
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
G4Box & operator=(const G4Box &rhs)
std::ostream & StreamInfo(std::ostream &os) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4VisExtent GetExtent() const
G4ThreeVector GetPointOnSurface() const
void SetZHalfLength(G4double dz)
G4GeometryType GetEntityType() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
void SetYHalfLength(G4double dy)
void SetXHalfLength(G4double dx)
EInside Inside(const G4ThreeVector &p) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4NURBS * CreateNURBS() const
G4Polyhedron * CreatePolyhedron() const
G4Polyhedron * fpPolyhedron
G4CSGSolid & operator=(const G4CSGSolid &rhs)
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void ClipBetweenSections(G4ThreeVectorList *pVertices, const G4int pSectionIndex, 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
G4double GetMinExtent(const EAxis pAxis) const
G4bool IsYLimited() const
G4double GetMinZExtent() const
G4bool IsXLimited() const
G4double GetMaxExtent(const EAxis pAxis) const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4double GetMaxXExtent() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)