55 fTAlph = std::tan(fAlpha) ;
59 fdeltaX = 2 * fDz * std::tan(fTheta) * std::cos(fPhi) ;
61 fdeltaY = 2 * fDz * std::tan(fTheta) * std::sin(fPhi) ;
64 fPhiTwist = PhiTwist ;
148 for (
auto i=0; i<2; ++i)
150 distance[i] = kInfinity;
153 gxx[i].
set(kInfinity, kInfinity, kInfinity);
165 if (std::fabs(p.
z()) == 0.)
201 isvalid[0], 0, validate, &gp, &gv);
205 distance[0] = - (p.
z() / v.
z());
215 if (distance[0] >= 0) isvalid[0] =
true;
223 if (distance[0] >= 0) isvalid[0] =
true;
229 if (distance[0] >= 0) isvalid[0] =
true;
233 isvalid[0], 1, validate, &gp, &gv);
236 G4cerr <<
"ERROR - G4TwistTrapFlatSide::DistanceToSurface(p,v)" <<
G4endl;
273 for (
auto i=0; i<2; ++i)
275 distance[i] = kInfinity;
277 gxx[i].
set(kInfinity, kInfinity, kInfinity);
293 distance[0] = std::fabs(p.
z());
294 xx.
set(p.
x(), p.
y(), 0);
320 G4double wmax = xAxisMax(xx.
y(), fTAlph ) ;
321 G4double wmin = -xAxisMax(xx.
y(), -fTAlph ) ;
329 if (xx.
x() < wmin + ctol)
332 if (xx.
x() <= wmin - ctol) isoutside =
true;
335 else if (xx.
x() > wmax - ctol)
338 if (xx.
x() >= wmax + ctol) isoutside =
true;
349 if (xx.
y() <=
fAxisMin[yaxis] - ctol) isoutside =
true;
352 else if (xx.
y() >
fAxisMax[yaxis] - ctol)
358 if (xx.
y() >=
fAxisMax[yaxis] + ctol) isoutside =
true;
366 G4int tmpareacode = areacode & (~sInside);
367 areacode = tmpareacode;
382 else if (xx.
x() > wmax)
414 "Feature NOT implemented !");
423void G4TwistTrapFlatSide::SetCorners()
432 x = -fDx1 + fDy * fTAlph ;
438 x = fDx1 + fDy * fTAlph ;
444 x = fDx2 - fDy * fTAlph ;
450 x = -fDx2 - fDy * fTAlph ;
458 std::ostringstream message;
459 message <<
"Feature NOT implemented !" <<
G4endl
461 <<
" fAxis[1] = " <<
fAxis[1];
470void G4TwistTrapFlatSide::SetBoundaries()
481 direction = direction.
unit();
487 direction = direction.
unit();
493 direction = direction.
unit();
499 direction = direction.
unit();
506 std::ostringstream message;
507 message <<
"Feature NOT implemented !" <<
G4endl
509 <<
" fAxis[1] = " <<
fAxis[1];
531 for (
G4int i = 0 ; i<n ; ++i )
533 y = -fDy + i*(2*fDy)/(n-1) ;
535 for (
G4int j = 0 ; j<k ; ++j )
539 x = xmin + j*(xmax-xmin)/(k-1) ;
541 nnode =
GetNode(i,j,k,n,iside) ;
544 xyz[nnode][0] = p.
x() ;
545 xyz[nnode][1] = p.
y() ;
546 xyz[nnode][2] = p.
z() ;
548 if ( i<n-1 && j<k-1 )
550 nface =
GetFace(i,j,k,n,iside) ;
555 * (
GetNode(i ,j ,k,n,iside)+1) ;
557 * (
GetNode(i+1,j ,k,n,iside)+1) ;
559 * (
GetNode(i+1,j+1,k,n,iside)+1) ;
561 * (
GetNode(i ,j+1,k,n,iside)+1) ;
566 * (
GetNode(i ,j ,k,n,iside)+1) ;
568 * (
GetNode(i ,j+1,k,n,iside)+1) ;
570 * (
GetNode(i+1,j+1,k,n,iside)+1) ;
572 * (
GetNode(i+1,j ,k,n,iside)+1) ;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cerr
void set(double x, double y, double z)
HepRotation & rotateZ(double delta)
G4int GetAreaCode(const G4ThreeVector &xx, G4bool withTol=true) override
~G4TwistTrapFlatSide() override
void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside) override
G4double GetBoundaryMax(G4double u) override
G4ThreeVector SurfacePoint(G4double x, G4double y, G4bool isGlobal=false) override
G4ThreeVector GetNormal(const G4ThreeVector &, G4bool isGlobal=false) override
G4double GetBoundaryMin(G4double u) override
G4TwistTrapFlatSide(const G4String &name, G4double PhiTwist, G4double pDx1, G4double pDx2, G4double pDy, G4double pDz, G4double pAlpha, G4double pPhi, G4double pTheta, G4int handedness)
G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol) override
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)
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)
G4ThreeVector ComputeLocalDirection(const G4ThreeVector &gp) const
static const G4int sAxisMin
static const G4int sC0Max1Max
static const G4int sAxis1
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
G4bool IsOutside(G4int areacode) const
static const G4int sCorner
static const G4int sC0Max1Min
static const G4int sInside
virtual G4String GetName() const
CurrentStatus fCurStatWithV
static const G4int sAxisY
static const G4int sAxisX
G4ThreeVector ComputeGlobalPoint(const G4ThreeVector &lp) const
G4SurfCurNormal fCurrentNormal