Geant4  10.02.p03
G4Ellipsoid Class Reference

#include <G4Ellipsoid.hh>

Inheritance diagram for G4Ellipsoid:
Collaboration diagram for G4Ellipsoid:

Public Member Functions

 G4Ellipsoid (const G4String &pName, G4double pxSemiAxis, G4double pySemiAxis, G4double pzSemiAxis, G4double pzBottomCut=0, G4double pzTopCut=0)
 
virtual ~G4Ellipsoid ()
 
G4double GetSemiAxisMax (G4int i) const
 
G4double GetZBottomCut () const
 
G4double GetZTopCut () const
 
void SetSemiAxis (G4double x, G4double y, G4double z)
 
void SetZCuts (G4double newzBottomCut, G4double newzTopCut)
 
G4double GetCubicVolume ()
 
G4double GetSurfaceArea ()
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
 
EInside Inside (const G4ThreeVector &p) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
G4GeometryType GetEntityType () const
 
G4VSolidClone () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4ThreeVector GetPointOnSurface () const
 
G4PolyhedronGetPolyhedron () const
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4VisExtent GetExtent () const
 
G4PolyhedronCreatePolyhedron () const
 
 G4Ellipsoid (__void__ &)
 
 G4Ellipsoid (const G4Ellipsoid &rhs)
 
G4Ellipsoidoperator= (const G4Ellipsoid &rhs)
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
void DumpInfo () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

Protected Member Functions

G4ThreeVectorListCreateRotatedVertices (const G4AffineTransform &pT, G4int &noPV) const
 
- Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
 

Protected Attributes

G4bool fRebuildPolyhedron
 
G4PolyhedronfpPolyhedron
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Private Attributes

G4double kRadTolerance
 
G4double halfCarTolerance
 
G4double halfRadTolerance
 
G4double fCubicVolume
 
G4double fSurfaceArea
 
G4double xSemiAxis
 
G4double ySemiAxis
 
G4double zSemiAxis
 
G4double semiAxisMax
 
G4double zBottomCut
 
G4double zTopCut
 

Detailed Description

Definition at line 60 of file G4Ellipsoid.hh.

Constructor & Destructor Documentation

◆ G4Ellipsoid() [1/3]

G4Ellipsoid::G4Ellipsoid ( const G4String pName,
G4double  pxSemiAxis,
G4double  pySemiAxis,
G4double  pzSemiAxis,
G4double  pzBottomCut = 0,
G4double  pzTopCut = 0 
)

Definition at line 69 of file G4Ellipsoid.cc.

75  : G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0),
76  fCubicVolume(0.), fSurfaceArea(0.), zBottomCut(0.), zTopCut(0.)
77 {
78  // note: for users that want to use the full ellipsoid it is useful
79  // to include a default for the cuts
80 
82 
85 
86  // Check Semi-Axis
87  if ( (pxSemiAxis<=0.) || (pySemiAxis<=0.) || (pzSemiAxis<=0.) )
88  {
89  std::ostringstream message;
90  message << "Invalid semi-axis - " << GetName();
91  G4Exception("G4Ellipsoid::G4Ellipsoid()", "GeomSolids0002",
92  FatalErrorInArgument, message);
93  }
94  SetSemiAxis(pxSemiAxis, pySemiAxis, pzSemiAxis);
95 
96  if ( pzBottomCut == 0 && pzTopCut == 0 )
97  {
98  SetZCuts(-pzSemiAxis, pzSemiAxis);
99  }
100  else if ( (pzBottomCut < pzSemiAxis) && (pzTopCut > -pzSemiAxis)
101  && (pzBottomCut < pzTopCut) )
102  {
103  SetZCuts(pzBottomCut, pzTopCut);
104  }
105  else
106  {
107  std::ostringstream message;
108  message << "Invalid z-coordinate for cutting plane - " << GetName();
109  G4Exception("G4Ellipsoid::G4Ellipsoid()", "GeomSolids0002",
110  FatalErrorInArgument, message);
111  }
112 }
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double halfRadTolerance
Definition: G4Ellipsoid.hh:142
G4double fSurfaceArea
Definition: G4Ellipsoid.hh:145
G4bool fRebuildPolyhedron
Definition: G4Ellipsoid.hh:136
G4String GetName() const
G4double kRadTolerance
Definition: G4Ellipsoid.hh:141
void SetZCuts(G4double newzBottomCut, G4double newzTopCut)
G4double GetRadialTolerance() const
G4Polyhedron * fpPolyhedron
Definition: G4Ellipsoid.hh:137
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
G4double fCubicVolume
Definition: G4Ellipsoid.hh:144
G4double halfCarTolerance
Definition: G4Ellipsoid.hh:142
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetSemiAxis(G4double x, G4double y, G4double z)
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
G4double kCarTolerance
Definition: G4VSolid.hh:304
static G4GeometryTolerance * GetInstance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~G4Ellipsoid()

G4Ellipsoid::~G4Ellipsoid ( )
virtual

Definition at line 131 of file G4Ellipsoid.cc.

132 {
133  delete fpPolyhedron; fpPolyhedron = 0;
134 }
G4Polyhedron * fpPolyhedron
Definition: G4Ellipsoid.hh:137

◆ G4Ellipsoid() [2/3]

G4Ellipsoid::G4Ellipsoid ( __void__ &  a)

Definition at line 119 of file G4Ellipsoid.cc.

122  fSurfaceArea(0.), xSemiAxis(0.), ySemiAxis(0.), zSemiAxis(0.),
123  semiAxisMax(0.), zBottomCut(0.), zTopCut(0.)
124 {
125 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double halfRadTolerance
Definition: G4Ellipsoid.hh:142
G4double fSurfaceArea
Definition: G4Ellipsoid.hh:145
G4bool fRebuildPolyhedron
Definition: G4Ellipsoid.hh:136
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double kRadTolerance
Definition: G4Ellipsoid.hh:141
G4double semiAxisMax
Definition: G4Ellipsoid.hh:146
G4Polyhedron * fpPolyhedron
Definition: G4Ellipsoid.hh:137
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
G4double fCubicVolume
Definition: G4Ellipsoid.hh:144
G4double halfCarTolerance
Definition: G4Ellipsoid.hh:142
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60

◆ G4Ellipsoid() [3/3]

G4Ellipsoid::G4Ellipsoid ( const G4Ellipsoid rhs)

Definition at line 140 of file G4Ellipsoid.cc.

141  : G4VSolid(rhs),
142  fRebuildPolyhedron(false), fpPolyhedron(0),
150 {
151 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double halfRadTolerance
Definition: G4Ellipsoid.hh:142
G4double fSurfaceArea
Definition: G4Ellipsoid.hh:145
G4bool fRebuildPolyhedron
Definition: G4Ellipsoid.hh:136
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double kRadTolerance
Definition: G4Ellipsoid.hh:141
G4double semiAxisMax
Definition: G4Ellipsoid.hh:146
G4Polyhedron * fpPolyhedron
Definition: G4Ellipsoid.hh:137
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
G4double fCubicVolume
Definition: G4Ellipsoid.hh:144
G4double halfCarTolerance
Definition: G4Ellipsoid.hh:142
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60

Member Function Documentation

◆ CalculateExtent()

G4bool G4Ellipsoid::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pmin,
G4double pmax 
) const
virtual

Implements G4VSolid.

Definition at line 199 of file G4Ellipsoid.cc.

203 {
204  if (!pTransform.IsRotated())
205  {
206  // Special case handling for unrotated solid ellipsoid
207  // Compute x/y/z mins and maxs for bounding box respecting limits,
208  // with early returns if outside limits. Then switch() on pAxis,
209  // and compute exact x and y limit for x/y case
210 
211  G4double xoffset,xMin,xMax;
212  G4double yoffset,yMin,yMax;
213  G4double zoffset,zMin,zMax;
214 
215  G4double maxDiff,newMin,newMax;
216  G4double xoff,yoff;
217 
218  xoffset=pTransform.NetTranslation().x();
219  xMin=xoffset - xSemiAxis;
220  xMax=xoffset + xSemiAxis;
221  if (pVoxelLimit.IsXLimited())
222  {
223  if ( (xMin>pVoxelLimit.GetMaxXExtent()+kCarTolerance)
224  || (xMax<pVoxelLimit.GetMinXExtent()-kCarTolerance) )
225  {
226  return false;
227  }
228  else
229  {
230  if (xMin<pVoxelLimit.GetMinXExtent())
231  {
232  xMin=pVoxelLimit.GetMinXExtent();
233  }
234  if (xMax>pVoxelLimit.GetMaxXExtent())
235  {
236  xMax=pVoxelLimit.GetMaxXExtent();
237  }
238  }
239  }
240 
241  yoffset=pTransform.NetTranslation().y();
242  yMin=yoffset - ySemiAxis;
243  yMax=yoffset + ySemiAxis;
244  if (pVoxelLimit.IsYLimited())
245  {
246  if ( (yMin>pVoxelLimit.GetMaxYExtent()+kCarTolerance)
247  || (yMax<pVoxelLimit.GetMinYExtent()-kCarTolerance) )
248  {
249  return false;
250  }
251  else
252  {
253  if (yMin<pVoxelLimit.GetMinYExtent())
254  {
255  yMin=pVoxelLimit.GetMinYExtent();
256  }
257  if (yMax>pVoxelLimit.GetMaxYExtent())
258  {
259  yMax=pVoxelLimit.GetMaxYExtent();
260  }
261  }
262  }
263 
264  zoffset=pTransform.NetTranslation().z();
265  zMin=zoffset + (-zSemiAxis > zBottomCut ? -zSemiAxis : zBottomCut);
266  zMax=zoffset + ( zSemiAxis < zTopCut ? zSemiAxis : zTopCut);
267  if (pVoxelLimit.IsZLimited())
268  {
269  if ( (zMin>pVoxelLimit.GetMaxZExtent()+kCarTolerance)
270  || (zMax<pVoxelLimit.GetMinZExtent()-kCarTolerance) )
271  {
272  return false;
273  }
274  else
275  {
276  if (zMin<pVoxelLimit.GetMinZExtent())
277  {
278  zMin=pVoxelLimit.GetMinZExtent();
279  }
280  if (zMax>pVoxelLimit.GetMaxZExtent())
281  {
282  zMax=pVoxelLimit.GetMaxZExtent();
283  }
284  }
285  }
286 
287  // if here, then known to cut bounding box around ellipsoid
288  //
289  xoff = (xoffset < xMin) ? (xMin-xoffset)
290  : (xoffset > xMax) ? (xoffset-xMax) : 0.0;
291  yoff = (yoffset < yMin) ? (yMin-yoffset)
292  : (yoffset > yMax) ? (yoffset-yMax) : 0.0;
293 
294  // detailed calculations
295  // NOTE: does not use X or Y offsets to adjust Z range,
296  // and does not use Z offset to adjust X or Y range,
297  // which is consistent with G4Sphere::CalculateExtent behavior
298  //
299  switch (pAxis)
300  {
301  case kXAxis:
302  if (yoff==0.)
303  {
304  // YZ limits cross max/min x => no change
305  //
306  pMin=xMin;
307  pMax=xMax;
308  }
309  else
310  {
311  // YZ limits don't cross max/min x => compute max delta x,
312  // hence new mins/maxs
313  //
314  maxDiff= 1.0-sqr(yoff/ySemiAxis);
315  if (maxDiff < 0.0) { return false; }
316  maxDiff= xSemiAxis * std::sqrt(maxDiff);
317  newMin=xoffset-maxDiff;
318  newMax=xoffset+maxDiff;
319  pMin=(newMin<xMin) ? xMin : newMin;
320  pMax=(newMax>xMax) ? xMax : newMax;
321  }
322  break;
323  case kYAxis:
324  if (xoff==0.)
325  {
326  // XZ limits cross max/min y => no change
327  //
328  pMin=yMin;
329  pMax=yMax;
330  }
331  else
332  {
333  // XZ limits don't cross max/min y => compute max delta y,
334  // hence new mins/maxs
335  //
336  maxDiff= 1.0-sqr(xoff/xSemiAxis);
337  if (maxDiff < 0.0) { return false; }
338  maxDiff= ySemiAxis * std::sqrt(maxDiff);
339  newMin=yoffset-maxDiff;
340  newMax=yoffset+maxDiff;
341  pMin=(newMin<yMin) ? yMin : newMin;
342  pMax=(newMax>yMax) ? yMax : newMax;
343  }
344  break;
345  case kZAxis:
346  pMin=zMin;
347  pMax=zMax;
348  break;
349  default:
350  break;
351  }
352 
353  pMin-=kCarTolerance;
354  pMax+=kCarTolerance;
355  return true;
356  }
357  else // not rotated
358  {
359  G4int i,j,noEntries,noBetweenSections;
360  G4bool existsAfterClip=false;
361 
362  // Calculate rotated vertex coordinates
363 
364  G4int noPolygonVertices=0;
365  G4ThreeVectorList* vertices =
366  CreateRotatedVertices(pTransform,noPolygonVertices);
367 
368  pMin=+kInfinity;
369  pMax=-kInfinity;
370 
371  noEntries=vertices->size(); // noPolygonVertices*noPhiCrossSections
372  noBetweenSections=noEntries-noPolygonVertices;
373 
374  G4ThreeVectorList ThetaPolygon;
375  for (i=0;i<noEntries;i+=noPolygonVertices)
376  {
377  for(j=0;j<(noPolygonVertices/2)-1;j++)
378  {
379  ThetaPolygon.push_back((*vertices)[i+j]);
380  ThetaPolygon.push_back((*vertices)[i+j+1]);
381  ThetaPolygon.push_back((*vertices)[i+noPolygonVertices-2-j]);
382  ThetaPolygon.push_back((*vertices)[i+noPolygonVertices-1-j]);
383  CalculateClippedPolygonExtent(ThetaPolygon,pVoxelLimit,pAxis,pMin,pMax);
384  ThetaPolygon.clear();
385  }
386  }
387  for (i=0;i<noBetweenSections;i+=noPolygonVertices)
388  {
389  for(j=0;j<noPolygonVertices-1;j++)
390  {
391  ThetaPolygon.push_back((*vertices)[i+j]);
392  ThetaPolygon.push_back((*vertices)[i+j+1]);
393  ThetaPolygon.push_back((*vertices)[i+noPolygonVertices+j+1]);
394  ThetaPolygon.push_back((*vertices)[i+noPolygonVertices+j]);
395  CalculateClippedPolygonExtent(ThetaPolygon,pVoxelLimit,pAxis,pMin,pMax);
396  ThetaPolygon.clear();
397  }
398  ThetaPolygon.push_back((*vertices)[i+noPolygonVertices-1]);
399  ThetaPolygon.push_back((*vertices)[i]);
400  ThetaPolygon.push_back((*vertices)[i+noPolygonVertices]);
401  ThetaPolygon.push_back((*vertices)[i+2*noPolygonVertices-1]);
402  CalculateClippedPolygonExtent(ThetaPolygon,pVoxelLimit,pAxis,pMin,pMax);
403  ThetaPolygon.clear();
404  }
405  if ( (pMin!=kInfinity) || (pMax!=-kInfinity) )
406  {
407  existsAfterClip=true;
408 
409  // Add 2*tolerance to avoid precision troubles
410  //
411  pMin-=kCarTolerance;
412  pMax+=kCarTolerance;
413 
414  }
415  else
416  {
417  // Check for case where completely enveloping clipping volume
418  // If point inside then we are confident that the solid completely
419  // envelopes the clipping volume. Hence set min/max extents according
420  // to clipping volume extents along the specified axis.
421  //
423  clipCentre((pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
424  (pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
425  (pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
426 
427  if (Inside(pTransform.Inverse().TransformPoint(clipCentre))!=kOutside)
428  {
429  existsAfterClip=true;
430  pMin=pVoxelLimit.GetMinExtent(pAxis);
431  pMax=pVoxelLimit.GetMaxExtent(pAxis);
432  }
433  }
434  delete vertices;
435  return existsAfterClip;
436  }
437 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double GetMinXExtent() const
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
static const G4double kInfinity
Definition: geomdefs.hh:42
G4double GetMinYExtent() const
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pT, G4int &noPV) const
Definition: G4Ellipsoid.cc:846
G4double GetMinZExtent() const
G4bool IsYLimited() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4bool IsXLimited() const
G4bool IsRotated() const
int G4int
Definition: G4Types.hh:78
G4double GetMaxZExtent() const
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
EInside Inside(const G4ThreeVector &p) const
Definition: G4Ellipsoid.cc:445
G4double GetMaxXExtent() const
G4AffineTransform Inverse() const
G4ThreeVector NetTranslation() const
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
G4double GetMinExtent(const EAxis pAxis) const
double x() const
G4bool IsZLimited() const
double y() const
double z() const
G4double GetMaxExtent(const EAxis pAxis) const
G4double kCarTolerance
Definition: G4VSolid.hh:304
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
void CalculateClippedPolygonExtent(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
Definition: G4VSolid.cc:427
G4double GetMaxYExtent() const
Here is the call graph for this function:

◆ Clone()

G4VSolid * G4Ellipsoid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 971 of file G4Ellipsoid.cc.

972 {
973  return new G4Ellipsoid(*this);
974 }
G4Ellipsoid(const G4String &pName, G4double pxSemiAxis, G4double pySemiAxis, G4double pzSemiAxis, G4double pzBottomCut=0, G4double pzTopCut=0)
Definition: G4Ellipsoid.cc:69
Here is the call graph for this function:

◆ ComputeDimensions()

void G4Ellipsoid::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtual

Reimplemented from G4VSolid.

Definition at line 187 of file G4Ellipsoid.cc.

190 {
191  p->ComputeDimensions(*this,n,pRep);
192 }
Char_t n[5]
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
Here is the call graph for this function:

◆ CreatePolyhedron()

G4Polyhedron * G4Ellipsoid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1087 of file G4Ellipsoid.cc.

1088 {
1090  zBottomCut, zTopCut);
1091 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
Here is the caller graph for this function:

◆ CreateRotatedVertices()

G4ThreeVectorList * G4Ellipsoid::CreateRotatedVertices ( const G4AffineTransform pT,
G4int noPV 
) const
protected

Definition at line 846 of file G4Ellipsoid.cc.

848 {
849  G4ThreeVectorList *vertices;
850  G4ThreeVector vertex;
851  G4double meshAnglePhi, meshRMaxFactor,
852  crossAnglePhi, coscrossAnglePhi, sincrossAnglePhi, sAnglePhi;
853  G4double meshTheta, crossTheta, startTheta;
854  G4double rMaxX, rMaxY, rMaxZ, rMaxMax, rx, ry, rz;
855  G4int crossSectionPhi, noPhiCrossSections, crossSectionTheta, noThetaSections;
856 
857  // Phi cross sections
858  //
859  noPhiCrossSections=G4int (twopi/kMeshAngleDefault)+1; // = 9!
860 
861 /*
862  if (noPhiCrossSections<kMinMeshSections) // <3
863  {
864  noPhiCrossSections=kMinMeshSections;
865  }
866  else if (noPhiCrossSections>kMaxMeshSections) // >37
867  {
868  noPhiCrossSections=kMaxMeshSections;
869  }
870 */
871  meshAnglePhi=twopi/(noPhiCrossSections-1);
872 
873  // Set start angle such that mesh will be at fRMax
874  // on the x axis. Will give better extent calculations when not rotated.
875 
876  sAnglePhi = -meshAnglePhi*0.5;
877 
878  // Theta cross sections
879 
880  noThetaSections = G4int(pi/kMeshAngleDefault)+3; // = 7!
881 
882 /*
883  if (noThetaSections<kMinMeshSections) // <3
884  {
885  noThetaSections=kMinMeshSections;
886  }
887  else if (noThetaSections>kMaxMeshSections) // >37
888  {
889  noThetaSections=kMaxMeshSections;
890  }
891 */
892  meshTheta= pi/(noThetaSections-2);
893 
894  // Set start angle such that mesh will be at fRMax
895  // on the z axis. Will give better extent calculations when not rotated.
896 
897  startTheta = -meshTheta*0.5;
898 
899  meshRMaxFactor = 1.0/std::cos(0.5*
900  std::sqrt(meshAnglePhi*meshAnglePhi+meshTheta*meshTheta));
901  rMaxMax= (xSemiAxis > ySemiAxis ? xSemiAxis : ySemiAxis);
902  if (zSemiAxis > rMaxMax) rMaxMax= zSemiAxis;
903  rMaxX= xSemiAxis + rMaxMax*(meshRMaxFactor-1.0);
904  rMaxY= ySemiAxis + rMaxMax*(meshRMaxFactor-1.0);
905  rMaxZ= zSemiAxis + rMaxMax*(meshRMaxFactor-1.0);
906  G4double* cosCrossTheta = new G4double[noThetaSections];
907  G4double* sinCrossTheta = new G4double[noThetaSections];
908  vertices=new G4ThreeVectorList(noPhiCrossSections*noThetaSections);
909  if (vertices && cosCrossTheta && sinCrossTheta)
910  {
911  for (crossSectionTheta=0; crossSectionTheta<noThetaSections;
912  crossSectionTheta++)
913  {
914  // Compute sine and cosine table (for historical reasons)
915  //
916  crossTheta=startTheta+crossSectionTheta*meshTheta;
917  cosCrossTheta[crossSectionTheta]=std::cos(crossTheta);
918  sinCrossTheta[crossSectionTheta]=std::sin(crossTheta);
919  }
920  for (crossSectionPhi=0; crossSectionPhi<noPhiCrossSections;
921  crossSectionPhi++)
922  {
923  crossAnglePhi=sAnglePhi+crossSectionPhi*meshAnglePhi;
924  coscrossAnglePhi=std::cos(crossAnglePhi);
925  sincrossAnglePhi=std::sin(crossAnglePhi);
926  for (crossSectionTheta=0; crossSectionTheta<noThetaSections;
927  crossSectionTheta++)
928  {
929  // Compute coordinates of cross section at section crossSectionPhi
930  //
931  rx= sinCrossTheta[crossSectionTheta]*coscrossAnglePhi*rMaxX;
932  ry= sinCrossTheta[crossSectionTheta]*sincrossAnglePhi*rMaxY;
933  rz= cosCrossTheta[crossSectionTheta]*rMaxZ;
934  if (rz < zBottomCut)
935  { rz= zBottomCut; }
936  if (rz > zTopCut)
937  { rz= zTopCut; }
938  vertex= G4ThreeVector(rx,ry,rz);
939  vertices->push_back(pTransform.TransformPoint(vertex));
940  } // Theta forward
941  } // Phi
942  noPolygonVertices = noThetaSections ;
943  }
944  else
945  {
946  DumpInfo();
947  G4Exception("G4Ellipsoid::CreateRotatedVertices()",
948  "GeomSolids0003", FatalException,
949  "Error in allocation of vertices. Out of memory !");
950  }
951 
952  delete[] cosCrossTheta;
953  delete[] sinCrossTheta;
954 
955  return vertices;
956 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
CLHEP::Hep3Vector G4ThreeVector
int G4int
Definition: G4Types.hh:78
void DumpInfo() const
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
static const double twopi
Definition: G4SIunits.hh:75
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const double pi
Definition: G4SIunits.hh:74
double G4double
Definition: G4Types.hh:76
const G4double kMeshAngleDefault
Definition: meshdefs.hh:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DescribeYourselfTo()

void G4Ellipsoid::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 1073 of file G4Ellipsoid.cc.

1074 {
1075  scene.AddSolid(*this);
1076 }
virtual void AddSolid(const G4Box &)=0
Here is the call graph for this function:

◆ DistanceToIn() [1/2]

G4double G4Ellipsoid::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 521 of file G4Ellipsoid.cc.

523 {
525  const G4double dRmax = 100.*std::min(distMin,zSemiAxis);
526  distMin= kInfinity;
527 
528  // check to see if Z plane is relevant
529  if (p.z() <= zBottomCut+halfCarTolerance)
530  {
531  if (v.z() <= 0.0) { return distMin; }
532  G4double distZ = (zBottomCut - p.z()) / v.z();
533 
534  if ( (distZ > -halfRadTolerance) && (Inside(p+distZ*v) != kOutside) )
535  {
536  // early exit since can't intercept curved surface if we reach here
537  if ( std::fabs(distZ) < halfRadTolerance ) { distZ=0.; }
538  return distMin= distZ;
539  }
540  }
541  if (p.z() >= zTopCut-halfCarTolerance)
542  {
543  if (v.z() >= 0.0) { return distMin;}
544  G4double distZ = (zTopCut - p.z()) / v.z();
545  if ( (distZ > -halfRadTolerance) && (Inside(p+distZ*v) != kOutside) )
546  {
547  // early exit since can't intercept curved surface if we reach here
548  if ( std::fabs(distZ) < halfRadTolerance ) { distZ=0.; }
549  return distMin= distZ;
550  }
551  }
552  // if fZCut1 <= p.z() <= fZCut2, then must hit curved surface
553 
554  // now check curved surface intercept
555  G4double A,B,C;
556 
557  A= sqr(v.x()/xSemiAxis) + sqr(v.y()/ySemiAxis) + sqr(v.z()/zSemiAxis);
558  C= sqr(p.x()/xSemiAxis) + sqr(p.y()/ySemiAxis) + sqr(p.z()/zSemiAxis) - 1.0;
559  B= 2.0 * ( p.x()*v.x()/(xSemiAxis*xSemiAxis)
560  + p.y()*v.y()/(ySemiAxis*ySemiAxis)
561  + p.z()*v.z()/(zSemiAxis*zSemiAxis) );
562 
563  C= B*B - 4.0*A*C;
564  if (C > 0.0)
565  {
566  G4double distR= (-B - std::sqrt(C)) / (2.0*A);
567  G4double intZ = p.z()+distR*v.z();
568  if ( (distR > halfRadTolerance)
569  && (intZ >= zBottomCut-halfRadTolerance)
570  && (intZ <= zTopCut+halfRadTolerance) )
571  {
572  distMin = distR;
573  }
574  else if( (distR >- halfRadTolerance)
575  && (intZ >= zBottomCut-halfRadTolerance)
576  && (intZ <= zTopCut+halfRadTolerance) )
577  {
578  // p is on the curved surface, DistanceToIn returns 0 or kInfinity:
579  // DistanceToIn returns 0, if second root is positive (means going inside)
580  // If second root is negative, DistanceToIn returns kInfinity (outside)
581  //
582  distR = (-B + std::sqrt(C) ) / (2.0*A);
583  if(distR>0.) { distMin=0.; }
584  }
585  else
586  {
587  distR= (-B + std::sqrt(C)) / (2.0*A);
588  intZ = p.z()+distR*v.z();
589  if ( (distR > halfRadTolerance)
590  && (intZ >= zBottomCut-halfRadTolerance)
591  && (intZ <= zTopCut+halfRadTolerance) )
592  {
594  if (norm.dot(v)<0.) { distMin = distR; }
595  }
596  }
597  if ( (distMin!=kInfinity) && (distMin>dRmax) )
598  { // Avoid rounding errors due to precision issues on
599  // 64 bits systems. Split long distances and recompute
600  G4double fTerm = distMin-std::fmod(distMin,dRmax);
601  distMin = fTerm + DistanceToIn(p+fTerm*v,v);
602  }
603  }
604 
605  if (std::fabs(distMin)<halfRadTolerance) { distMin=0.; }
606  return distMin;
607 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double halfRadTolerance
Definition: G4Ellipsoid.hh:142
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
static const G4double kInfinity
Definition: geomdefs.hh:42
Float_t norm
double C(double temp)
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Ellipsoid.cc:487
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
EInside Inside(const G4ThreeVector &p) const
Definition: G4Ellipsoid.cc:445
double A(double temperature)
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
G4double halfCarTolerance
Definition: G4Ellipsoid.hh:142
double x() const
double dot(const Hep3Vector &) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Ellipsoid.cc:521
double y() const
double z() const
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ DistanceToIn() [2/2]

G4double G4Ellipsoid::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 614 of file G4Ellipsoid.cc.

615 {
616  G4double distR, distZ;
617 
618  // normal vector: parallel to normal, magnitude 1/(characteristic radius)
619  //
621  p.y()/(ySemiAxis*ySemiAxis),
622  p.z()/(zSemiAxis*zSemiAxis));
623  G4double radius= 1.0/norm.mag();
624 
625  // approximate distance to curved surface ( <= actual distance )
626  //
627  distR= (p*norm - 1.0) * radius / 2.0;
628 
629  // Distance to z-cut plane
630  //
631  distZ= zBottomCut - p.z();
632  if (distZ < 0.0)
633  {
634  distZ = p.z() - zTopCut;
635  }
636 
637  // Distance to closest surface from outside
638  //
639  if (distZ < 0.0)
640  {
641  return (distR < 0.0) ? 0.0 : distR;
642  }
643  else if (distR < 0.0)
644  {
645  return distZ;
646  }
647  else
648  {
649  return (distZ < distR) ? distZ : distR;
650  }
651 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
Float_t norm
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
double x() const
double y() const
double z() const
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ DistanceToOut() [1/2]

G4double G4Ellipsoid::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm = G4bool(false),
G4bool validNorm = 0,
G4ThreeVector n = 0 
) const
virtual

Implements G4VSolid.

Definition at line 657 of file G4Ellipsoid.cc.

662 {
663  G4double distMin;
664  enum surface_e {kPlaneSurf, kCurvedSurf, kNoSurf} surface;
665 
666  distMin= kInfinity;
667  surface= kNoSurf;
668 
669  // check to see if Z plane is relevant
670  //
671  if (v.z() < 0.0)
672  {
673  G4double distZ = (zBottomCut - p.z()) / v.z();
674  if (distZ < 0.0)
675  {
676  distZ= 0.0;
677  if (!calcNorm) {return 0.0;}
678  }
679  distMin= distZ;
680  surface= kPlaneSurf;
681  }
682  if (v.z() > 0.0)
683  {
684  G4double distZ = (zTopCut - p.z()) / v.z();
685  if (distZ < 0.0)
686  {
687  distZ= 0.0;
688  if (!calcNorm) {return 0.0;}
689  }
690  distMin= distZ;
691  surface= kPlaneSurf;
692  }
693 
694  // normal vector: parallel to normal, magnitude 1/(characteristic radius)
695  //
696  G4ThreeVector nearnorm(p.x()/(xSemiAxis*xSemiAxis),
697  p.y()/(ySemiAxis*ySemiAxis),
698  p.z()/(zSemiAxis*zSemiAxis));
699 
700  // now check curved surface intercept
701  //
702  G4double A,B,C;
703 
704  A= sqr(v.x()/xSemiAxis) + sqr(v.y()/ySemiAxis) + sqr(v.z()/zSemiAxis);
705  C= (p * nearnorm) - 1.0;
706  B= 2.0 * (v * nearnorm);
707 
708  C= B*B - 4.0*A*C;
709  if (C > 0.0)
710  {
711  G4double distR= (-B + std::sqrt(C) ) / (2.0*A);
712  if (distR < 0.0)
713  {
714  distR= 0.0;
715  if (!calcNorm) {return 0.0;}
716  }
717  if (distR < distMin)
718  {
719  distMin= distR;
720  surface= kCurvedSurf;
721  }
722  }
723 
724  // set normal if requested
725  //
726  if (calcNorm)
727  {
728  if (surface == kNoSurf)
729  {
730  *validNorm = false;
731  }
732  else
733  {
734  *validNorm = true;
735  switch (surface)
736  {
737  case kPlaneSurf:
738  *n= G4ThreeVector(0.,0.,(v.z() > 0.0 ? 1. : -1.));
739  break;
740  case kCurvedSurf:
741  {
742  G4ThreeVector pexit= p + distMin*v;
743  G4ThreeVector truenorm(pexit.x()/(xSemiAxis*xSemiAxis),
744  pexit.y()/(ySemiAxis*ySemiAxis),
745  pexit.z()/(zSemiAxis*zSemiAxis));
746  truenorm *= 1.0/truenorm.mag();
747  *n= truenorm;
748  } break;
749  default: // Should never reach this case ...
750  DumpInfo();
751  std::ostringstream message;
752  G4int oldprc = message.precision(16);
753  message << "Undefined side for valid surface normal to solid."
754  << G4endl
755  << "Position:" << G4endl
756  << " p.x() = " << p.x()/mm << " mm" << G4endl
757  << " p.y() = " << p.y()/mm << " mm" << G4endl
758  << " p.z() = " << p.z()/mm << " mm" << G4endl
759  << "Direction:" << G4endl << G4endl
760  << " v.x() = " << v.x() << G4endl
761  << " v.y() = " << v.y() << G4endl
762  << " v.z() = " << v.z() << G4endl
763  << "Proposed distance :" << G4endl
764  << " distMin = " << distMin/mm << " mm";
765  message.precision(oldprc);
766  G4Exception("G4Ellipsoid::DistanceToOut(p,v,..)",
767  "GeomSolids1002", JustWarning, message);
768  break;
769  }
770  }
771  }
772 
773  return distMin;
774 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
static const G4double kInfinity
Definition: geomdefs.hh:42
CLHEP::Hep3Vector G4ThreeVector
double C(double temp)
int G4int
Definition: G4Types.hh:78
void DumpInfo() const
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
double A(double temperature)
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double x() const
double y() const
double z() const
#define G4endl
Definition: G4ios.hh:61
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
static const double mm
Definition: G4SIunits.hh:114
Here is the call graph for this function:

◆ DistanceToOut() [2/2]

G4double G4Ellipsoid::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 780 of file G4Ellipsoid.cc.

781 {
782  G4double distR, distZ;
783 
784 #ifdef G4SPECSDEBUG
785  if( Inside(p) == kOutside )
786  {
787  DumpInfo();
788  std::ostringstream message;
789  G4int oldprc = message.precision(16);
790  message << "Point p is outside !?" << G4endl
791  << "Position:" << G4endl
792  << " p.x() = " << p.x()/mm << " mm" << G4endl
793  << " p.y() = " << p.y()/mm << " mm" << G4endl
794  << " p.z() = " << p.z()/mm << " mm";
795  message.precision(oldprc) ;
796  G4Exception("G4Ellipsoid::DistanceToOut(p)", "GeomSolids1002",
797  JustWarning, message);
798  }
799 #endif
800 
801  // Normal vector: parallel to normal, magnitude 1/(characteristic radius)
802  //
804  p.y()/(ySemiAxis*ySemiAxis),
805  p.z()/(zSemiAxis*zSemiAxis));
806 
807  // the following is a safe inlined "radius= min(1.0/norm.mag(),p.mag())
808  //
809  G4double radius= p.mag();
810  G4double tmp= norm.mag();
811  if ( (tmp > 0.0) && (1.0 < radius*tmp) ) {radius = 1.0/tmp;}
812 
813  // Approximate distance to curved surface ( <= actual distance )
814  //
815  distR = (1.0 - p*norm) * radius / 2.0;
816 
817  // Distance to z-cut plane
818  //
819  distZ = p.z() - zBottomCut;
820  if (distZ < 0.0) {distZ= zTopCut - p.z();}
821 
822  // Distance to closest surface from inside
823  //
824  if ( (distZ < 0.0) || (distR < 0.0) )
825  {
826  return 0.0;
827  }
828  else
829  {
830  return (distZ < distR) ? distZ : distR;
831  }
832 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
Float_t tmp
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
Float_t norm
int G4int
Definition: G4Types.hh:78
void DumpInfo() const
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
EInside Inside(const G4ThreeVector &p) const
Definition: G4Ellipsoid.cc:445
double mag() const
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double x() const
double y() const
double z() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const double mm
Definition: G4SIunits.hh:114
Here is the call graph for this function:

◆ GetCubicVolume()

G4double G4Ellipsoid::GetCubicVolume ( )
inlinevirtual

Reimplemented from G4VSolid.

◆ GetEntityType()

G4GeometryType G4Ellipsoid::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 962 of file G4Ellipsoid.cc.

963 {
964  return G4String("G4Ellipsoid");
965 }

◆ GetExtent()

G4VisExtent G4Ellipsoid::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1078 of file G4Ellipsoid.cc.

1079 {
1080  // Define the sides of the box into which the G4Ellipsoid instance would fit.
1081  //
1085 }
G4double semiAxisMax
Definition: G4Ellipsoid.hh:146

◆ GetPointOnSurface()

G4ThreeVector G4Ellipsoid::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1005 of file G4Ellipsoid.cc.

1006 {
1007  G4double aTop, aBottom, aCurved, chose, xRand, yRand, zRand, phi;
1008  G4double cosphi, sinphi, costheta, sintheta, alpha, beta, max1, max2, max3;
1009 
1010  max1 = xSemiAxis > ySemiAxis ? xSemiAxis : ySemiAxis;
1011  max1 = max1 > zSemiAxis ? max1 : zSemiAxis;
1012  if (max1 == xSemiAxis) { max2 = ySemiAxis; max3 = zSemiAxis; }
1013  else if (max1 == ySemiAxis) { max2 = xSemiAxis; max3 = zSemiAxis; }
1014  else { max2 = xSemiAxis; max3 = ySemiAxis; }
1015 
1016  phi = G4RandFlat::shoot(0.,twopi);
1017 
1018  cosphi = std::cos(phi); sinphi = std::sin(phi);
1020  sintheta = std::sqrt(1.-sqr(costheta));
1021 
1022  alpha = 1.-sqr(max2/max1); beta = 1.-sqr(max3/max1);
1023 
1024  aTop = pi*xSemiAxis*ySemiAxis*(1 - sqr(zTopCut/zSemiAxis));
1025  aBottom = pi*xSemiAxis*ySemiAxis*(1 - sqr(zBottomCut/zSemiAxis));
1026 
1027  // approximation
1028  // from:" http://www.citr.auckland.ac.nz/techreports/2004/CITR-TR-139.pdf"
1029  aCurved = 4.*pi*max1*max2*(1.-1./6.*(alpha+beta)-
1030  1./120.*(3.*sqr(alpha)+2.*alpha*beta+3.*sqr(beta)));
1031 
1032  aCurved *= 0.5*(1.2*zTopCut/zSemiAxis - 1.2*zBottomCut/zSemiAxis);
1033 
1034  if( ( zTopCut >= zSemiAxis && zBottomCut <= -1.*zSemiAxis )
1035  || ( zTopCut == 0 && zBottomCut ==0 ) )
1036  {
1037  aTop = 0; aBottom = 0;
1038  }
1039 
1040  chose = G4RandFlat::shoot(0.,aTop + aBottom + aCurved);
1041 
1042  if(chose < aCurved)
1043  {
1044  xRand = xSemiAxis*sintheta*cosphi;
1045  yRand = ySemiAxis*sintheta*sinphi;
1046  zRand = zSemiAxis*costheta;
1047  return G4ThreeVector (xRand,yRand,zRand);
1048  }
1049  else if(chose >= aCurved && chose < aCurved + aTop)
1050  {
1051  xRand = G4RandFlat::shoot(-1.,1.)*xSemiAxis
1052  * std::sqrt(1-sqr(zTopCut/zSemiAxis));
1053  yRand = G4RandFlat::shoot(-1.,1.)*ySemiAxis
1054  * std::sqrt(1.-sqr(zTopCut/zSemiAxis)-sqr(xRand/xSemiAxis));
1055  zRand = zTopCut;
1056  return G4ThreeVector (xRand,yRand,zRand);
1057  }
1058  else
1059  {
1060  xRand = G4RandFlat::shoot(-1.,1.)*xSemiAxis
1061  * std::sqrt(1-sqr(zBottomCut/zSemiAxis));
1062  yRand = G4RandFlat::shoot(-1.,1.)*ySemiAxis
1063  * std::sqrt(1.-sqr(zBottomCut/zSemiAxis)-sqr(xRand/xSemiAxis));
1064  zRand = zBottomCut;
1065  return G4ThreeVector (xRand,yRand,zRand);
1066  }
1067 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
ThreeVector shoot(const G4int Ap, const G4int Af)
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
CLHEP::Hep3Vector G4ThreeVector
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
static const double twopi
Definition: G4SIunits.hh:75
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
static const double pi
Definition: G4SIunits.hh:74
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
static const G4double alpha
static int max3(int a, int b, int c)
Here is the call graph for this function:

◆ GetPolyhedron()

G4Polyhedron * G4Ellipsoid::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1093 of file G4Ellipsoid.cc.

1094 {
1095  if (!fpPolyhedron ||
1099  {
1100  G4AutoLock l(&polyhedronMutex);
1101  delete fpPolyhedron;
1103  fRebuildPolyhedron = false;
1104  l.unlock();
1105  }
1106  return fpPolyhedron;
1107 }
G4bool fRebuildPolyhedron
Definition: G4Ellipsoid.hh:136
G4Polyhedron * CreatePolyhedron() const
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4Polyhedron * fpPolyhedron
Definition: G4Ellipsoid.hh:137
static G4int GetNumberOfRotationSteps()
Here is the call graph for this function:

◆ GetSemiAxisMax()

G4double G4Ellipsoid::GetSemiAxisMax ( G4int  i) const
inline
Here is the caller graph for this function:

◆ GetSurfaceArea()

G4double G4Ellipsoid::GetSurfaceArea ( )
inlinevirtual

Reimplemented from G4VSolid.

◆ GetZBottomCut()

G4double G4Ellipsoid::GetZBottomCut ( ) const
inline
Here is the caller graph for this function:

◆ GetZTopCut()

G4double G4Ellipsoid::GetZTopCut ( ) const
inline
Here is the caller graph for this function:

◆ Inside()

EInside G4Ellipsoid::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 445 of file G4Ellipsoid.cc.

446 {
447  G4double rad2oo, // outside surface outer tolerance
448  rad2oi; // outside surface inner tolerance
449  EInside in;
450 
451  // check this side of z cut first, because that's fast
452  //
453  if (p.z() < zBottomCut-halfRadTolerance) { return in=kOutside; }
454  if (p.z() > zTopCut+halfRadTolerance) { return in=kOutside; }
455 
456  rad2oo= sqr(p.x()/(xSemiAxis+halfRadTolerance))
458  + sqr(p.z()/(zSemiAxis+halfRadTolerance));
459 
460  if (rad2oo > 1.0) { return in=kOutside; }
461 
462  rad2oi= sqr(p.x()*(1.0+halfRadTolerance/xSemiAxis)/xSemiAxis)
465 
466  // Check radial surfaces
467  // sets `in' (already checked for rad2oo > 1.0)
468  //
469  if (rad2oi < 1.0)
470  {
471  in = ( (p.z() < zBottomCut+halfRadTolerance)
472  || (p.z() > zTopCut-halfRadTolerance) ) ? kSurface : kInside;
473  if ( rad2oi > 1.0-halfRadTolerance ) { in=kSurface; }
474  }
475  else
476  {
477  in = kSurface;
478  }
479  return in;
480 
481 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double halfRadTolerance
Definition: G4Ellipsoid.hh:142
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
ifstream in
Definition: comparison.C:7
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
double x() const
double y() const
EInside
Definition: geomdefs.hh:58
double z() const
T sqr(const T &x)
Definition: templates.hh:145
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

G4Ellipsoid & G4Ellipsoid::operator= ( const G4Ellipsoid rhs)

Definition at line 157 of file G4Ellipsoid.cc.

158 {
159  // Check assignment to self
160  //
161  if (this == &rhs) { return *this; }
162 
163  // Copy base class data
164  //
165  G4VSolid::operator=(rhs);
166 
167  // Copy data
168  //
173  xSemiAxis = rhs.xSemiAxis; ySemiAxis = rhs.ySemiAxis;
175  zBottomCut = rhs.zBottomCut; zTopCut = rhs.zTopCut;
176  fRebuildPolyhedron = false;
177  delete fpPolyhedron; fpPolyhedron = 0;
178 
179  return *this;
180 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double halfRadTolerance
Definition: G4Ellipsoid.hh:142
G4double fSurfaceArea
Definition: G4Ellipsoid.hh:145
G4bool fRebuildPolyhedron
Definition: G4Ellipsoid.hh:136
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double kRadTolerance
Definition: G4Ellipsoid.hh:141
G4double semiAxisMax
Definition: G4Ellipsoid.hh:146
G4Polyhedron * fpPolyhedron
Definition: G4Ellipsoid.hh:137
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
G4double fCubicVolume
Definition: G4Ellipsoid.hh:144
G4double halfCarTolerance
Definition: G4Ellipsoid.hh:142
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:110
Here is the call graph for this function:

◆ SetSemiAxis()

void G4Ellipsoid::SetSemiAxis ( G4double  x,
G4double  y,
G4double  z 
)
inline
Here is the caller graph for this function:

◆ SetZCuts()

void G4Ellipsoid::SetZCuts ( G4double  newzBottomCut,
G4double  newzTopCut 
)
inline
Here is the caller graph for this function:

◆ StreamInfo()

std::ostream & G4Ellipsoid::StreamInfo ( std::ostream &  os) const
virtual

Implements G4VSolid.

Definition at line 980 of file G4Ellipsoid.cc.

981 {
982  G4int oldprc = os.precision(16);
983  os << "-----------------------------------------------------------\n"
984  << " *** Dump for solid - " << GetName() << " ***\n"
985  << " ===================================================\n"
986  << " Solid type: G4Ellipsoid\n"
987  << " Parameters: \n"
988 
989  << " semi-axis x: " << xSemiAxis/mm << " mm \n"
990  << " semi-axis y: " << ySemiAxis/mm << " mm \n"
991  << " semi-axis z: " << zSemiAxis/mm << " mm \n"
992  << " max semi-axis: " << semiAxisMax/mm << " mm \n"
993  << " lower cut plane level z: " << zBottomCut/mm << " mm \n"
994  << " upper cut plane level z: " << zTopCut/mm << " mm \n"
995  << "-----------------------------------------------------------\n";
996  os.precision(oldprc);
997 
998  return os;
999 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
int G4int
Definition: G4Types.hh:78
G4String GetName() const
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double semiAxisMax
Definition: G4Ellipsoid.hh:146
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
static const double mm
Definition: G4SIunits.hh:114
Here is the call graph for this function:

◆ SurfaceNormal()

G4ThreeVector G4Ellipsoid::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 487 of file G4Ellipsoid.cc.

488 {
489  G4double distR, distZBottom, distZTop;
490 
491  // normal vector with special magnitude: parallel to normal, units 1/length
492  // norm*p == 1.0 if on surface, >1.0 if outside, <1.0 if inside
493  //
495  p.y()/(ySemiAxis*ySemiAxis),
496  p.z()/(zSemiAxis*zSemiAxis));
497  G4double radius = 1.0/norm.mag();
498 
499  // approximate distance to curved surface
500  //
501  distR = std::fabs( (p*norm - 1.0) * radius ) / 2.0;
502 
503  // Distance to z-cut plane
504  //
505  distZBottom = std::fabs( p.z() - zBottomCut );
506  distZTop = std::fabs( p.z() - zTopCut );
507 
508  if ( (distZBottom < distR) || (distZTop < distR) )
509  {
510  return G4ThreeVector(0.,0.,(distZBottom < distZTop) ? -1.0 : 1.0);
511  }
512  return ( norm *= radius );
513 }
G4double zSemiAxis
Definition: G4Ellipsoid.hh:146
G4double zTopCut
Definition: G4Ellipsoid.hh:146
G4double xSemiAxis
Definition: G4Ellipsoid.hh:146
CLHEP::Hep3Vector G4ThreeVector
Float_t norm
G4double ySemiAxis
Definition: G4Ellipsoid.hh:146
G4double zBottomCut
Definition: G4Ellipsoid.hh:146
double x() const
double y() const
double z() const
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fCubicVolume

G4double G4Ellipsoid::fCubicVolume
private

Definition at line 144 of file G4Ellipsoid.hh.

◆ fpPolyhedron

G4Polyhedron* G4Ellipsoid::fpPolyhedron
mutableprotected

Definition at line 137 of file G4Ellipsoid.hh.

◆ fRebuildPolyhedron

G4bool G4Ellipsoid::fRebuildPolyhedron
mutableprotected

Definition at line 136 of file G4Ellipsoid.hh.

◆ fSurfaceArea

G4double G4Ellipsoid::fSurfaceArea
private

Definition at line 145 of file G4Ellipsoid.hh.

◆ halfCarTolerance

G4double G4Ellipsoid::halfCarTolerance
private

Definition at line 142 of file G4Ellipsoid.hh.

◆ halfRadTolerance

G4double G4Ellipsoid::halfRadTolerance
private

Definition at line 142 of file G4Ellipsoid.hh.

◆ kRadTolerance

G4double G4Ellipsoid::kRadTolerance
private

Definition at line 141 of file G4Ellipsoid.hh.

◆ semiAxisMax

G4double G4Ellipsoid::semiAxisMax
private

Definition at line 146 of file G4Ellipsoid.hh.

◆ xSemiAxis

G4double G4Ellipsoid::xSemiAxis
private

Definition at line 146 of file G4Ellipsoid.hh.

◆ ySemiAxis

G4double G4Ellipsoid::ySemiAxis
private

Definition at line 146 of file G4Ellipsoid.hh.

◆ zBottomCut

G4double G4Ellipsoid::zBottomCut
private

Definition at line 146 of file G4Ellipsoid.hh.

◆ zSemiAxis

G4double G4Ellipsoid::zSemiAxis
private

Definition at line 146 of file G4Ellipsoid.hh.

◆ zTopCut

G4double G4Ellipsoid::zTopCut
private

Definition at line 146 of file G4Ellipsoid.hh.


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