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)
150 if (
this == &rhs) {
return *
this; }
235 xMin = 2*xoffset - xMax ;
240 xMin = 2*xoffset - xMax ;
265 yMin = 2*yoffset - yMax ;
270 yMin = 2*yoffset - yMax ;
321 G4bool existsAfterClip=
false;
336 existsAfterClip=
true;
358 existsAfterClip=
true;
364 return existsAfterClip;
385 if (std::fabs(p.x())<=x)
388 if (std::fabs(p.y())<=y)
402 if (std::fabs(p.y())<=y)
418 if (std::fabs(p.x())<=x)
423 if (std::fabs(p.y())<=y) in=
kSurface;
438 G4int noSurfaces = 0;
445 secx = std::sqrt(1.0+tanx*tanx);
446 newpx = std::fabs(p.x())-p.z()*tanx;
450 secy = std::sqrt(1.0+tany*tany);
451 newpy = std::fabs(p.y())-p.z()*tany;
454 distx = std::fabs(newpx-widx)/secx;
455 disty = std::fabs(newpy-widy)/secy;
456 distz = std::fabs(std::fabs(p.z())-
fDz);
470 if ( p.x() >= 0.) sumnorm += nX;
476 if ( p.y() >= 0.) sumnorm += nY;
482 if ( p.z() >= 0.) sumnorm += nZ;
485 if ( noSurfaces == 0 )
489 "Point p is not on surface !?" );
493 else if ( noSurfaces == 1 ) norm = sumnorm;
494 else norm = sumnorm.unit();
514 secx=std::sqrt(1.0+tanx*tanx);
515 newpx=std::fabs(p.x())-p.z()*tanx;
519 secy=std::sqrt(1.0+tany*tany);
520 newpy=std::fabs(p.y())-p.z()*tany;
523 distx=std::fabs(newpx-widx)/secx;
524 disty=std::fabs(newpy-widy)/secy;
525 distz=std::fabs(std::fabs(p.z())-
fDz);
603 G4double ss1,ss2,sn1=0.,sn2=0.,Dist;
614 smin = -(
fDz + p.z())/v.z() ;
625 smin = (
fDz - p.z())/v.z() ;
629 if (smin < 0 ) smin = 0 ;
633 if (std::fabs(p.z()) >=
fDz )
return snxt ;
646 s1 = 0.5*(
fDx1+
fDx2) + tanxz*p.z() ;
647 ds1 = v.x() - tanxz*v.z() ;
648 ds2 = v.x() + tanxz*v.z() ;
654 if (ss1 < 0 && ss2 <= 0 )
660 if ( ds2 < 0 ) sn2 = ss2/ds2 ;
665 else if ( ss1 >= 0 && ss2 > 0 )
671 if (ds1 > 0) sn2 = ss1/ds1 ;
677 else if (ss1 >= 0 && ss2 <= 0 )
697 if ( Dist < sn2 ) sn2 = Dist ;
702 else if (ss1 < 0 && ss2 > 0 )
706 if ( ds1 >= 0 || ds2 <= 0 )
714 if (Dist > sn1 ) sn1 = Dist ;
721 if ( sn1 > smin ) smin = sn1 ;
722 if ( sn2 < smax ) smax = sn2 ;
727 if ( smax < smin )
return snxt ;
733 s2 = 0.5*(
fDy1+
fDy2) + tanyz*p.z() ;
734 ds1 = v.y() - tanyz*v.z() ;
735 ds2 = v.y() + tanyz*v.z() ;
739 if ( ss1 < 0 && ss2 <= 0 )
744 if ( ds2 < 0 ) sn2 = ss2/ds2 ;
749 else if ( ss1 >= 0 && ss2 > 0 )
754 if ( ds1 > 0 ) sn2 = ss1/ds1 ;
759 else if (ss1 >= 0 && ss2 <= 0 )
779 if (Dist < sn2) sn2=Dist;
784 else if (ss1 < 0 && ss2 > 0 )
788 if (ds1 >= 0 || ds2 <= 0 )
796 if (Dist > sn1 ) sn1 = Dist ;
803 if ( sn1 > smin) smin = sn1 ;
804 if ( sn2 < smax) smax = sn2 ;
809 if ( smax > smin ) snxt = smin ;
830 safe=std::fabs(p.z())-
fDz;
841 distx=std::fabs(p.x())-(
fDx1+tanxz*zbase);
844 safx=distx/std::sqrt(1.0+tanxz*tanxz);
845 if (safx>safe) safe=safx;
852 disty=std::fabs(p.y())-(
fDy1+tanyz*zbase);
855 safy=disty/std::sqrt(1.0+tanyz*tanyz);
856 if (safy>safe) safe=safy;
878 G4double central,ss1,ss2,ds1,ds2,sn=0.,sn2=0.;
879 G4double tanxz=0.,cosxz=0.,tanyz=0.,cosyz=0.;
881 if (calcNorm) *validNorm=
true;
931 ss1=central+tanxz*p.z()-p.x();
933 ds1=v.x()-tanxz*v.z();
937 ss2=-tanxz*p.z()-p.x()-central;
939 ds2=tanxz*v.z()+v.x();
957 else if (ds1>0&&ds2>=0)
970 else if (ds1>0&&ds2<0)
1008 else if (ss1<=0&&ss2<0)
1035 else if (ss1>0&&ss2>=0)
1079 ss1=central+tanyz*p.z()-p.y();
1081 ds1=v.y()-tanyz*v.z();
1085 ss2=-tanyz*p.z()-p.y()-central;
1087 ds2=tanyz*v.z()+v.y();
1106 else if (ds1>0&&ds2>=0)
1119 else if (ds1>0&&ds2<0)
1157 else if (ss1<=0&&ss2<0)
1184 else if (ss1>0&&ss2>=0)
1225 cosxz=1.0/std::sqrt(1.0+tanxz*tanxz);
1229 cosxz=-1.0/std::sqrt(1.0+tanxz*tanxz);
1233 cosyz=1.0/std::sqrt(1.0+tanyz*tanyz);
1237 cosyz=-1.0/std::sqrt(1.0+tanyz*tanyz);
1250 "Undefined side for valid surface normal to solid.");
1279 G4cout.precision(oldprc) ;
1281 "Point p is outside !?" );
1285 safe=
fDz-std::fabs(p.z());
1293 xdist=
fDx1+tanxz*zbase-std::fabs(p.x());
1294 saf1=xdist/std::sqrt(1.0+tanxz*tanxz);
1298 ydist=
fDy1+tanyz*zbase-std::fabs(p.y());
1299 saf2=ydist/std::sqrt(1.0+tanyz*tanyz);
1303 if (safe>saf1) safe=saf1;
1304 if (safe>saf2) safe=saf2;
1326 vertices->reserve(8);
1350 "Error in allocation of vertices. Out of memory !");
1370 return new G4Trd(*
this);
1379 G4int oldprc = os.precision(16);
1380 os <<
"-----------------------------------------------------------\n"
1381 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1382 <<
" ===================================================\n"
1383 <<
" Solid type: G4Trd\n"
1384 <<
" Parameters: \n"
1385 <<
" half length X, surface -dZ: " <<
fDx1/
mm <<
" mm \n"
1386 <<
" half length X, surface +dZ: " <<
fDx2/
mm <<
" mm \n"
1387 <<
" half length Y, surface -dZ: " <<
fDy1/
mm <<
" mm \n"
1388 <<
" half length Y, surface +dZ: " <<
fDy2/
mm <<
" mm \n"
1389 <<
" half length Z : " <<
fDz/
mm <<
" mm \n"
1390 <<
"-----------------------------------------------------------\n";
1391 os.precision(oldprc);
1406 G4double px, py, pz, tgX, tgY, secX, secY, select, sumS, tmp;
1407 G4double Sxy1, Sxy2, Sxy, Sxz, Syz;
1410 secX = std::sqrt(1+tgX*tgX);
1412 secY = std::sqrt(1+tgY*tgY);
1421 sumS = Sxy + Sxz + Syz;
1440 else if ( ( select - Sxy ) < Sxz )
1445 tmp = fDy1 + (pz +
fDz)*tgY;
1453 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 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
G4Polyhedron * fpPolyhedron
virtual G4Polyhedron * GetPolyhedron() 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