61 using namespace CLHEP;
70 :
G4VSolid( name ), fCubicVolume(0.), fSurfaceArea(0.),
71 fRebuildPolyhedron(false), fpPolyhedron(0)
86 :
G4VSolid(a), dx(0.), dy(0.), dz(0.), halfTol(0.),
87 fCubicVolume(0.), fSurfaceArea(0.),
88 fRebuildPolyhedron(false), fpPolyhedron(0)
106 :
G4VSolid(rhs), dx(rhs.dx), dy(rhs.dy), dz(rhs.dz), halfTol(rhs.halfTol),
107 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
108 fRebuildPolyhedron(false), fpPolyhedron(0)
120 if (
this == &rhs) {
return *
this; }
167 G4double rFudge = 1.0/std::cos(0.5*sigPhi);
179 cosPhi = std::cos(phi),
180 sinPhi = std::sin(phi);
182 v1( dxFudge*cosPhi, dyFudge*sinPhi, -
dz ),
189 if (numPhi == 1) phi = 0;
190 cosPhi = std::cos(phi),
191 sinPhi = std::sin(phi);
219 phiPoly.
SetNormal( (v1-v0).cross(w0-v0).unit() );
229 }
while( --numPhi > 0 );
303 G4double distZ = std::fabs(std::fabs(p.z()) -
dz);
308 if ( (distZ <
halfTol ) && ( distR1 <= 1 ) )
313 if( (distR1 <= 1 ) && ( distR2 >= 1 ) )
319 if ( noSurfaces == 0 )
322 G4Exception(
"G4EllipticalTube::SurfaceNormal(p)",
"GeomSolids1002",
327 else if ( noSurfaces == 1 ) { norm = sumnorm; }
328 else { norm = sumnorm.unit(); }
351 if (distZ*distZ < distR2)
415 yi = p.y() + q*v.y();
425 return (sigz < -
halfTol) ? q : 0;
427 else if (xi*
dy*
dy*v.x() + yi*
dx*
dx*v.y() >= 0)
454 yi = p.y() + q*v.y();
458 return (sigz > -
halfTol) ? q : 0;
460 else if (xi*
dy*
dy*v.x() + yi*
dx*
dx*v.y() >= 0)
484 if (p.x()*
dy*
dy*v.x() + p.y()*
dx*
dx*v.y() < 0)
return 0;
556 G4double xe = q*p.x(), ye = q*p.y();
562 G4double tnorm = std::sqrt( tx*tx + ty*ty );
567 G4double distR = ( (p.x()-xe)*ty - (p.y()-ye)*tx )/tnorm;
577 return std::sqrt( (p.z()+
dz)*(p.z()+
dz) + distR*distR );
579 return std::sqrt( (p.z()-
dz)*(p.z()-
dz) + distR*distR );
602 if (calcNorm) { *validNorm =
true; }
616 sBest = -(p.z()+
dz)/v.z();
623 if (calcNorm) { *norm = normHere; }
648 if (calcNorm) { *norm = normHere; }
655 if (q < sBest) { sBest = q; nBest = normHere; }
669 std::ostringstream message;
670 G4int oldprc = message.precision(16) ;
671 message <<
"Point p is outside !?" <<
G4endl
673 <<
" p.x() = " << p.x()/
mm <<
" mm" <<
G4endl
674 <<
" p.y() = " << p.y()/
mm <<
" mm" <<
G4endl
675 <<
" p.z() = " << p.z()/
mm <<
" mm" <<
G4endl
677 <<
" v.x() = " << v.x() <<
G4endl
678 <<
" v.y() = " << v.y() <<
G4endl
679 <<
" v.z() = " << v.z() <<
G4endl
680 <<
"Proposed distance :" <<
G4endl
681 <<
" snxt = " << sBest/
mm <<
" mm";
682 message.precision(oldprc) ;
683 G4Exception(
"G4EllipticalTube::DistanceToOut(p,v,...)",
686 if (calcNorm) { *norm = nBest; }
689 else if (q[n-1] > sBest)
691 if (calcNorm) { *norm = nBest; }
713 if (p.x()*
dy*
dy*v.x() + p.y()*
dx*
dx*v.y() > 0)
return 0;
748 if (radical < +
DBL_MIN)
return 0;
751 if (p.x() < 0) xi = -xi;
756 radical = 1.0 - p.x()*p.x()/
dx/
dx;
757 if (radical < +
DBL_MIN)
return 0;
760 if (p.y() < 0) yi = -yi;
769 G4double normi = std::sqrt( xdi*xdi + ydi*ydi );
774 G4double q = 0.5*(xdi*(p.y()-yi) - ydi*(p.x()-xi));
775 if (xi*yi < 0) q = -q;
777 if (q < sBest) sBest = q;
782 return sBest <
halfTol ? 0 : sBest;
826 if (radical < -
DBL_MIN)
return 0;
837 radical = std::sqrt(radical);
839 G4double q = -0.5*( b + (b < 0 ? -radical : +radical) );
842 if (sa < sb) { ss[0] = sa; ss[1] = sb; }
else { ss[0] = sb; ss[1] = sa; }
852 return G4String(
"G4EllipticalTube");
890 G4int oldprc = os.precision(16);
891 os <<
"-----------------------------------------------------------\n"
892 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
893 <<
" ===================================================\n"
894 <<
" Solid type: G4EllipticalTube\n"
896 <<
" length Z: " <<
dz/
mm <<
" mm \n"
897 <<
" surface equation in X and Y: \n"
898 <<
" (X / " <<
dx <<
")^2 + (Y / " <<
dy <<
")^2 = 1 \n"
899 <<
"-----------------------------------------------------------\n";
900 os.precision(oldprc);
914 G4double xRand, yRand, zRand, phi, cosphi, sinphi, zArea, cArea,p, chose;
917 cosphi = std::cos(phi);
918 sinphi = std::sin(phi);
938 if( (chose>=0) && (chose < cArea) )
942 else if( (chose >= cArea) && (chose < cArea + zArea) )
945 yRand = std::sqrt(1.-
sqr(xRand/
dx));
952 yRand = std::sqrt(1.-
sqr(xRand/
dx));
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
ThreeVector shoot(const G4int Ap, const G4int Af)
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
G4double GetSurfaceArea()
virtual ~G4EllipticalTube()
G4bool GetExtent(G4double &min, G4double &max) const
virtual G4double GetCubicVolume()
G4ThreeVector GetPointOnSurface() const
void SetNormal(const G4ThreeVector &newNormal)
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
virtual void AddVertexInOrder(const G4ThreeVector vertex)
virtual void ClearAllVertices()
G4VisExtent GetExtent() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
virtual void AddSolid(const G4Box &)=0
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
#define G4MUTEX_INITIALIZER
G4Polyhedron * GetPolyhedron() const
G4Polyhedron * fpPolyhedron
static double normal(HepRandomEngine *eptr)
G4EllipticalTube & operator=(const G4EllipticalTube &rhs)
G4double CheckXY(const G4double x, const G4double y, const G4double toler) const
G4int IntersectXY(const G4ThreeVector &p, const G4ThreeVector &v, G4double s[2]) const
G4double GetCubicVolume()
void AddSurface(const G4ClippablePolygon &surface)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
std::ostream & StreamInfo(std::ostream &os) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4Polyhedron * CreatePolyhedron() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4VSolid & operator=(const G4VSolid &rhs)
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4EllipticalTube(const G4String &name, G4double theDx, G4double theDy, G4double theDz)
G4bool fRebuildPolyhedron
G4GeometryType GetEntityType() const
virtual G4double GetSurfaceArea()
const G4int kMaxMeshSections
EInside Inside(const G4ThreeVector &p) const