Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VTwistSurface.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4VTwistSurface
27//
28// Class description:
29//
30// Abstract base class for boundary surface of G4VSolid.
31
32// 01-Aug-2002 - Kotoyo Hoshina ([email protected]), created.
33// 13-Nov-2003 - O.Link ([email protected]), Integration in Geant4
34// from original version in Jupiter-2.5.02 application.
35// --------------------------------------------------------------------
36#ifndef G4VTWISTSURFACE_HH
37#define G4VTWISTSURFACE_HH
38
40
41#include "G4VSolid.hh"
42#include "geomdefs.hh"
43
44#include "G4RotationMatrix.hh"
45
46#define G4VSURFACENXX 10
47
49{
50 public:
51
54
55 G4VTwistSurface (const G4String& name);
56 G4VTwistSurface (const G4String& name,
57 const G4RotationMatrix& rot,
58 const G4ThreeVector& tlate,
59 G4int handedness,
60 const EAxis axis1,
61 const EAxis axis2,
62 G4double axis0min = -kInfinity,
63 G4double axis1min = -kInfinity,
64 G4double axis0max = kInfinity,
65 G4double axis1max = kInfinity);
66
68
69 virtual G4int AmIOnLeftSide(const G4ThreeVector& me,
70 const G4ThreeVector& vec,
71 G4bool withTol = true);
72
73 virtual G4double DistanceToBoundary( G4int areacode,
74 G4ThreeVector& xx,
75 const G4ThreeVector& p) ;
76
77 virtual G4double DistanceToIn(const G4ThreeVector& gp,
78 const G4ThreeVector& gv,
79 G4ThreeVector& gxxbest);
80 virtual G4double DistanceToOut(const G4ThreeVector& gp,
81 const G4ThreeVector& gv,
82 G4ThreeVector& gxxbest);
83 virtual G4double DistanceTo(const G4ThreeVector& gp,
84 G4ThreeVector& gxx);
85
87 const G4ThreeVector& gv,
88 G4ThreeVector gxx[],
89 G4double distance[],
90 G4int areacode[],
91 G4bool isvalid[],
92 EValidate validate=kValidateWithTol) = 0;
93
95 G4ThreeVector gxx[],
96 G4double distance[],
97 G4int areacode[]) = 0;
98
99 void DebugPrint() const;
100
101 virtual G4ThreeVector GetNormal(const G4ThreeVector& xx,G4bool isGlobal) = 0;
102
103 virtual G4String GetName() const { return fName; }
104 virtual void GetBoundaryParameters(const G4int& areacode,
105 G4ThreeVector& d,
106 G4ThreeVector& x0,
107 G4int& boundarytype) const;
108 virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode,
109 const G4ThreeVector& p) const;
110
112 const G4ThreeVector& v,
113 const G4ThreeVector& x0,
114 const G4ThreeVector& n0,
115 G4ThreeVector& xx);
116
118 const G4ThreeVector& x0,
119 const G4ThreeVector& n0,
120 G4ThreeVector& xx);
121
123 const G4ThreeVector& x0,
124 const G4ThreeVector& t1,
125 const G4ThreeVector& t2,
126 G4ThreeVector& xx,
127 G4ThreeVector& n);
128
130 const G4ThreeVector& x0,
131 const G4ThreeVector& d,
132 G4ThreeVector& xx);
133
134 inline G4bool IsAxis0 (G4int areacode) const;
135 inline G4bool IsAxis1 (G4int areacode) const;
136 inline G4bool IsOutside (G4int areacode) const;
137 inline G4bool IsInside (G4int areacode, G4bool testbitmode = false) const;
138 inline G4bool IsBoundary (G4int areacode, G4bool testbitmode = false) const;
139 inline G4bool IsCorner (G4int areacode, G4bool testbitmode = false) const;
140 inline G4bool IsValidNorm() const { return fIsValidNorm; }
141 G4bool IsSameBoundary (G4VTwistSurface* surface1, G4int areacode1,
142 G4VTwistSurface* surface2, G4int areacode2 ) const;
143 inline G4int GetAxisType(G4int areacode, G4int whichaxis) const;
144
149
150 // set methods
151
152 inline void SetAxis(G4int i, const EAxis axis) { fAxis[i] = axis; }
153 inline void SetNeighbours(G4VTwistSurface* ax0min, G4VTwistSurface* ax1min,
154 G4VTwistSurface* ax0max, G4VTwistSurface* ax1max);
155
157 G4bool isGlobal = false ) = 0 ;
160 virtual G4double GetSurfaceArea() = 0 ;
161 virtual void GetFacets(G4int m, G4int n, G4double xyz[][3],
162 G4int faces[][4], G4int iside) = 0 ;
163 G4int GetNode( G4int i, G4int j, G4int m, G4int n, G4int iside ) ;
164 G4int GetFace( G4int i, G4int j, G4int m, G4int n, G4int iside ) ;
166 G4int number, G4int orientation) ;
167
168 G4VTwistSurface(__void__&);
169 // Fake default constructor for usage restricted to direct object
170 // persistency for clients requiring preallocation of memory for
171 // persistifiable objects.
172
173 protected:
174
175 inline G4VTwistSurface** GetNeighbours() { return fNeighbours; }
176 inline G4int GetNeighbours(G4int areacode, G4VTwistSurface* surfaces[]);
177 inline G4ThreeVector GetCorner(G4int areacode) const;
178 void GetBoundaryAxis(G4int areacode, EAxis axis[]) const;
179 void GetBoundaryLimit(G4int areacode, G4double limit[]) const;
180 virtual G4int GetAreaCode(const G4ThreeVector& xx, G4bool withtol=true) = 0;
181
182 virtual void SetBoundary(const G4int& axiscode,
183 const G4ThreeVector& direction,
184 const G4ThreeVector& x0,
185 const G4int& boundarytype);
186 // areacode must be one of them:
187 // sAxis0 & sAxisMin, sAxis0 & sAxisMax,
188 // sAxis1 & sAxisMin, sAxis1 & sAxisMax.
189 // boundarytype represents the shape of locus
190 // from the start point to end point of boundary.
191 // ex.
192 // sAxisRho = linear line which start point is fixed at origin.
193 // sAxisPhi = part of circle which center placed at the origin.
194
195 void SetCorner(G4int areacode, G4double x, G4double y, G4double z);
196
197 private:
198
199 virtual void SetBoundaries() = 0;
200 virtual void SetCorners() = 0;
201
202 // data members ---------------------------------------------------------
203
204 public:
205
206 static const G4int sOutside ;
207 static const G4int sInside ;
208 static const G4int sBoundary;
209 static const G4int sCorner;
210 static const G4int sC0Min1Min;
211 static const G4int sC0Max1Min;
212 static const G4int sC0Max1Max;
213 static const G4int sC0Min1Max;
214 static const G4int sAxisMin;
215 static const G4int sAxisMax;
216 static const G4int sAxisX;
217 static const G4int sAxisY;
218 static const G4int sAxisZ;
219 static const G4int sAxisRho;
220 static const G4int sAxisPhi;
221 static const G4int sAxis0;
222 static const G4int sAxis1;
223 static const G4int sSizeMask;
224 static const G4int sAxisMask;
225 static const G4int sAreaMask;
226
227 protected:
228
230 {
231 public:
232
234 virtual ~CurrentStatus();
235
236 inline G4ThreeVector GetXX(G4int i) const { return fXX[i]; }
237 inline G4double GetDistance(G4int i) const { return fDistance[i]; }
238 inline G4int GetAreacode(G4int i) const { return fAreacode[i]; }
239 inline G4int GetNXX() const { return fNXX; }
240 inline G4bool IsDone() const { return fDone; }
241 inline G4bool IsValid(G4int i) const { return fIsValid[i]; }
242
243 void SetCurrentStatus(G4int i,
244 G4ThreeVector& xx,
245 G4double& dist,
246 G4int& areacode,
247 G4bool& isvalid,
248 G4int nxx,
249 EValidate validate,
250 const G4ThreeVector* p,
251 const G4ThreeVector* v = nullptr);
252
253 void ResetfDone(EValidate validate,
254 const G4ThreeVector* p,
255 const G4ThreeVector* v = nullptr);
256
257
258 void DebugPrint() const;
259
260 private:
261
262 G4double fDistance[G4VSURFACENXX];
264 G4int fAreacode[G4VSURFACENXX];
265 G4bool fIsValid[G4VSURFACENXX];
266 G4int fNXX;
267 G4ThreeVector fLastp;
268 G4ThreeVector fLastv;
269 EValidate fLastValidate;
270 G4bool fDone;
271 };
272
273 class Boundary
274 {
275 public:
276
277 Boundary();
278 virtual ~Boundary();
279
280 void SetFields(const G4int& areacode,
281 const G4ThreeVector& d,
282 const G4ThreeVector& x0,
283 const G4int& boundarytype);
284
285 G4bool IsEmpty() const;
286
287 G4bool GetBoundaryParameters(const G4int& areacode,
288 G4ThreeVector& d,
289 G4ThreeVector& x0,
290 G4int& boundarytype) const;
291
292 private:
293
294 G4int fBoundaryAcode{-1};
295 G4ThreeVector fBoundaryDirection;
296 G4ThreeVector fBoundaryX0;
297 G4int fBoundaryType{0};
298 };
299
309 {
310 public:
311
314 };
318
319 private:
320
321 G4VTwistSurface* fNeighbours[4]; // {0,1,2,3} = sAxis0min, sAxis1min,
322 // sAxis0max, sAxis1max
323 G4ThreeVector fCorners[4]; // corners of the surface in local coordinate
324 Boundary fBoundaries[4]; // boundaries of the surface.
325 G4String fName;
326
327 class G4SurfSideQuery
328 {
329 public:
330
331 G4ThreeVector me;
332 G4ThreeVector vec;
333 G4bool withTol;
334 G4int amIOnLeftSide;
335 };
336 G4SurfSideQuery fAmIOnLeftSide;
337};
338
339//========================================================
340// inline functions
341//========================================================
342
344{
345 G4double phi ; // parameter phi
346 G4double u ; // parameter u
347 G4ThreeVector xx ; // intersection point in cartesian
348 G4double distance ; // distance to intersection
349 G4int areacode ; // the areacode of the intersection
350 G4bool isvalid ; // valid intersection ??
351
352};
353
354inline
356{
357 return a.distance < b.distance ;
358}
359
360inline
362{
363 return ( ( a.xx - b.xx ).mag() < 1E-9*CLHEP::mm ) ;
364}
365
366#include "G4VTwistSurface.icc"
367
368#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4bool DistanceSort(const Intersection &a, const Intersection &b)
G4bool EqualIntersection(const Intersection &a, const Intersection &b)
#define G4VSURFACENXX
void SetFields(const G4int &areacode, const G4ThreeVector &d, const G4ThreeVector &x0, const G4int &boundarytype)
G4bool GetBoundaryParameters(const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
G4double GetDistance(G4int i) const
void SetCurrentStatus(G4int i, G4ThreeVector &xx, G4double &dist, G4int &areacode, G4bool &isvalid, G4int nxx, EValidate validate, const G4ThreeVector *p, const G4ThreeVector *v=nullptr)
G4ThreeVector GetXX(G4int i) const
void ResetfDone(EValidate validate, const G4ThreeVector *p, const G4ThreeVector *v=nullptr)
virtual G4int AmIOnLeftSide(const G4ThreeVector &me, const G4ThreeVector &vec, G4bool withTol=true)
static const G4int sAxisMask
static const G4int sC0Min1Min
static const G4int sC0Min1Max
G4VTwistSurface(const G4String &name)
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)=0
G4bool IsAxis1(G4int areacode) const
G4double DistanceToPlane(const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
G4int GetNode(G4int i, G4int j, G4int m, G4int n, G4int iside)
static const G4int sOutside
void SetAxis(G4int i, const EAxis axis)
void SetNeighbours(G4VTwistSurface *ax0min, G4VTwistSurface *ax1min, G4VTwistSurface *ax0max, G4VTwistSurface *ax1max)
virtual ~G4VTwistSurface()
G4ThreeVector ComputeGlobalDirection(const G4ThreeVector &lp) const
G4bool IsCorner(G4int areacode, G4bool testbitmode=false) const
static const G4int sAxisMax
static const G4int sAxis0
virtual G4double GetBoundaryMin(G4double)=0
G4int GetFace(G4int i, G4int j, G4int m, G4int n, G4int iside)
G4bool IsValidNorm() const
void GetBoundaryAxis(G4int areacode, EAxis axis[]) const
virtual G4double DistanceTo(const G4ThreeVector &gp, G4ThreeVector &gxx)
G4bool IsAxis0(G4int areacode) const
G4RotationMatrix fRot
G4int GetEdgeVisibility(G4int i, G4int j, G4int m, G4int n, G4int number, G4int orientation)
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)=0
G4VTwistSurface ** GetNeighbours()
G4double DistanceToLine(const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
G4ThreeVector ComputeLocalDirection(const G4ThreeVector &gp) const
void GetBoundaryLimit(G4int areacode, G4double limit[]) const
void DebugPrint() const
G4int GetAxisType(G4int areacode, G4int whichaxis) const
static const G4int sAxisPhi
static const G4int sAxisMin
static const G4int sC0Max1Max
virtual G4double DistanceToOut(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4double DistanceToIn(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
static const G4int sAxis1
virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode, const G4ThreeVector &p) const
G4bool IsInside(G4int areacode, G4bool testbitmode=false) const
virtual G4ThreeVector SurfacePoint(G4double, G4double, G4bool isGlobal=false)=0
G4ThreeVector fTrans
virtual void SetBoundary(const G4int &axiscode, const G4ThreeVector &direction, const G4ThreeVector &x0, const G4int &boundarytype)
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &gp) const
virtual G4double GetBoundaryMax(G4double)=0
static const G4int sAxisRho
void SetCorner(G4int areacode, G4double x, G4double y, G4double z)
G4ThreeVector GetCorner(G4int areacode) const
virtual G4int GetAreaCode(const G4ThreeVector &xx, G4bool withtol=true)=0
static const G4int sBoundary
static const G4int sAxisZ
G4bool IsOutside(G4int areacode) const
virtual G4double DistanceToBoundary(G4int areacode, G4ThreeVector &xx, const G4ThreeVector &p)
virtual G4int DistanceToSurface(const G4ThreeVector &gp, G4ThreeVector gxx[], G4double distance[], G4int areacode[])=0
static const G4int sCorner
static const G4int sC0Max1Min
static const G4int sInside
G4bool IsSameBoundary(G4VTwistSurface *surface1, G4int areacode1, G4VTwistSurface *surface2, G4int areacode2) const
virtual G4String GetName() const
CurrentStatus fCurStatWithV
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
G4int GetNeighbours(G4int areacode, G4VTwistSurface *surfaces[])
static const G4int sAxisY
static const G4int sSizeMask
static const G4int sAxisX
G4double DistanceToPlaneWithV(const G4ThreeVector &p, const G4ThreeVector &v, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
static const G4int sAreaMask
G4bool IsBoundary(G4int areacode, G4bool testbitmode=false) const
G4ThreeVector ComputeGlobalPoint(const G4ThreeVector &lp) const
G4double DistanceToPlane(const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &t1, const G4ThreeVector &t2, G4ThreeVector &xx, G4ThreeVector &n)
G4SurfCurNormal fCurrentNormal
virtual G4double GetSurfaceArea()=0
virtual void GetBoundaryParameters(const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
CurrentStatus fCurStat
EAxis
Definition geomdefs.hh:54
G4ThreeVector xx