36 #if !defined(G4GEOM_USE_UPARA)
47 using namespace CLHEP;
72 fDx = (pt[3].
x() - pt[2].
x())*0.5;
73 fDy = (pt[2].
y() - pt[1].
y())*0.5;
77 fTalpha = (pt[2].
x() + pt[3].
x() - pt[1].
x() - pt[0].
x())*0.25/
fDy;
88 v[0].
set(-DzTthetaCphi-DyTalpha-
fDx, -DzTthetaSphi-
fDy, -
fDz);
89 v[1].
set(-DzTthetaCphi-DyTalpha+
fDx, -DzTthetaSphi-
fDy, -
fDz);
90 v[2].
set(-DzTthetaCphi+DyTalpha-
fDx, -DzTthetaSphi+
fDy, -
fDz);
91 v[3].
set(-DzTthetaCphi+DyTalpha+
fDx, -DzTthetaSphi+
fDy, -
fDz);
92 v[4].
set( DzTthetaCphi-DyTalpha-
fDx, DzTthetaSphi-
fDy,
fDz);
93 v[5].
set( DzTthetaCphi-DyTalpha+
fDx, DzTthetaSphi-
fDy,
fDz);
94 v[6].
set( DzTthetaCphi+DyTalpha-
fDx, DzTthetaSphi+
fDy,
fDz);
95 v[7].
set( DzTthetaCphi+DyTalpha+
fDx, DzTthetaSphi+
fDy,
fDz);
99 for (
G4int i=0; i<8; ++i)
108 G4int oldprc = message.precision(16);
109 message <<
"Invalid vertice coordinates for Solid: " <<
GetName()
110 <<
"\nVertix #" << i <<
", discrepancy = " << discrepancy
111 <<
"\n original : " << pt[i]
112 <<
"\n recomputed : " << v[i];
146 :
G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
147 fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), fTalpha(rhs.fTalpha),
148 fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(rhs.fTthetaSphi)
161 if (
this == &rhs) {
return *
this; }
216 message <<
"Invalid (too small or negative) dimensions for Solid: "
221 G4Exception(
"G4Para::CheckParameters()",
"GeomSolids0002",
327 std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
331 std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
337 pMin.
set(xmin,ymin,-dz);
338 pMax.
set(xmax,ymax, dz);
342 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
345 message <<
"Bad bounding box (min >= max) for solid: "
347 <<
"\npMin = " << pMin
348 <<
"\npMax = " <<
pMax;
349 G4Exception(
"G4Para::BoundingLimits()",
"GeomMgt0001",
376 return exist = (pMin <
pMax) ?
true :
false;
390 baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
391 baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
392 baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
393 baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
395 baseB[0].set(+x0-x1-dx, y0-dy, dz);
396 baseB[1].set(+x0-x1+dx, y0-dy, dz);
397 baseB[2].set(+x0+x1+dx, y0+dy, dz);
398 baseB[3].set(+x0+x1-dx, y0+dy, dz);
400 std::vector<const G4ThreeVectorList *> polygons(2);
401 polygons[0] = &baseA;
402 polygons[1] = &baseB;
444 nz = (p.
z() < 0) ? -1 : 1;
494 G4int oldprc = message.precision(16);
495 message <<
"Point p is not on surface (!?) of solid: "
497 message <<
"Position:\n";
498 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
499 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
500 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
501 G4cout.precision(oldprc) ;
502 G4Exception(
"G4Para::SurfaceNormal(p)",
"GeomSolids1002",
519 for (
G4int i=0; i<4; ++i)
524 if (d > dist) { dist =
d; iside = i; }
553 G4double tmin0 = tzmin, tmax0 = tzmax;
561 if (tmin0 < tmp) tmin0 =
tmp;
566 if (tmax0 > tmp) tmax0 =
tmp;
569 G4double tmin1 = tmin0, tmax1 = tmax0;
576 if (tmin1 < tmp) tmin1 =
tmp;
581 if (tmax1 > tmp) tmax1 =
tmp;
586 G4double tmin2 = tmin1, tmax2 = tmax1;
594 if (tmin2 < tmp) tmin2 =
tmp;
599 if (tmax2 > tmp) tmax2 =
tmp;
602 G4double tmin3 = tmin2, tmax3 = tmax2;
609 if (tmin3 < tmp) tmin3 =
tmp;
614 if (tmax3 > tmp) tmax3 =
tmp;
619 G4double tmin = tmin3, tmax = tmax3;
641 return (dist > 0) ? dist : 0.;
661 n->
set(0, 0, (p.
z() < 0) ? -1 : 1);
667 G4int iside = (vz < 0) ? -4 : -2;
685 if (tmax > tmp) { tmax =
tmp; iside = 0; }
702 if (tmax > tmp) { tmax =
tmp; iside = 1; }
721 if (tmax > tmp) { tmax =
tmp; iside = 2; }
738 if (tmax > tmp) { tmax =
tmp; iside = 3; }
747 n->
set(0, 0, iside + 3);
765 G4int oldprc = message.precision(16);
766 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
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(
"G4Para::DistanceToOut(p)",
"GeomSolids1002",
787 return (dist < 0) ? -dist : 0.;
820 G4int oldprc = os.precision(16);
821 os <<
"-----------------------------------------------------------\n"
822 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
823 <<
" ===================================================\n"
824 <<
" Solid type: G4Para\n"
826 <<
" half length X: " <<
fDx/
mm <<
" mm\n"
827 <<
" half length Y: " <<
fDy/
mm <<
" mm\n"
828 <<
" half length Z: " <<
fDz/
mm <<
" mm\n"
829 <<
" alpha: " << alpha/
degree << signDegree <<
"\n"
830 <<
" theta: " << theta/
degree << signDegree <<
"\n"
831 <<
" phi: " << phi/
degree << signDegree <<
"\n"
832 <<
"-----------------------------------------------------------\n";
833 os.precision(oldprc);
851 pt[0].
set(-DzTthetaCphi-DyTalpha-
fDx, -DzTthetaSphi-
fDy, -
fDz);
852 pt[1].
set(-DzTthetaCphi-DyTalpha+
fDx, -DzTthetaSphi-
fDy, -
fDz);
853 pt[2].
set(-DzTthetaCphi+DyTalpha-
fDx, -DzTthetaSphi+
fDy, -
fDz);
854 pt[3].
set(-DzTthetaCphi+DyTalpha+
fDx, -DzTthetaSphi+
fDy, -
fDz);
855 pt[4].
set( DzTthetaCphi-DyTalpha-
fDx, DzTthetaSphi-
fDy,
fDz);
856 pt[5].
set( DzTthetaCphi-DyTalpha+
fDx, DzTthetaSphi-
fDy,
fDz);
857 pt[6].
set( DzTthetaCphi+DyTalpha-
fDx, DzTthetaSphi+
fDy,
fDz);
858 pt[7].
set( DzTthetaCphi+DyTalpha+
fDx, DzTthetaSphi+
fDy,
fDz);
870 G4double sface[6] = { sxy, syz, syz, sxz, sxz, sxy };
871 for (
G4int i=1; i<6; ++i) { sface[i] += sface[i-1]; }
877 if (select <= sface[4]) k = 4;
878 if (select <= sface[3]) k = 3;
879 if (select <= sface[2]) k = 2;
880 if (select <= sface[1]) k = 1;
881 if (select <= sface[0]) k = 0;
885 G4int ip[6][3] = {{0,1,2}, {0,4,1}, {2,3,6}, {0,2,4}, {1,5,3}, {4,6,5}};
888 return (1.-u-v)*pt[ip[
k][0]] + u*pt[ip[
k][1]] + v*pt[ip[
k][2]];