71 :
G4Tubs(pName, pRMin, pRMax, pDz, pSPhi, pDPhi),
80 if(pDPhi<twopi) { fPhiFullCutTube=
false; }
82 if ( ( !pLowNorm.
x()) && ( !pLowNorm.
y())
83 && ( !pHighNorm.
x()) && (!pHighNorm.
y()) )
85 std::ostringstream message;
86 message <<
"Inexisting Low/High Normal to Z plane or Parallel to Z."
88 <<
"Normals to Z plane are (" << pLowNorm <<
" and "
89 << pHighNorm <<
") in solid: " <<
GetName();
90 G4Exception(
"G4CutTubs::G4CutTubs()",
"GeomSolids1001",
96 if (pLowNorm.
mag2() == 0.) { pLowNorm.
setZ(-1.); }
97 if (pHighNorm.
mag2()== 0.) { pHighNorm.
setZ(1.); }
102 if (pLowNorm.
mag2() != 1.) { pLowNorm = pLowNorm.
unit(); }
103 if (pHighNorm.
mag2()!= 1.) { pHighNorm = pHighNorm.
unit(); }
107 if( (pLowNorm.
mag2() != 0.) && (pHighNorm.
mag2()!= 0. ) )
109 if( ( pLowNorm.
z()>= 0. ) || ( pHighNorm.
z() <= 0.))
111 std::ostringstream message;
112 message <<
"Invalid Low or High Normal to Z plane; "
113 "has to point outside Solid." <<
G4endl
114 <<
"Invalid Norm to Z plane (" << pLowNorm <<
" or "
115 << pHighNorm <<
") in solid: " <<
GetName();
116 G4Exception(
"G4CutTubs::G4CutTubs()",
"GeomSolids0002",
121 fHighNorm = pHighNorm;
127 std::ostringstream message;
128 message <<
"Invalid Low or High Normal to Z plane; "
129 <<
"Crossing Cutted Planes." <<
G4endl
130 <<
"Invalid Norm to Z plane (" << pLowNorm <<
" and "
131 << pHighNorm <<
") in solid: " <<
GetName();
132 G4Exception(
"G4CutTubs::G4CutTubs()",
"GeomSolids0002",
145 fPhiFullCutTube(false)
163 fLowNorm(rhs.fLowNorm), fHighNorm(rhs.fHighNorm),
164 fPhiFullCutTube(rhs.fPhiFullCutTube)
176 if (
this == &rhs) {
return *
this; }
184 fLowNorm = rhs.fLowNorm; fHighNorm = rhs.fHighNorm;
185 fPhiFullCutTube = rhs.fPhiFullCutTube;
211 G4double diff1, diff2, maxDiff, newMin, newMax;
212 G4double xoff1, xoff2, yoff1, yoff2, delta;
215 xMin = xoffset -
fRMax;
216 xMax = xoffset +
fRMax;
238 yMin = yoffset -
fRMax;
239 yMax = yoffset +
fRMax;
288 yoff1 = yoffset - yMin;
289 yoff2 = yMax - yoffset;
291 if ( (yoff1 >= 0) && (yoff2 >= 0) )
302 diff1 = (delta>0.) ? std::sqrt(delta) : 0.;
304 diff2 = (delta>0.) ? std::sqrt(delta) : 0.;
305 maxDiff = (diff1 > diff2) ? diff1:diff2;
306 newMin = xoffset - maxDiff;
307 newMax = xoffset + maxDiff;
308 pMin = (newMin < xMin) ? xMin : newMin;
309 pMax = (newMax > xMax) ? xMax : newMax;
315 xoff1 = xoffset - xMin;
316 xoff2 = xMax - xoffset;
318 if ( (xoff1 >= 0) && (xoff2 >= 0) )
329 diff1 = (delta>0.) ? std::sqrt(delta) : 0.;
331 diff2 = (delta>0.) ? std::sqrt(delta) : 0.;
332 maxDiff = (diff1 > diff2) ? diff1 : diff2;
333 newMin = yoffset - maxDiff;
334 newMax = yoffset + maxDiff;
335 pMin = (newMin < yMin) ? yMin : newMin;
336 pMax = (newMax > yMax) ? yMax : newMax;
355 G4int i, noEntries, noBetweenSections4;
356 G4bool existsAfterClip =
false;
362 noEntries = vertices->size();
363 noBetweenSections4 = noEntries - 4;
365 for ( i = 0 ; i < noEntries ; i += 4 )
369 for ( i = 0 ; i < noBetweenSections4 ; i += 4 )
373 if ( (pMin != kInfinity) || (pMax != -kInfinity) )
375 existsAfterClip =
true;
393 existsAfterClip =
true;
399 return existsAfterClip;
421 zinLow =(p+vZ).dot(fLowNorm);
422 if (zinLow>halfCarTolerance) {
return kOutside; }
426 zinHigh = (p-vZ).dot(fHighNorm);
427 if (zinHigh>halfCarTolerance) {
return kOutside; }
431 r2 = p.
x()*p.
x() + p.
y()*p.
y() ;
435 tolRMin =
fRMin - halfRadTolerance ;
436 tolRMax =
fRMax + halfRadTolerance ;
437 if ( tolRMin < 0 ) { tolRMin = 0; }
439 if ( ((r2 < tolRMin*tolRMin) || (r2 > tolRMax*tolRMax))
440 && (r2 >=halfRadTolerance*halfRadTolerance) ) {
return kOutside; }
448 if ( (tolRMin==0) && (std::fabs(p.
x())<=halfCarTolerance)
449 && (std::fabs(p.
y())<=halfCarTolerance) )
454 pPhi = std::atan2(p.
y(),p.
x()) ;
456 if ( pPhi < -halfAngTolerance) { pPhi += twopi; }
459 if ( (std::fabs(pPhi) < halfAngTolerance)
460 && (std::fabs(
fSPhi +
fDPhi - twopi) < halfAngTolerance) )
464 if ( (pPhi <=
fSPhi - halfAngTolerance)
465 || (pPhi >=
fSPhi +
fDPhi + halfAngTolerance) )
469 else if ( (pPhi <=
fSPhi + halfAngTolerance)
470 || (pPhi >=
fSPhi +
fDPhi - halfAngTolerance) )
477 if ( (pPhi <=
fSPhi + twopi - halfAngTolerance)
478 && (pPhi >=
fSPhi +
fDPhi + halfAngTolerance) )
491 if ((zinLow>=-halfCarTolerance)
492 || (zinHigh>=-halfCarTolerance))
499 if (
fRMin) { tolRMin =
fRMin + halfRadTolerance ; }
500 else { tolRMin = 0 ; }
501 tolRMax =
fRMax - halfRadTolerance ;
502 if ( ((r2 <= tolRMin*tolRMin) || (r2 >= tolRMax*tolRMax))&&
503 (r2 >=halfRadTolerance*halfRadTolerance) )
519 G4int noSurfaces = 0;
521 G4double distZLow,distZHigh, distRMin, distRMax;
522 G4double distSPhi = kInfinity, distEPhi = kInfinity;
532 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y());
534 distRMin = std::fabs(rho -
fRMin);
535 distRMax = std::fabs(rho -
fRMax);
539 distZLow =std::fabs((p+vZ).dot(fLowNorm));
543 distZHigh = std::fabs((p-vZ).dot(fHighNorm));
545 if (!fPhiFullCutTube)
547 if ( rho > halfCarTolerance )
549 pPhi = std::atan2(p.
y(),p.
x());
551 if(pPhi <
fSPhi- halfCarTolerance) { pPhi += twopi; }
552 else if(pPhi >
fSPhi+
fDPhi+ halfCarTolerance) { pPhi -= twopi; }
554 distSPhi = std::fabs(pPhi -
fSPhi);
565 if ( rho > halfCarTolerance ) { nR =
G4ThreeVector(p.
x()/rho,p.
y()/rho,0); }
567 if( distRMax <= halfCarTolerance )
572 if(
fRMin && (distRMin <= halfCarTolerance) )
579 if (distSPhi <= halfAngTolerance)
584 if (distEPhi <= halfAngTolerance)
590 if (distZLow <= halfCarTolerance)
595 if (distZHigh <= halfCarTolerance)
598 sumnorm += fHighNorm;
600 if ( noSurfaces == 0 )
603 G4Exception(
"G4CutTubs::SurfaceNormal(p)",
"GeomSolids1002",
606 G4cout<<
"G4CutTubs::SN ( "<<p.
x()<<
", "<<p.
y()<<
", "<<p.
z()<<
" ); "
608 G4cout.precision(oldprc) ;
612 else if ( noSurfaces == 1 ) { norm = sumnorm; }
613 else { norm = sumnorm.
unit(); }
629 G4double distRMin, distRMax, distSPhi, distEPhi, distMin ;
632 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
634 distRMin = std::fabs(rho -
fRMin) ;
635 distRMax = std::fabs(rho -
fRMax) ;
639 distZLow =std::fabs((p+vZ).dot(fLowNorm));
643 distZHigh = std::fabs((p-vZ).dot(fHighNorm));
644 distZ=std::min(distZLow,distZHigh);
646 if (distRMin < distRMax)
648 if ( distZ < distRMin )
661 if ( distZ < distRMax )
672 if (!fPhiFullCutTube && rho )
674 phi = std::atan2(p.
y(),p.
x()) ;
676 if ( phi < 0 ) { phi += twopi; }
680 distSPhi = std::fabs(phi - (
fSPhi + twopi))*rho ;
684 distSPhi = std::fabs(phi -
fSPhi)*rho ;
686 distEPhi = std::fabs(phi -
fSPhi -
fDPhi)*rho ;
688 if (distSPhi < distEPhi)
690 if ( distSPhi < distMin )
697 if ( distEPhi < distMin )
717 if ( distZHigh > distZLow ) { norm = fHighNorm ; }
718 else { norm = fLowNorm; }
736 "Undefined side for valid surface normal to solid.");
779 G4double Dist, sd=0, xi, yi, zi, rho2, inum, iden, cosPsi, Comp,calf ;
786 tolORMin2 = (
fRMin - halfRadTolerance)*(
fRMin - halfRadTolerance) ;
787 tolIRMin2 = (
fRMin + halfRadTolerance)*(
fRMin + halfRadTolerance) ;
794 tolORMax2 = (
fRMax + halfRadTolerance)*(
fRMax + halfRadTolerance) ;
795 tolIRMax2 = (
fRMax - halfRadTolerance)*(
fRMax - halfRadTolerance) ;
801 distZLow =(p+vZ).dot(fLowNorm);
805 distZHigh = (p-vZ).dot(fHighNorm);
807 if ( distZLow >= -halfCarTolerance )
809 calf = v.
dot(fLowNorm);
813 if(sd < 0.0) { sd = 0.0; }
815 xi = p.
x() + sd*v.
x() ;
816 yi = p.
y() + sd*v.
y() ;
817 rho2 = xi*xi + yi*yi ;
821 if ((tolIRMin2 <= rho2) && (rho2 <= tolIRMax2))
823 if (!fPhiFullCutTube && rho2)
828 iden = std::sqrt(rho2) ;
840 if ( sd<halfCarTolerance )
842 if(calf>=0) { sd=kInfinity; }
848 if(distZHigh >= -halfCarTolerance )
850 calf = v.
dot(fHighNorm);
853 sd = -distZHigh/calf;
855 if(sd < 0.0) { sd = 0.0; }
857 xi = p.
x() + sd*v.
x() ;
858 yi = p.
y() + sd*v.
y() ;
859 rho2 = xi*xi + yi*yi ;
863 if ((tolIRMin2 <= rho2) && (rho2 <= tolIRMax2))
865 if (!fPhiFullCutTube && rho2)
870 iden = std::sqrt(rho2) ;
882 if ( sd<halfCarTolerance )
884 if(calf>=0) { sd=kInfinity; }
901 t1 = 1.0 - v.
z()*v.
z() ;
902 t2 = p.
x()*v.
x() + p.
y()*v.
y() ;
903 t3 = p.
x()*p.
x() + p.
y()*p.
y() ;
909 if ((t3 >= tolORMax2) && (t2<0))
918 sd = c/(-b+std::sqrt(d));
923 G4double fTerm = sd-std::fmod(sd,dRmax);
928 zi = p.
z() + sd*v.
z() ;
929 xi = p.
x() + sd*v.
x() ;
930 yi = p.
y() + sd*v.
y() ;
931 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
932 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
934 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
935 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
945 xi = p.
x() + sd*v.
x() ;
946 yi = p.
y() + sd*v.
y() ;
959 if ((t3 > tolIRMin2) && (t2 < 0)
960 && (std::fabs(p.
z()) <= std::fabs(
GetCutZ(p))-halfCarTolerance ))
964 if (!fPhiFullCutTube)
967 iden = std::sqrt(t3) ;
988 snxt = c/(-b+std::sqrt(d));
990 if ( snxt < halfCarTolerance ) { snxt=0; }
1019 snxt= c/(-b+std::sqrt(d));
1021 if ( snxt < halfCarTolerance ) { snxt=0; }
1042 sd =( b > 0. )? c/(-b - std::sqrt(d)) : (-b + std::sqrt(d));
1043 if (sd >= -10*halfCarTolerance)
1047 if (sd < 0.0) { sd = 0.0; }
1050 G4double fTerm = sd-std::fmod(sd,dRmax);
1053 zi = p.
z() + sd*v.
z() ;
1054 xi = p.
x() + sd*v.
x() ;
1055 yi = p.
y() + sd*v.
y() ;
1056 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
1057 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
1059 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
1060 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
1064 if ( fPhiFullCutTube )
1095 if ( !fPhiFullCutTube )
1105 if ( Dist < halfCarTolerance )
1111 if ( sd < 0 ) { sd = 0.0; }
1112 zi = p.
z() + sd*v.
z() ;
1113 xi = p.
x() + sd*v.
x() ;
1114 yi = p.
y() + sd*v.
y() ;
1115 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
1116 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
1118 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
1119 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
1121 rho2 = xi*xi + yi*yi ;
1122 if ( ( (rho2 >= tolIRMin2) && (rho2 <= tolIRMax2) )
1123 || ( (rho2 > tolORMin2) && (rho2 < tolIRMin2)
1126 || ( (rho2 > tolIRMax2) && (rho2 < tolORMax2)
1149 if ( Dist < halfCarTolerance )
1155 if ( sd < 0 ) { sd = 0; }
1156 zi = p.
z() + sd*v.
z() ;
1157 xi = p.
x() + sd*v.
x() ;
1158 yi = p.
y() + sd*v.
y() ;
1159 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
1160 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
1162 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
1163 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
1165 xi = p.
x() + sd*v.
x() ;
1166 yi = p.
y() + sd*v.
y() ;
1167 rho2 = xi*xi + yi*yi ;
1168 if ( ( (rho2 >= tolIRMin2) && (rho2 <= tolIRMax2) )
1169 || ( (rho2 > tolORMin2) && (rho2 < tolIRMin2)
1172 || ( (rho2 > tolIRMax2) && (rho2 < tolORMax2)
1190 if ( snxt<halfCarTolerance ) { snxt=0; }
1223 G4double safRMin,safRMax,safZLow,safZHigh,safePhi,safe,rho,cosPsi;
1228 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
1230 safRMin =
fRMin- rho ;
1231 safRMax = rho -
fRMax ;
1237 safZLow = (p+vZ).dot(fLowNorm);
1241 safZHigh = (p-vZ).dot(fHighNorm);
1243 safe = std::max(safZLow,safZHigh);
1245 if ( safRMin > safe ) { safe = safRMin; }
1246 if ( safRMax> safe ) { safe = safRMax; }
1250 if ( (!fPhiFullCutTube) && (rho) )
1256 if ( cosPsi < std::cos(
fDPhi*0.5) )
1268 if ( safePhi > safe ) { safe = safePhi; }
1271 if ( safe < 0 ) { safe = 0; }
1288 G4double snxt=kInfinity, srd=kInfinity,sz=kInfinity, sphi=kInfinity ;
1289 G4double deltaR, t1, t2, t3, b, c, d2, roMin2 ;
1290 G4double distZLow,distZHigh,calfH,calfL;
1297 G4double pDistS, compS, pDistE, compE, sphi2, xi, yi, vphi, roi2 ;
1304 distZLow =(p+vZ).dot(fLowNorm);
1308 distZHigh = (p-vZ).dot(fHighNorm);
1310 calfH = v.
dot(fHighNorm);
1311 calfL = v.
dot(fLowNorm);
1315 if ( distZHigh < halfCarTolerance )
1317 snxt = -distZHigh/calfH ;
1333 if ( distZLow < halfCarTolerance )
1335 sz = -distZLow/calfL ;
1352 if((calfH<=0)&&(calfL<=0))
1368 t1 = 1.0 - v.
z()*v.
z() ;
1369 t2 = p.
x()*v.
x() + p.
y()*v.
y() ;
1370 t3 = p.
x()*p.
x() + p.
y()*p.
y() ;
1373 else { roi2 = snxt*snxt*t1 + 2*snxt*t2 + t3; }
1393 if( d2 >= 0 ) { srd = c/( -b - std::sqrt(d2)); }
1412 roMin2 = t3 - t2*t2/t1 ;
1428 srd = c/(-b+std::sqrt(d2));
1433 if ( calcNorm ) { *validNorm =
false; }
1444 srd = -b + std::sqrt(d2) ;
1468 srd = -b + std::sqrt(d2) ;
1485 if ( !fPhiFullCutTube )
1490 vphi = std::atan2(v.
y(),v.
x()) ;
1492 if ( vphi <
fSPhi - halfAngTolerance ) { vphi += twopi; }
1493 else if ( vphi >
fSPhi +
fDPhi + halfAngTolerance ) { vphi -= twopi; }
1496 if ( p.
x() || p.
y() )
1510 if( ( (
fDPhi <= pi) && ( (pDistS <= halfCarTolerance)
1511 && (pDistE <= halfCarTolerance) ) )
1512 || ( (
fDPhi > pi) && !((pDistS > halfCarTolerance)
1513 && (pDistE > halfCarTolerance) ) ) )
1519 sphi = pDistS/compS ;
1521 if (sphi >= -halfCarTolerance)
1523 xi = p.
x() + sphi*v.
x() ;
1524 yi = p.
y() + sphi*v.
y() ;
1533 if (((
fSPhi-halfAngTolerance)<=vphi)
1546 if ( pDistS > -halfCarTolerance )
1564 sphi2 = pDistE/compE ;
1568 if ( (sphi2 > -halfCarTolerance) && (sphi2 < sphi) )
1570 xi = p.
x() + sphi2*v.
x() ;
1571 yi = p.
y() + sphi2*v.
y() ;
1577 if( !((
fSPhi-halfAngTolerance <= vphi)
1581 if ( pDistE <= -halfCarTolerance ) { sphi = sphi2 ; }
1582 else { sphi = 0.0 ; }
1592 if ( pDistE <= -halfCarTolerance ) { sphi = sphi2 ; }
1593 else { sphi = 0.0 ; }
1608 if ( (
fSPhi - halfAngTolerance <= vphi)
1609 && (vphi <=
fSPhi +
fDPhi + halfAngTolerance ) )
1639 xi = p.
x() + snxt*v.
x() ;
1640 yi = p.
y() + snxt*v.
y() ;
1646 *validNorm = false ;
1657 *validNorm = false ;
1669 *validNorm = false ;
1686 std::ostringstream message;
1687 G4int oldprc = message.precision(16);
1688 message <<
"Undefined side for valid surface normal to solid."
1691 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
1692 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
1695 <<
"v.x() = " << v.
x() <<
G4endl
1696 <<
"v.y() = " << v.
y() <<
G4endl
1699 <<
"snxt = " << snxt/mm <<
" mm" <<
G4endl ;
1700 message.precision(oldprc) ;
1701 G4Exception(
"G4CutTubs::DistanceToOut(p,v,..)",
"GeomSolids1002",
1706 if ( snxt<halfCarTolerance ) { snxt=0 ; }
1716 G4double safRMin,safRMax,safZLow,safZHigh,safePhi,safe,rho;
1719 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
1721 safRMin = rho -
fRMin ;
1722 safRMax =
fRMax - rho ;
1728 safZLow = std::fabs((p+vZ).dot(fLowNorm));
1732 safZHigh = std::fabs((p-vZ).dot(fHighNorm));
1733 safe = std::min(safZLow,safZHigh);
1735 if ( safRMin < safe ) { safe = safRMin; }
1736 if ( safRMax< safe ) { safe = safRMax; }
1740 if ( !fPhiFullCutTube )
1750 if (safePhi < safe) { safe = safePhi ; }
1752 if ( safe < 0 ) { safe = 0; }
1771 G4double meshAngle, meshRMax, crossAngle,
1772 cosCrossAngle, sinCrossAngle, sAngle;
1773 G4double rMaxX, rMaxY, rMinX, rMinY, meshRMin ;
1774 G4int crossSection, noCrossSections;
1790 meshAngle =
fDPhi/(noCrossSections - 1) ;
1799 if (fPhiFullCutTube && (
fSPhi == 0) ) { sAngle = -meshAngle*0.5 ; }
1800 else { sAngle =
fSPhi ; }
1806 vertices->reserve(noCrossSections*4);
1807 for (crossSection = 0 ; crossSection < noCrossSections ; crossSection++ )
1811 crossAngle = sAngle + crossSection*meshAngle ;
1812 cosCrossAngle = std::cos(crossAngle) ;
1813 sinCrossAngle = std::sin(crossAngle) ;
1815 rMaxX = meshRMax*cosCrossAngle ;
1816 rMaxY = meshRMax*sinCrossAngle ;
1825 rMinX = meshRMin*cosCrossAngle ;
1826 rMinY = meshRMin*sinCrossAngle ;
1844 "Error in allocation of vertices. Out of memory !");
1873 G4int oldprc = os.precision(16);
1874 os <<
"-----------------------------------------------------------\n"
1875 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1876 <<
" ===================================================\n"
1877 <<
" Solid type: G4CutTubs\n"
1878 <<
" Parameters: \n"
1879 <<
" inner radius : " <<
fRMin/mm <<
" mm \n"
1880 <<
" outer radius : " <<
fRMax/mm <<
" mm \n"
1881 <<
" half length Z: " <<
fDz/mm <<
" mm \n"
1882 <<
" starting phi : " <<
fSPhi/degree <<
" degrees \n"
1883 <<
" delta phi : " <<
fDPhi/degree <<
" degrees \n"
1884 <<
" low Norm : " << fLowNorm <<
" \n"
1885 <<
" high Norm : " <<fHighNorm <<
" \n"
1886 <<
"-----------------------------------------------------------\n";
1887 os.precision(oldprc);
1898 G4double xRand, yRand, zRand, phi, cosphi, sinphi, chose,
1899 aOne, aTwo, aThr, aFou;
1908 cosphi = std::cos(phi);
1909 sinphi = std::sin(phi);
1913 if( (
fSPhi == 0) && (
fDPhi == twopi) ) { aFou = 0; }
1917 if( (chose >=0) && (chose < aOne) )
1919 xRand =
fRMax*cosphi;
1920 yRand =
fRMax*sinphi;
1925 else if( (chose >= aOne) && (chose < aOne + aTwo) )
1927 xRand =
fRMin*cosphi;
1928 yRand =
fRMin*sinphi;
1933 else if( (chose >= aOne + aTwo) && (chose < aOne + aTwo + aThr) )
1935 xRand = rRand*cosphi;
1936 yRand = rRand*sinphi;
1940 else if( (chose >= aOne + aTwo + aThr) && (chose < aOne + aTwo + 2.*aThr) )
1942 xRand = rRand*cosphi;
1943 yRand = rRand*sinphi;
1947 else if( (chose >= aOne + aTwo + 2.*aThr)
1948 && (chose < aOne + aTwo + 2.*aThr + aFou) )
1950 xRand = rRand*std::cos(
fSPhi);
1951 yRand = rRand*std::sin(
fSPhi);
1978 typedef G4int G4int4[4];
1984 G4double3* xyz =
new G4double3[nn];
1985 G4int4* faces =
new G4int4[nf] ;
1987 for(
G4int i=0;i<nn;i++)
2008 for(
G4int i=0;i<nf;i++)
2011 for(
G4int k=0;k<n;k++)
2013 faces[i][k]=iNodes[k];
2015 for(
G4int k=n;k<4;k++)
2037 G4double zXLow1,zXLow2,zYLow1,zYLow2;
2038 G4double zXHigh1,zXHigh2,zYHigh1,zYHigh2;
2048 if ( (zXLow1>zXHigh1) ||(zXLow2>zXHigh2)
2049 || (zYLow1>zYHigh1) ||(zYLow2>zYHigh2)) {
return true; }
2063 if(fLowNorm.
z()!=0.)
2065 newz = -
fDz-(p.
x()*fLowNorm.
x()+p.
y()*fLowNorm.
y())/fLowNorm.
z();
2070 if(fHighNorm.
z()!=0.)
2072 newz =
fDz-(p.
x()*fHighNorm.
x()+p.
y()*fHighNorm.
y())/fHighNorm.
z();
2085 G4double phiLow = std::atan2(fLowNorm.
y(),fLowNorm.
x());
2086 G4double phiHigh= std::atan2(fHighNorm.
y(),fHighNorm.
x());
2090 G4bool in_range_low =
false;
2091 G4bool in_range_hi =
false;
2096 if (phiLow<0) { phiLow+=twopi; }
2098 if (ddp<0) { ddp += twopi; }
2101 xc =
fRMin*std::cos(phiLow);
2102 yc =
fRMin*std::sin(phiLow);
2104 xc =
fRMax*std::cos(phiLow);
2105 yc =
fRMax*std::sin(phiLow);
2107 if (in_range_low) { zmin = std::min(zmin, z1); }
2109 in_range_low =
true;
2112 if (phiLow>twopi) { phiLow-=twopi; }
2116 if (phiHigh<0) { phiHigh+=twopi; }
2118 if (ddp<0) { ddp += twopi; }
2121 xc =
fRMin*std::cos(phiHigh);
2122 yc =
fRMin*std::sin(phiHigh);
2124 xc =
fRMax*std::cos(phiHigh);
2125 yc =
fRMax*std::sin(phiHigh);
2127 if (in_range_hi) { zmax = std::min(zmax, z1); }
2132 if (phiLow>twopi) { phiHigh-=twopi; }
2158 for (i = 1; i < 4; i++)
2160 if(z[i] < z[i-1])z1=z[i];
2165 zmin = std::min(zmin, z1);
2172 for (i = 1; i < 4; i++)
2174 if(z[4+i] > z[4+i-1]) { z1=z[4+i]; }
2177 if (in_range_hi) { zmax = std::max(zmax, z1); }
CLHEP::Hep3Vector G4ThreeVector
std::vector< G4ThreeVector > G4ThreeVectorList
G4DLLIMPORT std::ostream G4cout
double dot(const Hep3Vector &) const
G4double GetRadiusInRing(G4double rmin, G4double rmax) const
EInside Inside(const G4ThreeVector &p) const
G4double GetCutZ(const G4ThreeVector &p) const
G4Polyhedron * CreatePolyhedron() const
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
G4bool IsCrossingCutPlanes() const
G4GeometryType GetEntityType() const
G4CutTubs & operator=(const G4CutTubs &rhs)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4ThreeVector GetPointOnSurface() const
void GetMaxMinZ(G4double &zmin, G4double &zmax) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
std::ostream & StreamInfo(std::ostream &os) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4CutTubs(const G4String &pName, G4double pRMin, G4double pRMax, G4double pDz, G4double pSPhi, G4double pDPhi, G4ThreeVector pLowNorm, G4ThreeVector pHighNorm)
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4double GetAngularTolerance() const
G4Polyhedron * CreatePolyhedron() const
G4Tubs & operator=(const G4Tubs &rhs)
virtual void AddSolid(const G4Box &)=0
void ClipBetweenSections(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipCrossSection(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
G4double GetMinExtent(const EAxis pAxis) const
G4bool IsYLimited() const
G4double GetMinZExtent() const
G4bool IsXLimited() const
G4double GetMaxExtent(const EAxis pAxis) const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4double GetMaxXExtent() const
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
G4Point3D GetVertex(G4int index) const
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
G4int GetNoFacets() const
G4int GetNoVertices() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const G4int kMaxMeshSections
const G4int kMinMeshSections
const G4double kMeshAngleDefault