89 "Invalid radius > 10*kCarTolerance.");
91 fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax);
101 :
G4CSGSolid(a), fRmax(0.), fRmaxTolerance(0.)
118 :
G4CSGSolid(rhs), fRmax(rhs.fRmax), fRmaxTolerance(rhs.fRmaxTolerance)
130 if (
this == &rhs) {
return *
this; }
139 fRmaxTolerance = rhs.fRmaxTolerance;
173 G4double diff1,diff2,delta,maxDiff,newMin,newMax;
254 if ( yoff1 >= 0 && yoff2 >= 0 )
266 delta=fRmax*fRmax-yoff1*yoff1;
267 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
268 delta=fRmax*fRmax-yoff2*yoff2;
269 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
270 maxDiff=(diff1>diff2) ? diff1:diff2;
271 newMin=xoffset-maxDiff;
272 newMax=xoffset+maxDiff;
273 pMin=(newMin<xMin) ? xMin : newMin;
274 pMax=(newMax>xMax) ? xMax : newMax;
280 if (xoff1>=0&&xoff2>=0)
292 delta=fRmax*fRmax-xoff1*xoff1;
293 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
294 delta=fRmax*fRmax-xoff2*xoff2;
295 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
296 maxDiff=(diff1>diff2) ? diff1:diff2;
297 newMin=yoffset-maxDiff;
298 newMax=yoffset+maxDiff;
299 pMin=(newMin<yMin) ? yMin : newMin;
300 pMax=(newMax>yMax) ? yMax : newMax;
310 pMin -= fRmaxTolerance;
311 pMax += fRmaxTolerance;
329 rad2 = p.
x()*p.
x()+p.
y()*p.
y()+p.
z()*p.
z();
337 tolRMax = fRmax - fRmaxTolerance*0.5;
339 if ( radius <= tolRMax ) { in =
kInside; }
342 tolRMax = fRmax + fRmaxTolerance*0.5;
343 if ( radius <= tolRMax ) { in =
kSurface; }
369 "Undefined side for valid surface normal to solid.");
397 radius = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y() + p.
z()*p.
z());
398 pDotV3d = p.
x()*v.
x() + p.
y()*v.
y() + p.
z()*v.
z();
419 c = (radius - fRmax)*(radius + fRmax);
421 if( radius > fRmax-fRmaxTolerance*0.5 )
423 if ( c > fRmaxTolerance*fRmax )
428 d2 = pDotV3d*pDotV3d - c;
432 sd = -pDotV3d - std::sqrt(d2);
437 G4double fTerm = sd - std::fmod(sd,dRmax);
445 return snxt = kInfinity;
450 if ( c > -fRmaxTolerance*fRmax )
452 d2 = pDotV3d*pDotV3d - c;
453 if ( (d2 < fRmaxTolerance*fRmax) || (pDotV3d >= 0) )
455 return snxt = kInfinity;
467 G4Exception(
"G4Orb::DistanceToIn(p,v)",
"GeomSolids1002",
484 radius = std::sqrt(p.
x()*p.
x()+p.
y()*p.
y()+p.
z()*p.
z());
485 safe = radius - fRmax;
486 if( safe < 0 ) { safe = 0.; }
508 rad2 = p.
x()*p.
x() + p.
y()*p.
y() + p.
z()*p.
z();
509 pDotV3d = p.
x()*v.
x() + p.
y()*v.
y() + p.
z()*v.
z();
527 const G4double Rmax_plus = fRmax + fRmaxTolerance*0.5;
530 if ( radius <= Rmax_plus )
532 c = (radius - fRmax)*(radius + fRmax);
534 if ( c < fRmaxTolerance*fRmax )
545 d2 = pDotV3d*pDotV3d - c;
547 if( ( c > -fRmaxTolerance*fRmax) &&
548 ( ( pDotV3d >= 0 ) || ( d2 < 0 )) )
560 snxt = -pDotV3d + std::sqrt(d2);
569 std::ostringstream message;
570 G4int oldprc = message.precision(16);
571 message <<
"Logic error: snxt = kInfinity ???" <<
G4endl
573 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
574 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
576 <<
"Rp = "<< std::sqrt( p.
x()*p.
x()+p.
y()*p.
y()+p.
z()*p.
z() )/mm
579 <<
"v.x() = " << v.
x() <<
G4endl
580 <<
"v.y() = " << v.
y() <<
G4endl
583 <<
"snxt = " << snxt/mm <<
" mm" <<
G4endl;
584 message.precision(oldprc);
585 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
602 std::ostringstream message;
603 G4int oldprc = message.precision(16);
604 message <<
"Undefined side for valid surface normal to solid."
607 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
608 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
611 <<
"v.x() = " << v.
x() <<
G4endl
612 <<
"v.y() = " << v.
y() <<
G4endl
615 <<
"snxt = " << snxt/mm <<
" mm" <<
G4endl;
616 message.precision(oldprc);
617 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
631 G4double safe=0.0,radius = std::sqrt(p.
x()*p.
x()+p.
y()*p.
y()+p.
z()*p.
z());
644 G4Exception(
"G4Orb::DistanceToOut(p)",
"GeomSolids1002",
649 safe = fRmax - radius;
650 if ( safe < 0. ) safe = 0.;
669 return new G4Orb(*
this);
678 G4int oldprc = os.precision(16);
679 os <<
"-----------------------------------------------------------\n"
680 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
681 <<
" ===================================================\n"
682 <<
" Solid type: G4Orb\n"
685 <<
" outer radius: " << fRmax/mm <<
" mm \n"
686 <<
"-----------------------------------------------------------\n";
687 os.precision(oldprc);
709 fRmax*sintheta*sinphi, fRmax*costheta);
CLHEP::Hep3Vector G4ThreeVector
G4DLLIMPORT std::ostream G4cout
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4ThreeVector GetPointOnSurface() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
G4NURBS * CreateNURBS() 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
std::ostream & StreamInfo(std::ostream &os) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4Orb & operator=(const G4Orb &rhs)
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4bool IsYLimited() const
G4double GetMinZExtent() const
G4bool IsXLimited() const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4double GetMaxXExtent() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)