42 #if !defined(G4GEOM_USE_UORB)
56 using namespace CLHEP;
86 "Invalid radius > 10*kCarTolerance.");
115 :
G4CSGSolid(rhs), fRmax(rhs.fRmax), fRmaxTolerance(rhs.fRmaxTolerance)
127 if (
this == &rhs) {
return *
this; }
170 G4double diff1,diff2,delta,maxDiff,newMin,newMax;
251 if ( yoff1 >= 0 && yoff2 >= 0 )
263 delta=fRmax*fRmax-yoff1*yoff1;
264 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
265 delta=fRmax*fRmax-yoff2*yoff2;
266 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
267 maxDiff=(diff1>diff2) ? diff1:diff2;
268 newMin=xoffset-maxDiff;
269 newMax=xoffset+maxDiff;
270 pMin=(newMin<xMin) ? xMin : newMin;
271 pMax=(newMax>xMax) ? xMax : newMax;
277 if (xoff1>=0&&xoff2>=0)
289 delta=fRmax*fRmax-xoff1*xoff1;
290 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
291 delta=fRmax*fRmax-xoff2*xoff2;
292 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
293 maxDiff=(diff1>diff2) ? diff1:diff2;
294 newMin=yoffset-maxDiff;
295 newMax=yoffset+maxDiff;
296 pMin=(newMin<yMin) ? yMin : newMin;
297 pMax=(newMax>yMax) ? yMax : newMax;
326 rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z();
336 if ( radius <= tolRMax ) { in =
kInside; }
340 if ( radius <= tolRMax ) { in =
kSurface; }
356 G4double radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
361 norm =
G4ThreeVector(p.x()/radius,p.y()/radius,p.z()/radius);
366 "Undefined side for valid surface normal to solid.");
394 radius = std::sqrt(p.x()*p.x() + p.y()*p.y() + p.z()*p.z());
395 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
425 d2 = pDotV3d*pDotV3d - c;
429 sd = -pDotV3d - std::sqrt(d2);
434 G4double fTerm = sd - std::fmod(sd,dRmax);
449 d2 = pDotV3d*pDotV3d - c;
464 G4Exception(
"G4Orb::DistanceToIn(p,v)",
"GeomSolids1002",
481 radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
482 safe = radius -
fRmax;
483 if( safe < 0 ) { safe = 0.; }
505 rad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z();
506 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
527 if ( radius <= Rmax_plus )
542 d2 = pDotV3d*pDotV3d - c;
545 ( ( pDotV3d >= 0 ) || ( d2 < 0 )) )
557 snxt = -pDotV3d + std::sqrt(d2);
566 std::ostringstream message;
567 G4int oldprc = message.precision(16);
568 message <<
"Logic error: snxt = kInfinity ???" << G4endl
569 <<
"Position:" << G4endl << G4endl
570 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
571 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
572 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
573 <<
"Rp = "<< std::sqrt( p.x()*p.x()+p.y()*p.y()+p.z()*p.z() )/
mm
574 <<
" mm" << G4endl << G4endl
575 <<
"Direction:" << G4endl << G4endl
576 <<
"v.x() = " << v.x() << G4endl
577 <<
"v.y() = " << v.y() << G4endl
578 <<
"v.z() = " << v.z() << G4endl << G4endl
579 <<
"Proposed distance :" << G4endl << G4endl
580 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
581 message.precision(oldprc);
582 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
599 std::ostringstream message;
600 G4int oldprc = message.precision(16);
601 message <<
"Undefined side for valid surface normal to solid."
603 <<
"Position:" << G4endl << G4endl
604 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
605 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
606 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
607 <<
"Direction:" << G4endl << G4endl
608 <<
"v.x() = " << v.x() << G4endl
609 <<
"v.y() = " << v.y() << G4endl
610 <<
"v.z() = " << v.z() << G4endl << G4endl
611 <<
"Proposed distance :" << G4endl << G4endl
612 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
613 message.precision(oldprc);
614 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
628 G4double safe=0.0,radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
641 G4Exception(
"G4Orb::DistanceToOut(p)",
"GeomSolids1002",
646 safe =
fRmax - radius;
647 if ( safe < 0. ) safe = 0.;
666 return new G4Orb(*
this);
675 G4int oldprc = os.precision(16);
676 os <<
"-----------------------------------------------------------\n"
677 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
678 <<
" ===================================================\n"
679 <<
" Solid type: G4Orb\n"
682 <<
" outer radius: " <<
fRmax/
mm <<
" mm \n"
683 <<
"-----------------------------------------------------------\n";
684 os.precision(oldprc);
ThreeVector shoot(const G4int Ap, const G4int Af)
static const G4double kInfinity
G4Orb & operator=(const G4Orb &rhs)
G4double GetMinYExtent() const
CLHEP::Hep3Vector G4ThreeVector
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4bool IsYLimited() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4bool IsXLimited() 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
G4Orb(const G4String &pName, G4double pRmax)
std::ostream & StreamInfo(std::ostream &os) const
G4double GetMaxXExtent() const
G4double GetMinZExtent() const
G4GLOB_DLL std::ostream G4cout
G4GeometryType GetEntityType() const
G4double GetRadialTolerance() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4double GetMinXExtent() const
G4double GetMaxZExtent() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double GetMaxYExtent() const
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)
G4bool IsZLimited() const
static G4GeometryTolerance * GetInstance()
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const