56 using namespace CLHEP;
73 if ( pDx > 0 && pDy > 0 && pDz > 0 )
78 fTalpha = std::tan(pAlpha);
79 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
80 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
84 std::ostringstream message;
85 message <<
"Invalid Length Parameters for Solid: " << GetName() <<
G4endl
86 <<
" pDx, pDy, pDz = "
87 << pDx <<
", " << pDy <<
", " << pDz;
88 G4Exception(
"G4Para::SetAllParameters()",
"GeomSolids0002",
103 if ((pDx<=0) || (pDy<=0) || (pDz<=0))
105 std::ostringstream message;
106 message <<
"Invalid Length Parameters for Solid: " <<
GetName() <<
G4endl
107 <<
" pDx, pDy, pDz = "
108 << pDx <<
", " << pDy <<
", " << pDz;
125 if (!( pt[0].
z()<0 && pt[0].
z()==pt[1].
z() && pt[0].
z()==pt[2].
z() &&
126 pt[0].
z()==pt[3].
z() && pt[4].
z()>0 && pt[4].
z()==pt[5].
z() &&
127 pt[4].
z()==pt[6].
z() && pt[4].
z()==pt[7].
z() &&
128 (pt[0].
z()+pt[4].
z())==0 &&
129 pt[0].y()==pt[1].y() && pt[2].y()==pt[3].y() &&
130 pt[4].y()==pt[5].y() && pt[6].y()==pt[7].y() &&
131 ( pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y() ) == 0 &&
132 ( pt[0].x() + pt[1].x() + pt[4].x() + pt[5].x() ) == 0) )
134 std::ostringstream message;
135 message <<
"Invalid vertice coordinates for Solid: " <<
GetName();
139 fDx = ((pt[3]).x()-(pt[2]).x())*0.5;
140 fDy = ((pt[2]).y()-(pt[1]).y())*0.5;
142 fTalpha = ((pt[2]).x()+(pt[3]).x()-(pt[1]).x()-(pt[0]).x())*0.25/
fDy ;
156 fTalpha(0.), fTthetaCphi(0.), fTthetaSphi(0.)
172 :
G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz),
173 fTalpha(rhs.fTalpha), fTthetaCphi(rhs.fTthetaCphi),
174 fTthetaSphi(rhs.fTthetaSphi)
186 if (
this == &rhs) {
return *
this; }
280 temp[0] = pt[0].y()+(pt[4].y()-pt[0].y())
281 *(zMin-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
282 temp[1] = pt[0].y()+(pt[4].y()-pt[0].y())
283 *(zMax-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
284 temp[2] = pt[2].y()+(pt[6].y()-pt[2].y())
285 *(zMin-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;
286 temp[3] = pt[2].y()+(pt[6].y()-pt[2].y())
287 *(zMax-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;
292 if(temp[i] > yMax) yMax = temp[i] ;
293 if(temp[i] < yMin) yMin = temp[i] ;
316 temp[0] = pt[0].x()+(pt[4].x()-pt[0].x())
317 *(zMin-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
318 temp[1] = pt[0].x()+(pt[4].x()-pt[0].x())
319 *(zMax-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
320 temp[2] = pt[2].x()+(pt[6].x()-pt[2].x())
321 *(zMin-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;
322 temp[3] = pt[2].x()+(pt[6].x()-pt[2].x())
323 *(zMax-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;
324 temp[4] = pt[3].x()+(pt[7].x()-pt[3].x())
325 *(zMin-pt[3].
z())/(pt[7].
z()-pt[3].z()) ;
326 temp[5] = pt[3].x()+(pt[7].x()-pt[3].x())
327 *(zMax-pt[3].
z())/(pt[7].
z()-pt[3].z()) ;
328 temp[6] = pt[1].x()+(pt[5].x()-pt[1].x())
329 *(zMin-pt[1].
z())/(pt[5].
z()-pt[1].z()) ;
330 temp[7] = pt[1].x()+(pt[5].x()-pt[1].x())
331 *(zMax-pt[1].
z())/(pt[5].
z()-pt[1].z()) ;
337 if(temp[i] > xMax) xMax = temp[i] ;
338 if(temp[i] < xMin) xMin = temp[i] ;
387 G4bool existsAfterClip=
false;
402 existsAfterClip=
true;
423 existsAfterClip=
true;
429 flag = existsAfterClip ;
444 yt = std::fabs(yt1) ;
480 G4int noSurfaces = 0;
492 if (fTalpha) {salpha = -calpha*
fTalpha;}
496 xshift = newpx - newpy*
fTalpha;
499 distx = std::fabs(std::fabs(xshift)-
fDx);
500 disty = std::fabs(std::fabs(newpy)-
fDy);
501 distz = std::fabs(std::fabs(p.z())-
fDz);
504 cosntheta = 1/std::sqrt(1+tntheta*tntheta);
516 if ( xshift >= 0.) {sumnorm += nX;}
517 else {sumnorm -= nX;}
522 if ( newpy >= 0.) {sumnorm += nY;}
523 else {sumnorm -= nY;}
528 if ( p.z() >= 0.) {sumnorm += nZ;}
529 else {sumnorm -= nZ;}
531 if ( noSurfaces == 0 )
534 G4Exception(
"G4Para::SurfaceNormal(p)",
"GeomSolids1002",
539 else if ( noSurfaces == 1 ) {norm = sumnorm;}
540 else {norm = sumnorm.unit();}
574 xshift=newpx*calpha+newpy*salpha;
576 distx=std::fabs(std::fabs(xshift)-
fDx*calpha);
577 disty=std::fabs(std::fabs(newpy)-
fDy);
578 distz=std::fabs(std::fabs(p.z())-
fDz);
582 if (distx<distz) {side=
kNX;}
587 if (disty<distz) {side=
kNY;}
597 cosntheta=-1/std::sqrt(1+tntheta*tntheta);
601 cosntheta=1/std::sqrt(1+tntheta*tntheta);
603 norm=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
663 smin=(-
fDz-p.z())/v.z();
676 smin=(
fDz-p.z())/v.z();
685 if (std::fabs(p.z())<=
fDz)
731 if (std::fabs(yt)<=
fDy)
744 if (tmin>smin) smin=tmin;
745 if (tmax<smax) smax=tmax;
785 if (std::fabs(xt)<=
fDx)
795 if (tmin>smin) smin=tmin;
796 if (tmax<smax) smax=tmax;
799 if (smax>0&&smin<smax)
825 G4double distz1,distz2,disty1,disty2,distx1,distx2;
846 disty1=(trany-
fDy)*cosy;
847 disty2=(-
fDy-trany)*cosy;
849 if (disty1>safe) safe=disty1;
850 if (disty2>safe) safe=disty2;
854 distx1=(tranx-
fDx)*cosx;
855 distx2=(-
fDx-tranx)*cosx;
857 if (distx1>safe) safe=distx1;
858 if (distx2>safe) safe=distx2;
878 G4double ycomp,calpha,salpha,tntheta,cosntheta;
1012 cosntheta=1/std::sqrt(1+tntheta*tntheta);
1013 *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1045 cosntheta=-1/std::sqrt(1+tntheta*tntheta);
1046 *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1068 ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
1082 cosntheta=-1/std::sqrt(1+tntheta*tntheta);
1083 *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1086 calpha=1/std::sqrt(1+fTalpha*fTalpha);
1096 cosntheta=1/std::sqrt(1+tntheta*tntheta);
1097 *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1103 "Undefined side for valid surface normal to solid.");
1118 G4double distz1,distz2,disty1,disty2,distx1,distx2;
1131 G4cout.precision(oldprc) ;
1132 G4Exception(
"G4Para::DistanceToOut(p)",
"GeomSolids1002",
1155 disty1=(
fDy-trany)*cosy;
1156 disty2=(
fDy+trany)*cosy;
1158 if (disty1<safe) safe=disty1;
1159 if (disty2<safe) safe=disty2;
1163 distx1=(
fDx-tranx)*cosx;
1164 distx2=(
fDx+tranx)*cosx;
1166 if (distx1<safe) safe=distx1;
1167 if (distx2<safe) safe=distx2;
1189 vertices->reserve(8);
1221 "Error in allocation of vertices. Out of memory !");
1241 return new G4Para(*
this);
1250 G4int oldprc = os.precision(16);
1251 os <<
"-----------------------------------------------------------\n"
1252 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1253 <<
" ===================================================\n"
1254 <<
" Solid type: G4Para\n"
1255 <<
" Parameters: \n"
1256 <<
" half length X: " <<
fDx/
mm <<
" mm \n"
1257 <<
" half length Y: " <<
fDy/
mm <<
" mm \n"
1258 <<
" half length Z: " <<
fDz/
mm <<
" mm \n"
1264 <<
"-----------------------------------------------------------\n";
1265 os.precision(oldprc);
1280 G4double lambda1, lambda2, chose, aOne, aTwo;
1289 w.z()*v.x() - w.x()*v.z(),
1290 w.x()*v.y() - w.y()*v.x());
1292 aOne = 0.5*Area.mag();
1295 t.z()*u.x() - t.x()*u.z(),
1296 t.x()*u.y() - t.y()*u.x());
1298 aTwo = 0.5*Area.mag();
1304 if( (chose>=0.) && (chose < aOne) )
1308 return (p2+lambda1*v+lambda2*w);
1315 return (p0+lambda1*t+lambda2*u);
1329 G4double chose, aOne, aTwo, aThree, aFour, aFive, aSix;
1359 if( (chose>=0.) && (chose<aOne) )
1361 else if(chose>=aOne && chose<aOne+aTwo)
1363 else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
1365 else if(chose>=aOne+aTwo+aThree && chose<aOne+aTwo+aThree+aFour)
1367 else if(chose>=aOne+aTwo+aThree+aFour && chose<aOne+aTwo+aThree+aFour+aFive)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
void ClipCrossSection(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
ThreeVector shoot(const G4int Ap, const G4int Af)
G4ThreeVector GetPointOnSurface() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
EInside Inside(const G4ThreeVector &p) const
void SetAllParameters(G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
static const G4double kInfinity
G4double GetMinYExtent() const
CLHEP::Hep3Vector G4ThreeVector
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
G4bool IsYLimited() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4Para(const G4String &pName, G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
G4bool IsXLimited() const
std::ostream & StreamInfo(std::ostream &os) const
G4Para & operator=(const G4Para &rhs)
virtual void AddSolid(const G4Box &)=0
G4Polyhedron * CreatePolyhedron() const
static double normal(HepRandomEngine *eptr)
G4double GetMaxXExtent() const
G4double GetMinZExtent() const
G4GLOB_DLL std::ostream G4cout
std::vector< G4ThreeVector > G4ThreeVectorList
G4GeometryType GetEntityType() 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
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4double GetMaxZExtent() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
static const double degree
G4double GetMaxYExtent() const
G4double GetMaxExtent(const EAxis pAxis) const
static const G4double alpha
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
G4ThreeVector GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4double &area) const