35#if !defined(G4GEOM_USE_UBOX)
69 std::ostringstream message;
70 message <<
"Dimensions too small for Solid: " <<
GetName() <<
"!" <<
G4endl
71 <<
" hX, hY, hZ = " << pX <<
", " << pY <<
", " << pZ;
94 if (
this == &rhs) {
return *
this; }
122 std::ostringstream message;
123 message <<
"Dimension X too small for solid: " <<
GetName() <<
"!"
126 G4Exception(
"G4Box::SetXHalfLength()",
"GeomSolids0002",
146 std::ostringstream message;
147 message <<
"Dimension Y too small for solid: " <<
GetName() <<
"!\n"
149 G4Exception(
"G4Box::SetYHalfLength()",
"GeomSolids0002",
169 std::ostringstream message;
170 message <<
"Dimension Z too small for solid: " <<
GetName() <<
"!\n"
172 G4Exception(
"G4Box::SetZHalfLength()",
"GeomSolids0002",
198 pMin.
set(-fDx,-fDy,-fDz);
199 pMax.
set( fDx, fDy, fDz);
203 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
205 std::ostringstream message;
206 message <<
"Bad bounding box (min >= max) for solid: "
208 <<
"\npMin = " << pMin
209 <<
"\npMax = " << pMax;
242 std::abs(p.
y())-fDy),
243 std::abs(p.
z())-fDz);
256 if (std::abs(std::abs(px)-fDx) <= delta) { norm.
setX(std::copysign(1.,px)); }
257 if (std::abs(std::abs(py)-fDy) <= delta) { norm.
setY(std::copysign(1.,py)); }
258 if (std::abs(std::abs(pz)-fDz) <= delta) { norm.
setZ(std::copysign(1.,pz)); }
273 std::ostringstream message;
274 G4int oldprc = message.precision(16);
275 message <<
"Point p is not on surface (!?) of solid: "
277 message <<
"Position:\n";
278 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
279 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
280 message <<
" p.z() = " << p.
z()/mm <<
" mm";
282 G4Exception(
"G4Box::SurfaceNormal(p)",
"GeomSolids1002",
287 return ApproxSurfaceNormal(p);
301 if (distx >= disty && distx >= distz)
303 return {std::copysign(1.,p.
x()), 0., 0.};
305 if (disty >= distx && disty >= distz)
307 return {0., std::copysign(1.,p.
y()), 0.};
310 return {0., 0., std::copysign(1.,p.
z())};
324 if ((std::abs(p.
x())-fDx) >= -delta && p.
x()*v.
x() >= 0) {
return kInfinity; }
325 if ((std::abs(p.
y())-fDy) >= -delta && p.
y()*v.
y() >= 0) {
return kInfinity; }
326 if ((std::abs(p.
z())-fDz) >= -delta && p.
z()*v.
z() >= 0) {
return kInfinity; }
331 G4double dx = std::copysign(fDx,invx);
336 G4double dy = std::copysign(fDy,invy);
337 G4double tymin = std::max(txmin,(p.
y() - dy)*invy);
338 G4double tymax = std::min(txmax,(p.
y() + dy)*invy);
341 G4double dz = std::copysign(fDz,invz);
342 G4double tmin = std::max(tymin,(p.
z() - dz)*invz);
343 G4double tmax = std::min(tymax,(p.
z() + dz)*invz);
345 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.;
383 if ((std::abs(px) - fDx) >= -delta && px*vx > 0) {
return 0.; }
384 if ((std::abs(py) - fDy) >= -delta && py*vy > 0) {
return 0.; }
385 if ((std::abs(pz) - fDz) >= -delta && pz*vz > 0) {
return 0.; }
389 G4double tmax = std::min(std::min(tx,ty),tz);
395 if ((std::abs(px) - fDx) >= -delta && px*vx > 0)
397 n->set(std::copysign(1.,px), 0., 0.);
400 if ((std::abs(py) - fDy) >= -delta && py*vy > 0)
402 n->set(0., std::copysign(1.,py), 0.);
405 if ((std::abs(pz) - fDz) >= -delta && pz*vz > 0)
407 n->set(0., 0., std::copysign(1.,pz));
415 G4double tmax = std::min(std::min(tx, ty), tz);
418 G4bool pickZ = (tmax == tz);
419 G4bool pickX = (!pickZ) && (tmax == tx);
420 G4bool pickY = (!pickZ) && (!pickX);
438 std::ostringstream message;
439 G4int oldprc = message.precision(16);
440 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
441 message <<
"Position:\n";
442 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
443 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
444 message <<
" p.z() = " << p.
z()/mm <<
" mm";
446 G4Exception(
"G4Box::DistanceToOut(p)",
"GeomSolids1002",
453 fDy-std::abs(p.
y())),
454 fDz-std::abs(p.
z()));
455 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;
512 z = (select < 0.5*sxy) ? -fDz : fDz;
514 else if (select < sxy + sxz)
517 y = (select < sxy + 0.5*sxz) ? -fDy : fDy;
522 x = (select < sxy + sxz + 0.5*syz) ? -fDx : fDx;
565 return new G4Box(*
this);
579 return { -fDx, fDx, -fDy, fDy, -fDz, fDz };
G4TemplateAutoLock< G4Mutex > G4AutoLock
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double G4QuickRand(uint32_t seed=0)
#define G4MUTEX_INITIALIZER
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
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
G4double GetCubicVolume() override
void SetZHalfLength(G4double dz)
EInside Inside(const G4ThreeVector &p) const override
G4ThreeVector GetPointOnSurface() const override
G4bool IsFaceted() 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
G4double GetSurfaceArea() override
G4bool fRebuildPolyhedron
G4CSGSolid(const G4String &pName)
G4CSGSolid & operator=(const G4CSGSolid &rhs)
virtual void AddSolid(const G4Box &)=0
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid(const G4String &name)
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...