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

#include <G4FCylindricalSurface.hh>

+ Inheritance diagram for G4FCylindricalSurface:

Public Member Functions

 G4FCylindricalSurface ()
 
 G4FCylindricalSurface (const G4Point3D &o, const G4Vector3D &a, G4double r, G4double l)
 
virtual ~G4FCylindricalSurface ()
 
G4int operator== (const G4FCylindricalSurface &c) const
 
virtual G4Vector3D SurfaceNormal (const G4Point3D &p) const
 
virtual G4int Inside (const G4Vector3D &x) const
 
G4String GetEntityType () const
 
G4int Intersect (const G4Ray &)
 
virtual G4double HowNear (const G4Vector3D &x) const
 
void CalcBBox ()
 
virtual const char * NameOf () const
 
virtual void PrintOn (std::ostream &os=G4cout) const
 
virtual G4int WithinBoundary (const G4Vector3D &x) const
 
virtual G4double Scale () const
 
virtual G4double Area () const
 
virtual void resize (G4double r, G4double l)
 
G4double GetLength () const
 
G4Vector3D GetAxis () const
 
G4double GetRadius () const
 
void SetRadius (G4double r)
 
void InitValues ()
 
- 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

G4Axis2Placement3D Position
 
G4double radius
 
G4double length
 
- 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 64 of file G4FCylindricalSurface.hh.

Constructor & Destructor Documentation

◆ G4FCylindricalSurface() [1/2]

G4FCylindricalSurface::G4FCylindricalSurface ( )

Definition at line 41 of file G4FCylindricalSurface.cc.

◆ G4FCylindricalSurface() [2/2]

G4FCylindricalSurface::G4FCylindricalSurface ( const G4Point3D o,
const G4Vector3D a,
G4double  r,
G4double  l 
)

Definition at line 52 of file G4FCylindricalSurface.cc.

57{
58 // make a G4FCylindricalSurface with origin o, axis a,
59 // radius r, and length l
60 G4Vector3D dir(1,1,1);
61 Position.Init(dir, a, o);
62
63 origin = o;
64 radius = r;
65
66 // Require length to be positive or zero
67 if ( l >= 0.0 )
68 length = l;
69 else
70 {
71 std::ostringstream message;
72 message << "Negative length." << G4endl
73 << "Default length of 0.0 is used.";
74 G4Exception("G4FCylindricalSurface::G4FCylindricalSurface()",
75 "GeomSolids1001", JustWarning, message);
76
77 length = 0.0;
78 }
79
80 // Require radius to be non-negative (i.e., allow zero)
81 if ( r >= 0.0 )
82 radius = r;
83 else
84 {
85 std::ostringstream message;
86 message << "Negative radius." << G4endl
87 << "Default value of 0.0 is used.";
88 G4Exception("G4FCylindricalSurface::G4FCylindricalSurface()",
89 "GeomSolids1001", JustWarning, message);
90
91 radius = 0.0;
92 }
93}
@ JustWarning
#define G4endl
Definition: G4ios.hh:52
void Init(const G4Vector3D &refDirection0, const G4Vector3D &axis0, const G4Point3D &location0)
G4Vector3D origin
Definition: G4Surface.hh:197
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ ~G4FCylindricalSurface()

G4FCylindricalSurface::~G4FCylindricalSurface ( )
virtual

Definition at line 47 of file G4FCylindricalSurface.cc.

48{
49}

Member Function Documentation

◆ Area()

G4double G4FCylindricalSurface::Area ( ) const
virtual

Definition at line 111 of file G4FCylindricalSurface.cc.

112{
113 return ( 2.0 * pi * radius * length );
114}

◆ CalcBBox()

void G4FCylindricalSurface::CalcBBox ( )
virtual

Reimplemented from G4Surface.

Definition at line 119 of file G4FCylindricalSurface.cc.

120{
121 // Finds the bounds of the surface iow
122 // calculates the bounds for a bounding box
123 // to the surface. The bounding box is used
124 // for a preliminary check of intersection.
127
128 G4Point3D Tmp;
129 G4Point3D Origin = Position.GetLocation();
130 G4Point3D EndOrigin = G4Point3D( Origin + (length*Position.GetAxis()) );
131 G4Point3D Radius(radius, radius, 0);
132
133 // Default BBox
135 G4Point3D BoxMin(Origin-Tolerance);
136 G4Point3D BoxMax(Origin+Tolerance);
137
138 bbox = new G4BoundingBox3D();
139 bbox->Init(BoxMin, BoxMax);
140
141
142 Tmp = (Origin - Radius);
143 bbox->Extend(Tmp);
144
145 Tmp = Origin + Radius;
146 bbox->Extend(Tmp);
147
148 Tmp = EndOrigin - Radius;
149 bbox->Extend(Tmp);
150
151 Tmp = EndOrigin + Radius;
152 bbox->Extend(Tmp);
153}
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

◆ GetAxis()

G4Vector3D G4FCylindricalSurface::GetAxis ( ) const
inline

◆ GetEntityType()

G4String G4FCylindricalSurface::GetEntityType ( ) const
inlinevirtual

Reimplemented from G4Surface.

◆ GetLength()

G4double G4FCylindricalSurface::GetLength ( ) const
inline

◆ GetRadius()

G4double G4FCylindricalSurface::GetRadius ( ) const
inline

◆ HowNear()

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

Reimplemented from G4Surface.

Definition at line 241 of file G4FCylindricalSurface.cc.

242{
243 // Shortest distance from the point x to the G4FCylindricalSurface.
244 // The distance will be always positive
245
246 G4double hownear;
247
248 G4Vector3D upcorner = G4Vector3D ( radius, 0 , origin.z()+length);
249 G4Vector3D downcorner = G4Vector3D ( radius, 0 , origin.z());
250 G4Vector3D xd;
251
252 xd = G4Vector3D ( std::sqrt ( x.x()*x.x() + x.y()*x.y() ) , 0 , x.z() );
253
254
255 G4double Zinter = (xd.z()) ;
256
257 if ( ((Zinter >= downcorner.z()) && (Zinter <=upcorner.z())) ) {
258 hownear = std::fabs( radius - xd.x() );
259 } else {
260 hownear = std::min ( (xd-upcorner).mag() , (xd-downcorner).mag() );
261 }
262
263 return hownear;
264}
double G4double
Definition: G4Types.hh:64
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35

Referenced by Inside().

◆ InitValues()

void G4FCylindricalSurface::InitValues ( )

◆ Inside()

G4int G4FCylindricalSurface::Inside ( const G4Vector3D x) const
virtual

Definition at line 309 of file G4FCylindricalSurface.cc.

310{
311 // Return 0 if point x is outside G4CylindricalSurface, 1 if Inside.
312 // Outside means that the distance to the G4CylindricalSurface would
313 // be negative.
314 // Use the HowNear function to calculate this distance.
315 if ( HowNear( x ) >= -0.5*kCarTolerance )
316 return 1;
317 else
318 return 0;
319}
virtual G4double HowNear(const G4Vector3D &x) const

Referenced by Intersect().

◆ Intersect()

G4int G4FCylindricalSurface::Intersect ( const G4Ray ry)
virtual

Reimplemented from G4Surface.

Definition at line 156 of file G4FCylindricalSurface.cc.

157{
158 // This function count the number of intersections of a
159 // bounded cylindrical surface by a ray.
160 // At first, calculates the intersections with the infinite
161 // cylindrical surfsace. After, count the intersections within the
162 // finite cylindrical surface boundaries, and set "distance" to the
163 // closest distance from the start point to the nearest intersection
164 // If the point is on the surface it returns or the intersection with
165 // the opposite surface or kInfinity
166
167 // If no intersection is founded, set distance = kInfinity and
168 // return 0
169
170 distance = kInfinity;
172
173 // origin and direction of the ray
174 G4Point3D x = ry.GetStart();
175 G4Vector3D dhat = ry.GetDir();
176
177 // cylinder axis
178 G4Vector3D ahat = Position.GetAxis();
179
180 // array of solutions in distance along the ray
181 G4double sol[2];
182 sol[0]=-1.0;
183 sol[1]=-1.0;
184
185 // calculate the two intersections (quadratic equation)
186 G4Vector3D gamma = G4Vector3D( x - Position.GetLocation() );
187
188 G4double ga = gamma * ahat;
189 G4double da = dhat * ahat;
190
191 G4double A = da * da - dhat * dhat;
192 G4double B = 2 * ( -gamma * dhat + ga * da );
193 G4double C = -gamma * gamma + ga * ga + radius * radius ;
194
195 G4double radical = B * B - 4.0 * A * C;
196
197 if ( radical < 0.0 )
198 // no intersection
199 return 0;
200 else
201 {
202 G4double root = std::sqrt( radical );
203 sol[0] = ( - B + root ) / ( 2. * A );
204 sol[1] = ( - B - root ) / ( 2. * A );
205 }
206
207 // validity of the solutions
208 // the hit point must be into the bounding box of the cylindrical surface
209 G4Point3D p0 = G4Point3D( x + sol[0]*dhat );
210 G4Point3D p1 = G4Point3D( x + sol[1]*dhat );
211
212 if( !GetBBox()->Inside(p0) )
213 sol[0] = kInfinity;
214
215 if( !GetBBox()->Inside(p1) )
216 sol[1] = kInfinity;
217
218 // now loop over each positive solution, keeping the first one (smallest
219 // distance along the Ray) which is within the boundary of the sub-shape
220 G4int nbinter = 0;
221 distance = kInfinity;
222
223 for ( G4int i = 0; i < 2; i++ )
224 {
225 if(sol[i] < kInfinity) {
226 if ( sol[i] >= kCarTolerance*0.5 ) {
227 nbinter ++;
228 // real intersection
229 // set the distance if it is the smallest
230 if( distance > sol[i]*sol[i]) {
231 distance = sol[i]*sol[i];
232 }
233 }
234 }
235 }
236
237 return nbinter;
238}
int G4int
Definition: G4Types.hh:66
virtual 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

◆ NameOf()

const char * G4FCylindricalSurface::NameOf ( ) const
virtual

Definition at line 96 of file G4FCylindricalSurface.cc.

97{
98 return "G4FCylindricalSurface";
99}

◆ operator==()

G4int G4FCylindricalSurface::operator== ( const G4FCylindricalSurface c) const
inline

◆ PrintOn()

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

Definition at line 102 of file G4FCylindricalSurface.cc.

103{
104 os << "G4FCylindricalSurface with origin: " << origin << "\t"
105 << "and axis: " << Position.GetAxis() << "\n"
106 << "\t radius: " << radius << "\t and length: "
107 << length << "\n";
108}

◆ resize()

void G4FCylindricalSurface::resize ( G4double  r,
G4double  l 
)
virtual

Definition at line 322 of file G4FCylindricalSurface.cc.

323{
324 // Resize a G4FCylindricalSurface to a new radius r and new length l
325 // Require radius to be non-negative
326 if ( r >= 0.0 )
327 radius = r;
328 else
329 {
330 std::ostringstream message;
331 message << "Negative radius." << G4endl
332 << "Original value of " << radius << " is retained.";
333 G4Exception("G4FCylindricalSurface::resize()",
334 "GeomSolids1001", JustWarning, message);
335 }
336
337 // Require length to be positive
338 if ( l > 0.0 )
339 length = l;
340 else
341 {
342 std::ostringstream message;
343 message << "Negative or zero length." << G4endl
344 << "Original value of " << length << " is retained.";
345 G4Exception("G4FCylindricalSurface::resize()",
346 "GeomSolids1001", JustWarning, message);
347 }
348}

◆ Scale()

G4double G4FCylindricalSurface::Scale ( ) const
virtual

Definition at line 278 of file G4FCylindricalSurface.cc.

279{
280 // Returns the radius of a G4FCylindricalSurface unless it is zero,
281 // in which case returns the length.
282 // Used for Scale-invariant tests of surface thickness.
283 if ( radius == 0.0 )
284 return length;
285 else
286 return radius;
287}

◆ SetRadius()

void G4FCylindricalSurface::SetRadius ( G4double  r)

◆ SurfaceNormal()

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

Implements G4Surface.

Definition at line 290 of file G4FCylindricalSurface.cc.

291{
292 // return the Normal unit vector to the G4CylindricalSurface at a point
293 // p on (or nearly on) the G4CylindricalSurface
294
296 ( ( p - Position.GetLocation()) *
298 G4double nmag = n.mag();
299
300 if ( nmag != 0.0 )
301 n = n * (1/nmag);
302
303 if( !sameSense )
304 n = -n;
305
306 return n;
307}
G4int sameSense
Definition: G4Surface.hh:207

◆ WithinBoundary()

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

Definition at line 266 of file G4FCylindricalSurface.cc.

267{
268 // return 1 if point x is within the boundaries of the G4FCylindricalSurface
269 // return 0 otherwise (assume it is on the cylinder)
270 if ( std::fabs( ( x - Position.GetLocation()) * Position.GetAxis() )
271 <= 0.5 * length )
272 return 1;
273 else
274 return 0;
275}

Member Data Documentation

◆ length

G4double G4FCylindricalSurface::length
protected

◆ Position

G4Axis2Placement3D G4FCylindricalSurface::Position
protected

◆ radius

G4double G4FCylindricalSurface::radius
protected

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