33#if !defined(G4GEOM_USE_UORB)
91 if (
this == &rhs) {
return *
this; }
100 halfRmaxTol = rhs.halfRmaxTol;
101 sqrRmaxPlusTol = rhs.sqrRmaxPlusTol;
102 sqrRmaxMinusTol = rhs.sqrRmaxMinusTol;
120 "Invalid radius < 10*kCarTolerance.");
123 G4double rmaxPlusTol = fRmax + halfRmaxTol;
124 G4double rmaxMinusTol = fRmax - halfRmaxTol;
125 sqrRmaxPlusTol = rmaxPlusTol*rmaxPlusTol;
126 sqrRmaxMinusTol = rmaxMinusTol*rmaxMinusTol;
148 pMin.
set(-radius,-radius,-radius);
149 pMax.
set( radius, radius, radius);
153 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
155 std::ostringstream message;
156 message <<
"Bad bounding box (min >= max) for solid: "
158 <<
"\npMin = " << pMin
159 <<
"\npMax = " << pMax;
160 G4Exception(
"G4Orb::BoundingLimits()",
"GeomMgt0001",
188 return exist = pMin < pMax;
193 static const G4int NTHETA = 8;
194 static const G4int NPHI = 16;
195 static const G4double sinHalfTheta = std::sin(halfpi/NTHETA);
196 static const G4double cosHalfTheta = std::cos(halfpi/NTHETA);
197 static const G4double sinHalfPhi = std::sin(pi/NPHI);
198 static const G4double cosHalfPhi = std::cos(pi/NPHI);
199 static const G4double sinStepTheta = 2.*sinHalfTheta*cosHalfTheta;
200 static const G4double cosStepTheta = 1. - 2.*sinHalfTheta*sinHalfTheta;
201 static const G4double sinStepPhi = 2.*sinHalfPhi*cosHalfPhi;
202 static const G4double cosStepPhi = 1. - 2.*sinHalfPhi*sinHalfPhi;
205 G4double rtheta = radius/cosHalfTheta;
214 k.set(cosCurPhi,sinCurPhi);
216 sinCurPhi = sinCurPhi*cosStepPhi + cosCurPhi*sinStepPhi;
217 cosCurPhi = cosCurPhi*cosStepPhi - sinTmpPhi*sinStepPhi;
222 for (
auto & circle : circles) { circle.resize(NPHI); }
224 G4double sinCurTheta = sinHalfTheta;
225 G4double cosCurTheta = cosHalfTheta;
226 for (
auto & circle : circles)
230 for (
G4int k=0; k<NPHI; ++k)
232 circle[k].set(rho*xy[k].x(),rho*xy[k].y(),z);
235 sinCurTheta = sinCurTheta*cosStepTheta + cosCurTheta*sinStepTheta;
236 cosCurTheta = cosCurTheta*cosStepTheta - sinTmpTheta*sinStepTheta;
240 std::vector<const G4ThreeVectorList *> polygons;
241 polygons.resize(NTHETA);
242 for (
G4int i=0; i<NTHETA; ++i) { polygons[i] = &circles[i]; }
256 if (rr > sqrRmaxPlusTol)
return kOutside;
266 return (1/p.
mag())*p;
282 if (rr >= sqrRmaxMinusTol && pv >= 0)
return kInfinity;
293 if (
D < 0)
return kInfinity;
304 dist = dist - 1.e-8*dist - fRmax;
306 return (dist >= kInfinity) ? kInfinity : dist;
309 if (sqrtD*2 <= halfRmaxTol)
return kInfinity;
310 return (dist < halfRmaxTol) ? 0. : dist;
321 return (dist > 0) ? dist : 0.;
340 if (rr >= sqrRmaxMinusTol && pv > 0)
345 *n = p*(1./std::sqrt(rr));
359 G4double tmax = (
D <= 0) ? 0. : std::sqrt(
D) - pv;
360 if (tmax < halfRmaxTol) tmax = 0.;
365 *n = ptmax*(1./ptmax.
mag());
379 std::ostringstream message;
380 G4int oldprc = message.precision(16);
381 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
"\n";
382 message <<
"Position:\n";
383 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
384 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
385 message <<
" p.z() = " << p.
z()/mm <<
" mm";
387 G4Exception(
"G4Trap::DistanceToOut(p)",
"GeomSolids1002",
393 return (dist > 0) ? dist : 0.;
411 return new G4Orb(*
this);
420 G4long oldprc = os.precision(16);
421 os <<
"-----------------------------------------------------------\n"
422 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
423 <<
" ===================================================\n"
424 <<
" Solid type: G4Orb\n"
426 <<
" outer radius: " << fRmax/mm <<
" mm \n"
427 <<
"-----------------------------------------------------------\n";
428 os.precision(oldprc);
452 return {-fRmax, fRmax, -fRmax, fRmax, -fRmax, fRmax};
std::vector< G4ThreeVector > G4ThreeVectorList
G4double D(G4double temp)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4ThreeVector G4RandomDirection()
G4GLOB_DLL std::ostream G4cout
double dot(const Hep3Vector &) const
void set(double x, double y, double z)
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 & operator=(const G4CSGSolid &rhs)
G4Polyhedron * CreatePolyhedron() const 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 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
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const