44 #if !defined(G4GEOM_USE_UTRD)
53 using namespace CLHEP;
76 if ( pdx1>0&&pdx2>0&&pdy1>0&&pdy2>0&&pdz>0 )
84 if ( pdx1>=0 && pdx2>=0 && pdy1>=0 && pdy2>=0 && pdz>=0 )
98 std::ostringstream message;
99 message <<
"Invalid negative dimensions for Solid: " <<
GetName()
101 <<
" X - " << pdx1 <<
", " << pdx2 <<
G4endl
102 <<
" Y - " << pdy1 <<
", " << pdy2 <<
G4endl
119 :
G4CSGSolid(a), fDx1(0.), fDx2(0.), fDy1(0.), fDy2(0.), fDz(0.)
136 :
G4CSGSolid(rhs), fDx1(rhs.fDx1), fDx2(rhs.fDx2),
137 fDy1(rhs.fDy1), fDy2(rhs.fDy2), fDz(rhs.fDz)
149 if (
this == &rhs) {
return *
this; }
233 xMin = 2*xoffset - xMax ;
238 xMin = 2*xoffset - xMax ;
263 yMin = 2*yoffset - yMax ;
268 yMin = 2*yoffset - yMax ;
319 G4bool existsAfterClip=
false;
334 existsAfterClip=
true;
356 existsAfterClip=
true;
362 return existsAfterClip;
383 if (std::fabs(p.x())<=x)
386 if (std::fabs(p.y())<=y)
400 if (std::fabs(p.y())<=y)
416 if (std::fabs(p.x())<=x)
421 if (std::fabs(p.y())<=y) in=
kSurface;
436 G4int noSurfaces = 0;
443 secx = std::sqrt(1.0+tanx*tanx);
444 newpx = std::fabs(p.x())-p.z()*tanx;
448 secy = std::sqrt(1.0+tany*tany);
449 newpy = std::fabs(p.y())-p.z()*tany;
452 distx = std::fabs(newpx-widx)/secx;
453 disty = std::fabs(newpy-widy)/secy;
454 distz = std::fabs(std::fabs(p.z())-
fDz);
468 if ( p.x() >= 0.) sumnorm += nX;
474 if ( p.y() >= 0.) sumnorm += nY;
480 if ( p.z() >= 0.) sumnorm += nZ;
483 if ( noSurfaces == 0 )
487 "Point p is not on surface !?" );
491 else if ( noSurfaces == 1 ) norm = sumnorm;
492 else norm = sumnorm.unit();
512 secx=std::sqrt(1.0+tanx*tanx);
513 newpx=std::fabs(p.x())-p.z()*tanx;
517 secy=std::sqrt(1.0+tany*tany);
518 newpy=std::fabs(p.y())-p.z()*tany;
521 distx=std::fabs(newpx-widx)/secx;
522 disty=std::fabs(newpy-widy)/secy;
523 distz=std::fabs(std::fabs(p.z())-
fDz);
601 G4double ss1,ss2,sn1=0.,sn2=0.,Dist;
612 smin = -(
fDz + p.z())/v.z() ;
623 smin = (
fDz - p.z())/v.z() ;
627 if (smin < 0 ) smin = 0 ;
631 if (std::fabs(p.z()) >=
fDz )
return snxt ;
644 s1 = 0.5*(
fDx1+
fDx2) + tanxz*p.z() ;
645 ds1 = v.x() - tanxz*v.z() ;
646 ds2 = v.x() + tanxz*v.z() ;
652 if (ss1 < 0 && ss2 <= 0 )
658 if ( ds2 < 0 ) sn2 = ss2/ds2 ;
663 else if ( ss1 >= 0 && ss2 > 0 )
669 if (ds1 > 0) sn2 = ss1/ds1 ;
675 else if (ss1 >= 0 && ss2 <= 0 )
695 if ( Dist < sn2 ) sn2 = Dist ;
700 else if (ss1 < 0 && ss2 > 0 )
704 if ( ds1 >= 0 || ds2 <= 0 )
712 if (Dist > sn1 ) sn1 = Dist ;
719 if ( sn1 > smin ) smin = sn1 ;
720 if ( sn2 < smax ) smax = sn2 ;
725 if ( smax < smin )
return snxt ;
731 s2 = 0.5*(
fDy1+
fDy2) + tanyz*p.z() ;
732 ds1 = v.y() - tanyz*v.z() ;
733 ds2 = v.y() + tanyz*v.z() ;
737 if ( ss1 < 0 && ss2 <= 0 )
742 if ( ds2 < 0 ) sn2 = ss2/ds2 ;
747 else if ( ss1 >= 0 && ss2 > 0 )
752 if ( ds1 > 0 ) sn2 = ss1/ds1 ;
757 else if (ss1 >= 0 && ss2 <= 0 )
777 if (Dist < sn2) sn2=Dist;
782 else if (ss1 < 0 && ss2 > 0 )
786 if (ds1 >= 0 || ds2 <= 0 )
794 if (Dist > sn1 ) sn1 = Dist ;
801 if ( sn1 > smin) smin = sn1 ;
802 if ( sn2 < smax) smax = sn2 ;
807 if ( smax > smin ) snxt = smin ;
828 safe=std::fabs(p.z())-
fDz;
839 distx=std::fabs(p.x())-(
fDx1+tanxz*zbase);
842 safx=distx/std::sqrt(1.0+tanxz*tanxz);
843 if (safx>safe) safe=safx;
850 disty=std::fabs(p.y())-(
fDy1+tanyz*zbase);
853 safy=disty/std::sqrt(1.0+tanyz*tanyz);
854 if (safy>safe) safe=safy;
876 G4double central,ss1,ss2,ds1,ds2,sn=0.,sn2=0.;
877 G4double tanxz=0.,cosxz=0.,tanyz=0.,cosyz=0.;
879 if (calcNorm) *validNorm=
true;
929 ss1=central+tanxz*p.z()-p.x();
931 ds1=v.x()-tanxz*v.z();
935 ss2=-tanxz*p.z()-p.x()-central;
937 ds2=tanxz*v.z()+v.x();
955 else if (ds1>0&&ds2>=0)
968 else if (ds1>0&&ds2<0)
1006 else if (ss1<=0&&ss2<0)
1033 else if (ss1>0&&ss2>=0)
1077 ss1=central+tanyz*p.z()-p.y();
1079 ds1=v.y()-tanyz*v.z();
1083 ss2=-tanyz*p.z()-p.y()-central;
1085 ds2=tanyz*v.z()+v.y();
1104 else if (ds1>0&&ds2>=0)
1117 else if (ds1>0&&ds2<0)
1155 else if (ss1<=0&&ss2<0)
1182 else if (ss1>0&&ss2>=0)
1223 cosxz=1.0/std::sqrt(1.0+tanxz*tanxz);
1227 cosxz=-1.0/std::sqrt(1.0+tanxz*tanxz);
1231 cosyz=1.0/std::sqrt(1.0+tanyz*tanyz);
1235 cosyz=-1.0/std::sqrt(1.0+tanyz*tanyz);
1248 "Undefined side for valid surface normal to solid.");
1277 G4cout.precision(oldprc) ;
1279 "Point p is outside !?" );
1283 safe=
fDz-std::fabs(p.z());
1291 xdist=
fDx1+tanxz*zbase-std::fabs(p.x());
1292 saf1=xdist/std::sqrt(1.0+tanxz*tanxz);
1296 ydist=
fDy1+tanyz*zbase-std::fabs(p.y());
1297 saf2=ydist/std::sqrt(1.0+tanyz*tanyz);
1301 if (safe>saf1) safe=saf1;
1302 if (safe>saf2) safe=saf2;
1324 vertices->reserve(8);
1348 "Error in allocation of vertices. Out of memory !");
1368 return new G4Trd(*
this);
1377 G4int oldprc = os.precision(16);
1378 os <<
"-----------------------------------------------------------\n"
1379 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1380 <<
" ===================================================\n"
1381 <<
" Solid type: G4Trd\n"
1382 <<
" Parameters: \n"
1383 <<
" half length X, surface -dZ: " <<
fDx1/
mm <<
" mm \n"
1384 <<
" half length X, surface +dZ: " <<
fDx2/
mm <<
" mm \n"
1385 <<
" half length Y, surface -dZ: " <<
fDy1/
mm <<
" mm \n"
1386 <<
" half length Y, surface +dZ: " <<
fDy2/
mm <<
" mm \n"
1387 <<
" half length Z : " <<
fDz/
mm <<
" mm \n"
1388 <<
"-----------------------------------------------------------\n";
1389 os.precision(oldprc);
1404 G4double px, py, pz, tgX, tgY, secX, secY, select, sumS, tmp;
1405 G4double Sxy1, Sxy2, Sxy, Sxz, Syz;
1408 secX = std::sqrt(1+tgX*tgX);
1410 secY = std::sqrt(1+tgY*tgY);
1419 sumS = Sxy + Sxz + Syz;
1438 else if ( ( select - Sxy ) < Sxz )
1443 tmp = fDy1 + (pz +
fDz)*tgY;
1451 tmp = fDy1 + (pz +
fDz)*tgY;
void DescribeYourselfTo(G4VGraphicsScene &scene) const
void SetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
void ClipCrossSection(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
static const G4double kInfinity
G4double GetMinYExtent() const
CLHEP::Hep3Vector G4ThreeVector
G4bool fRebuildPolyhedron
G4bool IsYLimited() const
std::ostream & StreamInfo(std::ostream &os) const
G4GeometryType GetEntityType() const
G4bool IsXLimited() const
G4double fcos(G4double arg)
virtual void AddSolid(const G4Box &)=0
G4ThreeVector GetPointOnSurface() const
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
G4double GetMaxXExtent() const
G4double GetMinZExtent() const
G4GLOB_DLL std::ostream G4cout
G4Polyhedron * CreatePolyhedron() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
std::vector< G4ThreeVector > G4ThreeVectorList
EInside Inside(const G4ThreeVector &p) 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 DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
void CheckAndSetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4Trd & operator=(const G4Trd &rhs)
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetMaxYExtent() const
G4Trd(const G4String &pName, G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4double GetMaxExtent(const EAxis pAxis) const
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4bool IsZLimited() const
void ClipBetweenSections(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
G4double GetMinExtent(const EAxis pAxis) const