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 )
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."
848 <<
"Position:" << G4endl << G4endl
849 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
850 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
851 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
852 <<
"Direction:" << G4endl << G4endl
853 <<
"v.x() = " << v.
x() << G4endl
854 <<
"v.y() = " << v.
y() << G4endl
855 <<
"v.z() = " << v.
z() << G4endl << G4endl
856 <<
"Proposed distance :" << G4endl << 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);