43 const G4int handedness,
54 axis0min, axis1min, axis0max, axis1max),
55 fKappa(kappa), fTanStereo(tanstereo),
56 fTan2Stereo(tanstereo*tanstereo), fR0(r0), fR02(r0*r0), fDPhi(twopi)
60 G4Exception(
"G4TwistTubsHypeSide::G4TwistTubsHypeSide()",
62 "Should swap axis0 and axis1!");
64 fInside.gp.set(kInfinity, kInfinity, kInfinity);
98 fTanStereo = TanInnerStereo;
103 fTanStereo = TanOuterStereo;
106 fTan2Stereo = fTanStereo * fTanStereo;
112 fInside.gp.set(kInfinity, kInfinity, kInfinity);
115 SetCorners(EndInnerRadius, EndOuterRadius, DPhi, EndPhi, EndZ) ;
125 fR0(0.), fR02(0.), fDPhi(0.)
168 normal = normal.
unit();
190 if (fInside.gp == gp)
192 return fInside.inside;
202 return fInside.inside;
209 if (distanceToOut < -halftol)
215 G4int areacode = GetAreaCode(p);
226 if (distanceToOut <= halftol)
237 G4cout <<
"WARNING - G4TwistTubsHypeSide::Inside()" <<
G4endl
238 <<
" Invalid option !" <<
G4endl
239 <<
" name, areacode, distanceToOut = "
240 <<
GetName() <<
", " << std::hex << areacode
241 << std::dec <<
", " << distanceToOut <<
G4endl;
245 return fInside.inside;
310 for (
auto i=0; i<2; ++i)
312 distance[i] = kInfinity;
315 gxx[i].
set(kInfinity, kInfinity, kInfinity);
345 if (vrho == 0 || (vrho/absvz) <= (absvz*std::fabs(fTanStereo)/absvz))
348 distance[0] = kInfinity;
350 isvalid[0], 0, validate, &gp, &gv);
356 G4double xxz = std::sqrt(fR02 / (vslope2 - fTan2Stereo))
357 * (vz / std::fabs(vz)) ;
359 xx[0].
set(t*v.
x(), t*v.
y(), xxz);
364 xx[0].
set(v.
x()*fR0, v.
y()*fR0, 0);
366 distance[0] = xx[0].
mag();
371 areacode[0] = GetAreaCode(xx[0]);
374 if (distance[0] >= 0) isvalid[0] =
true;
379 areacode[0] = GetAreaCode(xx[0],
false);
382 if (distance[0] >= 0) isvalid[0] =
true;
388 if (distance[0] >= 0) isvalid[0] =
true;
392 isvalid[0], 1, validate, &gp, &gv);
402 * ( p.
x() * v.
x() + p.
y() * v.
y() - p.
z() * v.
z() * fTan2Stereo );
403 G4double c = p.
x()*p.
x() + p.
y()*p.
y() - fR02 - p.
z()*p.
z()*fTan2Stereo;
412 xx[0] = p + distance[0]*v;
417 areacode[0] = GetAreaCode(xx[0]);
420 if (distance[0] >= 0) isvalid[0] =
true;
425 areacode[0] = GetAreaCode(xx[0],
false);
428 if (distance[0] >= 0) isvalid[0] =
true;
434 if (distance[0] >= 0) isvalid[0] =
true;
438 isvalid[0], 1, validate, &gp, &gv);
448 isvalid[0], 0, validate, &gp, &gv);
456 G4double tmpdist[2] = {kInfinity, kInfinity};
459 G4bool tmpisvalid[2] = {
false,
false};
461 for (
auto i=0; i<2; ++i)
463 tmpdist[i] = factor*(-b -
D);
465 tmpxx[i] = p + tmpdist[i]*v;
469 tmpareacode[i] = GetAreaCode(tmpxx[i]);
472 if (tmpdist[i] >= 0) tmpisvalid[i] =
true;
478 tmpareacode[i] = GetAreaCode(tmpxx[i],
false);
481 if (tmpdist[i] >= 0) tmpisvalid[i] =
true;
488 if (tmpdist[i] >= 0) tmpisvalid[i] =
true;
493 if (tmpdist[0] <= tmpdist[1])
495 distance[0] = tmpdist[0];
496 distance[1] = tmpdist[1];
501 areacode[0] = tmpareacode[0];
502 areacode[1] = tmpareacode[1];
503 isvalid[0] = tmpisvalid[0];
504 isvalid[1] = tmpisvalid[1];
508 distance[0] = tmpdist[1];
509 distance[1] = tmpdist[0];
514 areacode[0] = tmpareacode[1];
515 areacode[1] = tmpareacode[0];
516 isvalid[0] = tmpisvalid[1];
517 isvalid[1] = tmpisvalid[0];
521 isvalid[0], 2, validate, &gp, &gv);
523 isvalid[1], 2, validate, &gp, &gv);
532 isvalid[0], 0, validate, &gp, &gv);
571 for (
auto i=0; i<2; ++i)
573 distance[i] = kInfinity;
575 gxx[i].
set(kInfinity, kInfinity, kInfinity);
588 for (
auto i=0; i<2; ++i)
593 if ((gp - lastgxx[0]).mag() < halftol || (gp - lastgxx[1]).mag() < halftol)
612 G4double r1 = std::sqrt(fR02 + pz * pz * fTan2Stereo);
616 if (prho > r1 + halftol)
623 G4double z2 = (prho * fTanStereo + pz) / (1 + fTan2Stereo);
624 G4double r2 = std::sqrt(fR02 + z2 * z2 * fTan2Stereo);
633 distance[0] = (pabsz - xx1).mag();
642 else if (prho < r1 - halftol)
649 xx1.
set(r1, 0. , pz);
654 xx1.
set(t * pabsz.
x(), t * pabsz.
y() , pz);
670 xx2.
set(r2, 0. , 0.);
675 xx2.
set(t * pabsz.
x(), t * pabsz.
y() , 0.);
685 xx.
set(p.
x(), p.
y(), pz);
718 G4int phiareacode = GetAreaCodeInPhi(xx);
726 if (isoutsideinphi) isoutside =
true;
731 if (isoutsideinphi) isoutside =
true;
742 if (xx.
z() <=
fAxisMin[zaxis] - ctol) isoutside =
true;
745 else if (xx.
z() >
fAxisMax[zaxis] - ctol)
751 if (xx.
z() >=
fAxisMax[zaxis] + ctol) isoutside =
true;
759 G4int tmpareacode = areacode & (~sInside);
760 areacode = tmpareacode;
771 G4int phiareacode = GetAreaCodeInPhi(xx,
false);
812 std::ostringstream message;
813 message <<
"Feature NOT implemented !" <<
G4endl
815 <<
" fAxis[1] = " <<
fAxis[1];
855 G4int tmpareacode = areacode & (~sInside);
856 areacode = tmpareacode;
877void G4TwistTubsHypeSide::SetCorners(
G4double EndInnerRadius[2],
890 for (
auto i=0; i<2; ++i)
892 endRad[i] = (
fHandedness == 1 ? EndOuterRadius[i] : EndInnerRadius[i]);
901 x = endRad[zmin]*std::cos(endPhi[zmin] - halfdphi);
902 y = endRad[zmin]*std::sin(endPhi[zmin] - halfdphi);
907 x = endRad[zmin]*std::cos(endPhi[zmin] + halfdphi);
908 y = endRad[zmin]*std::sin(endPhi[zmin] + halfdphi);
913 x = endRad[zmax]*std::cos(endPhi[zmax] + halfdphi);
914 y = endRad[zmax]*std::sin(endPhi[zmax] + halfdphi);
919 x = endRad[zmax]*std::cos(endPhi[zmax] - halfdphi);
920 y = endRad[zmax]*std::sin(endPhi[zmax] - halfdphi);
927 std::ostringstream message;
928 message <<
"Feature NOT implemented !" <<
G4endl
930 <<
" fAxis[1] = " <<
fAxis[1];
939void G4TwistTubsHypeSide::SetCorners()
943 "Method NOT implemented !");
949void G4TwistTubsHypeSide::SetBoundaries()
960 direction = direction.
unit();
966 direction = direction.
unit();
972 direction = direction.
unit();
978 direction = direction.
unit();
984 std::ostringstream message;
985 message <<
"Feature NOT implemented !" <<
G4endl
987 <<
" fAxis[1] = " <<
fAxis[1];
988 G4Exception(
"G4TwistTubsHypeSide::SetBoundaries()",
1009 for (
G4int i = 0 ; i<n ; ++i )
1013 for (
G4int j = 0 ; j<k ; ++j )
1015 nnode =
GetNode(i,j,k,n,iside) ;
1022 x = xmin + j*(xmax-xmin)/(k-1) ;
1026 x = xmax - j*(xmax-xmin)/(k-1) ;
1031 xyz[nnode][0] = p.
x() ;
1032 xyz[nnode][1] = p.
y() ;
1033 xyz[nnode][2] = p.
z() ;
1035 if ( i<n-1 && j<k-1 )
1037 nface =
GetFace(i,j,k,n,iside) ;
1039 * (
GetNode(i ,j ,k,n,iside)+1) ;
1041 * (
GetNode(i+1,j ,k,n,iside)+1) ;
1043 * (
GetNode(i+1,j+1,k,n,iside)+1) ;
1045 * (
GetNode(i ,j+1,k,n,iside)+1) ;
G4double D(G4double temp)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal=false)
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)
virtual G4double GetBoundaryMin(G4double phi)
virtual EInside Inside(const G4ThreeVector &gp)
virtual G4ThreeVector SurfacePoint(G4double, G4double, G4bool isGlobal=false)
G4TwistTubsHypeSide(const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, const G4int handedness, const G4double kappa, const G4double tanstereo, const G4double r0, const EAxis axis0=kPhi, const EAxis axis1=kZAxis, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)
virtual ~G4TwistTubsHypeSide()
virtual G4double GetRhoAtPZ(const G4ThreeVector &p, G4bool isglobal=false) const
virtual G4double GetBoundaryMax(G4double phi)
G4int GetAreacode(G4int i) const
G4double GetDistance(G4int i) const
G4bool IsValid(G4int i) const
void SetCurrentStatus(G4int i, G4ThreeVector &xx, G4double &dist, G4int &areacode, G4bool &isvalid, G4int nxx, EValidate validate, const G4ThreeVector *p, const G4ThreeVector *v=nullptr)
G4ThreeVector GetXX(G4int i) const
void ResetfDone(EValidate validate, const G4ThreeVector *p, const G4ThreeVector *v=nullptr)
virtual G4int AmIOnLeftSide(const G4ThreeVector &me, const G4ThreeVector &vec, G4bool withTol=true)
static const G4int sC0Min1Min
static const G4int sC0Min1Max
G4int GetNode(G4int i, G4int j, G4int m, G4int n, G4int iside)
static const G4int sOutside
G4ThreeVector ComputeGlobalDirection(const G4ThreeVector &lp) const
static const G4int sAxisMax
static const G4int sAxis0
G4int GetFace(G4int i, G4int j, G4int m, G4int n, G4int iside)
G4int GetEdgeVisibility(G4int i, G4int j, G4int m, G4int n, G4int number, G4int orientation)
G4double DistanceToLine(const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
G4ThreeVector ComputeLocalDirection(const G4ThreeVector &gp) const
static const G4int sAxisPhi
static const G4int sAxisMin
static const G4int sC0Max1Max
static const G4int sAxis1
virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode, const G4ThreeVector &p) const
G4bool IsInside(G4int areacode, G4bool testbitmode=false) const
virtual void SetBoundary(const G4int &axiscode, const G4ThreeVector &direction, const G4ThreeVector &x0, const G4int &boundarytype)
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &gp) const
void SetCorner(G4int areacode, G4double x, G4double y, G4double z)
G4ThreeVector GetCorner(G4int areacode) const
static const G4int sBoundary
static const G4int sAxisZ
G4bool IsOutside(G4int areacode) const
static const G4int sCorner
static const G4int sC0Max1Min
static const G4int sInside
virtual G4String GetName() const
CurrentStatus fCurStatWithV
G4bool IsBoundary(G4int areacode, G4bool testbitmode=false) const
G4ThreeVector ComputeGlobalPoint(const G4ThreeVector &lp) const
G4SurfCurNormal fCurrentNormal