35#if !defined(G4GEOM_USE_UBOX)
63 std::ostringstream message;
64 message <<
"Dimensions too small for Solid: " <<
GetName() <<
"!" <<
G4endl
65 <<
" hX, hY, hZ = " << pX <<
", " << pY <<
", " << pZ;
93 :
G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), delta(rhs.delta)
105 if (
this == &rhs) {
return *
this; }
133 std::ostringstream message;
134 message <<
"Dimension X too small for solid: " <<
GetName() <<
"!"
137 G4Exception(
"G4Box::SetXHalfLength()",
"GeomSolids0002",
157 std::ostringstream message;
158 message <<
"Dimension Y too small for solid: " <<
GetName() <<
"!\n"
160 G4Exception(
"G4Box::SetYHalfLength()",
"GeomSolids0002",
180 std::ostringstream message;
181 message <<
"Dimension Z too small for solid: " <<
GetName() <<
"!\n"
183 G4Exception(
"G4Box::SetZHalfLength()",
"GeomSolids0002",
209 pMin.
set(-fDx,-fDy,-fDz);
210 pMax.
set( fDx, fDy, fDz);
214 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
216 std::ostringstream message;
217 message <<
"Bad bounding box (min >= max) for solid: "
219 <<
"\npMin = " << pMin
220 <<
"\npMax = " << pMax;
253 std::abs(p.
y())-fDy),
254 std::abs(p.
z())-fDz);
267 if (std::abs(std::abs(px) - fDx) <= delta) norm.
setX(px < 0 ? -1. : 1.);
269 if (std::abs(std::abs(py) - fDy) <= delta) norm.
setY(py < 0 ? -1. : 1.);
271 if (std::abs(std::abs(pz) - fDz) <= delta) norm.
setZ(pz < 0 ? -1. : 1.);
283 std::ostringstream message;
284 G4int oldprc = message.precision(16);
285 message <<
"Point p is not on surface (!?) of solid: "
287 message <<
"Position:\n";
288 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
289 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
290 message <<
" p.z() = " << p.
z()/mm <<
" mm";
292 G4Exception(
"G4Box::SurfaceNormal(p)",
"GeomSolids1002",
296 return ApproxSurfaceNormal(p);
311 if (distx >= disty && distx >= distz)
313 if (disty >= distx && disty >= distz)
330 if ((std::abs(p.
x()) - fDx) >= -delta && p.
x()*v.
x() >= 0)
return kInfinity;
331 if ((std::abs(p.
y()) - fDy) >= -delta && p.
y()*v.
y() >= 0)
return kInfinity;
332 if ((std::abs(p.
z()) - fDz) >= -delta && p.
z()*v.
z() >= 0)
return kInfinity;
337 G4double dx = std::copysign(fDx,invx);
342 G4double dy = std::copysign(fDy,invy);
343 G4double tymin = std::max(txmin,(p.
y() - dy)*invy);
344 G4double tymax = std::min(txmax,(p.
y() + dy)*invy);
347 G4double dz = std::copysign(fDz,invz);
348 G4double tmin = std::max(tymin,(p.
z() - dz)*invz);
349 G4double tmax = std::min(tymax,(p.
z() + dz)*invz);
351 if (tmax <= tmin + delta)
return kInfinity;
352 return (tmin < delta) ? 0. : tmin;
366 std::abs(p.
y())-fDy),
367 std::abs(p.
z())-fDz);
368 return (dist > 0) ? dist : 0.;
384 if ((std::abs(p.
x()) - fDx) >= -delta && p.
x()*v.
x() > 0)
389 n->set((p.
x() < 0) ? -1. : 1., 0., 0.);
393 if ((std::abs(p.
y()) - fDy) >= -delta && p.
y()*v.
y() > 0)
398 n->set(0., (p.
y() < 0) ? -1. : 1., 0.);
402 if ((std::abs(p.
z()) - fDz) >= -delta && p.
z()*v.
z() > 0)
407 n->set(0., 0., (p.
z() < 0) ? -1. : 1.);
418 G4double ty = (vy == 0) ? tx : (std::copysign(fDy,vy) - p.
y())/vy;
422 G4double tz = (vz == 0) ? txy : (std::copysign(fDz,vz) - p.
z())/vz;
430 if (tmax == tx) n->set((v.
x() < 0) ? -1. : 1., 0., 0.);
431 else if (tmax == ty) n->set(0., (v.
y() < 0) ? -1. : 1., 0.);
432 else n->set(0., 0., (v.
z() < 0) ? -1. : 1.);
447 std::ostringstream message;
448 G4int oldprc = message.precision(16);
449 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
450 message <<
"Position:\n";
451 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
452 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
453 message <<
" p.z() = " << p.
z()/mm <<
" mm";
455 G4Exception(
"G4Box::DistanceToOut(p)",
"GeomSolids1002",
462 fDy-std::abs(p.
y())),
463 fDz-std::abs(p.
z()));
464 return (dist > 0) ? dist : 0.;
482 G4long oldprc = os.precision(16);
483 os <<
"-----------------------------------------------------------\n"
484 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
485 <<
" ===================================================\n"
486 <<
"Solid type: G4Box\n"
488 <<
" half length X: " << fDx/mm <<
" mm \n"
489 <<
" half length Y: " << fDy/mm <<
" mm \n"
490 <<
" half length Z: " << fDz/mm <<
" mm \n"
491 <<
"-----------------------------------------------------------\n";
492 os.precision(oldprc);
502 G4double sxy = fDx*fDy, sxz = fDx*fDz, syz = fDy*fDz;
510 ((select < 0.5*sxy) ? -fDz : fDz));
511 else if (select < sxy + sxz)
513 ((select < sxy + 0.5*sxz) ? -fDy : fDy),
516 return G4ThreeVector(((select < sxy + sxz + 0.5*syz) ? -fDx : fDx),
527 return new G4Box(*
this);
541 return G4VisExtent (-fDx, fDx, -fDy, fDy, -fDz, fDz);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4Box & operator=(const G4Box &rhs)
std::ostream & StreamInfo(std::ostream &os) 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
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4Polyhedron * CreatePolyhedron() const
G4bool fRebuildPolyhedron
G4CSGSolid & operator=(const G4CSGSolid &rhs)
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const