43 #if !defined(G4GEOM_USE_UORB)
59 using namespace CLHEP;
89 "Invalid radius < 10*kCarTolerance.");
101 :
G4CSGSolid(a), fRmax(0.), fRmaxTolerance(0.)
118 :
G4CSGSolid(rhs), fRmax(rhs.fRmax), fRmaxTolerance(rhs.fRmaxTolerance)
130 if (
this == &rhs) {
return *
this; }
163 pMin.set(-radius,-radius,-radius);
164 pMax.set( radius, radius, radius);
168 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
170 std::ostringstream message;
171 message <<
"Bad bounding box (min >= max) for solid: "
173 <<
"\npMin = " << pMin
174 <<
"\npMax = " << pMax;
198 if (
true)
return bbox.
CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
202 return exist = (pMin < pMax) ?
true :
false;
207 static const G4int NTHETA = 8;
208 static const G4int NPHI = 16;
211 static const G4double sinHalfPhi = std::sin(
pi/NPHI);
212 static const G4double cosHalfPhi = std::cos(
pi/NPHI);
213 static const G4double sinStepTheta = 2.*sinHalfTheta*cosHalfTheta;
214 static const G4double cosStepTheta = 1. - 2.*sinHalfTheta*sinHalfTheta;
215 static const G4double sinStepPhi = 2.*sinHalfPhi*cosHalfPhi;
216 static const G4double cosStepPhi = 1. - 2.*sinHalfPhi*sinHalfPhi;
219 G4double rtheta = radius/cosHalfTheta;
226 for (
G4int k=0; k<NPHI; ++k)
228 xy[k].set(cosCurPhi,sinCurPhi);
230 sinCurPhi = sinCurPhi*cosStepPhi + cosCurPhi*sinStepPhi;
231 cosCurPhi = cosCurPhi*cosStepPhi - sinTmpPhi*sinStepPhi;
236 for (
G4int i=0; i<NTHETA; ++i) circles[i].resize(NPHI);
238 G4double sinCurTheta = sinHalfTheta;
239 G4double cosCurTheta = cosHalfTheta;
240 for (
G4int i=0; i<NTHETA; ++i)
244 for (
G4int k=0; k<NPHI; ++k)
246 circles[i][k].set(rho*xy[k].x(),rho*xy[k].y(),z);
249 sinCurTheta = sinCurTheta*cosStepTheta + cosCurTheta*sinStepTheta;
250 cosCurTheta = cosCurTheta*cosStepTheta - sinTmpTheta*sinStepTheta;
254 std::vector<const G4ThreeVectorList *> polygons;
255 polygons.resize(NTHETA);
256 for (
G4int i=0; i<NTHETA; ++i) polygons[i] = &circles[i];
275 rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z();
285 if ( radius <= tolRMax ) { in =
kInside; }
289 if ( radius <= tolRMax ) { in =
kSurface; }
305 G4double radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
310 norm =
G4ThreeVector(p.x()/radius,p.y()/radius,p.z()/radius);
315 "Undefined side for valid surface normal to solid.");
343 radius = std::sqrt(p.x()*p.x() + p.y()*p.y() + p.z()*p.z());
344 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
374 d2 = pDotV3d*pDotV3d - c;
378 sd = -pDotV3d - std::sqrt(d2);
383 G4double fTerm = sd - std::fmod(sd,dRmax);
398 d2 = pDotV3d*pDotV3d - c;
413 G4Exception(
"G4Orb::DistanceToIn(p,v)",
"GeomSolids1002",
430 radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
431 safe = radius -
fRmax;
432 if( safe < 0 ) { safe = 0.; }
454 rad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z();
455 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
476 if ( radius <= Rmax_plus )
491 d2 = pDotV3d*pDotV3d - c;
494 ( ( pDotV3d >= 0 ) || ( d2 < 0 )) )
506 snxt = -pDotV3d + std::sqrt(d2);
515 std::ostringstream message;
516 G4int oldprc = message.precision(16);
517 message <<
"Logic error: snxt = kInfinity ???" << G4endl
518 <<
"Position:" << G4endl << G4endl
519 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
520 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
521 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
522 <<
"Rp = "<< std::sqrt( p.x()*p.x()+p.y()*p.y()+p.z()*p.z() )/
mm
523 <<
" mm" << G4endl << G4endl
524 <<
"Direction:" << G4endl << G4endl
525 <<
"v.x() = " << v.x() << G4endl
526 <<
"v.y() = " << v.y() << G4endl
527 <<
"v.z() = " << v.z() << G4endl << G4endl
528 <<
"Proposed distance :" << G4endl << G4endl
529 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
530 message.precision(oldprc);
531 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
548 std::ostringstream message;
549 G4int oldprc = message.precision(16);
550 message <<
"Undefined side for valid surface normal to solid."
552 <<
"Position:" << G4endl << G4endl
553 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
554 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
555 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
556 <<
"Direction:" << G4endl << G4endl
557 <<
"v.x() = " << v.x() << G4endl
558 <<
"v.y() = " << v.y() << G4endl
559 <<
"v.z() = " << v.z() << G4endl << G4endl
560 <<
"Proposed distance :" << G4endl << G4endl
561 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
562 message.precision(oldprc);
563 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
577 G4double safe=0.0,radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
590 G4Exception(
"G4Orb::DistanceToOut(p)",
"GeomSolids1002",
595 safe =
fRmax - radius;
596 if ( safe < 0. ) safe = 0.;
615 return new G4Orb(*
this);
624 G4int oldprc = os.precision(16);
625 os <<
"-----------------------------------------------------------\n"
626 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
627 <<
" ===================================================\n"
628 <<
" Solid type: G4Orb\n"
631 <<
" outer radius: " <<
fRmax/
mm <<
" mm \n"
632 <<
"-----------------------------------------------------------\n";
633 os.precision(oldprc);
ThreeVector shoot(const G4int Ap, const G4int Af)
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
static constexpr double mm
static const G4double kInfinity
G4Orb & operator=(const G4Orb &rhs)
CLHEP::Hep3Vector G4ThreeVector
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
std::vector< ExP01TrackerHit * > a
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4ThreeVector GetPointOnSurface() const
virtual void AddSolid(const G4Box &)=0
EInside Inside(const G4ThreeVector &p) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4Polyhedron * CreatePolyhedron() const
G4double GetRadius() const
G4Orb(const G4String &pName, G4double pRmax)
std::ostream & StreamInfo(std::ostream &os) const
G4GLOB_DLL std::ostream G4cout
G4GeometryType GetEntityType() const
G4double GetRadialTolerance() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
CLHEP::Hep2Vector G4TwoVector
static constexpr double pi
static constexpr double halfpi
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
G4CSGSolid & operator=(const G4CSGSolid &rhs)
static G4GeometryTolerance * GetInstance()
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const