Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ToroidalSurface Class Reference

#include <G4ToroidalSurface.hh>

+ Inheritance diagram for G4ToroidalSurface:

Public Member Functions

 G4ToroidalSurface ()
 
 G4ToroidalSurface (const G4Vector3D &, const G4Vector3D &, const G4Vector3D &, G4double, G4double)
 
virtual ~G4ToroidalSurface ()
 
G4String GetEntityType () const
 
G4int Intersect (const G4Ray &)
 
void CalcBBox ()
 
G4Vector3D GetDirection () const
 
G4Vector3D GetAxis () const
 
G4Point3D GetLocation () const
 
G4double GetMinRadius () const
 
G4double GetMaxRadius () const
 
G4double ClosestDistanceToPoint (const G4Point3D &x)
 
virtual G4Vector3D SurfaceNormal (const G4Point3D &Pt) const
 
void MultiplyPointByMatrix (G4Point3D &Base)
 
void MultiplyVectorByMatrix (G4Vector3D &DCos)
 
- Public Member Functions inherited from G4Surface
 G4Surface ()
 
virtual ~G4Surface ()
 
G4int operator== (const G4Surface &s)
 
virtual G4String GetEntityType () const
 
virtual const char * Name () const
 
virtual G4int MyType () const
 
void SetBoundaries (G4CurveVector *)
 
virtual G4double HowNear (const G4Vector3D &x) const
 
virtual G4double ClosestDistanceToPoint (const G4Point3D &Pt)
 
G4Vector3D GetOrigin () const
 
G4double GetDistance () const
 
void SetDistance (G4double Dist)
 
G4int IsActive () const
 
void SetActive (G4int act)
 
void Deactivate ()
 
void SetSameSense (G4int sameSense0)
 
G4int GetSameSense () const
 
G4BoundingBox3DGetBBox ()
 
const G4Point3DGetClosestHit () const
 
void SetNextNode (G4Surface *)
 
G4SurfaceGetNextNode ()
 
virtual void Reset ()
 
virtual G4int Intersect (const G4Ray &)
 
virtual G4Vector3D Normal (const G4Vector3D &p) const
 
virtual void CalcBBox ()
 
virtual G4double GetUHit () const
 
virtual G4double GetVHit () const
 
virtual G4Point3D Evaluation (const G4Ray &G4Rayref)
 
virtual G4int Evaluate (register const G4Ray &Rayref)
 
virtual void Project ()
 
virtual void CalcNormal ()
 
virtual G4int IsConvex () const
 
virtual G4int GetConvex () const
 
virtual G4int GetNumberOfPoints () const
 
virtual const G4Point3DGetPoint (G4int Count) const
 
virtual G4RayNorm ()
 
virtual G4Vector3D SurfaceNormal (const G4Point3D &Pt) const =0
 
- Public Member Functions inherited from G4STEPEntity
 G4STEPEntity ()
 
virtual ~G4STEPEntity ()
 
virtual G4String GetEntityType () const =0
 

Additional Inherited Members

- Static Public Member Functions inherited from G4Surface
static void Project (G4double &Coord, const G4Point3D &Pt, const G4Plane &Pl)
 
- Protected Member Functions inherited from G4Surface
virtual void InitBounded ()
 
- Protected Attributes inherited from G4Surface
G4BoundingBox3Dbbox
 
G4Point3D closest_hit
 
G4Surfacenext
 
G4SurfaceBoundary surfaceBoundary
 
G4double kCarTolerance
 
G4double kAngTolerance
 
G4int Intersected
 
G4Vector3D origin
 
G4int Type
 
G4int AdvancedFace
 
G4int active
 
G4double distance
 
G4double uhit
 
G4double vhit
 
G4int sameSense
 

Detailed Description

Definition at line 46 of file G4ToroidalSurface.hh.

Constructor & Destructor Documentation

◆ G4ToroidalSurface() [1/2]

G4ToroidalSurface::G4ToroidalSurface ( )

Definition at line 39 of file G4ToroidalSurface.cc.

40 : MinRadius(0.), MaxRadius(0.), TransMatrix(0), EQN_EPS(1e-9)
41{
42}

◆ G4ToroidalSurface() [2/2]

G4ToroidalSurface::G4ToroidalSurface ( const G4Vector3D Location,
const G4Vector3D Ax,
const G4Vector3D Dir,
G4double  MinRad,
G4double  MaxRad 
)

Definition at line 44 of file G4ToroidalSurface.cc.

49 : EQN_EPS(1e-9)
50{
51 Placement.Init(Dir, Ax, Location);
52
53 MinRadius = MinRad;
54 MaxRadius = MaxRad;
55 TransMatrix= new G4PointMatrix(4,4);
56}
void Init(const G4Vector3D &refDirection0, const G4Vector3D &axis0, const G4Point3D &location0)

◆ ~G4ToroidalSurface()

G4ToroidalSurface::~G4ToroidalSurface ( )
virtual

Definition at line 59 of file G4ToroidalSurface.cc.

60{
61 delete TransMatrix;
62}

Member Function Documentation

◆ CalcBBox()

void G4ToroidalSurface::CalcBBox ( )
virtual

Reimplemented from G4Surface.

Definition at line 65 of file G4ToroidalSurface.cc.

66{
67 // L. Broglia
68 // G4Point3D Origin = Placement.GetSrfPoint();
69 G4Point3D Origin = Placement.GetLocation();
70
71 G4Point3D Min(Origin.x()-MaxRadius,
72 Origin.y()-MaxRadius,
73 Origin.z()-MaxRadius);
74 G4Point3D Max(Origin.x()+MaxRadius,
75 Origin.y()+MaxRadius,
76 Origin.z()+MaxRadius);
77
78 bbox = new G4BoundingBox3D(Min,Max);
79}
G4Point3D GetLocation() const
G4BoundingBox3D * bbox
Definition: G4Surface.hh:185

◆ ClosestDistanceToPoint()

G4double G4ToroidalSurface::ClosestDistanceToPoint ( const G4Point3D x)
virtual

Reimplemented from G4Surface.

Definition at line 88 of file G4ToroidalSurface.cc.

89{
90 // L. Broglia
91 // G4Point3D Origin = Placement.GetSrfPoint();
92 G4Point3D Origin = Placement.GetLocation();
93
94 G4double Dist = Pt.distance(Origin);
95
96 return ((Dist - MaxRadius)*(Dist - MaxRadius));
97}
double G4double
Definition: G4Types.hh:64

◆ GetAxis()

G4Vector3D G4ToroidalSurface::GetAxis ( ) const
inline

◆ GetDirection()

G4Vector3D G4ToroidalSurface::GetDirection ( ) const
inline

◆ GetEntityType()

G4String G4ToroidalSurface::GetEntityType ( ) const
inlinevirtual

Reimplemented from G4Surface.

◆ GetLocation()

G4Point3D G4ToroidalSurface::GetLocation ( ) const
inline

◆ GetMaxRadius()

G4double G4ToroidalSurface::GetMaxRadius ( ) const
inline

◆ GetMinRadius()

G4double G4ToroidalSurface::GetMinRadius ( ) const
inline

◆ Intersect()

G4int G4ToroidalSurface::Intersect ( const G4Ray Ray)
virtual

Reimplemented from G4Surface.

Definition at line 100 of file G4ToroidalSurface.cc.

101{
102 // ---- inttor - Intersect a ray with a torus. ------------------------
103 // from GraphicsGems II by
104
105 // Description:
106 // Inttor determines the intersection of a ray with a torus.
107 //
108 // On entry:
109 // raybase = The coordinate defining the base of the
110 // intersecting ray.
111 // raycos = The G4Vector3D cosines of the above ray.
112 // center = The center location of the torus.
113 // radius = The major radius of the torus.
114 // rplane = The minor radius in the G4Plane of the torus.
115 // rnorm = The minor radius Normal to the G4Plane of the torus.
116 // tran = A 4x4 transformation matrix that will position
117 // the torus at the origin and orient it such that
118 // the G4Plane of the torus lyes in the x-z G4Plane.
119 //
120 // On return:
121 // nhits = The number of intersections the ray makes with
122 // the torus.
123 // rhits = The entering/leaving distances of the
124 // intersections.
125 //
126 // Returns: True if the ray intersects the torus.
127 //
128 // --------------------------------------------------------------------
129
130 // Variables. Should be optimized later...
131 G4Point3D Base = Ray.GetStart(); // Base of the intersection ray
132 G4Vector3D DCos = Ray.GetDir(); // Direction cosines of the ray
133 G4int nhits=0; // Number of intersections
134 G4double rhits[4]; // Intersection distances
135 G4double hits[4] = {0.,0.,0.,0.}; // Ordered intersection distances
136 G4double rho, a0, b0; // Related constants
137 G4double f, l, t, g1, q, m1, u; // Ray dependent terms
138 G4double C[5]; // Quartic coefficients
139
140 // Transform the intersection ray
141
142
143 // MultiplyPointByMatrix (Base); // Matriisi puuttuu viela!
144 // MultiplyVectorByMatrix (DCos);
145
146 // Compute constants related to the torus.
147 G4double rnorm = MaxRadius - MinRadius; // ei tietoa onko oikein...
148 rho = MinRadius*MinRadius / (rnorm*rnorm);
149 a0 = 4. * MaxRadius*MaxRadius;
150 b0 = MaxRadius*MaxRadius - MinRadius*MinRadius;
151
152 // Compute ray dependent terms.
153 f = 1. - DCos.y()*DCos.y();
154 l = 2. * (Base.x()*DCos.x() + Base.z()*DCos.z());
155 t = Base.x()*Base.x() + Base.z()*Base.z();
156 g1 = f + rho * DCos.y()*DCos.y();
157 q = a0 / (g1*g1);
158 m1 = (l + 2.*rho*DCos.y()*Base.y()) / g1;
159 u = (t + rho*Base.y()*Base.y() + b0) / g1;
160
161 // Compute the coefficients of the quartic.
162
163 C[4] = 1.0;
164 C[3] = 2. * m1;
165 C[2] = m1*m1 + 2.*u - q*f;
166 C[1] = 2.*m1*u - q*l;
167 C[0] = u*u - q*t;
168
169 // Use quartic root solver found in "Graphics Gems" by Jochen Schwarze.
170 nhits = SolveQuartic (C,rhits);
171
172 // SolveQuartic returns root pairs in reversed order.
173 m1 = rhits[0]; u = rhits[1]; rhits[0] = u; rhits[1] = m1;
174 m1 = rhits[2]; u = rhits[3]; rhits[2] = u; rhits[3] = m1;
175
176 // return (*nhits != 0);
177
178 if(nhits != 0)
179 {
180 // Convert Hit distances to intersection points
181 /*
182 G4Point3D** IntersectionPoints = new G4Point3D*[nhits];
183 for(G4int a=0;a<nhits;a++)
184 {
185 G4double Dist = rhits[a];
186 IntersectionPoints[a] = new G4Point3D((Base - Dist * DCos));
187 }
188 // Check wether any of the hits are on the actual surface
189 // Start with checking for the intersections that are Inside the bbox
190
191 G4Point3D* Hit;
192 G4int InsideBox[2]; // Max 2 intersections on the surface
193 G4int Counter=0;
194 */
195
196 G4Point3D BoxMin = bbox->GetBoxMin();
197 G4Point3D BoxMax = bbox->GetBoxMax();
198 G4Point3D Hit;
199 G4int c1 = 0;
200 G4int c2;
201 G4double tempVec[4];
202
203 for(G4int a=0;a<nhits;a++)
204 {
205 while ( (c1 < 4) && (hits[c1] <= rhits[a]) )
206 {
207 tempVec[c1]=hits[c1];
208 c1++;
209 }
210
211 for(c2=c1+1;c2<4;c2++)
212 tempVec[c2]=hits[c2-1];
213
214 if(c1<4)
215 {
216 tempVec[c1]=rhits[a];
217
218 for(c2=0;c2<4;c2++)
219 hits[c2]=tempVec[c2];
220 }
221 }
222
223 for(G4int b=0;b<nhits;b++)
224 {
225 // Hit = IntersectionPoints[b];
226 if(hits[b] >=kCarTolerance*0.5)
227 {
228 Hit = Base + (hits[b]*DCos);
229 // InsideBox[Counter]=b;
230 if( (Hit.x() > BoxMin.x()) &&
231 (Hit.x() < BoxMax.x()) &&
232 (Hit.y() > BoxMin.y()) &&
233 (Hit.y() < BoxMax.y()) &&
234 (Hit.z() > BoxMin.z()) &&
235 (Hit.z() < BoxMax.z()) )
236 {
237 closest_hit = Hit;
238 distance = hits[b]*hits[b];
239 return 1;
240 }
241
242 // Counter++;
243 }
244 }
245
246 // If two Inside bbox, find closest
247 // G4int Closest=0;
248
249 // if(Counter>1)
250 // if(rhits[InsideBox[0]] > rhits[InsideBox[1]])
251 // Closest=1;
252
253 // Project polygon and do point in polygon
254 // Projection also for curves etc.
255 // Should probably be implemented in the curve class.
256 // G4Plane Plane1 = Ray.GetPlane(1);
257 // G4Plane Plane2 = Ray.GetPlane(2);
258
259 // Point in polygon
260 return 1;
261 }
262 return 0;
263}
int G4int
Definition: G4Types.hh:66
G4Point3D GetBoxMin() const
G4Point3D GetBoxMax() const
const G4Vector3D & GetDir() const
const G4Point3D & GetStart() const
G4double distance
Definition: G4Surface.hh:203
G4Point3D closest_hit
Definition: G4Surface.hh:186
G4double kCarTolerance
Definition: G4Surface.hh:192

◆ MultiplyPointByMatrix()

void G4ToroidalSurface::MultiplyPointByMatrix ( G4Point3D Base)
inline

◆ MultiplyVectorByMatrix()

void G4ToroidalSurface::MultiplyVectorByMatrix ( G4Vector3D DCos)
inline

◆ SurfaceNormal()

G4Vector3D G4ToroidalSurface::SurfaceNormal ( const G4Point3D Pt) const
virtual

Implements G4Surface.

Definition at line 82 of file G4ToroidalSurface.cc.

83{
84 return G4Vector3D(0,0,0);
85}
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35

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