62 axis0min, axis1min, axis0max, axis1max),
66 G4Exception(
"G4TwistTubsSide::G4TwistTubsSide()",
"GeomSolids0002",
101 SetCorners( EndInnerRadius, EndOuterRadius, EndPhi, EndZ) ;
226 for (i=0; i<2; i++) {
227 distance[i] = kInfinity;
230 gxx[i].
set(kInfinity, kInfinity, kInfinity);
251 isvalid[0], 0, validate, &gp, &gv);
271 distance[0] = - c /
b;
272 xx[0] = p + distance[0]*
v;
276 areacode[0] = GetAreaCode(xx[0]);
278 if (distance[0] >= 0) isvalid[0] =
true;
281 areacode[0] = GetAreaCode(xx[0],
false);
283 if (distance[0] >= 0) isvalid[0] =
true;
289 if (distance[0] >= 0) isvalid[0] =
true;
291 distance[0] = kInfinity;
293 areacode[0], isvalid[0],
294 0, validate, &gp, &gv);
300 isvalid[0], 1, validate, &gp, &gv);
312 isvalid[0], 0, validate, &gp, &gv);
321 G4double tmpdist[2] = {kInfinity, kInfinity};
324 G4bool tmpisvalid[2] = {
false,
false};
327 for (i=0; i<2; i++) {
333 if ( b * D < 0 && std::fabs(bminusD / D) < protection ) {
335 tmpdist[i] = - c/b * ( 1 - acovbb * (1 + 2*acovbb));
337 tmpdist[i] = factor * bminusD;
341 tmpxx[i] = p + tmpdist[i]*
v;
344 tmpareacode[i] = GetAreaCode(tmpxx[i]);
346 if (tmpdist[i] >= 0) tmpisvalid[i] =
true;
350 tmpareacode[i] = GetAreaCode(tmpxx[i],
false);
352 if (tmpdist[i] >= 0) tmpisvalid[i] =
true;
357 if (tmpxx[i].
x() > 0) {
359 if (tmpdist[i] >= 0) tmpisvalid[i] =
true;
362 tmpdist[i] = kInfinity;
368 if (tmpdist[0] <= tmpdist[1]) {
369 distance[0] = tmpdist[0];
370 distance[1] = tmpdist[1];
375 areacode[0] = tmpareacode[0];
376 areacode[1] = tmpareacode[1];
377 isvalid[0] = tmpisvalid[0];
378 isvalid[1] = tmpisvalid[1];
380 distance[0] = tmpdist[1];
381 distance[1] = tmpdist[0];
386 areacode[0] = tmpareacode[1];
387 areacode[1] = tmpareacode[0];
388 isvalid[0] = tmpisvalid[1];
389 isvalid[1] = tmpisvalid[0];
393 isvalid[0], 2, validate, &gp, &gv);
395 isvalid[1], 2, validate, &gp, &gv);
399 for (
G4int k=0; k<2; k++) {
400 if (!isvalid[k])
continue;
403 * xx[k].
z() , xx[k].
z());
404 G4double deltaY = (xx[k] - xxonsurface).mag();
411 for (l=0; l<maxcount; l++) {
414 surfacenormal, xx[k]);
415 deltaY = (xx[k] - xxonsurface).mag();
416 if (deltaY > lastdeltaY) {
425 xxonsurface.
set(xx[k].
x(),
426 fKappa * std::fabs(xx[k].
x()) * xx[k].
z(),
430 std::ostringstream message;
431 message <<
"Exceeded maxloop count!" <<
G4endl
432 <<
" maxloop count " << maxcount;
433 G4Exception(
"G4TwistTubsFlatSide::DistanceToSurface(p,v)",
445 isvalid[0], 0, validate, &gp, &gv);
470 for (i=0; i<2; i++) {
471 distance[i] = kInfinity;
473 gxx[i].
set(kInfinity, kInfinity, kInfinity);
481 G4int parity = (fKappa >= 0 ? 1 : -1);
491 for (i=0; i<2; i++) {
495 if ((gp - lastgxx[0]).mag() < halftol
496 || (gp - lastgxx[1]).mag() < halftol) {
548 }
else if (p.
z() < C.
z()) {
554 }
else if (p.
z() < A.
z()) {
563 for (i=0; i<2; i++) {
566 B = x0[i] + ((A.
z() - x0[i].
z()) / d[i].
z()) * d[i];
570 D = x0[i] + ((C.
z() - x0[i].
z()) / d[i].
z()) * d[i];
604 }
else if (test < 0) {
636 if (std::fabs(distToACB) <= halftol || std::fabs(distToCAD) <= halftol) {
637 xx = (std::fabs(distToACB) < std::fabs(distToCAD) ? xxacb : xxcad);
647 if (distToACB * distToCAD > 0 && distToACB < 0) {
651 distance[0] = DistanceToPlane(p, A, B, C, D, parity, xx, normal);
653 if (distToACB * distToCAD > 0) {
656 if (distToACB <= distToCAD) {
657 distance[0] = distToACB;
660 distance[0] = distToCAD;
667 distance[0] = distToACB;
670 distance[0] = distToCAD;
709 if (distToanm * distTocmn > 0 && distToanm < 0) {
712 "Point p is behind the surfaces.");
716 if (std::fabs(distToanm) <= halftol) {
720 }
else if (std::fabs(distTocmn) <= halftol) {
726 if (distToanm <= distTocmn) {
734 return DistanceToPlane(p, A, M, N, D, parity, xx, n);
744 return DistanceToPlane(p, C, N, M, B, parity, xx, n);
773 if (xx.
x() <=
fAxisMin[xaxis] - ctol) isoutside =
true;
775 }
else if (xx.
x() >
fAxisMax[xaxis] - ctol) {
777 if (xx.
x() >=
fAxisMax[xaxis] + ctol) isoutside =
true;
787 if (xx.
z() <=
fAxisMin[zaxis] - ctol) isoutside =
true;
789 }
else if (xx.
z() >
fAxisMax[zaxis] - ctol) {
792 if (areacode & sBoundary) areacode |=
sCorner;
794 if (xx.
z() >=
fAxisMax[zaxis] + ctol) isoutside =
true;
802 areacode = tmpareacode;
803 }
else if ((areacode & sBoundary) !=
sBoundary) {
821 if (areacode & sBoundary) areacode |=
sCorner;
826 if (areacode & sBoundary) areacode |=
sCorner;
830 if ((areacode & sBoundary) !=
sBoundary) {
838 "Feature NOT implemented !");
846 void G4TwistTubsSide::SetCorners(
862 x = endInnerRad[zmin]*std::cos(endPhi[zmin]);
863 y = endInnerRad[zmin]*std::sin(endPhi[zmin]);
868 x = endOuterRad[zmin]*std::cos(endPhi[zmin]);
869 y = endOuterRad[zmin]*std::sin(endPhi[zmin]);
874 x = endOuterRad[zmax]*std::cos(endPhi[zmax]);
875 y = endOuterRad[zmax]*std::sin(endPhi[zmax]);
880 x = endInnerRad[zmax]*std::cos(endPhi[zmax]);
881 y = endInnerRad[zmax]*std::sin(endPhi[zmax]);
886 std::ostringstream message;
887 message <<
"Feature NOT implemented !" <<
G4endl
889 <<
" fAxis[1] = " <<
fAxis[1];
898 void G4TwistTubsSide::SetCorners()
902 "Method NOT implemented !");
908 void G4TwistTubsSide::SetBoundaries()
918 direction = direction.
unit();
924 direction = direction.
unit();
930 direction = direction.
unit();
936 direction = direction.
unit();
941 std::ostringstream message;
942 message <<
"Feature NOT implemented !" <<
G4endl
944 <<
" fAxis[1] = " <<
fAxis[1];
969 for ( i = 0 ; i<
n ; i++ )
974 for ( j = 0 ; j<k ; j++ ) {
976 nnode =
GetNode(i,j,k,n,iside) ;
982 x = xmin + j*(xmax-xmin)/(k-1) ;
984 x = xmax - j*(xmax-xmin)/(k-1) ;
989 xyz[nnode][0] = p.
x() ;
990 xyz[nnode][1] = p.
y() ;
991 xyz[nnode][2] = p.
z() ;
993 if ( i<n-1 && j<k-1 ) {
995 nface =
GetFace(i,j,k,n,iside) ;