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

#include <G4FConicalSurface.hh>

+ Inheritance diagram for G4FConicalSurface:

Public Member Functions

 G4FConicalSurface ()
 
virtual ~G4FConicalSurface ()
 
 G4FConicalSurface (const G4Point3D &o, const G4Vector3D &a, G4double l, G4double sr, G4double lr)
 
virtual G4Vector3D SurfaceNormal (const G4Point3D &p) const
 
G4int Inside (const G4Vector3D &x) const
 
G4String GetEntityType () const
 
virtual const char * Name () const
 
virtual void PrintOn (std::ostream &os=G4cout) const
 
G4int operator== (const G4FConicalSurface &c) const
 
G4int Intersect (const G4Ray &ry)
 
void CalcBBox ()
 
virtual G4double HowNear (const G4Vector3D &x) const
 
virtual G4int WithinBoundary (const G4Vector3D &x) const
 
virtual G4double Scale () const
 
virtual G4double Area () const
 
virtual void resize (G4double l, G4double sr, G4double lr)
 
G4double GetLength () const
 
G4double GetSmallRadius () const
 
G4double GetLargeRadius () const
 
G4double GetTan_Angle () const
 
- 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
 

Protected Attributes

G4double length
 
G4double small_radius
 
G4double large_radius
 
G4Axis2Placement3D Position
 
G4double tan_angle
 
- 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
 

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

Detailed Description

Definition at line 63 of file G4FConicalSurface.hh.

Constructor & Destructor Documentation

◆ G4FConicalSurface() [1/2]

G4FConicalSurface::G4FConicalSurface ( )

Definition at line 42 of file G4FConicalSurface.cc.

◆ ~G4FConicalSurface()

G4FConicalSurface::~G4FConicalSurface ( )
virtual

Definition at line 50 of file G4FConicalSurface.cc.

51{
52}

◆ G4FConicalSurface() [2/2]

G4FConicalSurface::G4FConicalSurface ( const G4Point3D o,
const G4Vector3D a,
G4double  l,
G4double  sr,
G4double  lr 
)

Definition at line 54 of file G4FConicalSurface.cc.

60{
61 // Make a G4FConicalSurface with origin o, axis a, length l, small radius
62 // srad, and large radius lr. The angle is calculated below and the SetAngle
63 // function of G4ConicalSurface is used to set it properly from the default
64 // value used above in the initialization.
65
66 // Create the position with origin o, axis a, and a direction
67
68 G4Vector3D dir(1,1,1);
69 Position.Init(dir, a, o);
70 origin = o;
71
72 // Require length to be nonnegative
73 if (l >=0)
74 length = l;
75 else
76 {
77 std::ostringstream message;
78 message << "Negative length." << G4endl
79 << "Default length of 0.0 is used.";
80 G4Exception("G4FConicalSurface::G4FConicalSurface()",
81 "GeomSolids1001", JustWarning, message);
82
83 length = 0.0;
84 }
85
86 // Require small radius to be non-negative (i.e., allow zero)
87 if ( srad >= 0.0 )
88 small_radius = srad;
89 else
90 {
91 std::ostringstream message;
92 message << "Negative small radius." << G4endl
93 << "Default value of 0.0 is used.";
94 G4Exception("G4FConicalSurface::G4FConicalSurface()",
95 "GeomSolids1001", JustWarning, message);
96
97 small_radius = 0.0;
98 }
99
100 // Require large radius to exceed small radius
101 if ( lr > small_radius )
102 large_radius = lr;
103 else
104 {
105 std::ostringstream message;
106 message << "Large radius must exceed small radius" << G4endl
107 << "Default value of small radius +1 is used.";
108 G4Exception("G4FConicalSurface::G4FConicalSurface()",
109 "GeomSolids1001", JustWarning, message);
110
112 }
113
114 // Calculate the angle of the G4ConicalSurface from the length and radii
116}
@ JustWarning
#define G4endl
Definition: G4ios.hh:52
void Init(const G4Vector3D &refDirection0, const G4Vector3D &axis0, const G4Point3D &location0)
G4Axis2Placement3D Position
G4Vector3D origin
Definition: G4Surface.hh:197
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Member Function Documentation

◆ Area()

G4double G4FConicalSurface::Area ( ) const
virtual

Definition at line 211 of file G4FConicalSurface.cc.

212{
213 // Returns the Area of a G4FConicalSurface
215
216 return ( pi * ( small_radius + large_radius ) *
217 std::sqrt( length * length + rdif * rdif ) );
218}
double G4double
Definition: G4Types.hh:64

◆ CalcBBox()

void G4FConicalSurface::CalcBBox ( )
virtual

Reimplemented from G4Surface.

Definition at line 125 of file G4FConicalSurface.cc.

126{
129 G4Point3D Tmp;
130
131 G4Point3D Origin = Position.GetLocation();
132 G4Point3D EndOrigin = G4Point3D( Origin + (length * Position.GetAxis()) );
133
134 G4double radius = large_radius;
135 G4Point3D Radius(radius, radius, 0);
136
137 // Default BBox
139 G4Point3D BoxMin(Origin-Tolerance);
140 G4Point3D BoxMax(Origin+Tolerance);
141
142 bbox = new G4BoundingBox3D();
143 bbox->Init(BoxMin, BoxMax);
144
145 Tmp = (Origin - Radius);
146 bbox->Extend(Tmp);
147
148 Tmp = Origin + Radius;
149 bbox->Extend(Tmp);
150
151 Tmp = EndOrigin - Radius;
152 bbox->Extend(Tmp);
153
154 Tmp = EndOrigin + Radius;
155 bbox->Extend(Tmp);
156}
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
const G4Point3D PINFINITY(kInfinity, kInfinity, kInfinity)
G4Point3D GetLocation() const
G4Vector3D GetAxis() const
void Init(const G4Point3D &)
void Extend(const G4Point3D &)
G4BoundingBox3D * bbox
Definition: G4Surface.hh:185
G4double kCarTolerance
Definition: G4Surface.hh:192

◆ GetEntityType()

G4String G4FConicalSurface::GetEntityType ( ) const
inlinevirtual

Reimplemented from G4Surface.

◆ GetLargeRadius()

G4double G4FConicalSurface::GetLargeRadius ( ) const
inline

◆ GetLength()

G4double G4FConicalSurface::GetLength ( ) const
inline

◆ GetSmallRadius()

G4double G4FConicalSurface::GetSmallRadius ( ) const
inline

◆ GetTan_Angle()

G4double G4FConicalSurface::GetTan_Angle ( ) const
inline

◆ HowNear()

G4double G4FConicalSurface::HowNear ( const G4Vector3D x) const
virtual

Reimplemented from G4Surface.

Definition at line 360 of file G4FConicalSurface.cc.

361{
362// Shortest distance from the point x to the G4FConicalSurface.
363// The distance will be always positive
364// This function works only with Cone axis equal (0,0,1) or (0,0,-1), it project
365// the surface and the point on the x,z plane and compute the distance in analytical
366// way
367
368 G4double hownear ;
369
371 G4Vector3D downcorner = G4Vector3D ( large_radius, 0 , origin.z());
372 G4Vector3D xd;
373
374 xd = G4Vector3D ( std::sqrt ( x.x()*x.x() + x.y()*x.y() ) , 0 , x.z() );
375
376 G4double r = (upcorner.z() - downcorner.z()) / (upcorner.x() - downcorner.x());
377 G4double q = (downcorner.z()*upcorner.x() - upcorner.z()*downcorner.x()) /
378 (upcorner.x() - downcorner.x());
379
380 G4double Zinter = (xd.z()*r*r + xd.x()*r +q)/(1+r*r) ;
381
382 if ( ((Zinter >= downcorner.z()) && (Zinter <=upcorner.z())) ||
383 ((Zinter >= upcorner.z()) && (Zinter <=downcorner.z())) ) {
384 hownear = std::fabs(r*xd.x()-xd.z()+q)/std::sqrt(1+r*r);
385 return hownear;
386 } else {
387 hownear = std::min ( (xd-upcorner).mag() , (xd-downcorner).mag() );
388 return hownear;
389 }
390}
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35

Referenced by Inside().

◆ Inside()

G4int G4FConicalSurface::Inside ( const G4Vector3D x) const

Definition at line 414 of file G4FConicalSurface.cc.

415{
416 // Return 0 if point x is outside G4ConicalSurface, 1 if Inside.
417 if ( HowNear( x ) >= -0.5*kCarTolerance )
418 return 1;
419 else
420 return 0;
421}
virtual G4double HowNear(const G4Vector3D &x) const

Referenced by Intersect().

◆ Intersect()

G4int G4FConicalSurface::Intersect ( const G4Ray ry)
virtual

Reimplemented from G4Surface.

Definition at line 274 of file G4FConicalSurface.cc.

275{
276 // This function count the number of intersections of a
277 // bounded conical surface by a ray.
278 // At first, calculates the intersections with the semi-infinite
279 // conical surfsace. After, count the intersections within the
280 // finite conical surface boundaries, and set "distance" to the
281 // closest distance from the start point to the nearest intersection
282 // If the point is on the surface it returns or the intersection with
283 // the opposite surface or kInfinity
284 // If no intersection is founded, set distance = kInfinity and
285 // return 0
286
287 distance = kInfinity;
289
290 // origin and direction of the ray
291 G4Point3D x = ry.GetStart();
292 G4Vector3D dhat = ry.GetDir();
293
294 // cone angle and axis
295 G4double ta = tan_angle;
296 G4Vector3D ahat = Position.GetAxis();
297
298 // array of solutions in distance along the ray
299 G4double sol[2];
300 sol[0]=-1.0;
301 sol[1]=-1.0;
302
303 // calculate the two intersections (quadratic equation)
304 G4Vector3D gamma = G4Vector3D( x - Position.GetLocation() );
305
306 G4double t = 1 + ta * ta;
307 G4double ga = gamma * ahat;
308 G4double da = dhat * ahat;
309
310 G4double A = t * da * da - dhat * dhat;
311 G4double B = 2 * ( -gamma * dhat + t * ga * da - large_radius * ta * da);
312 G4double C = ( -gamma * gamma + t * ga * ga
313 - 2 * large_radius * ta * ga
315
316 G4double radical = B * B - 4.0 * A * C;
317
318 if ( radical < 0.0 )
319 // no intersection
320 return 0;
321 else
322 {
323 G4double root = std::sqrt( radical );
324 sol[0] = ( - B + root ) / ( 2. * A );
325 sol[1] = ( - B - root ) / ( 2. * A );
326 }
327
328 // validity of the solutions
329 // the hit point must be into the bounding box of the conical surface
330 G4Point3D p0 = G4Point3D( x + sol[0]*dhat );
331 G4Point3D p1 = G4Point3D( x + sol[1]*dhat );
332
333 if( !GetBBox()->Inside(p0) )
334 sol[0] = kInfinity;
335
336 if( !GetBBox()->Inside(p1) )
337 sol[1] = kInfinity;
338
339 // now loop over each positive solution, keeping the first one (smallest
340 // distance along the ray) which is within the boundary of the sub-shape
341 G4int nbinter = 0;
342 distance = kInfinity;
343
344 for ( G4int i = 0; i < 2; i++ )
345 {
346 if(sol[i] < kInfinity) {
347 if ( (sol[i] > kCarTolerance*0.5) ) {
348 nbinter++;
349 if ( distance > (sol[i]*sol[i]) ) {
350 distance = sol[i]*sol[i];
351 }
352 }
353 }
354 }
355
356 return nbinter;
357}
int G4int
Definition: G4Types.hh:66
G4int Inside(const G4Vector3D &x) const
const G4Vector3D & GetDir() const
const G4Point3D & GetStart() const
G4BoundingBox3D * GetBBox()
G4double distance
Definition: G4Surface.hh:203
G4Point3D closest_hit
Definition: G4Surface.hh:186

◆ Name()

const char * G4FConicalSurface::Name ( ) const
virtual

Reimplemented from G4Surface.

Definition at line 119 of file G4FConicalSurface.cc.

120{
121 return "G4FConicalSurface";
122}

◆ operator==()

G4int G4FConicalSurface::operator== ( const G4FConicalSurface c) const

Definition at line 170 of file G4FConicalSurface.cc.

171{
172 return ( origin == c.origin &&
173 Position.GetAxis() == c.Position.GetAxis() &&
176 length == c.length &&
177 tan_angle == c.tan_angle );
178}

◆ PrintOn()

void G4FConicalSurface::PrintOn ( std::ostream &  os = G4cout) const
virtual

Definition at line 159 of file G4FConicalSurface.cc.

160{
161 // printing function using C++ std::ostream class
162 os << "G4FConicalSurface with origin: " << origin << "\t"
163 << "and axis: " << Position.GetAxis() << "\n"
164 << "\t small radius: " << small_radius
165 << "\t large radius: " << large_radius
166 << "\t and length: " << length << "\n";
167}

◆ resize()

void G4FConicalSurface::resize ( G4double  l,
G4double  sr,
G4double  lr 
)
virtual

Definition at line 221 of file G4FConicalSurface.cc.

222{
223 // Resize a G4FConicalSurface to a new length l, and new radii srad and lr.
224 // Must Reset angle of the G4ConicalSurface as well based on these new
225 // values.
226 // Require length to be non-negative
227
228 // if ( l > 0.0 )
229 if ( l >= 0.0 )
230 length = l;
231 else
232 {
233 std::ostringstream message;
234 message << "Negative length." << G4endl
235 << "Original value of " << length << " is retained.";
236 G4Exception("G4FConicalSurface::resize()",
237 "GeomSolids1001", JustWarning, message);
238 }
239
240 // Require small radius to be non-negative (i.e., allow zero)
241 if ( srad >= 0.0 )
242 small_radius = srad;
243 else
244 {
245 std::ostringstream message;
246 message << "Negative small radius." << G4endl
247 << "Original value of " << small_radius << " is retained.";
248 G4Exception("G4FConicalSurface::resize()",
249 "GeomSolids1001", JustWarning, message);
250 }
251
252 // Require large radius to exceed small radius
253 if ( lr > small_radius )
254 large_radius = lr;
255 else
256 {
257 G4double r = small_radius + 1.0;
258 lr = ( large_radius <= small_radius ) ? r : large_radius;
259 large_radius = lr;
260
261 std::ostringstream message;
262 message << "Large radius must exceed small radius." << G4endl
263 << "Default value of " << large_radius << " is used.";
264 G4Exception("G4FConicalSurface::resize()",
265 "GeomSolids1001", JustWarning, message);
266 }
267
268 // Calculate the angle of the G4ConicalSurface from the length and radii
270
271}

◆ Scale()

G4double G4FConicalSurface::Scale ( ) const
virtual

Definition at line 199 of file G4FConicalSurface.cc.

200{
201 // Returns the small radius of a G4FConicalSurface unless it is zero, in
202 // which case returns the large radius.
203 // Used for Scale-invariant tests of surface thickness.
204 if ( small_radius == 0.0 )
205 return large_radius;
206 else
207 return small_radius;
208}

◆ SurfaceNormal()

G4Vector3D G4FConicalSurface::SurfaceNormal ( const G4Point3D p) const
virtual

Implements G4Surface.

Definition at line 393 of file G4FConicalSurface.cc.

394{
395 // return the Normal unit vector to the G4ConicalSurface at a point p
396 // on (or nearly on) the G4ConicalSurface
397 G4Vector3D ss = G4Vector3D( p - origin );
398 G4double da = ss * Position.GetAxis();
399 G4double r = std::sqrt( ss*ss - da*da);
400 G4double z = tan_angle * r;
401
402 if (Position.GetAxis().z() < 0)
403 z = -z;
404
405 G4Vector3D n(p.x(), p.y(), z);
406 n = n.unit();
407
408 if( !sameSense )
409 n = -n;
410
411 return n;
412}
G4int sameSense
Definition: G4Surface.hh:207

◆ WithinBoundary()

G4int G4FConicalSurface::WithinBoundary ( const G4Vector3D x) const
virtual

Definition at line 181 of file G4FConicalSurface.cc.

182{
183 // return 1 if point x is within the boundaries of the G4FConicalSurface
184 // return 0 otherwise (assume it is on the G4ConicalSurface)
185 G4Vector3D q = G4Vector3D( x - origin );
186
187 G4double qmag = q.mag();
188 G4double ss = std::sin( std::atan2(large_radius-small_radius, length) );
189 G4double ls = small_radius / ss;
190 G4double ll = large_radius / ss;
191
192 if ( ( qmag >= ls ) && ( qmag <= ll ) )
193 return 1;
194 else
195 return 0;
196}

Member Data Documentation

◆ large_radius

G4double G4FConicalSurface::large_radius
protected

◆ length

G4double G4FConicalSurface::length
protected

◆ Position

G4Axis2Placement3D G4FConicalSurface::Position
protected

◆ small_radius

G4double G4FConicalSurface::small_radius
protected

◆ tan_angle

G4double G4FConicalSurface::tan_angle
protected

Definition at line 155 of file G4FConicalSurface.hh.

Referenced by G4FConicalSurface(), Intersect(), operator==(), resize(), and SurfaceNormal().


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