63 using namespace CLHEP;
91 if ( pDz <= 0 || pDy1 <= 0 || pDx1 <= 0 ||
92 pDx2 <= 0 || pDy2 <= 0 || pDx3 <= 0 || pDx4 <= 0 )
94 std::ostringstream message;
95 message <<
"Invalid length parameters for Solid: " <<
GetName() <<
G4endl
97 << pDx1 <<
", " << pDx2 <<
", " << pDx3 <<
", " << pDx4 <<
G4endl
98 <<
" Y - " << pDy1 <<
", " << pDy2 <<
G4endl
105 fTthetaCphi=std::tan(pTheta)*std::cos(pPhi);
106 fTthetaSphi=std::tan(pTheta)*std::sin(pPhi);
111 fTalpha1=std::tan(pAlp1);
116 fTalpha2=std::tan(pAlp2);
137 && pt[0].
z() == pt[1].
z() && pt[0].
z() == pt[2].
z()
138 && pt[0].
z() == pt[3].
z()
140 && pt[4].
z() == pt[5].
z() && pt[4].
z() == pt[6].
z()
141 && pt[4].
z() == pt[7].
z()
143 && pt[0].
y() == pt[1].
y() && pt[2].
y() == pt[3].
y()
144 && pt[4].
y() == pt[5].
y() && pt[6].
y() == pt[7].
y()
146 && std::fabs( pt[0].
x() + pt[1].
x() + pt[4].
x() + pt[5].
x() +
149 std::ostringstream message;
150 message <<
"Invalid vertice coordinates for Solid: " <<
GetName();
157 good =
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
163 "Face at ~-Y not planar.");
168 good =
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
172 std::ostringstream message;
173 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
180 good =
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
184 std::ostringstream message;
185 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
192 good =
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
195 std::ostringstream message;
196 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
202 fDy1 = ((pt[2]).
y()-(pt[1]).
y())*0.5;
203 fDx1 = ((pt[1]).
x()-(pt[0]).
x())*0.5;
204 fDx2 = ((pt[3]).
x()-(pt[2]).
x())*0.5;
205 fTalpha1 = ((pt[2]).
x()+(pt[3]).
x()-(pt[1]).
x()-(pt[0]).
x())*0.25/fDy1;
207 fDy2 = ((pt[6]).
y()-(pt[5]).
y())*0.5;
208 fDx3 = ((pt[5]).
x()-(pt[4]).
x())*0.5;
209 fDx4 = ((pt[7]).
x()-(pt[6]).
x())*0.5;
210 fTalpha2 = ((pt[6]).
x()+(pt[7]).
x()-(pt[5]).
x()-(pt[4]).
x())*0.25/fDy2;
212 fTthetaCphi = ((pt[4]).
x()+fDy2*fTalpha2+fDx3)/fDz;
213 fTthetaSphi = ((pt[4]).
y()+fDy2)/fDz;
228 if ( pZ<=0 || pY<=0 || pX<=0 || pLTX<=0 || pLTX>pX )
230 std::ostringstream message;
231 message <<
"Invalid length parameters for Solid: " <<
GetName();
243 fTalpha1 = 0.5*(pLTX - pX)/pY;
248 fTalpha2 = fTalpha1 ;
253 -fDz*fTthetaSphi-fDy1,-fDz);
255 -fDz*fTthetaSphi-fDy1,-fDz);
257 -fDz*fTthetaSphi+fDy1,-fDz);
259 -fDz*fTthetaSphi+fDy1,-fDz);
261 +fDz*fTthetaSphi-fDy2,+fDz);
263 +fDz*fTthetaSphi-fDy2,+fDz);
265 +fDz*fTthetaSphi+fDy2,+fDz);
267 +fDz*fTthetaSphi+fDy2,+fDz);
271 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
274 std::ostringstream message;
275 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
282 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
285 std::ostringstream message;
286 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
293 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
296 std::ostringstream message;
297 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
304 good=
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
307 std::ostringstream message;
308 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
326 if ( pDz<=0 || pDy1<=0 || pDx1<=0 || pDx2<=0 || pDy2<=0 )
328 std::ostringstream message;
329 message <<
"Invalid length parameters for Solid: " <<
GetName();
351 -fDz*fTthetaSphi-fDy1,-fDz);
353 -fDz*fTthetaSphi-fDy1,-fDz);
355 -fDz*fTthetaSphi+fDy1,-fDz);
357 -fDz*fTthetaSphi+fDy1,-fDz);
359 +fDz*fTthetaSphi-fDy2,+fDz);
361 +fDz*fTthetaSphi-fDy2,+fDz);
363 +fDz*fTthetaSphi+fDy2,+fDz);
365 +fDz*fTthetaSphi+fDy2,+fDz);
369 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
372 std::ostringstream message;
373 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
380 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
383 std::ostringstream message;
384 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
391 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
394 std::ostringstream message;
395 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
402 good=
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
405 std::ostringstream message;
406 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
425 if ( pDz<=0 || pDy<=0 || pDx<=0 )
427 std::ostringstream message;
428 message <<
"Invalid length parameters for Solid: " <<
GetName();
434 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi) ;
435 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi) ;
440 fTalpha1 = std::tan(pAlpha) ;
445 fTalpha2 = fTalpha1 ;
450 -fDz*fTthetaSphi-fDy1,-fDz);
452 -fDz*fTthetaSphi-fDy1,-fDz);
454 -fDz*fTthetaSphi+fDy1,-fDz);
456 -fDz*fTthetaSphi+fDy1,-fDz);
458 +fDz*fTthetaSphi-fDy2,+fDz);
460 +fDz*fTthetaSphi-fDy2,+fDz);
462 +fDz*fTthetaSphi+fDy2,+fDz);
464 +fDz*fTthetaSphi+fDy2,+fDz);
468 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
471 std::ostringstream message;
472 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
479 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
482 std::ostringstream message;
483 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
490 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
493 std::ostringstream message;
494 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
501 good=
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
504 std::ostringstream message;
505 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
518 :
G4CSGSolid (pName), fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
519 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
520 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
531 :
G4CSGSolid(a), fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
532 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
533 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
552 fTthetaCphi(rhs.fTthetaCphi), fTthetaSphi(rhs.fTthetaSphi),
553 fDy1(rhs.fDy1), fDx1(rhs.fDx1), fDx2(rhs.fDx2), fTalpha1(rhs.fTalpha1),
554 fDy2(rhs.fDy2), fDx3(rhs.fDx3), fDx4(rhs.fDx4), fTalpha2(rhs.fTalpha2)
556 for (
size_t i=0; i<4; ++i)
558 fPlanes[i].
a = rhs.fPlanes[i].
a;
559 fPlanes[i].
b = rhs.fPlanes[i].
b;
560 fPlanes[i].
c = rhs.fPlanes[i].
c;
561 fPlanes[i].
d = rhs.fPlanes[i].
d;
573 if (
this == &rhs) {
return *
this; }
582 fTthetaCphi = rhs.fTthetaCphi; fTthetaSphi = rhs.fTthetaSphi;
583 fDy1 = rhs.fDy1; fDx1 = rhs.fDx1; fDx2 = rhs.fDx2; fTalpha1 = rhs.fTalpha1;
584 fDy2 = rhs.fDy2; fDx3 = rhs.fDx3; fDx4 = rhs.fDx4; fTalpha2 = rhs.fTalpha2;
585 for (
size_t i=0; i<4; ++i)
587 fPlanes[i].
a = rhs.fPlanes[i].
a;
588 fPlanes[i].
b = rhs.fPlanes[i].
b;
589 fPlanes[i].
c = rhs.fPlanes[i].
c;
590 fPlanes[i].
d = rhs.fPlanes[i].
d;
613 if ( pDz<=0 || pDy1<=0 || pDx1<=0 || pDx2<=0 || pDy2<=0 || pDx3<=0 || pDx4<=0 )
615 std::ostringstream message;
616 message <<
"Invalid Length Parameters for Solid: " <<
GetName() <<
G4endl
618 << pDx1 <<
", " << pDx2 <<
", " << pDx3 <<
", " << pDx4 <<
G4endl
619 <<
" Y - " << pDy1 <<
", " << pDy2 <<
G4endl
621 G4Exception(
"G4Trap::SetAllParameters()",
"GeomSolids0002",
628 fTthetaCphi=std::tan(pTheta)*std::cos(pPhi);
629 fTthetaSphi=std::tan(pTheta)*std::sin(pPhi);
634 fTalpha1=std::tan(pAlp1);
639 fTalpha2=std::tan(pAlp2);
655 -fDz*fTthetaSphi-fDy1,-fDz);
657 -fDz*fTthetaSphi-fDy1,-fDz);
659 -fDz*fTthetaSphi+fDy1,-fDz);
661 -fDz*fTthetaSphi+fDy1,-fDz);
663 +fDz*fTthetaSphi-fDy2,+fDz);
665 +fDz*fTthetaSphi-fDy2,+fDz);
667 +fDz*fTthetaSphi+fDy2,+fDz);
669 +fDz*fTthetaSphi+fDy2,+fDz);
673 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]) ;
676 std::ostringstream message;
677 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
678 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
684 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
687 std::ostringstream message;
688 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
689 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
695 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
698 std::ostringstream message;
699 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
700 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
706 good =
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
709 std::ostringstream message;
710 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
711 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
741 Vcross = v12.
cross(v13);
763 a = +(p4.
y() - p2.
y())*(p3.
z() - p1.z())
764 - (p3.
y() - p1.y())*(p4.
z() - p2.
z());
766 b = -(p4.
x() - p2.
x())*(p3.
z() - p1.z())
767 + (p3.
x() - p1.x())*(p4.
z() - p2.
z());
769 c = +(p4.
x() - p2.
x())*(p3.
y() - p1.y())
770 - (p3.
x() - p1.x())*(p4.
y() - p2.
y());
772 sd = std::sqrt( a*a + b*b + c*c );
782 std::ostringstream message;
783 message <<
"Invalid parameters: norm.mod() <= 0, for Solid: "
785 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
790 plane.
d = -( plane.
a*p1.x() + plane.
b*p1.y() + plane.
c*p1.z() );
819 G4double xMin, xMax, yMin, yMax, zMin, zMax;
839 pt[0]=
G4ThreeVector(xoffset-fDz*fTthetaCphi-fDy1*fTalpha1-fDx1,
840 yoffset-fDz*fTthetaSphi-fDy1,zoffset-fDz);
841 pt[1]=
G4ThreeVector(xoffset-fDz*fTthetaCphi-fDy1*fTalpha1+fDx1,
842 yoffset-fDz*fTthetaSphi-fDy1,zoffset-fDz);
843 pt[2]=
G4ThreeVector(xoffset-fDz*fTthetaCphi+fDy1*fTalpha1-fDx2,
844 yoffset-fDz*fTthetaSphi+fDy1,zoffset-fDz);
845 pt[3]=
G4ThreeVector(xoffset-fDz*fTthetaCphi+fDy1*fTalpha1+fDx2,
846 yoffset-fDz*fTthetaSphi+fDy1,zoffset-fDz);
847 pt[4]=
G4ThreeVector(xoffset+fDz*fTthetaCphi-fDy2*fTalpha2-fDx3,
848 yoffset+fDz*fTthetaSphi-fDy2,zoffset+fDz);
849 pt[5]=
G4ThreeVector(xoffset+fDz*fTthetaCphi-fDy2*fTalpha2+fDx3,
850 yoffset+fDz*fTthetaSphi-fDy2,zoffset+fDz);
851 pt[6]=
G4ThreeVector(xoffset+fDz*fTthetaCphi+fDy2*fTalpha2-fDx4,
852 yoffset+fDz*fTthetaSphi+fDy2,zoffset+fDz);
853 pt[7]=
G4ThreeVector(xoffset+fDz*fTthetaCphi+fDy2*fTalpha2+fDx4,
854 yoffset+fDz*fTthetaSphi+fDy2,zoffset+fDz);
877 temp[0] = pt[0].
y()+(pt[4].
y()-pt[0].
y())*(zMin-pt[0].
z())
878 /(pt[4].
z()-pt[0].
z()) ;
879 temp[1] = pt[0].
y()+(pt[4].
y()-pt[0].
y())*(zMax-pt[0].
z())
880 /(pt[4].
z()-pt[0].
z()) ;
881 temp[2] = pt[2].
y()+(pt[6].
y()-pt[2].
y())*(zMin-pt[2].
z())
882 /(pt[6].
z()-pt[2].
z()) ;
883 temp[3] = pt[2].
y()+(pt[6].
y()-pt[2].
y())*(zMax-pt[2].
z())
884 /(pt[6].
z()-pt[2].
z()) ;
886 yMax = yoffset - std::fabs(fDz*fTthetaSphi) - fDy1 - fDy2 ;
889 for( i = 0 ; i < 4 ; i++ )
891 if( temp[i] > yMax ) yMax = temp[i] ;
892 if( temp[i] < yMin ) yMin = temp[i] ;
913 temp[0] = pt[0].
x()+(pt[4].
x()-pt[0].
x())
914 *(zMin-pt[0].
z())/(pt[4].
z()-pt[0].
z()) ;
915 temp[1] = pt[0].
x()+(pt[4].
x()-pt[0].
x())
916 *(zMax-pt[0].
z())/(pt[4].
z()-pt[0].
z()) ;
917 temp[2] = pt[2].
x()+(pt[6].
x()-pt[2].
x())
918 *(zMin-pt[2].
z())/(pt[6].
z()-pt[2].
z()) ;
919 temp[3] = pt[2].
x()+(pt[6].
x()-pt[2].
x())
920 *(zMax-pt[2].
z())/(pt[6].
z()-pt[2].
z()) ;
921 temp[4] = pt[3].
x()+(pt[7].
x()-pt[3].
x())
922 *(zMin-pt[3].
z())/(pt[7].
z()-pt[3].
z()) ;
923 temp[5] = pt[3].
x()+(pt[7].
x()-pt[3].
x())
924 *(zMax-pt[3].
z())/(pt[7].
z()-pt[3].
z()) ;
925 temp[6] = pt[1].
x()+(pt[5].
x()-pt[1].
x())
926 *(zMin-pt[1].
z())/(pt[5].
z()-pt[1].
z()) ;
927 temp[7] = pt[1].
x()+(pt[5].
x()-pt[1].
x())
928 *(zMax-pt[1].
z())/(pt[5].
z()-pt[1].
z()) ;
930 xMax = xoffset - std::fabs(fDz*fTthetaCphi) - fDx1 - fDx2 -fDx3 - fDx4 ;
933 for( i = 0 ; i < 8 ; i++ )
935 if( temp[i] > xMax) xMax = temp[i] ;
936 if( temp[i] < xMin) xMin = temp[i] ;
984 G4bool existsAfterClip = false ;
993 xMin = +kInfinity; yMin = +kInfinity; zMin = +kInfinity;
994 xMax = -kInfinity; yMax = -kInfinity; zMax = -kInfinity;
996 for(
G4int nv = 0 ; nv < 8 ; nv++ )
998 if( (*vertices)[nv].
x() > xMax ) xMax = (*vertices)[nv].x();
999 if( (*vertices)[nv].
y() > yMax ) yMax = (*vertices)[nv].y();
1000 if( (*vertices)[nv].
z() > zMax ) zMax = (*vertices)[nv].z();
1002 if( (*vertices)[nv].
x() < xMin ) xMin = (*vertices)[nv].x();
1003 if( (*vertices)[nv].
y() < yMin ) yMin = (*vertices)[nv].y();
1004 if( (*vertices)[nv].
z() < zMin ) zMin = (*vertices)[nv].z();
1086 if ( (pMin != kInfinity) || (pMax != -kInfinity) )
1088 existsAfterClip=
true;
1096 flag = existsAfterClip ;
1115 for ( i = 0;i < 4;i++ )
1117 Dist = fPlanes[i].
a*p.
x() + fPlanes[i].
b*p.
y()
1118 +fPlanes[i].
c*p.
z() + fPlanes[i].
d;
1129 for ( i = 0; i < 4; i++ )
1131 Dist = fPlanes[i].
a*p.
x() + fPlanes[i].
b*p.
y()
1132 +fPlanes[i].
c*p.
z() + fPlanes[i].
d;
1149 G4int i, noSurfaces = 0;
1150 G4double dist, distz, distx, disty, distmx, distmy, safe = kInfinity;
1154 for (i = 0; i < 4; i++)
1156 dist = std::fabs(fPlanes[i].
a*p.
x() + fPlanes[i].
b*p.
y()
1157 + fPlanes[i].
c*p.
z() + fPlanes[i].
d);
1163 distz = std::fabs( std::fabs( p.
z() ) - fDz );
1165 distmy = std::fabs( fPlanes[0].
a*p.
x() + fPlanes[0].
b*p.
y()
1166 + fPlanes[0].
c*p.
z() + fPlanes[0].
d );
1168 disty = std::fabs( fPlanes[1].
a*p.
x() + fPlanes[1].
b*p.
y()
1169 + fPlanes[1].
c*p.
z() + fPlanes[1].
d );
1171 distmx = std::fabs( fPlanes[2].
a*p.
x() + fPlanes[2].
b*p.
y()
1172 + fPlanes[2].
c*p.
z() + fPlanes[2].
d );
1174 distx = std::fabs( fPlanes[3].
a*p.
x() + fPlanes[3].
b*p.
y()
1175 + fPlanes[3].
c*p.
z() + fPlanes[3].
d );
1188 if (distmx <= delta)
1198 if (distmy <= delta)
1206 if ( p.
z() >= 0.) sumnorm += nZ;
1209 if ( noSurfaces == 0 )
1212 G4Exception(
"G4Trap::SurfaceNormal(p)",
"GeomSolids1002",
1215 norm = ApproxSurfaceNormal(p);
1217 else if ( noSurfaces == 1 ) norm = sumnorm;
1218 else norm = sumnorm.
unit();
1229 G4double safe=kInfinity,Dist,safez;
1233 Dist=std::fabs(fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1234 +fPlanes[i].
c*p.
z()+fPlanes[i].
d);
1241 safez=std::fabs(std::fabs(p.
z())-fDz);
1285 smin = (-fDz-p.
z())/v.
z();
1289 return snxt=kInfinity;
1292 else if (v.
z() < 0 )
1294 max = - fDz - p.
z() ;
1298 smin=(fDz-p.
z())/v.
z();
1302 return snxt=kInfinity;
1314 return snxt=kInfinity;
1320 pdist=fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1321 +fPlanes[i].
c*p.
z()+fPlanes[i].
d;
1322 Comp=fPlanes[i].
a*v.
x()+fPlanes[i].
b*v.
y()+fPlanes[i].
c*v.
z();
1330 return snxt=kInfinity ;
1343 return snxt=kInfinity;
1364 return snxt=kInfinity;
1394 safe=std::fabs(p.
z())-fDz;
1397 Dist=fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1398 +fPlanes[i].
c*p.
z()+fPlanes[i].
d;
1399 if (Dist > safe) safe=Dist;
1464 pdist=fPlanes[0].
a*p.
x()+fPlanes[0].
b*p.
y()+fPlanes[0].
c*p.
z()+fPlanes[0].
d;
1465 Comp=fPlanes[0].
a*v.
x()+fPlanes[0].
b*v.
y()+fPlanes[0].
c*v.
z();
1511 pdist=fPlanes[1].
a*p.
x()+fPlanes[1].
b*p.
y()+fPlanes[1].
c*p.
z()+fPlanes[1].
d;
1512 Comp=fPlanes[1].
a*v.
x()+fPlanes[1].
b*v.
y()+fPlanes[1].
c*v.
z();
1558 pdist=fPlanes[2].
a*p.
x()+fPlanes[2].
b*p.
y()+fPlanes[2].
c*p.
z()+fPlanes[2].
d;
1559 Comp=fPlanes[2].
a*v.
x()+fPlanes[2].
b*v.
y()+fPlanes[2].
c*v.
z();
1605 pdist=fPlanes[3].
a*p.
x()+fPlanes[3].
b*p.
y()+fPlanes[3].
c*p.
z()+fPlanes[3].
d;
1606 Comp=fPlanes[3].
a*v.
x()+fPlanes[3].
b*v.
y()+fPlanes[3].
c*v.
z();
1676 std::ostringstream message;
1677 G4int oldprc = message.precision(16);
1678 message <<
"Undefined side for valid surface normal to solid."
1680 <<
"Position:" << G4endl << G4endl
1681 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
1682 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
1683 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
1684 <<
"Direction:" << G4endl << G4endl
1685 <<
"v.x() = " << v.
x() << G4endl
1686 <<
"v.y() = " << v.
y() << G4endl
1687 <<
"v.z() = " << v.
z() << G4endl << G4endl
1688 <<
"Proposed distance :" << G4endl << G4endl
1689 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
1690 message.precision(oldprc);
1691 G4Exception(
"G4Trap::DistanceToOut(p,v,..)",
"GeomSolids1002",
1719 G4cout.precision(oldprc) ;
1721 "GeomSolids1002",
JustWarning,
"Point p is outside !?" );
1725 safe=fDz-std::fabs(p.
z());
1731 Dist=-(fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1732 +fPlanes[i].
c*p.
z()+fPlanes[i].
d);
1733 if (Dist<safe) safe=Dist;
1756 vertices->reserve(8);
1758 -fDz*fTthetaSphi-fDy1,-fDz);
1760 -fDz*fTthetaSphi-fDy1,-fDz);
1762 -fDz*fTthetaSphi+fDy1,-fDz);
1764 -fDz*fTthetaSphi+fDy1,-fDz);
1766 +fDz*fTthetaSphi-fDy2,+fDz);
1768 +fDz*fTthetaSphi-fDy2,+fDz);
1770 +fDz*fTthetaSphi+fDy2,+fDz);
1772 +fDz*fTthetaSphi+fDy2,+fDz);
1788 "Error in allocation of vertices. Out of memory !");
1808 return new G4Trap(*
this);
1817 G4int oldprc = os.precision(16);
1818 os <<
"-----------------------------------------------------------\n"
1819 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1820 <<
" ===================================================\n"
1821 <<
" Solid type: G4Trap\n"
1822 <<
" Parameters: \n"
1823 <<
" half length Z: " << fDz/
mm <<
" mm \n"
1824 <<
" half length Y of face -fDz: " << fDy1/
mm <<
" mm \n"
1825 <<
" half length X of side -fDy1, face -fDz: " << fDx1/
mm <<
" mm \n"
1826 <<
" half length X of side +fDy1, face -fDz: " << fDx2/
mm <<
" mm \n"
1827 <<
" half length Y of face +fDz: " << fDy2/
mm <<
" mm \n"
1828 <<
" half length X of side -fDy2, face +fDz: " << fDx3/
mm <<
" mm \n"
1829 <<
" half length X of side +fDy2, face +fDz: " << fDx4/
mm <<
" mm \n"
1830 <<
" std::tan(theta)*std::cos(phi): " << fTthetaCphi/
degree <<
" degrees \n"
1831 <<
" std::tan(theta)*std::sin(phi): " << fTthetaSphi/
degree <<
" degrees \n"
1832 <<
" std::tan(alpha), -fDz: " << fTalpha1/
degree <<
" degrees \n"
1833 <<
" std::tan(alpha), +fDz: " << fTalpha2/
degree <<
" degrees \n"
1834 <<
" trap side plane equations:\n"
1835 <<
" " << fPlanes[0].
a <<
" X + " << fPlanes[0].
b <<
" Y + "
1836 << fPlanes[0].
c <<
" Z + " << fPlanes[0].
d <<
" = 0\n"
1837 <<
" " << fPlanes[1].
a <<
" X + " << fPlanes[1].
b <<
" Y + "
1838 << fPlanes[1].
c <<
" Z + " << fPlanes[1].
d <<
" = 0\n"
1839 <<
" " << fPlanes[2].
a <<
" X + " << fPlanes[2].
b <<
" Y + "
1840 << fPlanes[2].
c <<
" Z + " << fPlanes[2].
d <<
" = 0\n"
1841 <<
" " << fPlanes[3].
a <<
" X + " << fPlanes[3].
b <<
" Y + "
1842 << fPlanes[3].
c <<
" Z + " << fPlanes[3].
d <<
" = 0\n"
1843 <<
"-----------------------------------------------------------\n";
1844 os.precision(oldprc);
1859 G4double lambda1, lambda2, chose, aOne, aTwo;
1868 w.
z()*v.
x() - w.
x()*v.
z(),
1869 w.
x()*v.
y() - w.
y()*v.
x());
1871 aOne = 0.5*Area.
mag();
1874 t.
z()*u.
x() - t.
x()*u.
z(),
1875 t.
x()*u.
y() - t.
y()*u.
x());
1877 aTwo = 0.5*Area.
mag();
1883 if( (chose>=0.) && (chose < aOne) )
1887 return (p2+lambda1*v+lambda2*w);
1895 return (p0+lambda1*t+lambda2*u);
1904 G4double aOne, aTwo, aThree, aFour, aFive, aSix, chose;
1909 -fDz*fTthetaSphi-fDy1,-fDz);
1911 -fDz*fTthetaSphi-fDy1,-fDz);
1913 -fDz*fTthetaSphi+fDy1,-fDz);
1915 -fDz*fTthetaSphi+fDy1,-fDz);
1917 +fDz*fTthetaSphi-fDy2,+fDz);
1919 +fDz*fTthetaSphi-fDy2,+fDz);
1921 +fDz*fTthetaSphi+fDy2,+fDz);
1923 +fDz*fTthetaSphi+fDy2,+fDz);
1927 One = GetPointOnPlane(pt[0],pt[1],pt[3],pt[2], aOne);
1928 Two = GetPointOnPlane(pt[4],pt[5],pt[7],pt[6], aTwo);
1929 Three = GetPointOnPlane(pt[6],pt[7],pt[3],pt[2], aThree);
1930 Four = GetPointOnPlane(pt[4],pt[5],pt[1],pt[0], aFour);
1931 Five = GetPointOnPlane(pt[0],pt[2],pt[6],pt[4], aFive);
1932 Six = GetPointOnPlane(pt[1],pt[3],pt[7],pt[5], aSix);
1935 if( (chose>=0.) && (chose<aOne) )
1937 else if( (chose>=aOne) && (chose<aOne+aTwo) )
1939 else if( (chose>=aOne+aTwo) && (chose<aOne+aTwo+aThree) )
1941 else if( (chose>=aOne+aTwo+aThree) && (chose<aOne+aTwo+aThree+aFour) )
1943 else if( (chose>=aOne+aTwo+aThree+aFour)
1944 && (chose<aOne+aTwo+aThree+aFour+aFive) )
1960 G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
1961 G4double alpha1 = std::atan(fTalpha1);
1962 G4double alpha2 = std::atan(fTalpha2);
1963 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
1966 fDy1, fDx1, fDx2, alpha1,
1967 fDy2, fDx3, fDx4, alpha2);
ThreeVector shoot(const G4int Ap, const G4int Af)
G4GeometryType GetEntityType() const
G4double GetMinYExtent() const
CLHEP::Hep3Vector G4ThreeVector
G4Trap(const G4String &pName, G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
double dot(const Hep3Vector &) const
G4bool IsYLimited() const
G4Trap & operator=(const G4Trap &rhs)
G4bool IsXLimited() const
virtual void AddSolid(const G4Box &)=0
G4double GetMaxXExtent() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4double GetMinZExtent() const
G4GLOB_DLL std::ostream G4cout
G4Polyhedron * fpPolyhedron
void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
std::vector< G4ThreeVector > G4ThreeVectorList
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4ThreeVector SurfaceNormal(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
std::ostream & StreamInfo(std::ostream &os) const
G4double GetMaxZExtent() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4ThreeVector GetPointOnSurface() const
G4double GetMaxYExtent() const
const G4double kCoplanar_Tolerance
Hep3Vector cross(const Hep3Vector &) const
G4Polyhedron * CreatePolyhedron() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool MakePlane(const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, const G4ThreeVector &p4, TrapSidePlane &plane)
EInside Inside(const G4ThreeVector &p) const
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4bool IsZLimited() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const