Geant4-11
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4TwistTubsSide Class Reference

#include <G4TwistTubsSide.hh>

Inheritance diagram for G4TwistTubsSide:
G4VTwistSurface

Public Types

enum  EValidate { kDontValidate = 0 , kValidateWithTol = 1 , kValidateWithoutTol = 2 , kUninitialized = 3 }
 

Public Member Functions

virtual G4int AmIOnLeftSide (const G4ThreeVector &me, const G4ThreeVector &vec, G4bool withTol=true)
 
G4ThreeVector ComputeGlobalDirection (const G4ThreeVector &lp) const
 
G4ThreeVector ComputeGlobalPoint (const G4ThreeVector &lp) const
 
G4ThreeVector ComputeLocalDirection (const G4ThreeVector &gp) const
 
G4ThreeVector ComputeLocalPoint (const G4ThreeVector &gp) const
 
void DebugPrint () const
 
virtual G4double DistanceTo (const G4ThreeVector &gp, G4ThreeVector &gxx)
 
virtual G4double DistanceToBoundary (G4int areacode, G4ThreeVector &xx, const G4ThreeVector &p)
 
virtual G4double DistanceToIn (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
 
G4double DistanceToLine (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
 
virtual G4double DistanceToOut (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
 
G4double DistanceToPlane (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
 
G4double DistanceToPlane (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &t1, const G4ThreeVector &t2, G4ThreeVector &xx, G4ThreeVector &n)
 
G4double DistanceToPlaneWithV (const G4ThreeVector &p, const G4ThreeVector &v, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
 
virtual G4int DistanceToSurface (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)
 
virtual G4int DistanceToSurface (const G4ThreeVector &gp, G4ThreeVector gxx[], G4double distance[], G4int areacode[])
 
 G4TwistTubsSide (__void__ &)
 
 G4TwistTubsSide (const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, G4int handedness, const G4double kappa, const EAxis axis0=kXAxis, const EAxis axis1=kZAxis, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
 
 G4TwistTubsSide (const G4String &name, G4double EndInnerRadius[2], G4double EndOuterRadius[2], G4double DPhi, G4double EndPhi[2], G4double EndZ[2], G4double InnerRadius, G4double OuterRadius, G4double Kappa, G4int handedness)
 
G4int GetAxisType (G4int areacode, G4int whichaxis) const
 
virtual G4ThreeVector GetBoundaryAtPZ (G4int areacode, const G4ThreeVector &p) const
 
virtual G4double GetBoundaryMax (G4double phi)
 
virtual G4double GetBoundaryMin (G4double phi)
 
virtual void GetBoundaryParameters (const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
 
G4int GetEdgeVisibility (G4int i, G4int j, G4int m, G4int n, G4int number, G4int orientation)
 
G4int GetFace (G4int i, G4int j, G4int m, G4int n, G4int iside)
 
virtual void GetFacets (G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)
 
virtual G4String GetName () const
 
G4int GetNode (G4int i, G4int j, G4int m, G4int n, G4int iside)
 
virtual G4ThreeVector GetNormal (const G4ThreeVector &xx, G4bool isGlobal=false)
 
virtual G4double GetSurfaceArea ()
 
G4bool IsAxis0 (G4int areacode) const
 
G4bool IsAxis1 (G4int areacode) const
 
G4bool IsBoundary (G4int areacode, G4bool testbitmode=false) const
 
G4bool IsCorner (G4int areacode, G4bool testbitmode=false) const
 
G4bool IsInside (G4int areacode, G4bool testbitmode=false) const
 
G4bool IsOutside (G4int areacode) const
 
G4bool IsSameBoundary (G4VTwistSurface *surface1, G4int areacode1, G4VTwistSurface *surface2, G4int areacode2) const
 
G4bool IsValidNorm () const
 
G4ThreeVector ProjectAtPXPZ (const G4ThreeVector &p, G4bool isglobal=false) const
 
void SetAxis (G4int i, const EAxis axis)
 
void SetNeighbours (G4VTwistSurface *ax0min, G4VTwistSurface *ax1min, G4VTwistSurface *ax0max, G4VTwistSurface *ax1max)
 
virtual G4ThreeVector SurfacePoint (G4double, G4double, G4bool isGlobal=false)
 
virtual ~G4TwistTubsSide ()
 

Static Public Attributes

static const G4int sAreaMask = 0XF0000000
 
static const G4int sAxis0 = 0x0000FF00
 
static const G4int sAxis1 = 0x000000FF
 
static const G4int sAxisMask = 0x0000FCFC
 
static const G4int sAxisMax = 0x00000202
 
static const G4int sAxisMin = 0x00000101
 
static const G4int sAxisPhi = 0x00001414
 
static const G4int sAxisRho = 0x00001010
 
static const G4int sAxisX = 0x00000404
 
static const G4int sAxisY = 0x00000808
 
static const G4int sAxisZ = 0x00000C0C
 
static const G4int sBoundary = 0x20000000
 
static const G4int sC0Max1Max = 0x40000202
 
static const G4int sC0Max1Min = 0x40000201
 
static const G4int sC0Min1Max = 0x40000102
 
static const G4int sC0Min1Min = 0x40000101
 
static const G4int sCorner = 0x40000000
 
static const G4int sInside = 0x10000000
 
static const G4int sOutside = 0x00000000
 
static const G4int sSizeMask = 0x00000303
 

Protected Member Functions

void GetBoundaryAxis (G4int areacode, EAxis axis[]) const
 
void GetBoundaryLimit (G4int areacode, G4double limit[]) const
 
G4ThreeVector GetCorner (G4int areacode) const
 
G4VTwistSurface ** GetNeighbours ()
 
G4int GetNeighbours (G4int areacode, G4VTwistSurface *surfaces[])
 
virtual void SetBoundary (const G4int &axiscode, const G4ThreeVector &direction, const G4ThreeVector &x0, const G4int &boundarytype)
 
void SetCorner (G4int areacode, G4double x, G4double y, G4double z)
 

Protected Attributes

EAxis fAxis [2]
 
G4double fAxisMax [2]
 
G4double fAxisMin [2]
 
G4SurfCurNormal fCurrentNormal
 
CurrentStatus fCurStat
 
CurrentStatus fCurStatWithV
 
G4int fHandedness
 
G4bool fIsValidNorm
 
G4RotationMatrix fRot
 
G4ThreeVector fTrans
 
G4double kCarTolerance
 

Private Member Functions

virtual G4double DistanceToPlane (const G4ThreeVector &p, const G4ThreeVector &A, const G4ThreeVector &B, const G4ThreeVector &C, const G4ThreeVector &D, const G4int parity, G4ThreeVector &xx, G4ThreeVector &n)
 
virtual G4int GetAreaCode (const G4ThreeVector &xx, G4bool withTol=true)
 
virtual void SetBoundaries ()
 
virtual void SetCorners ()
 
virtual void SetCorners (G4double endInnerRad[2], G4double endOuterRad[2], G4double endPhi[2], G4double endZ[2])
 

Private Attributes

G4SurfSideQuery fAmIOnLeftSide
 
Boundary fBoundaries [4]
 
G4ThreeVector fCorners [4]
 
G4double fKappa
 
G4String fName
 
G4VTwistSurfacefNeighbours [4]
 

Detailed Description

Definition at line 41 of file G4TwistTubsSide.hh.

Member Enumeration Documentation

◆ EValidate

Enumerator
kDontValidate 
kValidateWithTol 
kValidateWithoutTol 
kUninitialized 

Definition at line 52 of file G4VTwistSurface.hh.

Constructor & Destructor Documentation

◆ G4TwistTubsSide() [1/3]

G4TwistTubsSide::G4TwistTubsSide ( const G4String name,
const G4RotationMatrix rot,
const G4ThreeVector tlate,
G4int  handedness,
const G4double  kappa,
const EAxis  axis0 = kXAxis,
const EAxis  axis1 = kZAxis,
G4double  axis0min = -kInfinity,
G4double  axis1min = -kInfinity,
G4double  axis0max = kInfinity,
G4double  axis1max = kInfinity 
)

Definition at line 38 of file G4TwistTubsSide.cc.

49 : G4VTwistSurface(name, rot, tlate, handedness, axis0, axis1,
50 axis0min, axis1min, axis0max, axis1max),
51 fKappa(kappa)
52{
53 if (axis0 == kZAxis && axis1 == kXAxis)
54 {
55 G4Exception("G4TwistTubsSide::G4TwistTubsSide()", "GeomSolids0002",
56 FatalErrorInArgument, "Should swap axis0 and axis1!");
57 }
58 fIsValidNorm = false;
59 SetCorners();
61}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
virtual void SetCorners()
virtual void SetBoundaries()
G4VTwistSurface(const G4String &name)
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57
const char * name(G4int ptype)

References FatalErrorInArgument, G4VTwistSurface::fIsValidNorm, G4Exception(), kXAxis, kZAxis, SetBoundaries(), and SetCorners().

◆ G4TwistTubsSide() [2/3]

G4TwistTubsSide::G4TwistTubsSide ( const G4String name,
G4double  EndInnerRadius[2],
G4double  EndOuterRadius[2],
G4double  DPhi,
G4double  EndPhi[2],
G4double  EndZ[2],
G4double  InnerRadius,
G4double  OuterRadius,
G4double  Kappa,
G4int  handedness 
)

Definition at line 63 of file G4TwistTubsSide.cc.

74{
75 fHandedness = handedness; // +z = +ve, -z = -ve
76 fAxis[0] = kXAxis; // in local coordinate system
77 fAxis[1] = kZAxis;
78 fAxisMin[0] = InnerRadius; // Inner-hype radius at z=0
79 fAxisMax[0] = OuterRadius; // Outer-hype radius at z=0
80 fAxisMin[1] = EndZ[0];
81 fAxisMax[1] = EndZ[1];
82
83 fKappa = Kappa;
85 ? -0.5*DPhi
86 : 0.5*DPhi );
87 fTrans.set(0, 0, 0);
88 fIsValidNorm = false;
89
90 SetCorners( EndInnerRadius, EndOuterRadius, EndPhi, EndZ) ;
92}
void set(double x, double y, double z)
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:87
G4double fAxisMax[2]
G4RotationMatrix fRot
G4ThreeVector fTrans
G4double fAxisMin[2]

References G4VTwistSurface::fAxis, G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4VTwistSurface::fHandedness, G4VTwistSurface::fIsValidNorm, fKappa, G4VTwistSurface::fRot, G4VTwistSurface::fTrans, kXAxis, kZAxis, CLHEP::HepRotation::rotateZ(), CLHEP::Hep3Vector::set(), SetBoundaries(), and SetCorners().

◆ ~G4TwistTubsSide()

G4TwistTubsSide::~G4TwistTubsSide ( )
virtual

Definition at line 106 of file G4TwistTubsSide.cc.

107{
108}

◆ G4TwistTubsSide() [3/3]

G4TwistTubsSide::G4TwistTubsSide ( __void__ &  a)

Definition at line 97 of file G4TwistTubsSide.cc.

98 : G4VTwistSurface(a), fKappa(0.)
99{
100}

Member Function Documentation

◆ AmIOnLeftSide()

G4int G4VTwistSurface::AmIOnLeftSide ( const G4ThreeVector me,
const G4ThreeVector vec,
G4bool  withTol = true 
)
virtualinherited

Definition at line 147 of file G4VTwistSurface.cc.

150{
151 // AmIOnLeftSide returns phi-location of "me"
152 // (phi relation between me and vec projected on z=0 plane).
153 // If "me" is on -ve-phi-side of "vec", it returns 1.
154 // On the other hand, if "me" is on +ve-phi-side of "vec",
155 // it returns -1.
156 // (The return value represents z-coordinate of normal vector
157 // of me.cross(vec).)
158 // If me is on boundary of vec, return 0.
159
160 const G4double kAngTolerance
162
163 G4RotationMatrix unitrot;
164 const G4RotationMatrix rottol = unitrot.rotateZ(0.5*kAngTolerance);
165 const G4RotationMatrix invrottol = unitrot.rotateZ(-1.*kAngTolerance);
166
167 if (fAmIOnLeftSide.me == me
168 && fAmIOnLeftSide.vec == vec
169 && fAmIOnLeftSide.withTol == withtol)
170 {
172 }
173
174 fAmIOnLeftSide.me = me;
175 fAmIOnLeftSide.vec = vec;
176 fAmIOnLeftSide.withTol = withtol;
177
178 G4ThreeVector met = (G4ThreeVector(me.x(), me.y(), 0.)).unit();
179 G4ThreeVector vect = (G4ThreeVector(vec.x(), vec.y(), 0.)).unit();
180
181 G4ThreeVector ivect = invrottol * vect;
182 G4ThreeVector rvect = rottol * vect;
183
184 G4double metcrossvect = met.x() * vect.y() - met.y() * vect.x();
185
186 if (withtol)
187 {
188 if (met.x() * ivect.y() - met.y() * ivect.x() > 0 &&
189 metcrossvect >= 0) {
191 } else if (met.x() * rvect.y() - met.y() * rvect.x() < 0 &&
192 metcrossvect <= 0) {
194 } else {
196 }
197 }
198 else
199 {
200 if (metcrossvect > 0) {
202 } else if (metcrossvect < 0 ) {
204 } else {
206 }
207 }
208
209#ifdef G4TWISTDEBUG
210 G4cout << " === G4VTwistSurface::AmIOnLeftSide() =============="
211 << G4endl;
212 G4cout << " Name , returncode : " << fName << " "
214 G4cout << " me, vec : " << std::setprecision(14) << me
215 << " " << vec << G4endl;
216 G4cout << " met, vect : " << met << " " << vect << G4endl;
217 G4cout << " ivec, rvec : " << ivect << " " << rvect << G4endl;
218 G4cout << " met x vect : " << metcrossvect << G4endl;
219 G4cout << " met x ivec : " << met.cross(ivect) << G4endl;
220 G4cout << " met x rvec : " << met.cross(rvect) << G4endl;
221 G4cout << " =============================================="
222 << G4endl;
223#endif
224
226}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
double x() const
double y() const
Hep3Vector cross(const Hep3Vector &) const
static G4GeometryTolerance * GetInstance()
G4double GetAngularTolerance() const
G4SurfSideQuery fAmIOnLeftSide

References G4VTwistSurface::G4SurfSideQuery::amIOnLeftSide, CLHEP::Hep3Vector::cross(), G4VTwistSurface::fAmIOnLeftSide, G4VTwistSurface::fName, G4cout, G4endl, G4GeometryTolerance::GetAngularTolerance(), G4GeometryTolerance::GetInstance(), G4VTwistSurface::G4SurfSideQuery::me, CLHEP::HepRotation::rotateZ(), G4VTwistSurface::G4SurfSideQuery::vec, G4VTwistSurface::G4SurfSideQuery::withTol, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

Referenced by DistanceToSurface(), G4TwistTubsFlatSide::GetAreaCode(), and G4TwistTubsHypeSide::GetAreaCodeInPhi().

◆ ComputeGlobalDirection()

G4ThreeVector G4VTwistSurface::ComputeGlobalDirection ( const G4ThreeVector lp) const
inlineinherited

◆ ComputeGlobalPoint()

G4ThreeVector G4VTwistSurface::ComputeGlobalPoint ( const G4ThreeVector lp) const
inlineinherited

◆ ComputeLocalDirection()

G4ThreeVector G4VTwistSurface::ComputeLocalDirection ( const G4ThreeVector gp) const
inlineinherited

◆ ComputeLocalPoint()

G4ThreeVector G4VTwistSurface::ComputeLocalPoint ( const G4ThreeVector gp) const
inlineinherited

◆ DebugPrint()

void G4VTwistSurface::DebugPrint ( ) const
inherited

Definition at line 1139 of file G4VTwistSurface.cc.

1140{
1145
1146 G4cout << "/* G4VTwistSurface::DebugPrint():--------------------------"
1147 << G4endl;
1148 G4cout << "/* Name = " << fName << G4endl;
1149 G4cout << "/* Axis = " << std::hex << fAxis[0] << " "
1150 << std::hex << fAxis[1]
1151 << " (0,1,2,3,5 = kXAxis,kYAxis,kZAxis,kRho,kPhi)"
1152 << std::dec << G4endl;
1153 G4cout << "/* BoundaryLimit(in local) fAxis0(min, max) = ("<<fAxisMin[0]
1154 << ", " << fAxisMax[0] << ")" << G4endl;
1155 G4cout << "/* BoundaryLimit(in local) fAxis1(min, max) = ("<<fAxisMin[1]
1156 << ", " << fAxisMax[1] << ")" << G4endl;
1157 G4cout << "/* Cornar point sC0Min1Min = " << A << G4endl;
1158 G4cout << "/* Cornar point sC0Max1Min = " << B << G4endl;
1159 G4cout << "/* Cornar point sC0Max1Max = " << C << G4endl;
1160 G4cout << "/* Cornar point sC0Min1Max = " << D << G4endl;
1161 G4cout << "/*---------------------------------------------------------"
1162 << G4endl;
1163}
G4double C(G4double temp)
G4double B(G4double temperature)
G4double D(G4double temp)
const G4double A[17]
static const G4int sC0Min1Min
static const G4int sC0Min1Max
static const G4int sC0Max1Max
G4ThreeVector GetCorner(G4int areacode) const
static const G4int sC0Max1Min

References A, B(), C(), D(), G4VTwistSurface::fAxis, G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4VTwistSurface::fName, G4VTwistSurface::fRot, G4VTwistSurface::fTrans, G4cout, G4endl, G4VTwistSurface::GetCorner(), G4VTwistSurface::sC0Max1Max, G4VTwistSurface::sC0Max1Min, G4VTwistSurface::sC0Min1Max, and G4VTwistSurface::sC0Min1Min.

◆ DistanceTo()

G4double G4VTwistSurface::DistanceTo ( const G4ThreeVector gp,
G4ThreeVector gxx 
)
virtualinherited

Definition at line 577 of file G4VTwistSurface.cc.

579{
580#ifdef G4TWISTDEBUG
581 G4cout << "~~~~~ G4VTwistSurface::DistanceTo(p) - Start ~~~~~~~~~" << G4endl;
582 G4cout << " Name : " << fName << G4endl;
583 G4cout << " gp : " << gp << G4endl;
584 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
585#endif
586
587
589 G4double distance[G4VSURFACENXX] ;
590 G4int areacode[G4VSURFACENXX] ;
591
592 for (G4int i = 0 ; i<G4VSURFACENXX ; ++i )
593 {
594 distance[i] = kInfinity ;
595 areacode[i] = sOutside ;
596 }
597
598 DistanceToSurface(gp, gxx, distance, areacode);
599 gxxbest = gxx[0];
600
601#ifdef G4TWISTDEBUG
602 G4cout << "~~~~~ G4VTwistSurface::DistanceTo(p) - return ~~~~~~~~" << G4endl;
603 G4cout << " Name : " << fName << G4endl;
604 G4cout << " gxx : " << gxxbest << G4endl;
605 G4cout << " bestdist : " << distance[0] << G4endl;
606 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
607#endif
608
609 return distance[0];
610}
int G4int
Definition: G4Types.hh:85
#define G4VSURFACENXX
static const G4int sOutside
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)=0
static const G4double kInfinity
Definition: geomdefs.hh:41

References G4VTwistSurface::DistanceToSurface(), G4VTwistSurface::fName, G4cout, G4endl, G4VSURFACENXX, kInfinity, and G4VTwistSurface::sOutside.

Referenced by G4TwistedTubs::DistanceToIn(), G4VTwistedFaceted::DistanceToIn(), G4TwistedTubs::DistanceToOut(), G4VTwistedFaceted::DistanceToOut(), G4TwistedTubs::SurfaceNormal(), and G4VTwistedFaceted::SurfaceNormal().

◆ DistanceToBoundary()

G4double G4VTwistSurface::DistanceToBoundary ( G4int  areacode,
G4ThreeVector xx,
const G4ThreeVector p 
)
virtualinherited

Definition at line 231 of file G4VTwistSurface.cc.

234{
235 // DistanceToBoundary
236 //
237 // return distance to nearest boundary from arbitrary point p
238 // in local coodinate.
239 // Argument areacode must be one of them:
240 // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
241 // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
242 //
243
244 G4ThreeVector d; // direction vector of the boundary
245 G4ThreeVector x0; // reference point of the boundary
246 G4double dist = kInfinity;
247 G4int boundarytype;
248
249 if (IsAxis0(areacode) && IsAxis1(areacode))
250 {
251 std::ostringstream message;
252 message << "Point is in the corner area." << G4endl
253 << " Point is in the corner area. This function returns"
254 << G4endl
255 << " a direction vector of a boundary line." << G4endl
256 << " areacode = " << areacode;
257 G4Exception("G4VTwistSurface::DistanceToBoundary()", "GeomSolids0003",
258 FatalException, message);
259 }
260 else if (IsAxis0(areacode) || IsAxis1(areacode))
261 {
262 GetBoundaryParameters(areacode, d, x0, boundarytype);
263 if (boundarytype == sAxisPhi)
264 {
265 G4double t = x0.getRho() / p.getRho();
266 xx.set(t*p.x(), t*p.y(), x0.z());
267 dist = (xx - p).mag();
268 }
269 else
270 {
271 // linear boundary
272 // sAxisX, sAxisY, sAxisZ, sAxisRho
273 dist = DistanceToLine(p, x0, d, xx);
274 }
275 }
276 else
277 {
278 std::ostringstream message;
279 message << "Bad areacode of boundary." << G4endl
280 << " areacode = " << areacode;
281 G4Exception("G4VTwistSurface::DistanceToBoundary()", "GeomSolids0003",
282 FatalException, message);
283 }
284 return dist;
285}
@ FatalException
double z() const
double getRho() const
G4bool IsAxis1(G4int areacode) const
G4bool IsAxis0(G4int areacode) const
G4double DistanceToLine(const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
static const G4int sAxisPhi
virtual void GetBoundaryParameters(const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const

References G4VTwistSurface::DistanceToLine(), FatalException, G4endl, G4Exception(), G4VTwistSurface::GetBoundaryParameters(), CLHEP::Hep3Vector::getRho(), G4VTwistSurface::IsAxis0(), G4VTwistSurface::IsAxis1(), kInfinity, G4VTwistSurface::sAxisPhi, CLHEP::Hep3Vector::set(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToSurface().

◆ DistanceToIn()

G4double G4VTwistSurface::DistanceToIn ( const G4ThreeVector gp,
const G4ThreeVector gv,
G4ThreeVector gxxbest 
)
virtualinherited

Definition at line 290 of file G4VTwistSurface.cc.

293{
294#ifdef G4TWISTDEBUG
295 G4cout << " ~~~~ G4VTwistSurface::DistanceToIn(p,v) - Start ~~~~" << G4endl;
296 G4cout << " Name : " << fName << G4endl;
297 G4cout << " gp : " << gp << G4endl;
298 G4cout << " gv : " << gv << G4endl;
299 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
300#endif
301
303 G4double distance[G4VSURFACENXX] ;
304 G4int areacode[G4VSURFACENXX] ;
305 G4bool isvalid[G4VSURFACENXX] ;
306
307 for (G4int i = 0 ; i<G4VSURFACENXX ; ++i )
308 {
309 distance[i] = kInfinity ;
310 areacode[i] = sOutside ;
311 isvalid[i] = false ;
312 }
313
314 G4double bestdistance = kInfinity;
315#ifdef G4TWISTDEBUG
316 G4int besti = -1;
317#endif
319
320 G4int nxx = DistanceToSurface(gp, gv, gxx, distance, areacode,
321 isvalid, kValidateWithTol);
322
323 for (G4int i=0; i<nxx; ++i)
324 {
325
326 // skip this intersection if:
327 // - invalid intersection
328 // - particle goes outword the surface
329
330 if (!isvalid[i])
331 {
332 // xx[i] is sOutside or distance[i] < 0
333 continue;
334 }
335
336 G4ThreeVector normal = GetNormal(gxx[i], true);
337
338 if ((normal * gv) >= 0)
339 {
340
341#ifdef G4TWISTDEBUG
342 G4cout << " G4VTwistSurface::DistanceToIn(p,v): "
343 << "particle goes outword the surface." << G4endl;
344#endif
345 continue;
346 }
347
348 //
349 // accept this intersection if the intersection is inside.
350 //
351
352 if (IsInside(areacode[i]))
353 {
354 if (distance[i] < bestdistance)
355 {
356 bestdistance = distance[i];
357 bestgxx = gxx[i];
358#ifdef G4TWISTDEBUG
359 besti = i;
360 G4cout << " G4VTwistSurface::DistanceToIn(p,v): "
361 << " areacode sInside name, distance = "
362 << fName << " "<< bestdistance << G4endl;
363#endif
364 }
365
366 //
367 // else, the intersection is on boundary or corner.
368 //
369
370 }
371 else
372 {
373 G4VTwistSurface* neighbours[2];
374 G4bool isaccepted[2] = {false, false};
375 G4int nneighbours = GetNeighbours(areacode[i], neighbours);
376
377 for (G4int j=0; j<nneighbours; ++j)
378 {
379 // if on corner, nneighbours = 2.
380 // if on boundary, nneighbours = 1.
381
383 G4double tmpdist[G4VSURFACENXX] ;
384 G4int tmpareacode[G4VSURFACENXX] ;
385 G4bool tmpisvalid[G4VSURFACENXX] ;
386
387 for (G4int l = 0 ; l<G4VSURFACENXX ; ++l )
388 {
389 tmpdist[l] = kInfinity ;
390 tmpareacode[l] = sOutside ;
391 tmpisvalid[l] = false ;
392 }
393
394 G4int tmpnxx = neighbours[j]->DistanceToSurface(
395 gp, gv, tmpgxx, tmpdist,
396 tmpareacode, tmpisvalid,
398 G4ThreeVector neighbournormal;
399
400 for (G4int k=0; k< tmpnxx; ++k)
401 {
402 //
403 // if tmpxx[k] is valid && sInside, the final winner must
404 // be neighbour surface. return kInfinity.
405 // else , choose tmpxx on same boundary of xx, then check normal
406 //
407
408 if (IsInside(tmpareacode[k]))
409 {
410#ifdef G4TWISTDEBUG
411 G4cout << " G4VTwistSurface:DistanceToIn(p,v): "
412 << " intersection "<< tmpgxx[k] << G4endl
413 << " is inside of neighbour surface of " << fName
414 << " . returning kInfinity." << G4endl;
415 G4cout << "~~ G4VTwistSurface::DistanceToIn(p,v) - return ~~"
416 << G4endl;
417 G4cout << " No intersections " << G4endl;
418 G4cout << " Name : " << fName << G4endl;
419 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
420 << G4endl;
421#endif
422 if (tmpisvalid[k]) return kInfinity;
423 continue;
424
425 //
426 // if tmpxx[k] is valid && sInside, the final winner must
427 // be neighbour surface. return .
428 //
429
430 }
431 else if (IsSameBoundary(this,areacode[i],
432 neighbours[j], tmpareacode[k]))
433 {
434 // tmpxx[k] is same boundary (or corner) of xx.
435
436 neighbournormal = neighbours[j]->GetNormal(tmpgxx[k], true);
437 if (neighbournormal * gv < 0) isaccepted[j] = true;
438 }
439 }
440
441 // if nneighbours = 1, chabge isaccepted[1] before
442 // exiting neighboursurface loop.
443
444 if (nneighbours == 1) isaccepted[1] = true;
445
446 } // neighboursurface loop end
447
448 // now, we can accept xx intersection
449
450 if (isaccepted[0] == true && isaccepted[1] == true)
451 {
452 if (distance[i] < bestdistance)
453 {
454 bestdistance = distance[i];
455 gxxbest = gxx[i];
456#ifdef G4TWISTDEBUG
457 besti = i;
458 G4cout << " G4VTwistSurface::DistanceToIn(p,v): "
459 << " areacode sBoundary & sBoundary distance = "
460 << fName << " " << distance[i] << G4endl;
461#endif
462 }
463 }
464 } // else end
465 } // intersection loop end
466
467 gxxbest = bestgxx;
468
469#ifdef G4TWISTDEBUG
470 if (besti < 0)
471 {
472 G4cout << "~~~ G4VTwistSurface::DistanceToIn(p,v) - return ~~~" << G4endl;
473 G4cout << " No intersections " << G4endl;
474 G4cout << " Name : " << fName << G4endl;
475 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
476 }
477 else
478 {
479 G4cout << "~~~ G4VTwistSurface::DistanceToIn(p,v) : return ~~~" << G4endl;
480 G4cout << " Name, i : " << fName << " , " << besti << G4endl;
481 G4cout << " gxx[i] : " << gxxbest << G4endl;
482 G4cout << " bestdist : " << bestdistance << G4endl;
483 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
484 }
485
486#endif
487
488 return bestdistance;
489}
bool G4bool
Definition: G4Types.hh:86
G4VTwistSurface ** GetNeighbours()
G4bool IsInside(G4int areacode, G4bool testbitmode=false) const
G4bool IsSameBoundary(G4VTwistSurface *surface1, G4int areacode1, G4VTwistSurface *surface2, G4int areacode2) const
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:79

References G4VTwistSurface::DistanceToSurface(), G4VTwistSurface::fName, G4cout, G4endl, G4VSURFACENXX, G4VTwistSurface::GetNeighbours(), G4VTwistSurface::GetNormal(), G4VTwistSurface::IsInside(), G4VTwistSurface::IsSameBoundary(), kInfinity, G4VTwistSurface::kValidateWithTol, CLHEP::normal(), and G4VTwistSurface::sOutside.

Referenced by G4TwistedTubs::DistanceToIn(), and G4VTwistedFaceted::DistanceToIn().

◆ DistanceToLine()

G4double G4VTwistSurface::DistanceToLine ( const G4ThreeVector p,
const G4ThreeVector x0,
const G4ThreeVector d,
G4ThreeVector xx 
)
inlineinherited

◆ DistanceToOut()

G4double G4VTwistSurface::DistanceToOut ( const G4ThreeVector gp,
const G4ThreeVector gv,
G4ThreeVector gxxbest 
)
virtualinherited

Definition at line 494 of file G4VTwistSurface.cc.

497{
498#ifdef G4TWISTDEBUG
499 G4cout << "~~~~~ G4VTwistSurface::DistanceToOut(p,v) - Start ~~~~" << G4endl;
500 G4cout << " Name : " << fName << G4endl;
501 G4cout << " gp : " << gp << G4endl;
502 G4cout << " gv : " << gv << G4endl;
503 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
504#endif
505
507 G4double distance[G4VSURFACENXX];
508 G4int areacode[G4VSURFACENXX];
509 G4bool isvalid[G4VSURFACENXX];
510
511 for ( G4int i = 0 ; i<G4VSURFACENXX ; ++i )
512 {
513 distance[i] = kInfinity ;
514 areacode[i] = sOutside ;
515 isvalid[i] = false ;
516 }
517
518 G4int nxx;
519 G4double bestdistance = kInfinity;
520
521 nxx = DistanceToSurface(gp, gv, gxx, distance, areacode,
522 isvalid, kValidateWithTol);
523
524 for (G4int i=0; i<nxx; ++i)
525 {
526 if (!(isvalid[i]))
527 {
528 continue;
529 }
530
531 G4ThreeVector normal = GetNormal(gxx[i], true);
532 if (normal * gv <= 0)
533 {
534 // particle goes toword inside of solid, return kInfinity
535#ifdef G4TWISTDEBUG
536 G4cout << " G4VTwistSurface::DistanceToOut(p,v): normal*gv < 0 "
537 << fName << " " << normal
538 << G4endl;
539#endif
540 }
541 else
542 {
543 // gxx[i] is accepted.
544 if (distance[i] < bestdistance)
545 {
546 bestdistance = distance[i];
547 gxxbest = gxx[i];
548 }
549 }
550 }
551
552#ifdef G4TWISTDEBUG
553 if (besti < 0)
554 {
555 G4cout << "~~ G4VTwistSurface::DistanceToOut(p,v) - return ~~" << G4endl;
556 G4cout << " No intersections " << G4endl;
557 G4cout << " Name : " << fName << G4endl;
558 G4cout << " bestdist : " << bestdistance << G4endl;
559 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
560 }
561 else
562 {
563 G4cout << "~~ G4VTwistSurface::DistanceToOut(p,v) : return ~~" << G4endl;
564 G4cout << " Name, i : " << fName << " , " << i << G4endl;
565 G4cout << " gxx[i] : " << gxxbest << G4endl;
566 G4cout << " bestdist : " << bestdistance << G4endl;
567 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
568 }
569#endif
570
571 return bestdistance;
572}

References G4VTwistSurface::DistanceToSurface(), G4VTwistSurface::fName, G4cout, G4endl, G4VSURFACENXX, G4VTwistSurface::GetNormal(), kInfinity, G4VTwistSurface::kValidateWithTol, CLHEP::normal(), and G4VTwistSurface::sOutside.

Referenced by G4TwistedTubs::DistanceToOut(), and G4VTwistedFaceted::DistanceToOut().

◆ DistanceToPlane() [1/3]

G4double G4TwistTubsSide::DistanceToPlane ( const G4ThreeVector p,
const G4ThreeVector A,
const G4ThreeVector B,
const G4ThreeVector C,
const G4ThreeVector D,
const G4int  parity,
G4ThreeVector xx,
G4ThreeVector n 
)
privatevirtual

Definition at line 747 of file G4TwistTubsSide.cc.

755{
756 const G4double halftol = 0.5 * kCarTolerance;
757
758 G4ThreeVector M = 0.5*(A + B);
759 G4ThreeVector N = 0.5*(C + D);
760 G4ThreeVector xxanm; // foot of normal from p to plane ANM
761 G4ThreeVector nanm; // normal of plane ANM
762 G4ThreeVector xxcmn; // foot of normal from p to plane CMN
763 G4ThreeVector ncmn; // normal of plane CMN
764
765 G4double distToanm = G4VTwistSurface::DistanceToPlane(p, A, (N - A), (M - A),
766 xxanm, nanm) * parity;
767 G4double distTocmn = G4VTwistSurface::DistanceToPlane(p, C, (M - C), (N - C),
768 xxcmn, ncmn) * parity;
769#ifdef G4SPECSDEBUG
770 // if p is behind of both surfaces, abort.
771 if (distToanm * distTocmn > 0 && distToanm < 0)
772 {
773 G4Exception("G4TwistTubsSide::DistanceToPlane()",
774 "GeomSolids0003", FatalException,
775 "Point p is behind the surfaces.");
776 }
777#endif
778 // if p is on surface, return 0.
779 if (std::fabs(distToanm) <= halftol)
780 {
781 xx = xxanm;
782 n = nanm * parity;
783 return 0;
784 }
785 else if (std::fabs(distTocmn) <= halftol)
786 {
787 xx = xxcmn;
788 n = ncmn * parity;
789 return 0;
790 }
791
792 if (distToanm <= distTocmn)
793 {
794 if (distToanm > 0)
795 {
796 // both distanses are positive. take smaller one.
797 xx = xxanm;
798 n = nanm * parity;
799 return distToanm;
800 }
801 else
802 {
803 // take -ve distance and call the function recursively.
804 return DistanceToPlane(p, A, M, N, D, parity, xx, n);
805 }
806 }
807 else
808 {
809 if (distTocmn > 0)
810 {
811 // both distanses are positive. take smaller one.
812 xx = xxcmn;
813 n = ncmn * parity;
814 return distTocmn;
815 }
816 else
817 {
818 // take -ve distance and call the function recursively.
819 return DistanceToPlane(p, C, N, M, B, parity, xx, n);
820 }
821 }
822}
#define M(row, col)
virtual G4double DistanceToPlane(const G4ThreeVector &p, const G4ThreeVector &A, const G4ThreeVector &B, const G4ThreeVector &C, const G4ThreeVector &D, const G4int parity, G4ThreeVector &xx, G4ThreeVector &n)
G4double DistanceToPlane(const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
static int parity(int x)

References A, B(), C(), D(), DistanceToPlane(), G4VTwistSurface::DistanceToPlane(), FatalException, G4Exception(), G4VTwistSurface::kCarTolerance, M, CLHEP::detail::n, and parity().

Referenced by DistanceToPlane(), and DistanceToSurface().

◆ DistanceToPlane() [2/3]

G4double G4VTwistSurface::DistanceToPlane ( const G4ThreeVector p,
const G4ThreeVector x0,
const G4ThreeVector n0,
G4ThreeVector xx 
)
inlineinherited

◆ DistanceToPlane() [3/3]

G4double G4VTwistSurface::DistanceToPlane ( const G4ThreeVector p,
const G4ThreeVector x0,
const G4ThreeVector t1,
const G4ThreeVector t2,
G4ThreeVector xx,
G4ThreeVector n 
)
inlineinherited

◆ DistanceToPlaneWithV()

G4double G4VTwistSurface::DistanceToPlaneWithV ( const G4ThreeVector p,
const G4ThreeVector v,
const G4ThreeVector x0,
const G4ThreeVector n0,
G4ThreeVector xx 
)
inlineinherited

◆ DistanceToSurface() [1/2]

G4int G4TwistTubsSide::DistanceToSurface ( const G4ThreeVector gp,
const G4ThreeVector gv,
G4ThreeVector  gxx[],
G4double  distance[],
G4int  areacode[],
G4bool  isvalid[],
EValidate  validate = kValidateWithTol 
)
virtual

Implements G4VTwistSurface.

Definition at line 156 of file G4TwistTubsSide.cc.

163{
164 // Coordinate system:
165 //
166 // The coordinate system is so chosen that the intersection of
167 // the twisted surface with the z=0 plane coincides with the
168 // x-axis.
169 // Rotation matrix from this coordinate system (local system)
170 // to global system is saved in fRot field.
171 // So the (global) particle position and (global) velocity vectors,
172 // p and v, should be rotated fRot.inverse() in order to convert
173 // to local vectors.
174 //
175 // Equation of a twisted surface:
176 //
177 // x(rho(z=0), z) = rho(z=0)
178 // y(rho(z=0), z) = rho(z=0)*K*z
179 // z(rho(z=0), z) = z
180 // with
181 // K = std::tan(fPhiTwist/2)/fZHalfLen
182 //
183 // Equation of a line:
184 //
185 // gxx = p + t*v
186 // with
187 // p = fRot.inverse()*gp
188 // v = fRot.inverse()*gv
189 //
190 // Solution for intersection:
191 //
192 // Required time for crossing is given by solving the
193 // following quadratic equation:
194 //
195 // a*t^2 + b*t + c = 0
196 //
197 // where
198 //
199 // a = K*v_x*v_z
200 // b = K*(v_x*p_z + v_z*p_x) - v_y
201 // c = K*p_x*p_z - p_y
202 //
203 // Out of the possible two solutions you must choose
204 // the one that gives a positive rho(z=0).
205 //
206 //
207
208 fCurStatWithV.ResetfDone(validate, &gp, &gv);
209
210 if (fCurStatWithV.IsDone())
211 {
212 for (G4int i=0; i<fCurStatWithV.GetNXX(); ++i)
213 {
214 gxx[i] = fCurStatWithV.GetXX(i);
215 distance[i] = fCurStatWithV.GetDistance(i);
216 areacode[i] = fCurStatWithV.GetAreacode(i);
217 isvalid[i] = fCurStatWithV.IsValid(i);
218 }
219 return fCurStatWithV.GetNXX();
220 }
221 else // initialize
222 {
223 for (auto i=0; i<2; ++i)
224 {
225 distance[i] = kInfinity;
226 areacode[i] = sOutside;
227 isvalid[i] = false;
229 }
230 }
231
234 G4ThreeVector xx[2];
235
236 //
237 // special case!
238 // p is origin or
239 //
240
241 G4double absvz = std::fabs(v.z());
242
243 if ((absvz<DBL_MIN) && (std::fabs(p.x() * v.y() - p.y() * v.x())<DBL_MIN))
244 {
245 // no intersection
246
247 isvalid[0] = false;
248 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
249 isvalid[0], 0, validate, &gp, &gv);
250 return 0;
251 }
252
253 //
254 // special case end
255 //
256
257 G4double a = fKappa * v.x() * v.z();
258 G4double b = fKappa * (v.x() * p.z() + v.z() * p.x()) - v.y();
259 G4double c = fKappa * p.x() * p.z() - p.y();
260 G4double D = b * b - 4 * a * c; // discriminant
261 G4int vout = 0;
262
263 if (std::fabs(a) < DBL_MIN)
264 {
265 if (std::fabs(b) > DBL_MIN)
266 {
267 // single solution
268
269 distance[0] = - c / b;
270 xx[0] = p + distance[0]*v;
271 gxx[0] = ComputeGlobalPoint(xx[0]);
272
273 if (validate == kValidateWithTol)
274 {
275 areacode[0] = GetAreaCode(xx[0]);
276 if (!IsOutside(areacode[0]))
277 {
278 if (distance[0] >= 0) isvalid[0] = true;
279 }
280 }
281 else if (validate == kValidateWithoutTol)
282 {
283 areacode[0] = GetAreaCode(xx[0], false);
284 if (IsInside(areacode[0]))
285 {
286 if (distance[0] >= 0) isvalid[0] = true;
287 }
288 }
289 else // kDontValidate
290 {
291 // we must omit x(rho,z) = rho(z=0) < 0
292 if (xx[0].x() > 0)
293 {
294 areacode[0] = sInside;
295 if (distance[0] >= 0) isvalid[0] = true;
296 }
297 else
298 {
299 distance[0] = kInfinity;
300 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0],
301 areacode[0], isvalid[0],
302 0, validate, &gp, &gv);
303 return vout;
304 }
305 }
306
307 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
308 isvalid[0], 1, validate, &gp, &gv);
309 vout = 1;
310 }
311 else
312 {
313 // if a=b=0 , v.y=0 and (v.x=0 && p.x=0) or (v.z=0 && p.z=0) .
314 // if v.x=0 && p.x=0, no intersection unless p is on z-axis
315 // (in that case, v is paralell to surface).
316 // if v.z=0 && p.z=0, no intersection unless p is on x-axis
317 // (in that case, v is paralell to surface).
318 // return distance = infinity.
319
320 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
321 isvalid[0], 0, validate, &gp, &gv);
322 }
323 }
324 else if (D > DBL_MIN)
325 {
326 // double solutions
327
328 D = std::sqrt(D);
329 G4double factor = 0.5/a;
330 G4double tmpdist[2] = {kInfinity, kInfinity};
331 G4ThreeVector tmpxx[2];
332 G4int tmpareacode[2] = {sOutside, sOutside};
333 G4bool tmpisvalid[2] = {false, false};
334
335 for (auto i=0; i<2; ++i)
336 {
337 G4double bminusD = - b - D;
338
339 // protection against round off error
340 //G4double protection = 1.0e-6;
341 G4double protection = 0;
342 if ( b * D < 0 && std::fabs(bminusD / D) < protection )
343 {
344 G4double acovbb = (a*c)/(b*b);
345 tmpdist[i] = - c/b * ( 1 - acovbb * (1 + 2*acovbb));
346 }
347 else
348 {
349 tmpdist[i] = factor * bminusD;
350 }
351
352 D = -D;
353 tmpxx[i] = p + tmpdist[i]*v;
354
355 if (validate == kValidateWithTol)
356 {
357 tmpareacode[i] = GetAreaCode(tmpxx[i]);
358 if (!IsOutside(tmpareacode[i]))
359 {
360 if (tmpdist[i] >= 0) tmpisvalid[i] = true;
361 continue;
362 }
363 }
364 else if (validate == kValidateWithoutTol)
365 {
366 tmpareacode[i] = GetAreaCode(tmpxx[i], false);
367 if (IsInside(tmpareacode[i]))
368 {
369 if (tmpdist[i] >= 0) tmpisvalid[i] = true;
370 continue;
371 }
372 }
373 else // kDontValidate
374 {
375 // we must choose x(rho,z) = rho(z=0) > 0
376 if (tmpxx[i].x() > 0)
377 {
378 tmpareacode[i] = sInside;
379 if (tmpdist[i] >= 0) tmpisvalid[i] = true;
380 continue;
381 } else {
382 tmpdist[i] = kInfinity;
383 continue;
384 }
385 }
386 }
387
388 if (tmpdist[0] <= tmpdist[1])
389 {
390 distance[0] = tmpdist[0];
391 distance[1] = tmpdist[1];
392 xx[0] = tmpxx[0];
393 xx[1] = tmpxx[1];
394 gxx[0] = ComputeGlobalPoint(tmpxx[0]);
395 gxx[1] = ComputeGlobalPoint(tmpxx[1]);
396 areacode[0] = tmpareacode[0];
397 areacode[1] = tmpareacode[1];
398 isvalid[0] = tmpisvalid[0];
399 isvalid[1] = tmpisvalid[1];
400 }
401 else
402 {
403 distance[0] = tmpdist[1];
404 distance[1] = tmpdist[0];
405 xx[0] = tmpxx[1];
406 xx[1] = tmpxx[0];
407 gxx[0] = ComputeGlobalPoint(tmpxx[1]);
408 gxx[1] = ComputeGlobalPoint(tmpxx[0]);
409 areacode[0] = tmpareacode[1];
410 areacode[1] = tmpareacode[0];
411 isvalid[0] = tmpisvalid[1];
412 isvalid[1] = tmpisvalid[0];
413 }
414
415 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
416 isvalid[0], 2, validate, &gp, &gv);
417 fCurStatWithV.SetCurrentStatus(1, gxx[1], distance[1], areacode[1],
418 isvalid[1], 2, validate, &gp, &gv);
419
420 // protection against roundoff error
421
422 for (G4int k=0; k<2; ++k)
423 {
424 if (!isvalid[k]) continue;
425
426 G4ThreeVector xxonsurface(xx[k].x(), fKappa * std::fabs(xx[k].x())
427 * xx[k].z() , xx[k].z());
428 G4double deltaY = (xx[k] - xxonsurface).mag();
429
430 if ( deltaY > 0.5*kCarTolerance )
431 {
432 G4int maxcount = 10;
433 G4int l;
434 G4double lastdeltaY = deltaY;
435 for (l=0; l<maxcount; ++l)
436 {
437 G4ThreeVector surfacenormal = GetNormal(xxonsurface);
438 distance[k] = DistanceToPlaneWithV(p, v, xxonsurface,
439 surfacenormal, xx[k]);
440 deltaY = (xx[k] - xxonsurface).mag();
441 if (deltaY > lastdeltaY) { } // ???
442 gxx[k] = ComputeGlobalPoint(xx[k]);
443
444 if (deltaY <= 0.5*kCarTolerance) break;
445 xxonsurface.set(xx[k].x(),
446 fKappa * std::fabs(xx[k].x()) * xx[k].z(),
447 xx[k].z());
448 }
449 if (l == maxcount)
450 {
451 std::ostringstream message;
452 message << "Exceeded maxloop count!" << G4endl
453 << " maxloop count " << maxcount;
454 G4Exception("G4TwistTubsFlatSide::DistanceToSurface(p,v)",
455 "GeomSolids0003", FatalException, message);
456 }
457 }
458 }
459 vout = 2;
460 }
461 else
462 {
463 // if D<0, no solution
464 // if D=0, just grazing the surfaces, return kInfinity
465
466 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
467 isvalid[0], 0, validate, &gp, &gv);
468 }
469
470 return vout;
471}
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal=false)
virtual G4int GetAreaCode(const G4ThreeVector &xx, G4bool withTol=true)
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)
G4ThreeVector ComputeLocalDirection(const G4ThreeVector &gp) const
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &gp) const
G4bool IsOutside(G4int areacode) const
static const G4int sInside
CurrentStatus fCurStatWithV
G4double DistanceToPlaneWithV(const G4ThreeVector &p, const G4ThreeVector &v, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
G4ThreeVector ComputeGlobalPoint(const G4ThreeVector &lp) const
CurrentStatus fCurStat
#define DBL_MIN
Definition: templates.hh:54

References G4VTwistSurface::ComputeGlobalPoint(), G4VTwistSurface::ComputeLocalDirection(), G4VTwistSurface::ComputeLocalPoint(), D(), DBL_MIN, G4VTwistSurface::DistanceToPlaneWithV(), FatalException, G4VTwistSurface::fCurStat, G4VTwistSurface::fCurStatWithV, fKappa, G4endl, G4Exception(), GetAreaCode(), G4VTwistSurface::CurrentStatus::GetAreacode(), G4VTwistSurface::CurrentStatus::GetDistance(), GetNormal(), G4VTwistSurface::CurrentStatus::GetNXX(), G4VTwistSurface::CurrentStatus::GetXX(), G4VTwistSurface::CurrentStatus::IsDone(), G4VTwistSurface::IsInside(), G4VTwistSurface::IsOutside(), G4VTwistSurface::CurrentStatus::IsValid(), G4VTwistSurface::kCarTolerance, kInfinity, G4VTwistSurface::kValidateWithoutTol, G4VTwistSurface::kValidateWithTol, G4VTwistSurface::CurrentStatus::ResetfDone(), CLHEP::Hep3Vector::set(), G4VTwistSurface::CurrentStatus::SetCurrentStatus(), G4VTwistSurface::sInside, G4VTwistSurface::sOutside, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DistanceToSurface() [2/2]

G4int G4TwistTubsSide::DistanceToSurface ( const G4ThreeVector gp,
G4ThreeVector  gxx[],
G4double  distance[],
G4int  areacode[] 
)
virtual

Implements G4VTwistSurface.

Definition at line 476 of file G4TwistTubsSide.cc.

480{
482 if (fCurStat.IsDone())
483 {
484 for (G4int i=0; i<fCurStat.GetNXX(); ++i)
485 {
486 gxx[i] = fCurStat.GetXX(i);
487 distance[i] = fCurStat.GetDistance(i);
488 areacode[i] = fCurStat.GetAreacode(i);
489 }
490 return fCurStat.GetNXX();
491 }
492 else // initialize
493 {
494 for (auto i=0; i<2; ++i)
495 {
496 distance[i] = kInfinity;
497 areacode[i] = sOutside;
499 }
500 }
501
502 const G4double halftol = 0.5 * kCarTolerance;
503
505 G4ThreeVector xx;
506 G4int parity = (fKappa >= 0 ? 1 : -1);
507
508 //
509 // special case!
510 // If p is on surface, or
511 // p is on z-axis,
512 // return here immediatery.
513 //
514
515 G4ThreeVector lastgxx[2];
516 for (auto i=0; i<2; ++i)
517 {
518 lastgxx[i] = fCurStatWithV.GetXX(i);
519 }
520
521 if ((gp - lastgxx[0]).mag() < halftol
522 || (gp - lastgxx[1]).mag() < halftol)
523 {
524 // last winner, or last poststep point is on the surface.
525 xx = p;
526 distance[0] = 0;
527 gxx[0] = gp;
528
529 G4bool isvalid = true;
530 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
531 isvalid, 1, kDontValidate, &gp);
532 return 1;
533 }
534
535 if (p.getRho() == 0)
536 {
537 // p is on z-axis. Namely, p is on twisted surface (invalid area).
538 // We must return here, however, returning distance to x-minimum
539 // boundary is better than return 0-distance.
540 //
541 G4bool isvalid = true;
542 if (fAxis[0] == kXAxis && fAxis[1] == kZAxis)
543 {
544 distance[0] = DistanceToBoundary(sAxis0 & sAxisMin, xx, p);
545 areacode[0] = sInside;
546 }
547 else
548 {
549 distance[0] = 0;
550 xx.set(0., 0., 0.);
551 }
552 gxx[0] = ComputeGlobalPoint(xx);
553 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
554 isvalid, 0, kDontValidate, &gp);
555 return 1;
556 }
557
558 //
559 // special case end
560 //
561
562 // set corner points of quadrangle try area ...
563
564 G4ThreeVector A; // foot of normal from p to boundary of sAxis0 & sAxisMin
565 G4ThreeVector C; // foot of normal from p to boundary of sAxis0 & sAxisMax
566 G4ThreeVector B; // point on boundary sAxis0 & sAxisMax at z = A.z()
567 G4ThreeVector D; // point on boundary sAxis0 & sAxisMin at z = C.z()
568
569 // G4double distToA; // distance from p to A
571 // G4double distToC; // distance from p to C
573
574 // is p.z between a.z and c.z?
575 // p.z must be bracketed a.z and c.z.
576 if (A.z() > C.z())
577 {
578 if (p.z() > A.z())
579 {
581 }
582 else if (p.z() < C.z())
583 {
585 }
586 }
587 else
588 {
589 if (p.z() > C.z())
590 {
592 }
593 else if (p.z() < A.z())
594 {
596 }
597 }
598
599 G4ThreeVector d[2]; // direction vectors of boundary
600 G4ThreeVector x0[2]; // foot of normal from line to p
601 G4int btype[2]; // boundary type
602
603 for (auto i=0; i<2; ++i)
604 {
605 if (i == 0)
606 {
607 GetBoundaryParameters((sAxis0 & sAxisMax), d[i], x0[i], btype[i]);
608 B = x0[i] + ((A.z() - x0[i].z()) / d[i].z()) * d[i];
609 // x0 + t*d , d is direction unit vector.
610 }
611 else
612 {
613 GetBoundaryParameters((sAxis0 & sAxisMin), d[i], x0[i], btype[i]);
614 D = x0[i] + ((C.z() - x0[i].z()) / d[i].z()) * d[i];
615 }
616 }
617
618 // In order to set correct diagonal, swap A and D, C and B if needed.
619 G4ThreeVector pt(p.x(), p.y(), 0.);
620 G4double rc = std::fabs(p.x());
621 G4ThreeVector surfacevector(rc, rc * fKappa * p.z(), 0.);
622 G4int pside = AmIOnLeftSide(pt, surfacevector);
623 G4double test = (A.z() - C.z()) * parity * pside;
624
625 if (test == 0)
626 {
627 if (pside == 0)
628 {
629 // p is on surface.
630 xx = p;
631 distance[0] = 0;
632 gxx[0] = gp;
633
634 G4bool isvalid = true;
635 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
636 isvalid, 1, kDontValidate, &gp);
637 return 1;
638 }
639 else
640 {
641 // A.z = C.z(). return distance to line.
642 d[0] = C - A;
643 distance[0] = DistanceToLine(p, A, d[0], xx);
644 areacode[0] = sInside;
645 gxx[0] = ComputeGlobalPoint(xx);
646 G4bool isvalid = true;
647 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
648 isvalid, 1, kDontValidate, &gp);
649 return 1;
650 }
651 }
652 else if (test < 0) // wrong diagonal. vector AC is crossing the surface!
653 { // swap A and D, C and B
654 G4ThreeVector tmp;
655 tmp = A;
656 A = D;
657 D = tmp;
658 tmp = C;
659 C = B;
660 B = tmp;
661
662 }
663 else // correct diagonal. nothing to do.
664 {
665 }
666
667 // Now, we chose correct diagonal.
668 // First try. divide quadrangle into double triangle by diagonal and
669 // calculate distance to both surfaces.
670
671 G4ThreeVector xxacb; // foot of normal from plane ACB to p
672 G4ThreeVector nacb; // normal of plane ACD
673 G4ThreeVector xxcad; // foot of normal from plane CAD to p
674 G4ThreeVector ncad; // normal of plane CAD
675 G4ThreeVector AB(A.x(), A.y(), 0);
676 G4ThreeVector DC(C.x(), C.y(), 0);
677
678 G4double distToACB = G4VTwistSurface::DistanceToPlane(p, A, C-A, AB,
679 xxacb, nacb) * parity;
680 G4double distToCAD = G4VTwistSurface::DistanceToPlane(p, C, C-A, DC,
681 xxcad, ncad) * parity;
682 // if calculated distance = 0, return
683
684 if (std::fabs(distToACB) <= halftol || std::fabs(distToCAD) <= halftol)
685 {
686 xx = (std::fabs(distToACB) < std::fabs(distToCAD) ? xxacb : xxcad);
687 areacode[0] = sInside;
688 gxx[0] = ComputeGlobalPoint(xx);
689 distance[0] = 0;
690 G4bool isvalid = true;
691 fCurStat.SetCurrentStatus(0, gxx[0], distance[0] , areacode[0],
692 isvalid, 1, kDontValidate, &gp);
693 return 1;
694 }
695
696 if (distToACB * distToCAD > 0 && distToACB < 0)
697 {
698 // both distToACB and distToCAD are negative.
699 // divide quadrangle into double triangle by diagonal
701 distance[0] = DistanceToPlane(p, A, B, C, D, parity, xx, normal);
702 }
703 else
704 {
705 if (distToACB * distToCAD > 0)
706 {
707 // both distToACB and distToCAD are positive.
708 // Take smaller one.
709 if (distToACB <= distToCAD)
710 {
711 distance[0] = distToACB;
712 xx = xxacb;
713 }
714 else
715 {
716 distance[0] = distToCAD;
717 xx = xxcad;
718 }
719 }
720 else
721 {
722 // distToACB * distToCAD is negative.
723 // take positive one
724 if (distToACB > 0)
725 {
726 distance[0] = distToACB;
727 xx = xxacb;
728 }
729 else
730 {
731 distance[0] = distToCAD;
732 xx = xxcad;
733 }
734 }
735 }
736 areacode[0] = sInside;
737 gxx[0] = ComputeGlobalPoint(xx);
738 G4bool isvalid = true;
739 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
740 isvalid, 1, kDontValidate, &gp);
741 return 1;
742}
virtual G4int AmIOnLeftSide(const G4ThreeVector &me, const G4ThreeVector &vec, G4bool withTol=true)
static const G4int sAxisMax
static const G4int sAxis0
static const G4int sAxisMin
virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode, const G4ThreeVector &p) const
virtual G4double DistanceToBoundary(G4int areacode, G4ThreeVector &xx, const G4ThreeVector &p)
Definition: test.py:1

References A, G4VTwistSurface::AmIOnLeftSide(), B(), C(), G4VTwistSurface::ComputeGlobalPoint(), G4VTwistSurface::ComputeLocalPoint(), D(), G4VTwistSurface::DistanceToBoundary(), G4VTwistSurface::DistanceToLine(), DistanceToPlane(), G4VTwistSurface::DistanceToPlane(), G4VTwistSurface::fAxis, G4VTwistSurface::fCurStat, G4VTwistSurface::fCurStatWithV, fKappa, G4VTwistSurface::CurrentStatus::GetAreacode(), G4VTwistSurface::GetBoundaryAtPZ(), G4VTwistSurface::GetBoundaryParameters(), G4VTwistSurface::CurrentStatus::GetDistance(), G4VTwistSurface::CurrentStatus::GetNXX(), CLHEP::Hep3Vector::getRho(), G4VTwistSurface::CurrentStatus::GetXX(), G4VTwistSurface::CurrentStatus::IsDone(), G4VTwistSurface::kCarTolerance, G4VTwistSurface::kDontValidate, kInfinity, kXAxis, kZAxis, CLHEP::normal(), parity(), G4VTwistSurface::CurrentStatus::ResetfDone(), G4VTwistSurface::sAxis0, G4VTwistSurface::sAxisMax, G4VTwistSurface::sAxisMin, CLHEP::Hep3Vector::set(), G4VTwistSurface::CurrentStatus::SetCurrentStatus(), G4VTwistSurface::sInside, G4VTwistSurface::sOutside, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ GetAreaCode()

G4int G4TwistTubsSide::GetAreaCode ( const G4ThreeVector xx,
G4bool  withTol = true 
)
privatevirtual

Implements G4VTwistSurface.

Definition at line 827 of file G4TwistTubsSide.cc.

829{
830 // We must use the function in local coordinate system.
831 // See the description of DistanceToSurface(p,v).
832
833 const G4double ctol = 0.5 * kCarTolerance;
834 G4int areacode = sInside;
835
836 if (fAxis[0] == kXAxis && fAxis[1] == kZAxis)
837 {
838 G4int xaxis = 0;
839 G4int zaxis = 1;
840
841 if (withTol)
842 {
843 G4bool isoutside = false;
844
845 // test boundary of xaxis
846
847 if (xx.x() < fAxisMin[xaxis] + ctol)
848 {
849 areacode |= (sAxis0 & (sAxisX | sAxisMin)) | sBoundary;
850 if (xx.x() <= fAxisMin[xaxis] - ctol) isoutside = true;
851
852 }
853 else if (xx.x() > fAxisMax[xaxis] - ctol)
854 {
855 areacode |= (sAxis0 & (sAxisX | sAxisMax)) | sBoundary;
856 if (xx.x() >= fAxisMax[xaxis] + ctol) isoutside = true;
857 }
858
859 // test boundary of z-axis
860
861 if (xx.z() < fAxisMin[zaxis] + ctol)
862 {
863 areacode |= (sAxis1 & (sAxisZ | sAxisMin));
864
865 if (areacode & sBoundary) areacode |= sCorner; // xx is on corner
866 else areacode |= sBoundary;
867 if (xx.z() <= fAxisMin[zaxis] - ctol) isoutside = true;
868
869 }
870 else if (xx.z() > fAxisMax[zaxis] - ctol)
871 {
872 areacode |= (sAxis1 & (sAxisZ | sAxisMax));
873
874 if (areacode & sBoundary) areacode |= sCorner; // xx is on corner
875 else areacode |= sBoundary;
876 if (xx.z() >= fAxisMax[zaxis] + ctol) isoutside = true;
877 }
878
879 // if isoutside = true, clear inside bit.
880 // if not on boundary, add axis information.
881
882 if (isoutside)
883 {
884 G4int tmpareacode = areacode & (~sInside);
885 areacode = tmpareacode;
886 }
887 else if ((areacode & sBoundary) != sBoundary)
888 {
889 areacode |= (sAxis0 & sAxisX) | (sAxis1 & sAxisZ);
890 }
891 }
892 else
893 {
894 // boundary of x-axis
895
896 if (xx.x() < fAxisMin[xaxis] )
897 {
898 areacode |= (sAxis0 & (sAxisX | sAxisMin)) | sBoundary;
899 }
900 else if (xx.x() > fAxisMax[xaxis])
901 {
902 areacode |= (sAxis0 & (sAxisX | sAxisMax)) | sBoundary;
903 }
904
905 // boundary of z-axis
906
907 if (xx.z() < fAxisMin[zaxis])
908 {
909 areacode |= (sAxis1 & (sAxisZ | sAxisMin));
910 if (areacode & sBoundary) areacode |= sCorner; // xx is oncorner
911 else areacode |= sBoundary;
912
913 }
914 else if (xx.z() > fAxisMax[zaxis])
915 {
916 areacode |= (sAxis1 & (sAxisZ | sAxisMax)) ;
917 if (areacode & sBoundary) areacode |= sCorner; // xx is on corner
918 else areacode |= sBoundary;
919 }
920
921 if ((areacode & sBoundary) != sBoundary)
922 {
923 areacode |= (sAxis0 & sAxisX) | (sAxis1 & sAxisZ);
924 }
925 }
926 return areacode;
927 }
928 else
929 {
930 G4Exception("G4TwistTubsSide::GetAreaCode()",
931 "GeomSolids0001", FatalException,
932 "Feature NOT implemented !");
933 }
934 return areacode;
935}
static const G4int sAxis1
static const G4int sBoundary
static const G4int sAxisZ
static const G4int sCorner
static const G4int sAxisX

References FatalException, G4VTwistSurface::fAxis, G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4Exception(), G4VTwistSurface::kCarTolerance, kXAxis, kZAxis, G4VTwistSurface::sAxis0, G4VTwistSurface::sAxis1, G4VTwistSurface::sAxisMax, G4VTwistSurface::sAxisMin, G4VTwistSurface::sAxisX, G4VTwistSurface::sAxisZ, G4VTwistSurface::sBoundary, G4VTwistSurface::sCorner, G4VTwistSurface::sInside, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToSurface().

◆ GetAxisType()

G4int G4VTwistSurface::GetAxisType ( G4int  areacode,
G4int  whichaxis 
) const
inlineinherited

◆ GetBoundaryAtPZ()

G4ThreeVector G4VTwistSurface::GetBoundaryAtPZ ( G4int  areacode,
const G4ThreeVector p 
) const
virtualinherited

Definition at line 698 of file G4VTwistSurface.cc.

700{
701 // areacode must be one of them:
702 // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
703 // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
704
705 if (areacode & sAxis0 && areacode & sAxis1)
706 {
707 std::ostringstream message;
708 message << "Point is in the corner area." << G4endl
709 << " This function returns "
710 << "a direction vector of a boundary line." << G4endl
711 << " areacode = " << areacode;
712 G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0003",
713 FatalException, message);
714 }
715
717 G4ThreeVector x0;
718 G4int boundarytype;
719 G4bool found = false;
720
721 for (G4int i=0; i<4; ++i)
722 {
723 if (fBoundaries[i].GetBoundaryParameters(areacode, d, x0,
724 boundarytype))
725 {
726 found = true;
727 continue;
728 }
729 }
730
731 if (!found)
732 {
733 std::ostringstream message;
734 message << "Not registered boundary." << G4endl
735 << " Boundary at areacode " << areacode << G4endl
736 << " is not registered.";
737 G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0002",
738 FatalException, message);
739 }
740
741 if (((boundarytype & sAxisPhi) == sAxisPhi) ||
742 ((boundarytype & sAxisRho) == sAxisRho))
743 {
744 std::ostringstream message;
745 message << "Not a z-depended line boundary." << G4endl
746 << " Boundary at areacode " << areacode << G4endl
747 << " is not a z-depended line.";
748 G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0002",
749 FatalException, message);
750 }
751 return ((p.z() - x0.z()) / d.z()) * d + x0;
752}
Boundary fBoundaries[4]
static const G4int sAxisRho

References FatalException, G4VTwistSurface::fBoundaries, G4endl, G4Exception(), G4VTwistSurface::GetBoundaryParameters(), G4VTwistSurface::sAxis0, G4VTwistSurface::sAxis1, G4VTwistSurface::sAxisPhi, G4VTwistSurface::sAxisRho, and CLHEP::Hep3Vector::z().

Referenced by DistanceToSurface(), G4TwistTubsHypeSide::GetAreaCodeInPhi(), G4TwistTubsHypeSide::GetBoundaryMax(), and G4TwistTubsHypeSide::GetBoundaryMin().

◆ GetBoundaryAxis()

void G4VTwistSurface::GetBoundaryAxis ( G4int  areacode,
EAxis  axis[] 
) const
protectedinherited

Definition at line 783 of file G4VTwistSurface.cc.

784{
785 if ((areacode & sBoundary) != sBoundary) {
786 G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0003",
787 FatalException, "Not located on a boundary!");
788 }
789 for (G4int i=0; i<2; ++i)
790 {
791 G4int whichaxis = 0 ;
792 if (i == 0) {
793 whichaxis = sAxis0;
794 } else if (i == 1) {
795 whichaxis = sAxis1;
796 }
797
798 // extracted axiscode of whichaxis
799 G4int axiscode = whichaxis & sAxisMask & areacode ;
800 if (axiscode) {
801 if (axiscode == (whichaxis & sAxisX)) {
802 axis[i] = kXAxis;
803 } else if (axiscode == (whichaxis & sAxisY)) {
804 axis[i] = kYAxis;
805 } else if (axiscode == (whichaxis & sAxisZ)) {
806 axis[i] = kZAxis;
807 } else if (axiscode == (whichaxis & sAxisRho)) {
808 axis[i] = kRho;
809 } else if (axiscode == (whichaxis & sAxisPhi)) {
810 axis[i] = kPhi;
811 } else {
812 std::ostringstream message;
813 message << "Not supported areacode." << G4endl
814 << " areacode " << areacode;
815 G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0001",
816 FatalException, message);
817 }
818 }
819 }
820}
static const G4int sAxisMask
static const G4int sAxisY
@ kPhi
Definition: geomdefs.hh:60
@ kYAxis
Definition: geomdefs.hh:56
@ kRho
Definition: geomdefs.hh:58

References FatalException, G4endl, G4Exception(), kPhi, kRho, kXAxis, kYAxis, kZAxis, G4VTwistSurface::sAxis0, G4VTwistSurface::sAxis1, G4VTwistSurface::sAxisMask, G4VTwistSurface::sAxisPhi, G4VTwistSurface::sAxisRho, G4VTwistSurface::sAxisX, G4VTwistSurface::sAxisY, G4VTwistSurface::sAxisZ, and G4VTwistSurface::sBoundary.

◆ GetBoundaryLimit()

void G4VTwistSurface::GetBoundaryLimit ( G4int  areacode,
G4double  limit[] 
) const
protectedinherited

Definition at line 825 of file G4VTwistSurface.cc.

826{
827 if (areacode & sCorner) {
828 if (areacode & sC0Min1Min) {
829 limit[0] = fAxisMin[0];
830 limit[1] = fAxisMin[1];
831 } else if (areacode & sC0Max1Min) {
832 limit[0] = fAxisMax[0];
833 limit[1] = fAxisMin[1];
834 } else if (areacode & sC0Max1Max) {
835 limit[0] = fAxisMax[0];
836 limit[1] = fAxisMax[1];
837 } else if (areacode & sC0Min1Max) {
838 limit[0] = fAxisMin[0];
839 limit[1] = fAxisMax[1];
840 }
841 } else if (areacode & sBoundary) {
842 if (areacode & (sAxis0 | sAxisMin)) {
843 limit[0] = fAxisMin[0];
844 } else if (areacode & (sAxis1 | sAxisMin)) {
845 limit[0] = fAxisMin[1];
846 } else if (areacode & (sAxis0 | sAxisMax)) {
847 limit[0] = fAxisMax[0];
848 } else if (areacode & (sAxis1 | sAxisMax)) {
849 limit[0] = fAxisMax[1];
850 }
851 } else {
852 std::ostringstream message;
853 message << "Not located on a boundary!" << G4endl
854 << " areacode " << areacode;
855 G4Exception("G4VTwistSurface::GetBoundaryLimit()", "GeomSolids1002",
856 JustWarning, message);
857 }
858}
@ JustWarning

References G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4endl, G4Exception(), JustWarning, G4VTwistSurface::sAxis0, G4VTwistSurface::sAxis1, G4VTwistSurface::sAxisMax, G4VTwistSurface::sAxisMin, G4VTwistSurface::sBoundary, G4VTwistSurface::sC0Max1Max, G4VTwistSurface::sC0Max1Min, G4VTwistSurface::sC0Min1Max, G4VTwistSurface::sC0Min1Min, and G4VTwistSurface::sCorner.

◆ GetBoundaryMax()

G4double G4TwistTubsSide::GetBoundaryMax ( G4double  phi)
inlinevirtual

Implements G4VTwistSurface.

Definition at line 167 of file G4TwistTubsSide.hh.

168{
169 return fAxisMax[0] ; // outer radius at z = 0
170}

References G4VTwistSurface::fAxisMax.

Referenced by GetFacets().

◆ GetBoundaryMin()

G4double G4TwistTubsSide::GetBoundaryMin ( G4double  phi)
inlinevirtual

Implements G4VTwistSurface.

Definition at line 161 of file G4TwistTubsSide.hh.

162{
163 return fAxisMin[0] ; // inner radius at z = 0
164}

References G4VTwistSurface::fAxisMin.

Referenced by GetFacets().

◆ GetBoundaryParameters()

void G4VTwistSurface::GetBoundaryParameters ( const G4int areacode,
G4ThreeVector d,
G4ThreeVector x0,
G4int boundarytype 
) const
virtualinherited

Definition at line 668 of file G4VTwistSurface.cc.

672{
673 // areacode must be one of them:
674 // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
675 // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
676
677 for (G4int i=0; i<4; ++i)
678 {
679 if (fBoundaries[i].GetBoundaryParameters(areacode, d, x0,
680 boundarytype))
681 {
682 return;
683 }
684 }
685
686 std::ostringstream message;
687 message << "Not registered boundary." << G4endl
688 << " Boundary at areacode " << std::hex << areacode
689 << std::dec << G4endl
690 << " is not registered.";
691 G4Exception("G4VTwistSurface::GetBoundaryParameters()", "GeomSolids0002",
692 FatalException, message);
693}

References FatalException, G4VTwistSurface::fBoundaries, G4endl, G4Exception(), and G4VTwistSurface::GetBoundaryParameters().

Referenced by G4VTwistSurface::DistanceToBoundary(), DistanceToSurface(), G4VTwistSurface::GetBoundaryAtPZ(), G4VTwistSurface::GetBoundaryParameters(), and G4VTwistSurface::IsSameBoundary().

◆ GetCorner()

G4ThreeVector G4VTwistSurface::GetCorner ( G4int  areacode) const
inlineprotectedinherited

◆ GetEdgeVisibility()

G4int G4VTwistSurface::GetEdgeVisibility ( G4int  i,
G4int  j,
G4int  m,
G4int  n,
G4int  number,
G4int  orientation 
)
inherited

Definition at line 1031 of file G4VTwistSurface.cc.

1033{
1034 // clockwise filling -> positive orientation
1035 // counter clockwise filling -> negative orientation
1036
1037 //
1038 // d C c
1039 // +------+
1040 // | |
1041 // | |
1042 // | |
1043 // D | |B
1044 // | |
1045 // | |
1046 // | |
1047 // +------+
1048 // a A b
1049 //
1050 // a = +--+ A = ---+
1051 // b = --++ B = --+-
1052 // c = -++- C = -+--
1053 // d = ++-- D = +---
1054
1055
1056 // check first invisible faces
1057
1058 if ( ( i>0 && i<n-2 ) && ( j>0 && j<k-2 ) )
1059 {
1060 return -1 ; // always invisible, signs: ----
1061 }
1062
1063 // change first the vertex number (depends on the orientation)
1064 // 0,1,2,3 -> 3,2,1,0
1065 if ( orientation < 0 ) { number = ( 3 - number ) ; }
1066
1067 // check true edges
1068 if ( ( j>=1 && j<=k-3 ) )
1069 {
1070 if ( i == 0 ) { // signs (A): ---+
1071 return ( number == 3 ) ? 1 : -1 ;
1072 }
1073
1074 else if ( i == n-2 ) { // signs (C): -+--
1075 return ( number == 1 ) ? 1 : -1 ;
1076 }
1077
1078 else
1079 {
1080 std::ostringstream message;
1081 message << "Not correct face number: " << GetName() << " !";
1082 G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1083 "GeomSolids0003", FatalException, message);
1084 }
1085 }
1086
1087 if ( ( i>=1 && i<=n-3 ) )
1088 {
1089 if ( j == 0 ) { // signs (D): +---
1090 return ( number == 0 ) ? 1 : -1 ;
1091 }
1092
1093 else if ( j == k-2 ) { // signs (B): --+-
1094 return ( number == 2 ) ? 1 : -1 ;
1095 }
1096
1097 else
1098 {
1099 std::ostringstream message;
1100 message << "Not correct face number: " << GetName() << " !";
1101 G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1102 "GeomSolids0003", FatalException, message);
1103 }
1104 }
1105
1106 // now the corners
1107 if ( i == 0 && j == 0 ) { // signs (a) : +--+
1108 return ( number == 0 || number == 3 ) ? 1 : -1 ;
1109 }
1110 else if ( i == 0 && j == k-2 ) { // signs (b) : --++
1111 return ( number == 2 || number == 3 ) ? 1 : -1 ;
1112 }
1113 else if ( i == n-2 && j == k-2 ) { // signs (c) : -++-
1114 return ( number == 1 || number == 2 ) ? 1 : -1 ;
1115 }
1116 else if ( i == n-2 && j == 0 ) { // signs (d) : ++--
1117 return ( number == 0 || number == 1 ) ? 1 : -1 ;
1118 }
1119 else
1120 {
1121 std::ostringstream message;
1122 message << "Not correct face number: " << GetName() << " !";
1123 G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1124 "GeomSolids0003", FatalException, message);
1125 }
1126
1127 std::ostringstream message;
1128 message << "Not correct face number: " << GetName() << " !";
1129 G4Exception("G4TwistSurface::G4GetEdgeVisibility()", "GeomSolids0003",
1130 FatalException, message);
1131
1132 return 0 ;
1133}
virtual G4String GetName() const

References FatalException, G4Exception(), G4VTwistSurface::GetName(), and CLHEP::detail::n.

Referenced by G4TwistBoxSide::GetFacets(), G4TwistTrapAlphaSide::GetFacets(), G4TwistTrapFlatSide::GetFacets(), G4TwistTrapParallelSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsHypeSide::GetFacets(), and GetFacets().

◆ GetFace()

G4int G4VTwistSurface::GetFace ( G4int  i,
G4int  j,
G4int  m,
G4int  n,
G4int  iside 
)
inherited

Definition at line 906 of file G4VTwistSurface.cc.

908{
909 // this is the face mapping function
910 // (i,j) -> face number
911
912 if ( iside == 0 ) {
913 return i * ( k - 1 ) + j ;
914 }
915
916 else if ( iside == 1 ) {
917 return (k-1)*(k-1) + i*(k-1) + j ;
918 }
919
920 else if ( iside == 2 ) {
921 return 2*(k-1)*(k-1) + i*(k-1) + j ;
922 }
923
924 else if ( iside == 3 ) {
925 return 2*(k-1)*(k-1) + (n-1)*(k-1) + i*(k-1) + j ;
926 }
927
928 else if ( iside == 4 ) {
929 return 2*(k-1)*(k-1) + 2*(n-1)*(k-1) + i*(k-1) + j ;
930 }
931
932 else if ( iside == 5 ) {
933 return 2*(k-1)*(k-1) + 3*(n-1)*(k-1) + i*(k-1) + j ;
934 }
935
936 else {
937 std::ostringstream message;
938 message << "Not correct side number: "
939 << GetName() << G4endl
940 << "iside is " << iside << " but should be "
941 << "0,1,2,3,4 or 5" << ".";
942 G4Exception("G4TwistSurface::G4GetFace()", "GeomSolids0002",
943 FatalException, message);
944 }
945
946 return -1 ; // wrong face
947}

References FatalException, G4endl, G4Exception(), G4VTwistSurface::GetName(), and CLHEP::detail::n.

Referenced by G4TwistBoxSide::GetFacets(), G4TwistTrapAlphaSide::GetFacets(), G4TwistTrapFlatSide::GetFacets(), G4TwistTrapParallelSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsHypeSide::GetFacets(), and GetFacets().

◆ GetFacets()

void G4TwistTubsSide::GetFacets ( G4int  m,
G4int  n,
G4double  xyz[][3],
G4int  faces[][4],
G4int  iside 
)
virtual

Implements G4VTwistSurface.

Definition at line 1050 of file G4TwistTubsSide.cc.

1052{
1053 G4double z ; // the two parameters for the surface equation
1054 G4double x,xmin,xmax ;
1055
1056 G4ThreeVector p ; // a point on the surface, given by (z,u)
1057
1058 G4int nnode ;
1059 G4int nface ;
1060
1061 // calculate the (n-1)*(k-1) vertices
1062
1063 for ( G4int i = 0 ; i<n ; ++i )
1064 {
1065 z = fAxisMin[1] + i*(fAxisMax[1]-fAxisMin[1])/(n-1) ;
1066
1067 for ( G4int j = 0 ; j<k ; ++j )
1068 {
1069 nnode = GetNode(i,j,k,n,iside) ;
1070
1071 xmin = GetBoundaryMin(z) ;
1072 xmax = GetBoundaryMax(z) ;
1073
1074 if (fHandedness < 0)
1075 {
1076 x = xmin + j*(xmax-xmin)/(k-1) ;
1077 }
1078 else
1079 {
1080 x = xmax - j*(xmax-xmin)/(k-1) ;
1081 }
1082
1083 p = SurfacePoint(x,z,true) ; // surface point in global coord.system
1084
1085 xyz[nnode][0] = p.x() ;
1086 xyz[nnode][1] = p.y() ;
1087 xyz[nnode][2] = p.z() ;
1088
1089 if ( i<n-1 && j<k-1 ) // clock wise filling
1090 {
1091 nface = GetFace(i,j,k,n,iside) ;
1092
1093 faces[nface][0] = GetEdgeVisibility(i,j,k,n,0,1)
1094 * ( GetNode(i ,j ,k,n,iside)+1) ;
1095 faces[nface][1] = GetEdgeVisibility(i,j,k,n,1,1)
1096 * ( GetNode(i+1,j ,k,n,iside)+1) ;
1097 faces[nface][2] = GetEdgeVisibility(i,j,k,n,2,1)
1098 * ( GetNode(i+1,j+1,k,n,iside)+1) ;
1099 faces[nface][3] = GetEdgeVisibility(i,j,k,n,3,1)
1100 * ( GetNode(i ,j+1,k,n,iside)+1) ;
1101 }
1102 }
1103 }
1104}
virtual G4double GetBoundaryMax(G4double phi)
virtual G4double GetBoundaryMin(G4double phi)
virtual G4ThreeVector SurfacePoint(G4double, G4double, G4bool isGlobal=false)
G4int GetNode(G4int i, G4int j, G4int m, G4int n, G4int iside)
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)

References G4VTwistSurface::fAxisMax, G4VTwistSurface::fAxisMin, G4VTwistSurface::fHandedness, GetBoundaryMax(), GetBoundaryMin(), G4VTwistSurface::GetEdgeVisibility(), G4VTwistSurface::GetFace(), G4VTwistSurface::GetNode(), CLHEP::detail::n, SurfacePoint(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ GetName()

virtual G4String G4VTwistSurface::GetName ( ) const
inlinevirtualinherited

◆ GetNeighbours() [1/2]

G4VTwistSurface ** G4VTwistSurface::GetNeighbours ( )
inlineprotectedinherited

Definition at line 183 of file G4VTwistSurface.hh.

183{ return fNeighbours; }
G4VTwistSurface * fNeighbours[4]

References G4VTwistSurface::fNeighbours.

Referenced by G4VTwistSurface::DistanceToIn().

◆ GetNeighbours() [2/2]

G4int G4VTwistSurface::GetNeighbours ( G4int  areacode,
G4VTwistSurface surfaces[] 
)
inlineprotectedinherited

◆ GetNode()

G4int G4VTwistSurface::GetNode ( G4int  i,
G4int  j,
G4int  m,
G4int  n,
G4int  iside 
)
inherited

Definition at line 952 of file G4VTwistSurface.cc.

954{
955 // this is the node mapping function
956 // (i,j) -> node number
957 // Depends on the side iside and the used meshing of the surface
958
959 if ( iside == 0 )
960 {
961 // lower endcap is kxk squared.
962 // n = k
963 return i * k + j ;
964 }
965
966 if ( iside == 1 )
967 {
968 // upper endcap is kxk squared. Shift by k*k
969 // n = k
970 return k*k + i*k + j ;
971 }
972
973 else if ( iside == 2 )
974 {
975 // front side.
976 if ( i == 0 ) { return j ; }
977 else if ( i == n-1 ) { return k*k + j ; }
978 else { return 2*k*k + 4*(i-1)*(k-1) + j ; }
979 }
980
981 else if ( iside == 3 )
982 {
983 // right side
984 if ( i == 0 ) { return (j+1)*k - 1 ; }
985 else if ( i == n-1 ) { return k*k + (j+1)*k - 1 ; }
986 else
987 {
988 return 2*k*k + 4*(i-1)*(k-1) + (k-1) + j ;
989 }
990 }
991 else if ( iside == 4 )
992 {
993 // back side
994 if ( i == 0 ) { return k*k - 1 - j ; } // reversed order
995 else if ( i == n-1 ) { return 2*k*k - 1 - j ; } // reversed order
996 else
997 {
998 return 2*k*k + 4*(i-1)*(k-1) + 2*(k-1) + j ; // normal order
999 }
1000 }
1001 else if ( iside == 5 )
1002 {
1003 // left side
1004 if ( i == 0 ) { return k*k - (j+1)*k ; } // reversed order
1005 else if ( i == n-1) { return 2*k*k - (j+1)*k ; } // reverded order
1006 else
1007 {
1008 if ( j == k-1 ) { return 2*k*k + 4*(i-1)*(k-1) ; } // special case
1009 else
1010 {
1011 return 2*k*k + 4*(i-1)*(k-1) + 3*(k-1) + j ; // normal order
1012 }
1013 }
1014 }
1015 else
1016 {
1017 std::ostringstream message;
1018 message << "Not correct side number: "
1019 << GetName() << G4endl
1020 << "iside is " << iside << " but should be "
1021 << "0,1,2,3,4 or 5" << ".";
1022 G4Exception("G4TwistSurface::G4GetNode()", "GeomSolids0002",
1023 FatalException, message);
1024 }
1025 return -1 ; // wrong node
1026}

References FatalException, G4endl, G4Exception(), G4VTwistSurface::GetName(), and CLHEP::detail::n.

Referenced by G4TwistBoxSide::GetFacets(), G4TwistTrapAlphaSide::GetFacets(), G4TwistTrapFlatSide::GetFacets(), G4TwistTrapParallelSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsHypeSide::GetFacets(), and GetFacets().

◆ GetNormal()

G4ThreeVector G4TwistTubsSide::GetNormal ( const G4ThreeVector xx,
G4bool  isGlobal = false 
)
virtual

Implements G4VTwistSurface.

Definition at line 113 of file G4TwistTubsSide.cc.

115{
116 // GetNormal returns a normal vector at a surface (or very close
117 // to surface) point at tmpxx.
118 // If isGlobal=true, it returns the normal in global coordinate.
119 //
120 G4ThreeVector xx;
121 if (isGlobal)
122 {
123 xx = ComputeLocalPoint(tmpxx);
124 if ((xx - fCurrentNormal.p).mag() < 0.5 * kCarTolerance)
125 {
127 }
128 }
129 else
130 {
131 xx = tmpxx;
132 if (xx == fCurrentNormal.p)
133 {
134 return fCurrentNormal.normal;
135 }
136 }
137
138 G4ThreeVector er(1, fKappa * xx.z(), 0);
139 G4ThreeVector ez(0, fKappa * xx.x(), 1);
140 G4ThreeVector normal = fHandedness*(er.cross(ez));
141
142 if (isGlobal)
143 {
145 }
146 else
147 {
149 }
150 return fCurrentNormal.normal;
151}
G4ThreeVector ComputeGlobalDirection(const G4ThreeVector &lp) const
G4SurfCurNormal fCurrentNormal

References G4VTwistSurface::ComputeGlobalDirection(), G4VTwistSurface::ComputeLocalPoint(), CLHEP::Hep3Vector::cross(), G4VTwistSurface::fCurrentNormal, G4VTwistSurface::fHandedness, fKappa, G4VTwistSurface::kCarTolerance, CLHEP::normal(), G4VTwistSurface::G4SurfCurNormal::normal, G4VTwistSurface::G4SurfCurNormal::p, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToSurface().

◆ GetSurfaceArea()

G4double G4TwistTubsSide::GetSurfaceArea ( )
inlinevirtual

Implements G4VTwistSurface.

Definition at line 173 of file G4TwistTubsSide.hh.

174{
175 // approximation only
176 return ( fAxisMax[0] - fAxisMin[0] ) * ( fAxisMax[1] - fAxisMin[1] ) ;
177}

References G4VTwistSurface::fAxisMax, and G4VTwistSurface::fAxisMin.

◆ IsAxis0()

G4bool G4VTwistSurface::IsAxis0 ( G4int  areacode) const
inlineinherited

◆ IsAxis1()

G4bool G4VTwistSurface::IsAxis1 ( G4int  areacode) const
inlineinherited

◆ IsBoundary()

G4bool G4VTwistSurface::IsBoundary ( G4int  areacode,
G4bool  testbitmode = false 
) const
inlineinherited

◆ IsCorner()

G4bool G4VTwistSurface::IsCorner ( G4int  areacode,
G4bool  testbitmode = false 
) const
inlineinherited

◆ IsInside()

G4bool G4VTwistSurface::IsInside ( G4int  areacode,
G4bool  testbitmode = false 
) const
inlineinherited

◆ IsOutside()

G4bool G4VTwistSurface::IsOutside ( G4int  areacode) const
inlineinherited

◆ IsSameBoundary()

G4bool G4VTwistSurface::IsSameBoundary ( G4VTwistSurface surface1,
G4int  areacode1,
G4VTwistSurface surface2,
G4int  areacode2 
) const
inherited

Definition at line 616 of file G4VTwistSurface.cc.

618{
619 //
620 // IsSameBoundary
621 //
622 // checking tool whether two boundaries on different surfaces are same or not.
623 //
624
625 G4bool testbitmode = true;
626 G4bool iscorner[2] = {IsCorner(areacode1, testbitmode),
627 IsCorner(areacode2, testbitmode)};
628
629 if (iscorner[0] && iscorner[1])
630 {
631 // on corner
632 G4ThreeVector corner1 =
633 surf1->ComputeGlobalPoint(surf1->GetCorner(areacode1));
634 G4ThreeVector corner2 =
635 surf2->ComputeGlobalPoint(surf2->GetCorner(areacode2));
636
637 if ((corner1 - corner2).mag() < kCarTolerance) { return true; }
638 else { return false; }
639 }
640 else if ((IsBoundary(areacode1, testbitmode) && (!iscorner[0])) &&
641 (IsBoundary(areacode2, testbitmode) && (!iscorner[1])))
642 {
643 // on boundary
644 G4ThreeVector d1, d2, ld1, ld2;
645 G4ThreeVector x01, x02, lx01, lx02;
646 G4int type1, type2;
647 surf1->GetBoundaryParameters(areacode1, ld1, lx01, type1);
648 surf2->GetBoundaryParameters(areacode2, ld2, lx02, type2);
649
650 x01 = surf1->ComputeGlobalPoint(lx01);
651 x02 = surf2->ComputeGlobalPoint(lx02);
652 d1 = surf1->ComputeGlobalDirection(ld1);
653 d2 = surf2->ComputeGlobalDirection(ld2);
654
655 if ((x01 - x02).mag() < kCarTolerance &&
656 (d1 - d2).mag() < kCarTolerance) { return true; }
657 else { return false; }
658 }
659 else
660 {
661 return false;
662 }
663}
static const G4double d1
static const G4double d2
G4bool IsCorner(G4int areacode, G4bool testbitmode=false) const
G4bool IsBoundary(G4int areacode, G4bool testbitmode=false) const

References G4VTwistSurface::ComputeGlobalDirection(), G4VTwistSurface::ComputeGlobalPoint(), d1, d2, G4VTwistSurface::GetBoundaryParameters(), G4VTwistSurface::GetCorner(), G4VTwistSurface::IsBoundary(), G4VTwistSurface::IsCorner(), and G4VTwistSurface::kCarTolerance.

Referenced by G4VTwistSurface::DistanceToIn().

◆ IsValidNorm()

G4bool G4VTwistSurface::IsValidNorm ( ) const
inlineinherited

◆ ProjectAtPXPZ()

G4ThreeVector G4TwistTubsSide::ProjectAtPXPZ ( const G4ThreeVector p,
G4bool  isglobal = false 
) const
inline

Definition at line 138 of file G4TwistTubsSide.hh.

140{
141 // Get Rho at p.z() on Hyperbolic Surface.
142 G4ThreeVector tmpp;
143 if (isglobal) { tmpp = fRot.inverse()*p - fTrans; }
144 else { tmpp = p; }
145 G4ThreeVector xx(p.x(), p.x() * fKappa * p.z(), p.z());
146 if (isglobal) { return (fRot * xx + fTrans); }
147 return xx;
148}
HepRotation inverse() const

References fKappa, G4VTwistSurface::fRot, G4VTwistSurface::fTrans, CLHEP::HepRotation::inverse(), CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::z().

◆ SetAxis()

void G4VTwistSurface::SetAxis ( G4int  i,
const EAxis  axis 
)
inlineinherited

Definition at line 156 of file G4VTwistSurface.hh.

156{ fAxis[i] = axis; }

References G4VTwistSurface::fAxis.

◆ SetBoundaries()

void G4TwistTubsSide::SetBoundaries ( )
privatevirtual

Implements G4VTwistSurface.

Definition at line 1003 of file G4TwistTubsSide.cc.

1004{
1005 // Set direction-unit vector of boundary-lines in local coodinate.
1006 //
1007 G4ThreeVector direction;
1008
1009 if (fAxis[0] == kXAxis && fAxis[1] == kZAxis)
1010 {
1011 // sAxis0 & sAxisMin
1012 direction = GetCorner(sC0Min1Max) - GetCorner(sC0Min1Min);
1013 direction = direction.unit();
1014 SetBoundary(sAxis0 & (sAxisX | sAxisMin), direction,
1016
1017 // sAxis0 & sAxisMax
1018 direction = GetCorner(sC0Max1Max) - GetCorner(sC0Max1Min);
1019 direction = direction.unit();
1020 SetBoundary(sAxis0 & (sAxisX | sAxisMax), direction,
1022
1023 // sAxis1 & sAxisMin
1024 direction = GetCorner(sC0Max1Min) - GetCorner(sC0Min1Min);
1025 direction = direction.unit();
1026 SetBoundary(sAxis1 & (sAxisZ | sAxisMin), direction,
1028
1029 // sAxis1 & sAxisMax
1030 direction = GetCorner(sC0Max1Max) - GetCorner(sC0Min1Max);
1031 direction = direction.unit();
1032 SetBoundary(sAxis1 & (sAxisZ | sAxisMax), direction,
1034
1035 }
1036 else
1037 {
1038 std::ostringstream message;
1039 message << "Feature NOT implemented !" << G4endl
1040 << " fAxis[0] = " << fAxis[0] << G4endl
1041 << " fAxis[1] = " << fAxis[1];
1042 G4Exception("G4TwistTubsSide::SetCorners()",
1043 "GeomSolids0001", FatalException, message);
1044 }
1045}
Hep3Vector unit() const
virtual void SetBoundary(const G4int &axiscode, const G4ThreeVector &direction, const G4ThreeVector &x0, const G4int &boundarytype)

References FatalException, G4VTwistSurface::fAxis, G4endl, G4Exception(), G4VTwistSurface::GetCorner(), kXAxis, kZAxis, G4VTwistSurface::sAxis0, G4VTwistSurface::sAxis1, G4VTwistSurface::sAxisMax, G4VTwistSurface::sAxisMin, G4VTwistSurface::sAxisX, G4VTwistSurface::sAxisZ, G4VTwistSurface::sC0Max1Max, G4VTwistSurface::sC0Max1Min, G4VTwistSurface::sC0Min1Max, G4VTwistSurface::sC0Min1Min, G4VTwistSurface::SetBoundary(), and CLHEP::Hep3Vector::unit().

Referenced by G4TwistTubsSide().

◆ SetBoundary()

void G4VTwistSurface::SetBoundary ( const G4int axiscode,
const G4ThreeVector direction,
const G4ThreeVector x0,
const G4int boundarytype 
)
protectedvirtualinherited

Definition at line 863 of file G4VTwistSurface.cc.

867{
868 G4int code = (~sAxisMask) & axiscode;
869 if ((code == (sAxis0 & sAxisMin)) ||
870 (code == (sAxis0 & sAxisMax)) ||
871 (code == (sAxis1 & sAxisMin)) ||
872 (code == (sAxis1 & sAxisMax)))
873 {
874 G4bool done = false;
875 for (auto i=0; i<4; ++i)
876 {
877 if (fBoundaries[i].IsEmpty())
878 {
879 fBoundaries[i].SetFields(axiscode, direction,
880 x0, boundarytype);
881 done = true;
882 break;
883 }
884 }
885
886 if (!done)
887 {
888 G4Exception("G4VTwistSurface::SetBoundary()", "GeomSolids0003",
889 FatalException, "Number of boundary exceeding 4!");
890 }
891 }
892 else
893 {
894 std::ostringstream message;
895 message << "Invalid axis-code." << G4endl
896 << " axiscode = "
897 << std::hex << axiscode << std::dec;
898 G4Exception("G4VTwistSurface::SetBoundary()", "GeomSolids0003",
899 FatalException, message);
900 }
901}
void SetFields(const G4int &areacode, const G4ThreeVector &d, const G4ThreeVector &x0, const G4int &boundarytype)
Definition: inftrees.h:24

References FatalException, G4VTwistSurface::fBoundaries, G4endl, G4Exception(), G4VTwistSurface::sAxis0, G4VTwistSurface::sAxis1, G4VTwistSurface::sAxisMax, G4VTwistSurface::sAxisMin, and G4VTwistSurface::Boundary::SetFields().

Referenced by G4TwistBoxSide::SetBoundaries(), G4TwistTrapAlphaSide::SetBoundaries(), G4TwistTrapFlatSide::SetBoundaries(), G4TwistTrapParallelSide::SetBoundaries(), G4TwistTubsFlatSide::SetBoundaries(), G4TwistTubsHypeSide::SetBoundaries(), and SetBoundaries().

◆ SetCorner()

void G4VTwistSurface::SetCorner ( G4int  areacode,
G4double  x,
G4double  y,
G4double  z 
)
protectedinherited

Definition at line 757 of file G4VTwistSurface.cc.

759{
760 if ((areacode & sCorner) != sCorner)
761 {
762 std::ostringstream message;
763 message << "Area code must represents corner." << G4endl
764 << " areacode " << areacode;
765 G4Exception("G4VTwistSurface::SetCorner()", "GeomSolids0002",
766 FatalException, message);
767 }
768
769 if ((areacode & sC0Min1Min) == sC0Min1Min) {
770 fCorners[0].set(x, y, z);
771 } else if ((areacode & sC0Max1Min) == sC0Max1Min) {
772 fCorners[1].set(x, y, z);
773 } else if ((areacode & sC0Max1Max) == sC0Max1Max) {
774 fCorners[2].set(x, y, z);
775 } else if ((areacode & sC0Min1Max) == sC0Min1Max) {
776 fCorners[3].set(x, y, z);
777 }
778}
G4ThreeVector fCorners[4]

References FatalException, G4VTwistSurface::fCorners, G4endl, G4Exception(), G4VTwistSurface::sC0Max1Max, G4VTwistSurface::sC0Max1Min, G4VTwistSurface::sC0Min1Max, G4VTwistSurface::sC0Min1Min, G4VTwistSurface::sCorner, and CLHEP::Hep3Vector::set().

Referenced by G4TwistBoxSide::SetCorners(), G4TwistTrapAlphaSide::SetCorners(), G4TwistTrapFlatSide::SetCorners(), G4TwistTrapParallelSide::SetCorners(), G4TwistTubsFlatSide::SetCorners(), SetCorners(), and G4TwistTubsHypeSide::SetCorners().

◆ SetCorners() [1/2]

void G4TwistTubsSide::SetCorners ( )
privatevirtual

Implements G4VTwistSurface.

Definition at line 993 of file G4TwistTubsSide.cc.

994{
995 G4Exception("G4TwistTubsSide::SetCorners()",
996 "GeomSolids0001", FatalException,
997 "Method NOT implemented !");
998}

References FatalException, and G4Exception().

Referenced by G4TwistTubsSide().

◆ SetCorners() [2/2]

void G4TwistTubsSide::SetCorners ( G4double  endInnerRad[2],
G4double  endOuterRad[2],
G4double  endPhi[2],
G4double  endZ[2] 
)
privatevirtual

Definition at line 940 of file G4TwistTubsSide.cc.

944{
945 // Set Corner points in local coodinate.
946
947 if (fAxis[0] == kXAxis && fAxis[1] == kZAxis)
948 {
949 G4int zmin = 0 ; // at -ve z
950 G4int zmax = 1 ; // at +ve z
951
952 G4double x, y, z;
953
954 // corner of Axis0min and Axis1min
955 x = endInnerRad[zmin]*std::cos(endPhi[zmin]);
956 y = endInnerRad[zmin]*std::sin(endPhi[zmin]);
957 z = endZ[zmin];
958 SetCorner(sC0Min1Min, x, y, z);
959
960 // corner of Axis0max and Axis1min
961 x = endOuterRad[zmin]*std::cos(endPhi[zmin]);
962 y = endOuterRad[zmin]*std::sin(endPhi[zmin]);
963 z = endZ[zmin];
964 SetCorner(sC0Max1Min, x, y, z);
965
966 // corner of Axis0max and Axis1max
967 x = endOuterRad[zmax]*std::cos(endPhi[zmax]);
968 y = endOuterRad[zmax]*std::sin(endPhi[zmax]);
969 z = endZ[zmax];
970 SetCorner(sC0Max1Max, x, y, z);
971
972 // corner of Axis0min and Axis1max
973 x = endInnerRad[zmax]*std::cos(endPhi[zmax]);
974 y = endInnerRad[zmax]*std::sin(endPhi[zmax]);
975 z = endZ[zmax];
976 SetCorner(sC0Min1Max, x, y, z);
977
978 }
979 else
980 {
981 std::ostringstream message;
982 message << "Feature NOT implemented !" << G4endl
983 << " fAxis[0] = " << fAxis[0] << G4endl
984 << " fAxis[1] = " << fAxis[1];
985 G4Exception("G4TwistTubsSide::SetCorners()",
986 "GeomSolids0001", FatalException, message);
987 }
988}
void SetCorner(G4int areacode, G4double x, G4double y, G4double z)

References FatalException, G4VTwistSurface::fAxis, G4endl, G4Exception(), kXAxis, kZAxis, G4VTwistSurface::sC0Max1Max, G4VTwistSurface::sC0Max1Min, G4VTwistSurface::sC0Min1Max, G4VTwistSurface::sC0Min1Min, and G4VTwistSurface::SetCorner().

◆ SetNeighbours()

void G4VTwistSurface::SetNeighbours ( G4VTwistSurface ax0min,
G4VTwistSurface ax1min,
G4VTwistSurface ax0max,
G4VTwistSurface ax1max 
)
inlineinherited

◆ SurfacePoint()

G4ThreeVector G4TwistTubsSide::SurfacePoint ( G4double  x,
G4double  z,
G4bool  isGlobal = false 
)
inlinevirtual

Implements G4VTwistSurface.

Definition at line 152 of file G4TwistTubsSide.hh.

153{
154 G4ThreeVector SurfPoint( x , x * fKappa * z , z ) ;
155
156 if (isGlobal) { return (fRot * SurfPoint + fTrans); }
157 return SurfPoint;
158}

References fKappa, G4VTwistSurface::fRot, and G4VTwistSurface::fTrans.

Referenced by GetFacets().

Field Documentation

◆ fAmIOnLeftSide

G4SurfSideQuery G4VTwistSurface::fAmIOnLeftSide
privateinherited

◆ fAxis

EAxis G4VTwistSurface::fAxis[2]
protectedinherited

◆ fAxisMax

G4double G4VTwistSurface::fAxisMax[2]
protectedinherited

◆ fAxisMin

G4double G4VTwistSurface::fAxisMin[2]
protectedinherited

◆ fBoundaries

Boundary G4VTwistSurface::fBoundaries[4]
privateinherited

◆ fCorners

G4ThreeVector G4VTwistSurface::fCorners[4]
privateinherited

◆ fCurrentNormal

G4SurfCurNormal G4VTwistSurface::fCurrentNormal
protectedinherited

◆ fCurStat

CurrentStatus G4VTwistSurface::fCurStat
protectedinherited

◆ fCurStatWithV

CurrentStatus G4VTwistSurface::fCurStatWithV
protectedinherited

◆ fHandedness

G4int G4VTwistSurface::fHandedness
protectedinherited

◆ fIsValidNorm

G4bool G4VTwistSurface::fIsValidNorm
protectedinherited

◆ fKappa

G4double G4TwistTubsSide::fKappa
private

◆ fName

G4String G4VTwistSurface::fName
privateinherited

◆ fNeighbours

G4VTwistSurface* G4VTwistSurface::fNeighbours[4]
privateinherited

◆ fRot

G4RotationMatrix G4VTwistSurface::fRot
protectedinherited

◆ fTrans

G4ThreeVector G4VTwistSurface::fTrans
protectedinherited

◆ kCarTolerance

G4double G4VTwistSurface::kCarTolerance
protectedinherited

◆ sAreaMask

const G4int G4VTwistSurface::sAreaMask = 0XF0000000
staticinherited

Definition at line 235 of file G4VTwistSurface.hh.

◆ sAxis0

const G4int G4VTwistSurface::sAxis0 = 0x0000FF00
staticinherited

◆ sAxis1

const G4int G4VTwistSurface::sAxis1 = 0x000000FF
staticinherited

◆ sAxisMask

const G4int G4VTwistSurface::sAxisMask = 0x0000FCFC
staticinherited

Definition at line 234 of file G4VTwistSurface.hh.

Referenced by G4VTwistSurface::GetBoundaryAxis().

◆ sAxisMax

const G4int G4VTwistSurface::sAxisMax = 0x00000202
staticinherited

◆ sAxisMin

const G4int G4VTwistSurface::sAxisMin = 0x00000101
staticinherited

◆ sAxisPhi

const G4int G4VTwistSurface::sAxisPhi = 0x00001414
staticinherited

◆ sAxisRho

const G4int G4VTwistSurface::sAxisRho = 0x00001010
staticinherited

◆ sAxisX

const G4int G4VTwistSurface::sAxisX = 0x00000404
staticinherited

◆ sAxisY

const G4int G4VTwistSurface::sAxisY = 0x00000808
staticinherited

◆ sAxisZ

const G4int G4VTwistSurface::sAxisZ = 0x00000C0C
staticinherited

◆ sBoundary

const G4int G4VTwistSurface::sBoundary = 0x20000000
staticinherited

◆ sC0Max1Max

const G4int G4VTwistSurface::sC0Max1Max = 0x40000202
staticinherited

◆ sC0Max1Min

const G4int G4VTwistSurface::sC0Max1Min = 0x40000201
staticinherited

◆ sC0Min1Max

const G4int G4VTwistSurface::sC0Min1Max = 0x40000102
staticinherited

◆ sC0Min1Min

const G4int G4VTwistSurface::sC0Min1Min = 0x40000101
staticinherited

◆ sCorner

const G4int G4VTwistSurface::sCorner = 0x40000000
staticinherited

◆ sInside

const G4int G4VTwistSurface::sInside = 0x10000000
staticinherited

◆ sOutside

const G4int G4VTwistSurface::sOutside = 0x00000000
staticinherited

◆ sSizeMask

const G4int G4VTwistSurface::sSizeMask = 0x00000303
staticinherited

The documentation for this class was generated from the following files: