37#if !(defined(G4GEOM_USE_UELLIPSOID) && defined(G4GEOM_USE_SYS_USOLIDS))
73 :
G4VSolid(
name), fDx(xSemiAxis), fDy(ySemiAxis), fDz(zSemiAxis),
74 fZBottomCut(zBottomCut), fZTopCut(zTopCut)
85 :
G4VSolid(a), fDx(0.), fDy(0.), fDz(0.), fZBottomCut(0.), fZTopCut(0.)
104 fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz),
105 fZBottomCut(rhs.fZBottomCut), fZTopCut(rhs.fZTopCut),
106 halfTolerance(rhs.halfTolerance),
107 fXmax(rhs.fXmax), fYmax(rhs.fYmax),
108 fRsph(rhs.fRsph), fR(rhs.fR),
109 fSx(rhs.fSx), fSy(rhs.fSy), fSz(rhs.fSz),
110 fZMidCut(rhs.fZMidCut), fZDimCut(rhs.fZDimCut),
111 fQ1(rhs.fQ1), fQ2(rhs.fQ2),
112 fCubicVolume(rhs.fCubicVolume),
113 fSurfaceArea(rhs.fSurfaceArea),
114 fLateralArea(rhs.fLateralArea)
126 if (
this == &rhs) {
return *
this; }
174 if (
fDx < dmin ||
fDy < dmin ||
fDz < dmin)
176 std::ostringstream message;
177 message <<
"Invalid (too small or negative) dimensions for Solid: "
179 <<
" semi-axis x: " <<
fDx <<
"\n"
180 <<
" semi-axis y: " <<
fDy <<
"\n"
181 <<
" semi-axis z: " <<
fDz;
182 G4Exception(
"G4Ellipsoid::CheckParameters()",
"GeomSolids0002",
198 std::ostringstream message;
199 message <<
"Invalid Z cuts for Solid: "
203 G4Exception(
"G4Ellipsoid::CheckParameters()",
"GeomSolids0002",
216 G4double scale = std::sqrt((1. - ratio) * (1 + ratio));
223 G4double scale = std::sqrt((1. - ratio) * (1 + ratio));
300 G4double rr = x * x + y * y + z * z;
339 if (nsurf == 1)
return norm;
340 else if (nsurf > 1)
return norm.
unit();
344 std::ostringstream message;
345 G4int oldprc = message.precision(16);
346 message <<
"Point p is not on surface (!?) of solid: "
348 message <<
"Position:\n";
349 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
350 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
351 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
353 G4Exception(
"G4Ellipsoid::SurfaceNormal(p)",
"GeomSolids1002",
371 G4double rr = x * x + y * y + z * z;
374 if (distR > distZ && rr > 0.)
405 if (safe > 32. *
fRsph)
407 offset = (1. - 1.e-08) * safe - 2. *
fRsph;
426 G4double distZ = std::abs(pzcut) - dzcut;
429 G4double rr = px * px + py * py + pz * pz;
430 G4double pv = px * vx + py * vy + pz * vz;
434 G4double A = vx * vx + vy * vy + vz * vz;
445 G4double dz = std::copysign(dzcut, invz);
446 G4double tzmin = (pzcut - dz) * invz;
447 G4double tzmax = (pzcut + dz) * invz;
451 G4double tmp = -
B - std::copysign(std::sqrt(
D),
B);
486 G4double distR = std::sqrt(x*x + y*y + z*z) -
fR;
490 return (dist < 0.) ? 0. : dist;
509 G4double distZ = std::abs(pzcut) - dzcut;
515 n->set(0., 0., std::copysign(1., pzcut));
526 G4double rr = px * px + py * py + pz * pz;
527 G4double pv = px * vx + py * vy + pz * vz;
544 std::ostringstream message;
545 G4int oldprc = message.precision(16);
546 message <<
"Point p is outside (!?) of solid: "
548 message <<
"Position: " << p <<
G4endl;;
549 message <<
"Direction: " << v;
551 G4Exception(
"G4Ellipsoid::DistanceToOut(p,v)",
"GeomSolids1002",
565 G4double A = vx * vx + vy * vy + vz * vz;
587 G4double tzmax = (vz == 0.) ?
DBL_MAX : (std::copysign(dzcut, vz) - pzcut) / vz;
591 G4double tmp = -
B - std::copysign(std::sqrt(
D),
B);
605 n->set(0., 0., (pznew >
fZMidCut) ? 1. : -1.);
631 G4double distR =
fR - std::sqrt(x*x + y*y + z*z);
635 return (dist < 0.) ? 0. : dist;
662 G4int oldprc = os.precision(16);
663 os <<
"-----------------------------------------------------------\n"
664 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
665 <<
" ===================================================\n"
668 <<
" semi-axis x: " <<
GetDx()/
mm <<
" mm \n"
669 <<
" semi-axis y: " <<
GetDy()/
mm <<
" mm \n"
670 <<
" semi-axis z: " <<
GetDz()/
mm <<
" mm \n"
673 <<
"-----------------------------------------------------------\n";
674 os.precision(oldprc);
708 const G4int Nphi = 100;
709 const G4int Nz = 200;
716 for (
G4int iz = 0; iz < Nz; ++iz)
719 rho[iz] = std::sqrt((1. + z) * (1. - z));
721 rho[Nz] = std::sqrt((1. + ztop) * (1. - ztop));
726 dz = (ztop - zbot) / Nz;
729 for (
G4int iphi = 0; iphi < Nphi; ++iphi)
737 for (
G4int iz = 0; iz < Nz; ++iz)
740 G4double z2 = (iz == Nz - 1) ? ztop : z1 + dz;
747 area += ((p4 - p1).cross(p3 - p2)).mag();
793 G4double Sbot = piAB * Hbot * (2. - Hbot);
794 G4double Stop = piAB * Htop * (2. - Htop);
808 if (select > Sbot) k = 1;
809 if (select > Sbot + Slat) k = 2;
817 G4double scale = std::sqrt(Hbot * (2. - Hbot));
819 p.
set(rho.
x(), rho.
y(), Zbot);
826 for (
G4int i = 0; i < 1000; ++i)
830 G4double rho = std::sqrt((1. + z) * (1. - z));
832 x = rho * std::cos(phi);
833 y = rho * std::sin(phi);
838 G4double mu = std::sqrt(xbc * xbc + yac * yac + zab * zab);
841 p.
set(
A * x,
B * y,
C * z);
846 G4double scale = std::sqrt(Htop * (2. - Htop));
848 p.
set(rho.
x(), rho.
y(), Ztop);
G4double C(G4double temp)
G4double B(G4double temperature)
G4double D(G4double temp)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static const G4double pMax
static const G4double pMin
static constexpr double mm
#define G4MUTEX_INITIALIZER
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
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4Ellipsoid(const G4String &name, G4double xSemiAxis, G4double ySemiAxis, G4double zSemiAxis, G4double zBottomCut=0., G4double zTopCut=0.)
G4double LateralSurfaceArea() const
std::ostream & StreamInfo(std::ostream &os) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4Polyhedron * GetPolyhedron() const
G4Polyhedron * CreatePolyhedron() const
G4double GetZTopCut() const
G4Polyhedron * fpPolyhedron
G4double GetZBottomCut() const
EInside Inside(const G4ThreeVector &p) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4double GetSurfaceArea()
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4bool fRebuildPolyhedron
G4Ellipsoid & operator=(const G4Ellipsoid &rhs)
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4double GetCubicVolume()
G4ThreeVector GetPointOnSurface() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4VisExtent GetExtent() const
G4GeometryType GetEntityType() const
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4VSolid & operator=(const G4VSolid &rhs)
static G4int GetNumberOfRotationSteps()
static const G4double kInfinity
static constexpr double twopi
static constexpr double halfpi
static constexpr double pi
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
const char * name(G4int ptype)