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

#include <G4VTwistSurface.hh>

+ Inheritance diagram for G4VTwistSurface:

Classes

class  Boundary
 
class  CurrentStatus
 
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 axis1, const EAxis axis2, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
 
virtual ~G4VTwistSurface ()
 
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
 
void DebugPrint () const
 
virtual G4ThreeVector GetNormal (const G4ThreeVector &xx, G4bool isGlobal)=0
 
virtual G4String GetName () const
 
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)
 
 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

Definition at line 48 of file G4VTwistSurface.hh.

Member Enumeration Documentation

◆ EValidate

Enumerator
kDontValidate 
kValidateWithTol 
kValidateWithoutTol 
kUninitialized 

Definition at line 52 of file G4VTwistSurface.hh.

Constructor & Destructor Documentation

◆ G4VTwistSurface() [1/3]

G4VTwistSurface::G4VTwistSurface ( const G4String & 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}
void set(double x, double y, double z)
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4SurfCurNormal fCurrentNormal
@ kUndefined
Definition geomdefs.hh:61

◆ G4VTwistSurface() [2/3]

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

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()

G4VTwistSurface::~G4VTwistSurface ( )
virtualdefault

◆ G4VTwistSurface() [3/3]

G4VTwistSurface::G4VTwistSurface ( __void__ & )

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

Definition at line 145 of file G4VTwistSurface.cc.

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

◆ ComputeGlobalDirection()

◆ ComputeGlobalPoint()

◆ ComputeLocalDirection()

◆ ComputeLocalPoint()

◆ DebugPrint()

void G4VTwistSurface::DebugPrint ( ) const

Definition at line 1132 of file G4VTwistSurface.cc.

1133{
1138
1139 G4cout << "/* G4VTwistSurface::DebugPrint():--------------------------"
1140 << G4endl;
1141 G4cout << "/* Name = " << fName << G4endl;
1142 G4cout << "/* Axis = " << std::hex << fAxis[0] << " "
1143 << std::hex << fAxis[1]
1144 << " (0,1,2,3,5 = kXAxis,kYAxis,kZAxis,kRho,kPhi)"
1145 << std::dec << G4endl;
1146 G4cout << "/* BoundaryLimit(in local) fAxis0(min, max) = ("<<fAxisMin[0]
1147 << ", " << fAxisMax[0] << ")" << G4endl;
1148 G4cout << "/* BoundaryLimit(in local) fAxis1(min, max) = ("<<fAxisMin[1]
1149 << ", " << fAxisMax[1] << ")" << G4endl;
1150 G4cout << "/* Cornar point sC0Min1Min = " << A << G4endl;
1151 G4cout << "/* Cornar point sC0Max1Min = " << B << G4endl;
1152 G4cout << "/* Cornar point sC0Max1Max = " << C << G4endl;
1153 G4cout << "/* Cornar point sC0Min1Max = " << D << G4endl;
1154 G4cout << "/*---------------------------------------------------------"
1155 << G4endl;
1156}
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

Definition at line 575 of file G4VTwistSurface.cc.

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

Definition at line 229 of file G4VTwistSurface.cc.

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

Referenced by G4TwistTubsSide::DistanceToSurface().

◆ DistanceToIn()

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

Definition at line 288 of file G4VTwistSurface.cc.

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

◆ 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

Definition at line 492 of file G4VTwistSurface.cc.

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

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()

◆ 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

◆ DistanceToSurface() [2/2]

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

◆ 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

Definition at line 693 of file G4VTwistSurface.cc.

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

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

◆ GetBoundaryAxis()

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

Definition at line 777 of file G4VTwistSurface.cc.

778{
779 if ((areacode & sBoundary) != sBoundary) {
780 G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0003",
781 FatalException, "Not located on a boundary!");
782 }
783 for (G4int i=0; i<2; ++i)
784 {
785 G4int whichaxis = 0 ;
786 if (i == 0) {
787 whichaxis = sAxis0;
788 } else if (i == 1) {
789 whichaxis = sAxis1;
790 }
791
792 // extracted axiscode of whichaxis
793 G4int axiscode = whichaxis & sAxisMask & areacode ;
794 if (axiscode != 0) {
795 if (axiscode == (whichaxis & sAxisX)) {
796 axis[i] = kXAxis;
797 } else if (axiscode == (whichaxis & sAxisY)) {
798 axis[i] = kYAxis;
799 } else if (axiscode == (whichaxis & sAxisZ)) {
800 axis[i] = kZAxis;
801 } else if (axiscode == (whichaxis & sAxisRho)) {
802 axis[i] = kRho;
803 } else if (axiscode == (whichaxis & sAxisPhi)) {
804 axis[i] = kPhi;
805 } else {
806 std::ostringstream message;
807 message << "Not supported areacode." << G4endl
808 << " areacode " << areacode;
809 G4Exception("G4VTwistSurface::GetBoundaryAxis()", "GeomSolids0001",
810 FatalException, message);
811 }
812 }
813 }
814}
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

◆ GetBoundaryLimit()

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

Definition at line 819 of file G4VTwistSurface.cc.

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

◆ GetBoundaryParameters()

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

Definition at line 664 of file G4VTwistSurface.cc.

668{
669 // areacode must be one of them:
670 // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
671 // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
672
673 for (const auto & boundary : fBoundaries)
674 {
675 if (boundary.GetBoundaryParameters(areacode, d, x0, boundarytype))
676 {
677 return;
678 }
679 }
680
681 std::ostringstream message;
682 message << "Not registered boundary." << G4endl
683 << " Boundary at areacode " << std::hex << areacode
684 << std::dec << G4endl
685 << " is not registered.";
686 G4Exception("G4VTwistSurface::GetBoundaryParameters()", "GeomSolids0002",
687 FatalException, message);
688}

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

◆ GetCorner()

◆ GetEdgeVisibility()

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

Definition at line 1024 of file G4VTwistSurface.cc.

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

Referenced by G4TwistTrapFlatSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsHypeSide::GetFacets(), and G4TwistTubsSide::GetFacets().

◆ GetFace()

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

Definition at line 899 of file G4VTwistSurface.cc.

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

Referenced by G4TwistTrapFlatSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsHypeSide::GetFacets(), and G4TwistTubsSide::GetFacets().

◆ GetFacets()

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

◆ GetName()

virtual G4String G4VTwistSurface::GetName ( ) const
inlinevirtual

◆ GetNeighbours() [1/2]

G4VTwistSurface ** G4VTwistSurface::GetNeighbours ( )
inlineprotected

Definition at line 175 of file G4VTwistSurface.hh.

175{ 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 )

Definition at line 945 of file G4VTwistSurface.cc.

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

Referenced by G4TwistTrapFlatSide::GetFacets(), G4TwistTubsFlatSide::GetFacets(), G4TwistTubsHypeSide::GetFacets(), and G4TwistTubsSide::GetFacets().

◆ GetNormal()

◆ GetSurfaceArea()

virtual G4double G4VTwistSurface::GetSurfaceArea ( )
pure virtual

◆ IsAxis0()

G4bool G4VTwistSurface::IsAxis0 ( G4int areacode) const
inline

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 614 of file G4VTwistSurface.cc.

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

140{ return fIsValidNorm; }

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

◆ SetAxis()

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

Definition at line 152 of file G4VTwistSurface.hh.

152{ fAxis[i] = axis; }

◆ SetBoundary()

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

Definition at line 857 of file G4VTwistSurface.cc.

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

◆ SetCorner()

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

Definition at line 751 of file G4VTwistSurface.cc.

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

◆ 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

Member Data Documentation

◆ fAxis

◆ fAxisMax

◆ fAxisMin

◆ fCurrentNormal

◆ fCurStat

◆ fCurStatWithV

◆ fHandedness

◆ fIsValidNorm

◆ fRot

◆ fTrans

◆ kCarTolerance

◆ sAreaMask

const G4int G4VTwistSurface::sAreaMask = 0XF0000000
static

Definition at line 225 of file G4VTwistSurface.hh.

◆ sAxis0

◆ sAxis1

◆ sAxisMask

const G4int G4VTwistSurface::sAxisMask = 0x0000FCFC
static

Definition at line 224 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis().

◆ sAxisMax

◆ sAxisMin

◆ sAxisPhi

const G4int G4VTwistSurface::sAxisPhi = 0x00001414
static

◆ sAxisRho

const G4int G4VTwistSurface::sAxisRho = 0x00001010
static

◆ sAxisX

const G4int G4VTwistSurface::sAxisX = 0x00000404
static

Definition at line 216 of file G4VTwistSurface.hh.

Referenced by G4TwistTrapFlatSide::GetAreaCode(), and GetBoundaryAxis().

◆ sAxisY

const G4int G4VTwistSurface::sAxisY = 0x00000808
static

Definition at line 217 of file G4VTwistSurface.hh.

Referenced by G4TwistTrapFlatSide::GetAreaCode(), and GetBoundaryAxis().

◆ sAxisZ

const G4int G4VTwistSurface::sAxisZ = 0x00000C0C
static

Definition at line 218 of file G4VTwistSurface.hh.

Referenced by GetBoundaryAxis().

◆ sBoundary

const G4int G4VTwistSurface::sBoundary = 0x20000000
static

◆ sC0Max1Max

const G4int G4VTwistSurface::sC0Max1Max = 0x40000202
static

◆ sC0Max1Min

const G4int G4VTwistSurface::sC0Max1Min = 0x40000201
static

◆ sC0Min1Max

const G4int G4VTwistSurface::sC0Min1Max = 0x40000102
static

Definition at line 213 of file G4VTwistSurface.hh.

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

◆ sC0Min1Min

const G4int G4VTwistSurface::sC0Min1Min = 0x40000101
static

Definition at line 210 of file G4VTwistSurface.hh.

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

◆ sCorner

const G4int G4VTwistSurface::sCorner = 0x40000000
static

◆ sInside

◆ sOutside

◆ sSizeMask

const G4int G4VTwistSurface::sSizeMask = 0x00000303
static

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