Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VTwistSurface Class Referenceabstract

G4VTwistSurface is a base class for boundary surface of a G4VSolid. More...

#include <G4VTwistSurface.hh>

Inheritance diagram for G4VTwistSurface:

Classes

class  CurrentStatus
class  Boundary
class  G4SurfCurNormal

Public Types

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

Public Member Functions

 G4VTwistSurface (const G4String &name)
 G4VTwistSurface (const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, G4int handedness, const EAxis axis0, const EAxis axis1, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
virtual ~G4VTwistSurface ()=default
virtual G4int AmIOnLeftSide (const G4ThreeVector &me, const G4ThreeVector &vec, G4bool withTol=true)
virtual G4double DistanceToBoundary (G4int areacode, G4ThreeVector &xx, const G4ThreeVector &p)
virtual G4double DistanceToIn (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4double DistanceToOut (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4double DistanceTo (const G4ThreeVector &gp, G4ThreeVector &gxx)
virtual G4int DistanceToSurface (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)=0
virtual G4int DistanceToSurface (const G4ThreeVector &gp, G4ThreeVector gxx[], G4double distance[], G4int areacode[])=0
virtual G4ThreeVector GetNormal (const G4ThreeVector &p, G4bool isGlobal)=0
virtual void GetBoundaryParameters (const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
virtual G4ThreeVector GetBoundaryAtPZ (G4int areacode, const G4ThreeVector &p) const
G4double DistanceToPlaneWithV (const G4ThreeVector &p, const G4ThreeVector &v, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
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 DistanceToLine (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
G4bool IsAxis0 (G4int areacode) const
G4bool IsAxis1 (G4int areacode) const
G4bool IsOutside (G4int areacode) const
G4bool IsInside (G4int areacode, G4bool testbitmode=false) const
G4bool IsBoundary (G4int areacode, G4bool testbitmode=false) const
G4bool IsCorner (G4int areacode, G4bool testbitmode=false) const
G4bool IsValidNorm () const
G4bool IsSameBoundary (G4VTwistSurface *surface1, G4int areacode1, G4VTwistSurface *surface2, G4int areacode2) const
G4int GetAxisType (G4int areacode, G4int whichaxis) const
G4ThreeVector ComputeGlobalPoint (const G4ThreeVector &lp) const
G4ThreeVector ComputeLocalPoint (const G4ThreeVector &gp) const
G4ThreeVector ComputeGlobalDirection (const G4ThreeVector &lp) const
G4ThreeVector ComputeLocalDirection (const G4ThreeVector &gp) 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)=0
virtual G4double GetBoundaryMin (G4double)=0
virtual G4double GetBoundaryMax (G4double)=0
virtual G4double GetSurfaceArea ()=0
virtual void GetFacets (G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)=0
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)
const G4StringGetName () const
void DebugPrint () const
 G4VTwistSurface (__void__ &)

Static Public Attributes

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

Protected Member Functions

G4VTwistSurface ** GetNeighbours ()
G4int GetNeighbours (G4int areacode, G4VTwistSurface *surfaces[])
G4ThreeVector GetCorner (G4int areacode) const
void GetBoundaryAxis (G4int areacode, EAxis axis[]) const
void GetBoundaryLimit (G4int areacode, G4double limit[]) const
virtual G4int GetAreaCode (const G4ThreeVector &xx, G4bool withtol=true)=0
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 fAxisMin [2]
G4double fAxisMax [2]
CurrentStatus fCurStatWithV
CurrentStatus fCurStat
G4RotationMatrix fRot
G4ThreeVector fTrans
G4int fHandedness
G4SurfCurNormal fCurrentNormal
G4bool fIsValidNorm
G4double kCarTolerance

Detailed Description

G4VTwistSurface is a base class for boundary surface of a G4VSolid.

Definition at line 52 of file G4VTwistSurface.hh.

Member Enumeration Documentation

◆ EValidate

Enumerator
kDontValidate 
kValidateWithTol 
kValidateWithoutTol 
kUninitialized 

Definition at line 56 of file G4VTwistSurface.hh.

Constructor & Destructor Documentation

◆ G4VTwistSurface() [1/3]

G4VTwistSurface::G4VTwistSurface ( const G4String & name)

Base constructor, given a name.

Parameters
[in]nameThe surface name.

Definition at line 64 of file G4VTwistSurface.cc.

65 : fIsValidNorm(false), fName(name)
66{
67
68 fAxis[0] = kUndefined;
69 fAxis[1] = kUndefined;
70 fAxisMin[0] = kInfinity;
71 fAxisMin[1] = kInfinity;
72 fAxisMax[0] = kInfinity;
73 fAxisMax[1] = kInfinity;
74 fHandedness = 1;
75
76 for (auto i=0; i<4; ++i)
77 {
78 fCorners[i].set(kInfinity, kInfinity, kInfinity);
79 fNeighbours[i] = nullptr;
80 }
81
82 fCurrentNormal.p.set(kInfinity, kInfinity, kInfinity);
83
84 fAmIOnLeftSide.me.set(kInfinity, kInfinity, kInfinity);
85 fAmIOnLeftSide.vec.set(kInfinity, kInfinity, kInfinity);
87}
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4SurfCurNormal fCurrentNormal
@ kUndefined
Definition geomdefs.hh:61

Referenced by DistanceToIn(), G4TwistBoxSide::G4TwistBoxSide(), G4TwistBoxSide::G4TwistBoxSide(), G4TwistTrapAlphaSide::G4TwistTrapAlphaSide(), G4TwistTrapAlphaSide::G4TwistTrapAlphaSide(), G4TwistTrapFlatSide::G4TwistTrapFlatSide(), G4TwistTrapFlatSide::G4TwistTrapFlatSide(), G4TwistTrapParallelSide::G4TwistTrapParallelSide(), G4TwistTrapParallelSide::G4TwistTrapParallelSide(), G4TwistTubsFlatSide::G4TwistTubsFlatSide(), G4TwistTubsFlatSide::G4TwistTubsFlatSide(), G4TwistTubsFlatSide::G4TwistTubsFlatSide(), G4TwistTubsHypeSide::G4TwistTubsHypeSide(), G4TwistTubsHypeSide::G4TwistTubsHypeSide(), G4TwistTubsHypeSide::G4TwistTubsHypeSide(), G4TwistTubsSide::G4TwistTubsSide(), G4TwistTubsSide::G4TwistTubsSide(), G4TwistTubsSide::G4TwistTubsSide(), GetNeighbours(), GetNeighbours(), IsSameBoundary(), and SetNeighbours().

◆ G4VTwistSurface() [2/3]

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

Constructs a surface, given its parameters.

Parameters
[in]nameThe surface name.
[in]rotRotation: 0.5*(phi-width segment).
[in]tlateTranslation.
[in]handednessOrientation: R-hand = 1, L-hand = -1.
[in]axis0First axis.
[in]axis1Second axis.
[in]axis0minMinimum in first axis.
[in]axis1minMinimum in second axis.
[in]axis0maxMaximum in first axis.
[in]axis1maxMaximum in second axis.

Definition at line 89 of file G4VTwistSurface.cc.

99 : fIsValidNorm(false), fName(name)
100{
101 fAxis[0] = axis0;
102 fAxis[1] = axis1;
103 fAxisMin[0] = axis0min;
104 fAxisMin[1] = axis1min;
105 fAxisMax[0] = axis0max;
106 fAxisMax[1] = axis1max;
107 fHandedness = handedness;
108 fRot = rot;
109 fTrans = tlate;
110
111 for (auto i=0; i<4; ++i)
112 {
113 fCorners[i].set(kInfinity, kInfinity, kInfinity);
114 fNeighbours[i] = nullptr;
115 }
116
117 fCurrentNormal.p.set(kInfinity, kInfinity, kInfinity);
118
119 fAmIOnLeftSide.me.set(kInfinity, kInfinity, kInfinity);
120 fAmIOnLeftSide.vec.set(kInfinity, kInfinity, kInfinity);
122}
G4RotationMatrix fRot
G4ThreeVector fTrans

◆ ~G4VTwistSurface()

virtual G4VTwistSurface::~G4VTwistSurface ( )
virtualdefault

Default destructor.

◆ G4VTwistSurface() [3/3]

G4VTwistSurface::G4VTwistSurface ( __void__ & )

Fake default constructor for usage restricted to direct object persistency for clients requiring preallocation of memory for persistifiable objects.

Definition at line 127 of file G4VTwistSurface.cc.

128 : fHandedness(0), fIsValidNorm(false), kCarTolerance(0.),
129 fName("")
130{
131 fAxis[0] = fAxis[1] = kXAxis;
132 fAxisMin[0] = fAxisMin[1] = 0.;
133 fAxisMax[0] = fAxisMax[1] = 0.;
134 fNeighbours[0] = fNeighbours[1] = fNeighbours[2] = fNeighbours[3] = nullptr;
135}
@ kXAxis
Definition geomdefs.hh:55

Member Function Documentation

◆ AmIOnLeftSide()

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

Returns the phi-location of point 'me' (phi relation between 'me' and 'vec' projected on z=0 plane). If 'me' is on -ve-phi-side of 'vec', it returns 1; on the other hand, if 'me' is on +ve-phi-side of 'vec', it returns -1. If 'me' is on boundary of 'vec', it returns 0.

Returns
The z-coordinate of normal vector of me.cross(vec).

Definition at line 140 of file G4VTwistSurface.cc.

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

Referenced by G4TwistTubsSide::DistanceToSurface().

◆ ComputeGlobalDirection()

◆ ComputeGlobalPoint()

◆ ComputeLocalDirection()

◆ ComputeLocalPoint()

◆ DebugPrint()

void G4VTwistSurface::DebugPrint ( ) const

Prints on standard output surface data.

Definition at line 1084 of file G4VTwistSurface.cc.

1085{
1090
1091 G4cout << "/* G4VTwistSurface::DebugPrint():--------------------------"
1092 << G4endl;
1093 G4cout << "/* Name = " << fName << G4endl;
1094 G4cout << "/* Axis = " << std::hex << fAxis[0] << " "
1095 << std::hex << fAxis[1]
1096 << " (0,1,2,3,5 = kXAxis,kYAxis,kZAxis,kRho,kPhi)"
1097 << std::dec << G4endl;
1098 G4cout << "/* BoundaryLimit(in local) fAxis0(min, max) = ("<<fAxisMin[0]
1099 << ", " << fAxisMax[0] << ")" << G4endl;
1100 G4cout << "/* BoundaryLimit(in local) fAxis1(min, max) = ("<<fAxisMin[1]
1101 << ", " << fAxisMax[1] << ")" << G4endl;
1102 G4cout << "/* Cornar point sC0Min1Min = " << A << G4endl;
1103 G4cout << "/* Cornar point sC0Max1Min = " << B << G4endl;
1104 G4cout << "/* Cornar point sC0Max1Max = " << C << G4endl;
1105 G4cout << "/* Cornar point sC0Min1Max = " << D << G4endl;
1106 G4cout << "/*---------------------------------------------------------"
1107 << G4endl;
1108}
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

◆ DistanceTo()

G4double G4VTwistSurface::DistanceTo ( const G4ThreeVector & gp,
G4ThreeVector & gxx )
virtual

Returns the safety distance to a boundary from an arbitrary point 'gp'.

Parameters
[in]gpThe arbitrary point.
[out]gxxbestThe returned reference point on boundary.

Definition at line 570 of file G4VTwistSurface.cc.

572{
573#ifdef G4TWISTDEBUG
574 G4cout << "~~~~~ G4VTwistSurface::DistanceTo(p) - Start ~~~~~~~~~" << G4endl;
575 G4cout << " Name : " << fName << G4endl;
576 G4cout << " gp : " << gp << G4endl;
577 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
578#endif
579
580
582 G4double distance[G4VSURFACENXX] ;
583 G4int areacode[G4VSURFACENXX] ;
584
585 for (G4int i = 0 ; i<G4VSURFACENXX ; ++i )
586 {
587 distance[i] = kInfinity ;
588 areacode[i] = sOutside ;
589 }
590
591 DistanceToSurface(gp, gxx, distance, areacode);
592 gxxbest = gxx[0];
593
594#ifdef G4TWISTDEBUG
595 G4cout << "~~~~~ G4VTwistSurface::DistanceTo(p) - return ~~~~~~~~" << G4endl;
596 G4cout << " Name : " << fName << G4endl;
597 G4cout << " gxx : " << gxxbest << G4endl;
598 G4cout << " bestdist : " << distance[0] << G4endl;
599 G4cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << G4endl;
600#endif
601
602 return distance[0];
603}
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

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

◆ DistanceToBoundary()

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

Returns the distance to the nearest boundary from an arbitrary point 'p' in local coodinate.

Parameters
[in]areacodePoint location code according to axes.
[out]xxThe returned reference point on boundary.
[in]pThe arbitrary point in input.

Definition at line 224 of file G4VTwistSurface.cc.

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

Referenced by G4TwistTubsSide::DistanceToSurface().

◆ DistanceToIn()

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

Returns the distance from outside to a boundary from an arbitrary point 'gp' and direction 'gv'.

Parameters
[in]gpThe arbitrary point.
[in]gvThe direction vector.
[out]gxxbestThe returned reference point on boundary.

Definition at line 283 of file G4VTwistSurface.cc.

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

◆ DistanceToLine()

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

◆ DistanceToOut()

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

Returns the distance from inside to a boundary from an arbitrary point 'gp' and direction 'gv'.

Parameters
[in]gpThe arbitrary point.
[in]gvThe direction vector.
[out]gxxbestThe returned reference point on boundary.

Definition at line 487 of file G4VTwistSurface.cc.

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

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

◆ DistanceToPlane() [1/2]

◆ DistanceToPlane() [2/2]

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

◆ DistanceToPlaneWithV()

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

◆ DistanceToSurface() [1/2]

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

Returns the distance to surface, given point 'gp' and direction 'gv'.

Parameters
[in]gpThe point from where computing the distance.
[in]gvThe direction along which computing the distance.
[out]gxxVector of global points based on number of solutions.
[out]distanceThe distance vector based on number of solutions.
[out]areacodeThe location vector based on number of solutions.
[out]isvalidValidity vector based on number of solutions.
[in]validateAdopted validation criteria.
Returns
The number of solutions.

Implemented in G4TwistBoxSide, G4TwistTrapAlphaSide, G4TwistTrapFlatSide, G4TwistTrapParallelSide, G4TwistTubsFlatSide, G4TwistTubsHypeSide, and G4TwistTubsSide.

Referenced by DistanceTo(), DistanceToIn(), and DistanceToOut().

◆ DistanceToSurface() [2/2]

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

Returns the safety distance to surface, given point 'gp'.

Parameters
[in]gpThe point from where computing the safety distance.
[out]gxxVector of global points based on number of solutions.
[out]distanceThe distance vector based on number of solutions.
[out]areacodeThe location vector based on number of solutions.
Returns
The number of solutions.

Implemented in G4TwistBoxSide, G4TwistTrapAlphaSide, G4TwistTrapFlatSide, G4TwistTrapParallelSide, G4TwistTubsFlatSide, G4TwistTubsHypeSide, and G4TwistTubsSide.

◆ GetAreaCode()

virtual G4int G4VTwistSurface::GetAreaCode ( const G4ThreeVector & xx,
G4bool withtol = true )
protectedpure virtual

◆ GetAxisType()

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

◆ GetBoundaryAtPZ()

G4ThreeVector G4VTwistSurface::GetBoundaryAtPZ ( G4int areacode,
const G4ThreeVector & p ) const
virtual

Returns Z projection of point 'p' on boundary.

Parameters
[in]areacodeThe location code.
[out]pThe arbitrary point.
Returns
The Z projection on boundary.

Definition at line 685 of file G4VTwistSurface.cc.

687{
688 // areacode must be one of them:
689 // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
690 // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
691
692 if (((areacode & sAxis0) != 0) && ((areacode & sAxis1) != 0))
693 {
694 std::ostringstream message;
695 message << "Point is in the corner area." << G4endl
696 << " This function returns "
697 << "a direction vector of a boundary line." << G4endl
698 << " areacode = " << areacode;
699 G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0003",
700 FatalException, message);
701 }
702
704 G4ThreeVector x0;
705 G4int boundarytype = 0;
706 G4bool found = false;
707
708 for (const auto & boundary : fBoundaries)
709 {
710 if (boundary.GetBoundaryParameters(areacode, d, x0, boundarytype))
711 {
712 found = true;
713 continue;
714 }
715 }
716
717 if (!found)
718 {
719 std::ostringstream message;
720 message << "Not registered boundary." << G4endl
721 << " Boundary at areacode " << areacode << G4endl
722 << " is not registered.";
723 G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0002",
724 FatalException, message);
725 }
726
727 if (((boundarytype & sAxisPhi) == sAxisPhi) ||
728 ((boundarytype & sAxisRho) == sAxisRho))
729 {
730 std::ostringstream message;
731 message << "Not a z-depended line boundary." << G4endl
732 << " Boundary at areacode " << areacode << G4endl
733 << " is not a z-depended line.";
734 G4Exception("G4VTwistSurface::GetBoundaryAtPZ()", "GeomSolids0002",
735 FatalException, message);
736 }
737 return ((p.z() - x0.z()) / d.z()) * d + x0;
738}
static const G4int sAxis0
static const G4int sAxis1
static const G4int sAxisRho

Referenced by G4TwistTubsSide::DistanceToSurface().

◆ GetBoundaryAxis()

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

Definition at line 769 of file G4VTwistSurface.cc.

770{
771 if ((areacode & sBoundary) != sBoundary) {
772 G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0003",
773 FatalException, "Not located on a boundary!");
774 }
775 for (G4int i=0; i<2; ++i)
776 {
777 G4int whichaxis = 0 ;
778 if (i == 0) {
779 whichaxis = sAxis0;
780 } else if (i == 1) {
781 whichaxis = sAxis1;
782 }
783
784 // extracted axiscode of whichaxis
785 G4int axiscode = whichaxis & sAxisMask & areacode ;
786 if (axiscode != 0) {
787 if (axiscode == (whichaxis & sAxisX)) {
788 axis[i] = kXAxis;
789 } else if (axiscode == (whichaxis & sAxisY)) {
790 axis[i] = kYAxis;
791 } else if (axiscode == (whichaxis & sAxisZ)) {
792 axis[i] = kZAxis;
793 } else if (axiscode == (whichaxis & sAxisRho)) {
794 axis[i] = kRho;
795 } else if (axiscode == (whichaxis & sAxisPhi)) {
796 axis[i] = kPhi;
797 } else {
798 std::ostringstream message;
799 message << "Not supported areacode." << G4endl
800 << " areacode " << areacode;
801 G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0001",
802 FatalException, message);
803 }
804 }
805 }
806}
static const G4int sAxisMask
static const G4int sBoundary
static const G4int sAxisZ
static const G4int sAxisY
static const G4int sAxisX
@ kPhi
Definition geomdefs.hh:60
@ kYAxis
Definition geomdefs.hh:56
@ kZAxis
Definition geomdefs.hh:57
@ kRho
Definition geomdefs.hh:58
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668

◆ GetBoundaryLimit()

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

Definition at line 811 of file G4VTwistSurface.cc.

812{
813 if ((areacode & sCorner) != 0) {
814 if ((areacode & sC0Min1Min) != 0) {
815 limit[0] = fAxisMin[0];
816 limit[1] = fAxisMin[1];
817 } else if ((areacode & sC0Max1Min) != 0) {
818 limit[0] = fAxisMax[0];
819 limit[1] = fAxisMin[1];
820 } else if ((areacode & sC0Max1Max) != 0) {
821 limit[0] = fAxisMax[0];
822 limit[1] = fAxisMax[1];
823 } else if ((areacode & sC0Min1Max) != 0) {
824 limit[0] = fAxisMin[0];
825 limit[1] = fAxisMax[1];
826 }
827 } else if ((areacode & sBoundary) != 0) {
828 if ((areacode & (sAxis0 | sAxisMin)) != 0) {
829 limit[0] = fAxisMin[0];
830 } else if ((areacode & (sAxis1 | sAxisMin)) != 0) {
831 limit[0] = fAxisMin[1];
832 } else if ((areacode & (sAxis0 | sAxisMax)) != 0) {
833 limit[0] = fAxisMax[0];
834 } else if ((areacode & (sAxis1 | sAxisMax)) != 0) {
835 limit[0] = fAxisMax[1];
836 }
837 } else {
838 std::ostringstream message;
839 message << "Not located on a boundary!" << G4endl
840 << " areacode " << areacode;
841 G4Exception("G4VTwistSurface::GetBoundaryLimit()", "GeomSolids1002",
842 JustWarning, message);
843 }
844}
@ JustWarning
static const G4int sAxisMax
static const G4int sAxisMin
static const G4int sCorner

◆ GetBoundaryMax()

virtual G4double G4VTwistSurface::GetBoundaryMax ( G4double )
pure virtual

◆ GetBoundaryMin()

virtual G4double G4VTwistSurface::GetBoundaryMin ( G4double )
pure virtual

Internal accessors to be implemented in concrete derived classes.

◆ GetBoundaryParameters()

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

Returns parameters of boundaries.

Parameters
[in]areacodeThe location code.
[out]dBoundary direction.
[out]x0The point on boundary.
[out]boundarytypeThe boundary code.

Definition at line 656 of file G4VTwistSurface.cc.

660{
661 // areacode must be one of them:
662 // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
663 // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
664
665 for (const auto & boundary : fBoundaries)
666 {
667 if (boundary.GetBoundaryParameters(areacode, d, x0, boundarytype))
668 {
669 return;
670 }
671 }
672
673 std::ostringstream message;
674 message << "Not registered boundary." << G4endl
675 << " Boundary at areacode " << std::hex << areacode
676 << std::dec << G4endl
677 << " is not registered.";
678 G4Exception("G4VTwistSurface::GetBoundaryParameters()", "GeomSolids0002",
679 FatalException, message);
680}

Referenced by DistanceToBoundary(), G4TwistTubsSide::DistanceToSurface(), and IsSameBoundary().

◆ GetCorner()

G4ThreeVector G4VTwistSurface::GetCorner ( G4int areacode) const
inlineprotected

Referenced by DebugPrint(), and IsSameBoundary().

◆ GetEdgeVisibility()

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

Checks face visibility, based on verteces and orientation.

Returns
-1 if invisible; 1 if visible.

Definition at line 981 of file G4VTwistSurface.cc.

983{
984 // clockwise filling -> positive orientation
985 // counter clockwise filling -> negative orientation
986
987 //
988 // d C c
989 // +------+
990 // | |
991 // | |
992 // | |
993 // D | |B
994 // | |
995 // | |
996 // | |
997 // +------+
998 // a A b
999 //
1000 // a = +--+ A = ---+
1001 // b = --++ B = --+-
1002 // c = -++- C = -+--
1003 // d = ++-- D = +---
1004
1005
1006 // check first invisible faces
1007
1008 if ( ( i>0 && i<n-2 ) && ( j>0 && j<k-2 ) )
1009 {
1010 return -1 ; // always invisible, signs: ----
1011 }
1012
1013 // change first the vertex number (depends on the orientation)
1014 // 0,1,2,3 -> 3,2,1,0
1015 if ( orientation < 0 ) { number = ( 3 - number ) ; }
1016
1017 // check true edges
1018 if ( ( j>=1 && j<=k-3 ) )
1019 {
1020 if ( i == 0 ) // signs (A): ---+
1021 {
1022 return ( number == 3 ) ? 1 : -1 ;
1023 }
1024
1025 if ( i == n-2 ) // signs (C): -+--
1026 {
1027 return ( number == 1 ) ? 1 : -1 ;
1028 }
1029
1030 std::ostringstream message;
1031 message << "Not correct face number: " << GetName() << " !";
1032 G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1033 "GeomSolids0003", FatalException, message);
1034 }
1035
1036 if ( ( i>=1 && i<=n-3 ) )
1037 {
1038 if ( j == 0 ) // signs (D): +---
1039 {
1040 return ( number == 0 ) ? 1 : -1 ;
1041 }
1042
1043 if ( j == k-2 ) // signs (B): --+-
1044 {
1045 return ( number == 2 ) ? 1 : -1 ;
1046 }
1047
1048 std::ostringstream message;
1049 message << "Not correct face number: " << GetName() << " !";
1050 G4Exception("G4TwistSurface::G4GetEdgeVisibility()",
1051 "GeomSolids0003", FatalException, message);
1052 }
1053
1054 // now the corners
1055 if ( i == 0 && j == 0 ) // signs (a) : +--+
1056 {
1057 return ( number == 0 || number == 3 ) ? 1 : -1 ;
1058 }
1059 if ( i == 0 && j == k-2 ) // signs (b) : --++
1060 {
1061 return ( number == 2 || number == 3 ) ? 1 : -1 ;
1062 }
1063 if ( i == n-2 && j == k-2 ) // signs (c) : -++-
1064 {
1065 return ( number == 1 || number == 2 ) ? 1 : -1 ;
1066 }
1067 if ( i == n-2 && j == 0 ) // signs (d) : ++--
1068 {
1069 return ( number == 0 || number == 1 ) ? 1 : -1 ;
1070 }
1071
1072 std::ostringstream message;
1073 message << "Not correct face number: " << GetName() << " !";
1074 G4Exception("G4TwistSurface::G4GetEdgeVisibility()", "GeomSolids0003",
1075 FatalException, message);
1076
1077 return 0 ;
1078}
const G4String & GetName() const

◆ GetFace()

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

Definition at line 891 of file G4VTwistSurface.cc.

893{
894 // this is the face mapping function
895 // (i,j) -> face number
896
897 if ( iside == 0 ) { return i * ( k - 1 ) + j ; }
898 if ( iside == 1 ) { return (k-1)*(k-1) + i*(k-1) + j ; }
899 if ( iside == 2 ) { return 2*(k-1)*(k-1) + i*(k-1) + j ; }
900 if ( iside == 3 ) { return 2*(k-1)*(k-1) + (n-1)*(k-1) + i*(k-1) + j ; }
901 if ( iside == 4 ) { return 2*(k-1)*(k-1) + 2*(n-1)*(k-1) + i*(k-1) + j ; }
902 if ( iside == 5 ) { return 2*(k-1)*(k-1) + 3*(n-1)*(k-1) + i*(k-1) + j ; }
903
904 std::ostringstream message;
905 message << "Not correct side number: "
906 << GetName() << G4endl
907 << "iside is " << iside << " but should be "
908 << "0,1,2,3,4 or 5" << ".";
909 G4Exception("G4TwistSurface::G4GetFace()", "GeomSolids0002",
910 FatalException, message);
911
912 return -1 ; // wrong face
913}

◆ GetFacets()

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

◆ GetName()

const G4String & G4VTwistSurface::GetName ( ) const
inline

◆ GetNeighbours() [1/2]

G4VTwistSurface ** G4VTwistSurface::GetNeighbours ( )
inlineprotected

Internal accessors.

Definition at line 311 of file G4VTwistSurface.hh.

311{ return fNeighbours; }

Referenced by DistanceToIn().

◆ GetNeighbours() [2/2]

G4int G4VTwistSurface::GetNeighbours ( G4int areacode,
G4VTwistSurface * surfaces[] )
inlineprotected

◆ GetNode()

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

Node/face mapping functions.

Definition at line 918 of file G4VTwistSurface.cc.

920{
921 // this is the node mapping function
922 // (i,j) -> node number
923 // Depends on the side iside and the used meshing of the surface
924
925 if ( iside == 0 )
926 {
927 // lower endcap is kxk squared.
928 // n = k
929 return i * k + j ;
930 }
931 if ( iside == 1 )
932 {
933 // upper endcap is kxk squared. Shift by k*k
934 // n = k
935 return k*k + i*k + j ;
936 }
937 if ( iside == 2 )
938 {
939 // front side.
940 if ( i == 0 ) { return j ; }
941 if ( i == n-1 ) { return k*k + j ; }
942 return 2*k*k + 4*(i-1)*(k-1) + j ;
943 }
944 if ( iside == 3 )
945 {
946 // right side
947 if ( i == 0 ) { return (j+1)*k - 1 ; }
948 if ( i == n-1 ) { return k*k + (j+1)*k - 1 ; }
949 return 2*k*k + 4*(i-1)*(k-1) + (k-1) + j ;
950 }
951 if ( iside == 4 )
952 {
953 // back side
954 if ( i == 0 ) { return k*k - 1 - j ; } // reversed order
955 if ( i == n-1 ) { return 2*k*k - 1 - j ; } // reversed order
956 return 2*k*k + 4*(i-1)*(k-1) + 2*(k-1) + j ; // normal order
957 }
958 if ( iside == 5 )
959 {
960 // left side
961 if ( i == 0 ) { return k*k - (j+1)*k ; } // reversed order
962 if ( i == n-1) { return 2*k*k - (j+1)*k ; } // reverded order
963 if ( j == k-1 ) { return 2*k*k + 4*(i-1)*(k-1) ; } // special case
964 return 2*k*k + 4*(i-1)*(k-1) + 3*(k-1) + j ; // normal order
965 }
966
967 std::ostringstream message;
968 message << "Not correct side number: "
969 << GetName() << G4endl
970 << "iside is " << iside << " but should be "
971 << "0,1,2,3,4 or 5" << ".";
972 G4Exception("G4TwistSurface::G4GetNode()", "GeomSolids0002",
973 FatalException, message);
974
975 return -1 ; // wrong node
976}

◆ GetNormal()

virtual G4ThreeVector G4VTwistSurface::GetNormal ( const G4ThreeVector & p,
G4bool isGlobal )
pure virtual

Returns a normal vector at a surface (or very close to the surface) point at 'p'.

Parameters
[in]pThe point where computing the normal.
[in]isGlobalIf true, it returns the normal in global coordinates.
Returns
The normal vector.

Implemented in G4TwistBoxSide, G4TwistTrapAlphaSide, G4TwistTrapFlatSide, G4TwistTrapParallelSide, G4TwistTubsFlatSide, G4TwistTubsHypeSide, and G4TwistTubsSide.

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

◆ GetSurfaceArea()

virtual G4double G4VTwistSurface::GetSurfaceArea ( )
pure virtual

◆ IsAxis0()

G4bool G4VTwistSurface::IsAxis0 ( G4int areacode) const
inline

Test functions/accessors, based on 'areacode' location.

Referenced by DistanceToBoundary().

◆ IsAxis1()

G4bool G4VTwistSurface::IsAxis1 ( G4int areacode) const
inline

Referenced by DistanceToBoundary().

◆ IsBoundary()

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

◆ IsCorner()

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

Referenced by IsSameBoundary().

◆ IsInside()

◆ IsOutside()

◆ IsSameBoundary()

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

Definition at line 609 of file G4VTwistSurface.cc.

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

Referenced by DistanceToIn().

◆ IsValidNorm()

G4bool G4VTwistSurface::IsValidNorm ( ) const
inline

Definition at line 241 of file G4VTwistSurface.hh.

241{ return fIsValidNorm; }

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

◆ SetAxis()

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

Modifiers for axes.

Definition at line 257 of file G4VTwistSurface.hh.

257{ fAxis[i] = axis; }

◆ SetBoundary()

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

Modifier for boundaries.

Parameters
[in]axiscodeThe location code, either: sAxis0 & sAxisMin, sAxis0 & sAxisMax, sAxis1 & sAxisMin, sAxis1 & sAxisMax.
[in]directionDirection.
[in]x0Point on boundary.
[in]boundarytypeThe shape of locus from the start point to end point of boundary (ex. sAxisRho = linear line which start point is fixed at origin; sAxisPhi = part of circle which center placed at the origin.

Definition at line 849 of file G4VTwistSurface.cc.

853{
854 G4int code = (~sAxisMask) & axiscode;
855 if ((code == (sAxis0 & sAxisMin)) ||
856 (code == (sAxis0 & sAxisMax)) ||
857 (code == (sAxis1 & sAxisMin)) ||
858 (code == (sAxis1 & sAxisMax)))
859 {
860 G4bool done = false;
861 for (auto & boundary : fBoundaries)
862 {
863 if (boundary.IsEmpty())
864 {
865 boundary.SetFields(axiscode, direction, x0, boundarytype);
866 done = true;
867 break;
868 }
869 }
870
871 if (!done)
872 {
873 G4Exception("G4VTwistSurface::SetBoundary()", "GeomSolids0003",
874 FatalException, "Number of boundary exceeding 4!");
875 }
876 }
877 else
878 {
879 std::ostringstream message;
880 message << "Invalid axis-code." << G4endl
881 << " axiscode = "
882 << std::hex << axiscode << std::dec;
883 G4Exception("G4VTwistSurface::SetBoundary()", "GeomSolids0003",
884 FatalException, message);
885 }
886}

◆ SetCorner()

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

Modifier for corners.

Definition at line 743 of file G4VTwistSurface.cc.

745{
746 if ((areacode & sCorner) != sCorner)
747 {
748 std::ostringstream message;
749 message << "Area code must represents corner." << G4endl
750 << " areacode " << areacode;
751 G4Exception("G4VTwistSurface::SetCorner()", "GeomSolids0002",
752 FatalException, message);
753 }
754
755 if ((areacode & sC0Min1Min) == sC0Min1Min) {
756 fCorners[0].set(x, y, z);
757 } else if ((areacode & sC0Max1Min) == sC0Max1Min) {
758 fCorners[1].set(x, y, z);
759 } else if ((areacode & sC0Max1Max) == sC0Max1Max) {
760 fCorners[2].set(x, y, z);
761 } else if ((areacode & sC0Min1Max) == sC0Min1Max) {
762 fCorners[3].set(x, y, z);
763 }
764}

◆ SetNeighbours()

void G4VTwistSurface::SetNeighbours ( G4VTwistSurface * ax0min,
G4VTwistSurface * ax1min,
G4VTwistSurface * ax0max,
G4VTwistSurface * ax1max )
inline

◆ SurfacePoint()

virtual G4ThreeVector G4VTwistSurface::SurfacePoint ( G4double ,
G4double ,
G4bool isGlobal = false )
pure virtual

Returns point on surface given the axes.

Member Data Documentation

◆ fAxis

◆ fAxisMax

◆ fAxisMin

◆ fCurrentNormal

◆ fCurStat

◆ fCurStatWithV

◆ fHandedness

◆ fIsValidNorm

◆ fRot

◆ fTrans

◆ kCarTolerance

◆ sAreaMask

const G4int G4VTwistSurface::sAreaMask = 0XF0000000
static

Definition at line 371 of file G4VTwistSurface.hh.

◆ sAxis0

◆ sAxis1

const G4int G4VTwistSurface::sAxis1 = 0x000000FF
static

◆ sAxisMask

const G4int G4VTwistSurface::sAxisMask = 0x0000FCFC
static

Definition at line 370 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis(), and SetBoundary().

◆ sAxisMax

const G4int G4VTwistSurface::sAxisMax = 0x00000202
static

◆ sAxisMin

const G4int G4VTwistSurface::sAxisMin = 0x00000101
static

◆ sAxisPhi

const G4int G4VTwistSurface::sAxisPhi = 0x00001414
static

Definition at line 366 of file G4VTwistSurface.hh.

Referenced by DistanceToBoundary(), GetBoundaryAtPZ(), and GetBoundaryAxis().

◆ sAxisRho

const G4int G4VTwistSurface::sAxisRho = 0x00001010
static

Definition at line 365 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAtPZ(), and GetBoundaryAxis().

◆ sAxisX

const G4int G4VTwistSurface::sAxisX = 0x00000404
static

Definition at line 362 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis().

◆ sAxisY

const G4int G4VTwistSurface::sAxisY = 0x00000808
static

Definition at line 363 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis().

◆ sAxisZ

const G4int G4VTwistSurface::sAxisZ = 0x00000C0C
static

Definition at line 364 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis().

◆ sBoundary

const G4int G4VTwistSurface::sBoundary = 0x20000000
static

Definition at line 354 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis(), and GetBoundaryLimit().

◆ sC0Max1Max

const G4int G4VTwistSurface::sC0Max1Max = 0x40000202
static

Definition at line 358 of file G4VTwistSurface.hh.

Referenced by DebugPrint(), GetBoundaryLimit(), and SetCorner().

◆ sC0Max1Min

const G4int G4VTwistSurface::sC0Max1Min = 0x40000201
static

Definition at line 357 of file G4VTwistSurface.hh.

Referenced by DebugPrint(), GetBoundaryLimit(), and SetCorner().

◆ sC0Min1Max

const G4int G4VTwistSurface::sC0Min1Max = 0x40000102
static

Definition at line 359 of file G4VTwistSurface.hh.

Referenced by DebugPrint(), GetBoundaryLimit(), and SetCorner().

◆ sC0Min1Min

const G4int G4VTwistSurface::sC0Min1Min = 0x40000101
static

Definition at line 356 of file G4VTwistSurface.hh.

Referenced by DebugPrint(), GetBoundaryLimit(), and SetCorner().

◆ sCorner

const G4int G4VTwistSurface::sCorner = 0x40000000
static

Definition at line 355 of file G4VTwistSurface.hh.

Referenced by GetBoundaryLimit(), and SetCorner().

◆ sInside

◆ sOutside

◆ sSizeMask

const G4int G4VTwistSurface::sSizeMask = 0x00000303
static

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