37 #if !defined(G4GEOM_USE_UTRAP)
53 using namespace CLHEP;
94 && pt[0].
z() == pt[1].
z()
95 && pt[0].
z() == pt[2].
z()
96 && pt[0].
z() == pt[3].
z()
99 && pt[4].
z() == pt[5].
z()
100 && pt[4].
z() == pt[6].
z()
101 && pt[4].
z() == pt[7].
z()
105 && pt[0].
y() == pt[1].
y()
106 && pt[2].
y() == pt[3].
y()
107 && pt[4].
y() == pt[5].
y()
108 && pt[6].
y() == pt[7].
y()
111 && std::fabs(pt[0].
x()+pt[1].
x()+pt[4].
x()+pt[5].
x() +
115 message <<
"Invalid vertice coordinates for Solid: " <<
GetName();
124 fDy1 = ((pt[2]).
y()-(pt[1]).
y())*0.5;
125 fDx1 = ((pt[1]).
x()-(pt[0]).
x())*0.5;
126 fDx2 = ((pt[3]).
x()-(pt[2]).
x())*0.5;
129 fDy2 = ((pt[6]).
y()-(pt[5]).
y())*0.5;
130 fDx3 = ((pt[5]).
x()-(pt[4]).
x())*0.5;
131 fDx4 = ((pt[7]).
x()-(pt[6]).
x())*0.5;
207 fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
208 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
209 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
221 fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
222 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
223 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
241 :
G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
242 fDz(rhs.fDz), fTthetaCphi(rhs.fTthetaCphi), fTthetaSphi(rhs.fTthetaSphi),
243 fDy1(rhs.fDy1), fDx1(rhs.fDx1), fDx2(rhs.fDx2), fTalpha1(rhs.fTalpha1),
244 fDy2(rhs.fDy2), fDx3(rhs.fDx3), fDx4(rhs.fDx4), fTalpha2(rhs.fTalpha2)
258 if (
this == &rhs) {
return *
this; }
320 message <<
"Invalid Length Parameters for Solid: " <<
GetName()
324 G4Exception(
"G4Trap::CheckParameters()",
"GeomSolids0002",
361 G4int iface[4][4] = { {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3} };
362 G4String side[4] = {
"~-Y",
"~+Y",
"~-X",
"~+X" };
364 for (
G4int i=0; i<4; ++i)
381 message <<
"Side face " << side[i] <<
" is not planar for solid: "
382 <<
GetName() <<
"\nDiscrepancy: " << dmax/
mm <<
" mm\n";
384 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
436 normal = normal.
unit();
439 plane.
a = normal.
x();
440 plane.
b = normal.
y();
441 plane.
c = normal.
z();
442 plane.
d = -normal.
dot(centre);
474 (dx4 + dx3 - dx2 - dx1)*(dy2 - dy1)/3)*dz*0.125;
489 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
492 for (
G4int i=0; i<6; ++i)
497 pt[iface[i][3]]).
mag();
526 for (
G4int i=0; i<8; ++i)
529 if (x < xmin) xmin =
x;
530 if (x > xmax) xmax =
x;
532 if (y < ymin) ymin =
y;
533 if (y > ymax) ymax =
y;
537 pMin.
set(xmin,ymin,-dz);
538 pMax.
set(xmax,ymax, dz);
542 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
545 message <<
"Bad bounding box (min >= max) for solid: "
547 <<
"\npMin = " << pMin
548 <<
"\npMax = " <<
pMax;
549 G4Exception(
"G4Trap::BoundingLimits()",
"GeomMgt0001",
576 return exist = (pMin <
pMax) ?
true :
false;
595 std::vector<const G4ThreeVectorList *> polygons(2);
596 polygons[0] = &baseA;
597 polygons[1] = &baseB;
677 nz = (p.
z() < 0) ? -1 : 1;
685 for (
G4int i=0; i<2; ++i)
694 for (
G4int i=2; i<4; ++i)
711 for (
G4int i=2; i<4; ++i)
764 G4int oldprc = message.precision(16);
765 message <<
"Point p is not on surface (!?) of solid: "
767 message <<
"Position:\n";
768 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
769 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
770 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
771 G4cout.precision(oldprc) ;
772 G4Exception(
"G4Trap::SurfaceNormal(p)",
"GeomSolids1002",
789 for (
G4int i=0; i<4; ++i)
794 if (d > dist) { dist =
d; iside = i; }
833 if (tymin < tmp) tymin =
tmp;
838 if (tymax > tmp) tymax =
tmp;
854 if (txmin < tmp) txmin =
tmp;
859 if (txmax > tmp) txmax =
tmp;
894 return (dist > 0) ? dist : 0.;
905 return (dist > 0) ? dist : 0.;
914 return (dist > 0) ? dist : 0.;
923 return (dist > 0) ? dist : 0.;
946 n->
set(0, 0, (p.
z() < 0) ? -1 : 1);
952 G4int iside = (vz < 0) ? -4 : -2;
973 if (tmax > tmp) { tmax =
tmp; iside = i; }
996 if (tmax > tmp) { tmax =
tmp; iside = i; }
1006 n->
set(0, 0, iside + 3);
1024 G4int oldprc = message.precision(16);
1025 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
1026 message <<
"Position:\n";
1027 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
1028 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
1029 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
1030 G4cout.precision(oldprc) ;
1031 G4Exception(
"G4Trap::DistanceToOut(p)",
"GeomSolids1002",
1050 return (dist < 0) ? -dist : 0.;
1061 return (dist < 0) ? -dist : 0.;
1070 return (dist < 0) ? -dist : 0.;
1079 return (dist < 0) ? -dist : 0.;
1100 return new G4Trap(*
this);
1116 G4int oldprc = os.precision(16);
1117 os <<
"-----------------------------------------------------------\n"
1118 <<
" *** Dump for solid: " <<
GetName() <<
" ***\n"
1119 <<
" ===================================================\n"
1120 <<
" Solid type: G4Trap\n"
1122 <<
" half length Z: " <<
fDz/
mm <<
" mm\n"
1123 <<
" half length Y, face -Dz: " <<
fDy1/
mm <<
" mm\n"
1124 <<
" half length X, face -Dz, side -Dy1: " <<
fDx1/
mm <<
" mm\n"
1125 <<
" half length X, face -Dz, side +Dy1: " <<
fDx2/
mm <<
" mm\n"
1126 <<
" half length Y, face +Dz: " <<
fDy2/
mm <<
" mm\n"
1127 <<
" half length X, face +Dz, side -Dy2: " <<
fDx3/
mm <<
" mm\n"
1128 <<
" half length X, face +Dz, side +Dy2: " <<
fDx4/
mm <<
" mm\n"
1129 <<
" theta: " << theta/
degree << signDegree <<
"\n"
1130 <<
" phi: " << phi/
degree << signDegree <<
"\n"
1131 <<
" alpha, face -Dz: " << alpha1/
degree << signDegree <<
"\n"
1132 <<
" alpha, face +Dz: " << alpha2/
degree << signDegree <<
"\n"
1133 <<
"-----------------------------------------------------------\n";
1134 os.precision(oldprc);
1145 for (
G4int i=0; i<8; ++i)
1147 G4int iy = (i==0 || i==1 || i==4 || i==5) ? 0 : 1;
1148 G4int ix = (i==0 || i==2 || i==4 || i==6) ? 2 : 3;
1164 G4int iface [6][4] =
1165 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
1170 for (
G4int i=0; i<6; ++i)
1175 pt[iface[i][3]]).
mag();
1184 if (select <= sface[4]) k = 4;
1185 if (select <= sface[3]) k = 3;
1186 if (select <= sface[2]) k = 2;
1187 if (select <= sface[1]) k = 1;
1188 if (select <= sface[0]) k = 0;
1204 if (u + v > 1.) { u = 1. -
u; v = 1. -
v; }
1205 return (1.-u-v)*pt[i0] + u*pt[i1] + v*pt[i3];