33#if !defined(G4GEOM_USE_UORB)
84 :
G4CSGSolid(rhs), fRmax(rhs.fRmax), halfRmaxTol(rhs.halfRmaxTol),
85 sqrRmaxPlusTol(rhs.sqrRmaxPlusTol), sqrRmaxMinusTol(rhs.sqrRmaxMinusTol)
97 if (
this == &rhs) {
return *
this; }
106 halfRmaxTol = rhs.halfRmaxTol;
107 sqrRmaxPlusTol = rhs.sqrRmaxPlusTol;
108 sqrRmaxMinusTol = rhs.sqrRmaxMinusTol;
126 "Invalid radius < 10*kCarTolerance.");
129 G4double rmaxPlusTol = fRmax + halfRmaxTol;
130 G4double rmaxMinusTol = fRmax - halfRmaxTol;
131 sqrRmaxPlusTol = rmaxPlusTol*rmaxPlusTol;
132 sqrRmaxMinusTol = rmaxMinusTol*rmaxMinusTol;
154 pMin.
set(-radius,-radius,-radius);
155 pMax.
set( radius, radius, radius);
159 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
161 std::ostringstream message;
162 message <<
"Bad bounding box (min >= max) for solid: "
164 <<
"\npMin = " << pMin
165 <<
"\npMax = " << pMax;
166 G4Exception(
"G4Orb::BoundingLimits()",
"GeomMgt0001",
194 return exist = (pMin < pMax) ?
true :
false;
199 static const G4int NTHETA = 8;
200 static const G4int NPHI = 16;
201 static const G4double sinHalfTheta = std::sin(halfpi/NTHETA);
202 static const G4double cosHalfTheta = std::cos(halfpi/NTHETA);
203 static const G4double sinHalfPhi = std::sin(pi/NPHI);
204 static const G4double cosHalfPhi = std::cos(pi/NPHI);
205 static const G4double sinStepTheta = 2.*sinHalfTheta*cosHalfTheta;
206 static const G4double cosStepTheta = 1. - 2.*sinHalfTheta*sinHalfTheta;
207 static const G4double sinStepPhi = 2.*sinHalfPhi*cosHalfPhi;
208 static const G4double cosStepPhi = 1. - 2.*sinHalfPhi*sinHalfPhi;
211 G4double rtheta = radius/cosHalfTheta;
218 for (
G4int k=0; k<NPHI; ++k)
220 xy[k].
set(cosCurPhi,sinCurPhi);
222 sinCurPhi = sinCurPhi*cosStepPhi + cosCurPhi*sinStepPhi;
223 cosCurPhi = cosCurPhi*cosStepPhi - sinTmpPhi*sinStepPhi;
228 for (
G4int i=0; i<NTHETA; ++i) { circles[i].resize(NPHI); }
230 G4double sinCurTheta = sinHalfTheta;
231 G4double cosCurTheta = cosHalfTheta;
232 for (
G4int i=0; i<NTHETA; ++i)
236 for (
G4int k=0; k<NPHI; ++k)
238 circles[i][k].set(rho*xy[k].x(),rho*xy[k].y(),z);
241 sinCurTheta = sinCurTheta*cosStepTheta + cosCurTheta*sinStepTheta;
242 cosCurTheta = cosCurTheta*cosStepTheta - sinTmpTheta*sinStepTheta;
246 std::vector<const G4ThreeVectorList *> polygons;
247 polygons.resize(NTHETA);
248 for (
G4int i=0; i<NTHETA; ++i) { polygons[i] = &circles[i]; }
262 if (rr > sqrRmaxPlusTol)
return kOutside;
272 return (1/p.
mag())*p;
288 if (rr >= sqrRmaxMinusTol && pv >= 0)
return kInfinity;
299 if (
D < 0)
return kInfinity;
310 dist = dist - 1.e-8*dist - fRmax;
312 return (dist >= kInfinity) ? kInfinity : dist;
315 if (sqrtD*2 <= halfRmaxTol)
return kInfinity;
316 return (dist < halfRmaxTol) ? 0. : dist;
327 return (dist > 0) ? dist : 0.;
346 if (rr >= sqrRmaxMinusTol && pv > 0)
351 *n = p*(1./std::sqrt(rr));
365 G4double tmax = (
D <= 0) ? 0. : std::sqrt(
D) - pv;
366 if (tmax < halfRmaxTol) tmax = 0.;
371 *n = ptmax*(1./ptmax.
mag());
385 std::ostringstream message;
386 G4int oldprc = message.precision(16);
387 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
"\n";
388 message <<
"Position:\n";
389 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
390 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
391 message <<
" p.z() = " << p.
z()/mm <<
" mm";
393 G4Exception(
"G4Trap::DistanceToOut(p)",
"GeomSolids1002",
399 return (dist > 0) ? dist : 0.;
417 return new G4Orb(*
this);
426 G4int oldprc = os.precision(16);
427 os <<
"-----------------------------------------------------------\n"
428 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
429 <<
" ===================================================\n"
430 <<
" Solid type: G4Orb\n"
432 <<
" outer radius: " << fRmax/mm <<
" mm \n"
433 <<
"-----------------------------------------------------------\n";
434 os.precision(oldprc);
458 return G4VisExtent (-fRmax, fRmax, -fRmax, fRmax, -fRmax, fRmax);
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4ThreeVector G4RandomDirection()
G4GLOB_DLL std::ostream G4cout
void set(double x, double y)
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)
G4ThreeVector GetPointOnSurface() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4double GetRadius() const
EInside Inside(const G4ThreeVector &p) const
G4Orb(const G4String &pName, G4double pRmax)
G4GeometryType GetEntityType() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4Polyhedron * CreatePolyhedron() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
std::ostream & StreamInfo(std::ostream &os) const
G4VisExtent GetExtent() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
G4Orb & operator=(const G4Orb &rhs)
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const