42 #if !defined(G4GEOM_USE_UORB)
56 using namespace CLHEP;
86 "Invalid radius > 10*kCarTolerance.");
115 :
G4CSGSolid(rhs), fRmax(rhs.fRmax), fRmaxTolerance(rhs.fRmaxTolerance)
128 if (
this == &rhs) {
return *
this; }
172 G4double diff1,diff2,delta,maxDiff,newMin,newMax;
253 if ( yoff1 >= 0 && yoff2 >= 0 )
265 delta=fRmax*fRmax-yoff1*yoff1;
266 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
267 delta=fRmax*fRmax-yoff2*yoff2;
268 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
269 maxDiff=(diff1>diff2) ? diff1:diff2;
270 newMin=xoffset-maxDiff;
271 newMax=xoffset+maxDiff;
272 pMin=(newMin<xMin) ? xMin : newMin;
273 pMax=(newMax>xMax) ? xMax : newMax;
279 if (xoff1>=0&&xoff2>=0)
291 delta=fRmax*fRmax-xoff1*xoff1;
292 diff1=(delta>0.) ? std::sqrt(delta) : 0.;
293 delta=fRmax*fRmax-xoff2*xoff2;
294 diff2=(delta>0.) ? std::sqrt(delta) : 0.;
295 maxDiff=(diff1>diff2) ? diff1:diff2;
296 newMin=yoffset-maxDiff;
297 newMax=yoffset+maxDiff;
298 pMin=(newMin<yMin) ? yMin : newMin;
299 pMax=(newMax>yMax) ? yMax : newMax;
328 rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z();
338 if ( radius <= tolRMax ) { in =
kInside; }
342 if ( radius <= tolRMax ) { in =
kSurface; }
358 G4double radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
363 norm =
G4ThreeVector(p.x()/radius,p.y()/radius,p.z()/radius);
368 "Undefined side for valid surface normal to solid.");
396 radius = std::sqrt(p.x()*p.x() + p.y()*p.y() + p.z()*p.z());
397 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
427 d2 = pDotV3d*pDotV3d - c;
431 sd = -pDotV3d - std::sqrt(d2);
436 G4double fTerm = sd - std::fmod(sd,dRmax);
451 d2 = pDotV3d*pDotV3d - c;
466 G4Exception(
"G4Orb::DistanceToIn(p,v)",
"GeomSolids1002",
483 radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
484 safe = radius -
fRmax;
485 if( safe < 0 ) { safe = 0.; }
507 rad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z();
508 pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
529 if ( radius <= Rmax_plus )
544 d2 = pDotV3d*pDotV3d - c;
547 ( ( pDotV3d >= 0 ) || ( d2 < 0 )) )
559 snxt = -pDotV3d + std::sqrt(d2);
568 std::ostringstream message;
569 G4int oldprc = message.precision(16);
570 message <<
"Logic error: snxt = kInfinity ???" << G4endl
571 <<
"Position:" << G4endl << G4endl
572 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
573 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
574 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
575 <<
"Rp = "<< std::sqrt( p.x()*p.x()+p.y()*p.y()+p.z()*p.z() )/
mm
576 <<
" mm" << G4endl << G4endl
577 <<
"Direction:" << G4endl << G4endl
578 <<
"v.x() = " << v.x() << G4endl
579 <<
"v.y() = " << v.y() << G4endl
580 <<
"v.z() = " << v.z() << G4endl << G4endl
581 <<
"Proposed distance :" << G4endl << G4endl
582 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
583 message.precision(oldprc);
584 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
601 std::ostringstream message;
602 G4int oldprc = message.precision(16);
603 message <<
"Undefined side for valid surface normal to solid."
605 <<
"Position:" << G4endl << G4endl
606 <<
"p.x() = " << p.x()/
mm <<
" mm" << G4endl
607 <<
"p.y() = " << p.y()/
mm <<
" mm" << G4endl
608 <<
"p.z() = " << p.z()/
mm <<
" mm" << G4endl << G4endl
609 <<
"Direction:" << G4endl << G4endl
610 <<
"v.x() = " << v.x() << G4endl
611 <<
"v.y() = " << v.y() << G4endl
612 <<
"v.z() = " << v.z() << G4endl << G4endl
613 <<
"Proposed distance :" << G4endl << G4endl
614 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
615 message.precision(oldprc);
616 G4Exception(
"G4Orb::DistanceToOut(p,v,..)",
"GeomSolids1002",
630 G4double safe=0.0,radius = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
643 G4Exception(
"G4Orb::DistanceToOut(p)",
"GeomSolids1002",
648 safe =
fRmax - radius;
649 if ( safe < 0. ) safe = 0.;
668 return new G4Orb(*
this);
677 G4int oldprc = os.precision(16);
678 os <<
"-----------------------------------------------------------\n"
679 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
680 <<
" ===================================================\n"
681 <<
" Solid type: G4Orb\n"
684 <<
" outer radius: " <<
fRmax/
mm <<
" mm \n"
685 <<
"-----------------------------------------------------------\n";
686 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
G4Polyhedron * fpPolyhedron
G4double GetRadialTolerance() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
virtual G4Polyhedron * GetPolyhedron() const
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