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;
100 if (
this == &rhs) {
return *
this; }
128 std::ostringstream message;
129 message <<
"Dimension X too small for solid: " <<
GetName() <<
"!"
132 G4Exception(
"G4Box::SetXHalfLength()",
"GeomSolids0002",
152 std::ostringstream message;
153 message <<
"Dimension Y too small for solid: " <<
GetName() <<
"!\n"
155 G4Exception(
"G4Box::SetYHalfLength()",
"GeomSolids0002",
175 std::ostringstream message;
176 message <<
"Dimension Z too small for solid: " <<
GetName() <<
"!\n"
178 G4Exception(
"G4Box::SetZHalfLength()",
"GeomSolids0002",
204 pMin.
set(-fDx,-fDy,-fDz);
205 pMax.
set( fDx, fDy, fDz);
209 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
211 std::ostringstream message;
212 message <<
"Bad bounding box (min >= max) for solid: "
214 <<
"\npMin = " << pMin
215 <<
"\npMax = " << pMax;
248 std::abs(p.
y())-fDy),
249 std::abs(p.
z())-fDz);
262 if (std::abs(std::abs(px) - fDx) <= delta) norm.
setX(px < 0 ? -1. : 1.);
264 if (std::abs(std::abs(py) - fDy) <= delta) norm.
setY(py < 0 ? -1. : 1.);
266 if (std::abs(std::abs(pz) - fDz) <= delta) norm.
setZ(pz < 0 ? -1. : 1.);
278 std::ostringstream message;
279 G4int oldprc = message.precision(16);
280 message <<
"Point p is not on surface (!?) of solid: "
282 message <<
"Position:\n";
283 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
284 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
285 message <<
" p.z() = " << p.
z()/mm <<
" mm";
287 G4Exception(
"G4Box::SurfaceNormal(p)",
"GeomSolids1002",
291 return ApproxSurfaceNormal(p);
306 if (distx >= disty && distx >= distz)
307 return {std::copysign(1.,p.
x()), 0., 0.};
308 if (disty >= distx && disty >= distz)
309 return {0., std::copysign(1.,p.
y()), 0.};
311 return {0., 0., std::copysign(1.,p.
z())};
325 if ((std::abs(p.
x()) - fDx) >= -delta && p.
x()*v.
x() >= 0)
return kInfinity;
326 if ((std::abs(p.
y()) - fDy) >= -delta && p.
y()*v.
y() >= 0)
return kInfinity;
327 if ((std::abs(p.
z()) - fDz) >= -delta && p.
z()*v.
z() >= 0)
return kInfinity;
332 G4double dx = std::copysign(fDx,invx);
337 G4double dy = std::copysign(fDy,invy);
338 G4double tymin = std::max(txmin,(p.
y() - dy)*invy);
339 G4double tymax = std::min(txmax,(p.
y() + dy)*invy);
342 G4double dz = std::copysign(fDz,invz);
343 G4double tmin = std::max(tymin,(p.
z() - dz)*invz);
344 G4double tmax = std::min(tymax,(p.
z() + dz)*invz);
346 if (tmax <= tmin + delta)
return kInfinity;
347 return (tmin < delta) ? 0. : tmin;
361 std::abs(p.
y())-fDy),
362 std::abs(p.
z())-fDz);
363 return (dist > 0) ? dist : 0.;
379 if ((std::abs(p.
x()) - fDx) >= -delta && p.
x()*v.
x() > 0)
384 n->set((p.
x() < 0) ? -1. : 1., 0., 0.);
388 if ((std::abs(p.
y()) - fDy) >= -delta && p.
y()*v.
y() > 0)
393 n->set(0., (p.
y() < 0) ? -1. : 1., 0.);
397 if ((std::abs(p.
z()) - fDz) >= -delta && p.
z()*v.
z() > 0)
402 n->set(0., 0., (p.
z() < 0) ? -1. : 1.);
413 G4double ty = (vy == 0) ? tx : (std::copysign(fDy,vy) - p.
y())/vy;
417 G4double tz = (vz == 0) ? txy : (std::copysign(fDz,vz) - p.
z())/vz;
425 if (tmax == tx) n->set((v.
x() < 0) ? -1. : 1., 0., 0.);
426 else if (tmax == ty) n->set(0., (v.
y() < 0) ? -1. : 1., 0.);
427 else n->set(0., 0., (v.
z() < 0) ? -1. : 1.);
442 std::ostringstream message;
443 G4int oldprc = message.precision(16);
444 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
445 message <<
"Position:\n";
446 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
447 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
448 message <<
" p.z() = " << p.
z()/mm <<
" mm";
450 G4Exception(
"G4Box::DistanceToOut(p)",
"GeomSolids1002",
457 fDy-std::abs(p.
y())),
458 fDz-std::abs(p.
z()));
459 return (dist > 0) ? dist : 0.;
477 G4long oldprc = os.precision(16);
478 os <<
"-----------------------------------------------------------\n"
479 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
480 <<
" ===================================================\n"
481 <<
"Solid type: G4Box\n"
483 <<
" half length X: " << fDx/mm <<
" mm \n"
484 <<
" half length Y: " << fDy/mm <<
" mm \n"
485 <<
" half length Z: " << fDz/mm <<
" mm \n"
486 <<
"-----------------------------------------------------------\n";
487 os.precision(oldprc);
497 G4double sxy = fDx*fDy, sxz = fDx*fDz, syz = fDy*fDz;
503 return { u*fDx, v*fDy, ((select < 0.5*sxy) ? -fDz : fDz) };
504 else if (select < sxy + sxz)
505 return { u*fDx, ((select < sxy + 0.5*sxz) ? -fDy : fDy), v*fDz };
507 return { ((select < sxy + sxz + 0.5*syz) ? -fDx : fDx), u*fDy, v*fDz };
516 return new G4Box(*
this);
530 return { -fDx, fDx, -fDy, fDy, -fDz, fDz };
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
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
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4VSolid * Clone() const override
G4Polyhedron * CreatePolyhedron() const override
G4Box & operator=(const G4Box &rhs)
G4GeometryType GetEntityType() const override
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
G4VisExtent GetExtent() const override
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
void SetZHalfLength(G4double dz)
EInside Inside(const G4ThreeVector &p) const override
G4ThreeVector GetPointOnSurface() const override
void SetYHalfLength(G4double dy)
void SetXHalfLength(G4double dx)
std::ostream & StreamInfo(std::ostream &os) const override
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4bool fRebuildPolyhedron
G4CSGSolid & operator=(const G4CSGSolid &rhs)
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const