33#if !defined(G4GEOM_USE_UORB)
82 if (
this == &rhs) {
return *
this; }
91 halfRmaxTol = rhs.halfRmaxTol;
92 sqrRmaxPlusTol = rhs.sqrRmaxPlusTol;
93 sqrRmaxMinusTol = rhs.sqrRmaxMinusTol;
111 "Invalid radius < 10*kCarTolerance.");
114 G4double rmaxPlusTol = fRmax + halfRmaxTol;
115 G4double rmaxMinusTol = fRmax - halfRmaxTol;
116 sqrRmaxPlusTol = rmaxPlusTol*rmaxPlusTol;
117 sqrRmaxMinusTol = rmaxMinusTol*rmaxMinusTol;
139 pMin.
set(-radius,-radius,-radius);
140 pMax.
set( radius, radius, radius);
144 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
146 std::ostringstream message;
147 message <<
"Bad bounding box (min >= max) for solid: "
149 <<
"\npMin = " << pMin
150 <<
"\npMax = " << pMax;
151 G4Exception(
"G4Orb::BoundingLimits()",
"GeomMgt0001",
179 return exist = pMin < pMax;
184 static const G4int NTHETA = 8;
185 static const G4int NPHI = 16;
186 static const G4double sinHalfTheta = std::sin(halfpi/NTHETA);
187 static const G4double cosHalfTheta = std::cos(halfpi/NTHETA);
188 static const G4double sinHalfPhi = std::sin(pi/NPHI);
189 static const G4double cosHalfPhi = std::cos(pi/NPHI);
190 static const G4double sinStepTheta = 2.*sinHalfTheta*cosHalfTheta;
191 static const G4double cosStepTheta = 1. - 2.*sinHalfTheta*sinHalfTheta;
192 static const G4double sinStepPhi = 2.*sinHalfPhi*cosHalfPhi;
193 static const G4double cosStepPhi = 1. - 2.*sinHalfPhi*sinHalfPhi;
196 G4double rtheta = radius/cosHalfTheta;
205 k.set(cosCurPhi,sinCurPhi);
207 sinCurPhi = sinCurPhi*cosStepPhi + cosCurPhi*sinStepPhi;
208 cosCurPhi = cosCurPhi*cosStepPhi - sinTmpPhi*sinStepPhi;
213 for (
auto & circle : circles) { circle.resize(NPHI); }
215 G4double sinCurTheta = sinHalfTheta;
216 G4double cosCurTheta = cosHalfTheta;
217 for (
auto & circle : circles)
221 for (
G4int k=0; k<NPHI; ++k)
223 circle[k].set(rho*xy[k].x(),rho*xy[k].y(),z);
226 sinCurTheta = sinCurTheta*cosStepTheta + cosCurTheta*sinStepTheta;
227 cosCurTheta = cosCurTheta*cosStepTheta - sinTmpTheta*sinStepTheta;
231 std::vector<const G4ThreeVectorList *> polygons;
232 polygons.resize(NTHETA);
233 for (
G4int i=0; i<NTHETA; ++i) { polygons[i] = &circles[i]; }
247 if (rr > sqrRmaxPlusTol) {
return kOutside; }
257 return (1/p.
mag())*p;
273 if (rr >= sqrRmaxMinusTol && pv >= 0) {
return kInfinity; }
284 if (
D < 0) {
return kInfinity; }
295 dist = dist - 1.e-8*dist - fRmax;
297 return (dist >= kInfinity) ? kInfinity : dist;
300 if (sqrtD*2 <= halfRmaxTol) {
return kInfinity; }
302 return (dist < halfRmaxTol) ? 0. : dist;
313 return (dist > 0) ? dist : 0.;
332 if (rr >= sqrRmaxMinusTol && pv > 0)
337 *n = p*(1./std::sqrt(rr));
351 G4double tmax = (
D <= 0) ? 0. : std::sqrt(
D) - pv;
352 if (tmax < halfRmaxTol) { tmax = 0.; }
357 *n = ptmax*(1./ptmax.
mag());
371 std::ostringstream message;
372 G4int oldprc = message.precision(16);
373 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
"\n";
374 message <<
"Position:\n";
375 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
376 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
377 message <<
" p.z() = " << p.
z()/mm <<
" mm";
379 G4Exception(
"G4Trap::DistanceToOut(p)",
"GeomSolids1002",
385 return (dist > 0) ? dist : 0.;
403 return new G4Orb(*
this);
412 G4long oldprc = os.precision(16);
413 os <<
"-----------------------------------------------------------\n"
414 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
415 <<
" ===================================================\n"
416 <<
" Solid type: G4Orb\n"
418 <<
" outer radius: " << fRmax/mm <<
" mm \n"
419 <<
"-----------------------------------------------------------\n";
420 os.precision(oldprc);
438 return { fRmax*a*u, fRmax*a*v, fRmax*(2.*b - 1.) };
481 return {-fRmax, fRmax, -fRmax, fRmax, -fRmax, fRmax};
G4TemplateAutoLock< G4Mutex > G4AutoLock
std::vector< G4ThreeVector > G4ThreeVectorList
G4double D(G4double temp)
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
CLHEP::Hep2Vector G4TwoVector
G4GLOB_DLL std::ostream G4cout
double dot(const Hep3Vector &) const
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 BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4CSGSolid(const G4String &pName)
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4Polyhedron * CreatePolyhedron() const override
G4double GetSurfaceArea() override
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
EInside Inside(const G4ThreeVector &p) const override
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const override
G4double GetCubicVolume() override
G4double GetRadius() const
std::ostream & StreamInfo(std::ostream &os) const override
G4Orb(const G4String &pName, G4double pRmax)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
G4ThreeVector GetPointOnSurface() const override
G4GeometryType GetEntityType() const override
G4VisExtent GetExtent() const override
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
G4VSolid * Clone() const override
G4Orb & operator=(const G4Orb &rhs)
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
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...