Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4EllipticalTube Class Reference

#include <G4EllipticalTube.hh>

Inheritance diagram for G4EllipticalTube:
G4VSolid

Public Member Functions

void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
 
G4VSolidClone () const
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
G4PolyhedronCreatePolyhedron () const
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
 
void DumpInfo () const
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 
 G4EllipticalTube (__void__ &)
 
 G4EllipticalTube (const G4EllipticalTube &rhs)
 
 G4EllipticalTube (const G4String &name, G4double Dx, G4double Dy, G4double Dz)
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
G4double GetCubicVolume ()
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
G4double GetDx () const
 
G4double GetDy () const
 
G4double GetDz () const
 
G4GeometryType GetEntityType () const
 
G4VisExtent GetExtent () const
 
G4String GetName () const
 
G4ThreeVector GetPointOnSurface () const
 
G4PolyhedronGetPolyhedron () const
 
G4double GetSurfaceArea ()
 
G4double GetTolerance () const
 
EInside Inside (const G4ThreeVector &p) const
 
G4EllipticalTubeoperator= (const G4EllipticalTube &rhs)
 
G4bool operator== (const G4VSolid &s) const
 
void SetDx (G4double Dx)
 
void SetDy (G4double Dy)
 
void SetDz (G4double Dz)
 
void SetName (const G4String &name)
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
virtual ~G4EllipticalTube ()
 

Protected Member Functions

void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, 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 ClipCrossSection (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

G4double kCarTolerance
 

Private Member Functions

G4ThreeVector ApproxSurfaceNormal (const G4ThreeVector &p) const
 
void CheckParameters ()
 
void ClipPolygonToSimpleLimits (G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit) const
 
G4double GetCachedSurfaceArea () const
 

Private Attributes

G4double fCubicVolume = 0.0
 
G4double fDDx
 
G4double fDDy
 
G4double fDx
 
G4double fDy
 
G4double fDz
 
G4PolyhedronfpPolyhedron = nullptr
 
G4double fQ1
 
G4double fQ2
 
G4double fR
 
G4bool fRebuildPolyhedron = false
 
G4double fRsph
 
G4double fScratch
 
G4String fshapeName
 
G4double fSurfaceArea = 0.0
 
G4double fSx
 
G4double fSy
 
G4double halfTolerance
 

Detailed Description

Definition at line 60 of file G4EllipticalTube.hh.

Constructor & Destructor Documentation

◆ G4EllipticalTube() [1/3]

G4EllipticalTube::G4EllipticalTube ( const G4String name,
G4double  Dx,
G4double  Dy,
G4double  Dz 
)

Definition at line 61 of file G4EllipticalTube.cc.

65 : G4VSolid(name), fDx(Dx), fDy(Dy), fDz(Dz)
66{
68}
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:57
const char * name(G4int ptype)

References CheckParameters().

Referenced by Clone().

◆ ~G4EllipticalTube()

G4EllipticalTube::~G4EllipticalTube ( )
virtual

Definition at line 86 of file G4EllipticalTube.cc.

87{
88 delete fpPolyhedron; fpPolyhedron = nullptr;
89}
G4Polyhedron * fpPolyhedron

References fpPolyhedron.

◆ G4EllipticalTube() [2/3]

G4EllipticalTube::G4EllipticalTube ( __void__ &  a)

Definition at line 75 of file G4EllipticalTube.cc.

76 : G4VSolid(a), halfTolerance(0.), fDx(0.), fDy(0.), fDz(0.),
77 fRsph(0.), fDDx(0.), fDDy(0.), fSx(0.), fSy(0.), fR(0.),
78 fQ1(0.), fQ2(0.), fScratch(0.)
79{
80}

◆ G4EllipticalTube() [3/3]

G4EllipticalTube::G4EllipticalTube ( const G4EllipticalTube rhs)

Definition at line 95 of file G4EllipticalTube.cc.

97 fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz),
99 fRsph(rhs.fRsph), fDDx(rhs.fDDx), fDDy(rhs.fDDy),
100 fSx(rhs.fSx), fSy(rhs.fSy), fR(rhs.fR),
101 fQ1(rhs.fQ1), fQ2(rhs.fQ2), fScratch(rhs.fScratch)
102{
103}

Member Function Documentation

◆ ApproxSurfaceNormal()

G4ThreeVector G4EllipticalTube::ApproxSurfaceNormal ( const G4ThreeVector p) const
private

Definition at line 332 of file G4EllipticalTube.cc.

333{
334 G4double x = p.x() * fSx;
335 G4double y = p.y() * fSy;
336 G4double distR = fQ1 * (x * x + y * y) - fQ2;
337 G4double distZ = std::abs(p.z()) - fDz;
338 if (distR > distZ && (x * x + y * y) > 0)
339 return G4ThreeVector(p.x() * fDDy, p.y() * fDDx, 0.).unit();
340 else
341 return G4ThreeVector(0, 0, (p.z() < 0 ? -1. : 1.));
342}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
double z() const
Hep3Vector unit() const
double x() const
double y() const

References fDDx, fDDy, fDz, fQ1, fQ2, fSx, fSy, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToOut(), and SurfaceNormal().

◆ BoundingLimits()

void G4EllipticalTube::BoundingLimits ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 187 of file G4EllipticalTube.cc.

189{
190 pMin.set(-fDx,-fDy,-fDz);
191 pMax.set( fDx, fDy, fDz);
192}
static const G4double pMax
static const G4double pMin

References fDx, fDy, fDz, pMax, and pMin.

Referenced by CalculateExtent().

◆ CalculateClippedPolygonExtent()

void G4VSolid::CalculateClippedPolygonExtent ( G4ThreeVectorList pPolygon,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 489 of file G4VSolid.cc.

494{
495 G4int noLeft,i;
496 G4double component;
497
498 ClipPolygon(pPolygon,pVoxelLimit,pAxis);
499 noLeft = pPolygon.size();
500
501 if ( noLeft )
502 {
503 for (i=0; i<noLeft; ++i)
504 {
505 component = pPolygon[i].operator()(pAxis);
506
507 if (component < pMin)
508 {
509 pMin = component;
510 }
511 if (component > pMax)
512 {
513 pMax = component;
514 }
515 }
516 }
517}
int G4int
Definition: G4Types.hh:85
void ClipPolygon(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
Definition: G4VSolid.cc:539

References G4VSolid::ClipPolygon(), pMax, and pMin.

Referenced by G4VSolid::ClipBetweenSections(), and G4VSolid::ClipCrossSection().

◆ CalculateExtent()

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

Implements G4VSolid.

Definition at line 199 of file G4EllipticalTube.cc.

203{
204 G4ThreeVector bmin, bmax;
205 G4bool exist;
206
207 // Check bounding box (bbox)
208 //
209 BoundingLimits(bmin,bmax);
210 G4BoundingEnvelope bbox(bmin,bmax);
211#ifdef G4BBOX_EXTENT
212 return bbox.CalculateExtent(pAxis,pVoxelLimit, pTransform, pMin, pMax);
213#endif
214 if (bbox.BoundingBoxVsVoxelLimits(pAxis, pVoxelLimit, pTransform, pMin, pMax))
215 {
216 return exist = (pMin < pMax) ? true : false;
217 }
218
219 G4double dx = fDx;
220 G4double dy = fDy;
221 G4double dz = fDz;
222
223 // Set bounding envelope (benv) and calculate extent
224 //
225 const G4int NSTEPS = 24; // number of steps for whole circle
226 G4double ang = twopi/NSTEPS;
227
228 G4double sinHalf = std::sin(0.5*ang);
229 G4double cosHalf = std::cos(0.5*ang);
230 G4double sinStep = 2.*sinHalf*cosHalf;
231 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
232 G4double sx = dx/cosHalf;
233 G4double sy = dy/cosHalf;
234
235 G4double sinCur = sinHalf;
236 G4double cosCur = cosHalf;
237 G4ThreeVectorList baseA(NSTEPS),baseB(NSTEPS);
238 for (G4int k=0; k<NSTEPS; ++k)
239 {
240 baseA[k].set(sx*cosCur,sy*sinCur,-dz);
241 baseB[k].set(sx*cosCur,sy*sinCur, dz);
242
243 G4double sinTmp = sinCur;
244 sinCur = sinCur*cosStep + cosCur*sinStep;
245 cosCur = cosCur*cosStep - sinTmp*sinStep;
246 }
247
248 std::vector<const G4ThreeVectorList *> polygons(2);
249 polygons[0] = &baseA;
250 polygons[1] = &baseB;
251 G4BoundingEnvelope benv(bmin, bmax, polygons);
252 exist = benv.CalculateExtent(pAxis, pVoxelLimit, pTransform, pMin, pMax);
253 return exist;
254}
std::vector< G4ThreeVector > G4ThreeVectorList
static constexpr double twopi
Definition: G4SIunits.hh:56
bool G4bool
Definition: G4Types.hh:86
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const

References G4BoundingEnvelope::BoundingBoxVsVoxelLimits(), BoundingLimits(), G4BoundingEnvelope::CalculateExtent(), fDx, fDy, fDz, pMax, pMin, and twopi.

◆ CheckParameters()

void G4EllipticalTube::CheckParameters ( )
private

Definition at line 148 of file G4EllipticalTube.cc.

149{
150 // Check dimensions
151 //
152 halfTolerance = 0.5*kCarTolerance; // half tolerance
153 G4double dmin = 2*kCarTolerance;
154 if (fDx < dmin || fDy < dmin || fDz < dmin)
155 {
156 std::ostringstream message;
157 message << "Invalid (too small or negative) dimensions for Solid: "
158 << GetName()
159 << "\n Dx = " << fDx
160 << "\n Dy = " << fDy
161 << "\n Dz = " << fDz;
162 G4Exception("G4EllipticalTube::CheckParameters()", "GeomSolids0002",
163 FatalException, message);
164 }
165
166 // Set pre-calculatated values
167 //
168 halfTolerance = 0.5*kCarTolerance; // half tolerance
169 fRsph = std::sqrt(fDx * fDx + fDy * fDy + fDz * fDz); // radius of surrounding sphere
170 fDDx = fDx * fDx; // X semi-axis squared
171 fDDy = fDy * fDy; // Y semi-axis squared
172
173 fR = std::min(fDx, fDy); // resulting radius, after scaling elipse to circle
174 fSx = fR / fDx; // X scale factor
175 fSy = fR / fDy; // Y scale factor
176
177 fQ1 = 0.5 / fR; // distance approxiamtion dist = Q1 * (x^2 + y^2) - Q2
178 fQ2 = 0.5 * (fR + halfTolerance * halfTolerance / fR);
179 fScratch = 2. * fR * fR * DBL_EPSILON; // scratch within calculation error thickness
180 // fScratch = (B * B / A) * (2. + halfTolerance / A) * halfTolerance; // alternative
181}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4String GetName() const
G4double kCarTolerance
Definition: G4VSolid.hh:299
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
#define DBL_EPSILON
Definition: templates.hh:66

References DBL_EPSILON, FatalException, fDDx, fDDy, fDx, fDy, fDz, fQ1, fQ2, fR, fRsph, fScratch, fSx, fSy, G4Exception(), G4VSolid::GetName(), halfTolerance, G4VSolid::kCarTolerance, and G4INCL::Math::min().

Referenced by G4EllipticalTube().

◆ ClipBetweenSections()

void G4VSolid::ClipBetweenSections ( G4ThreeVectorList pVertices,
const G4int  pSectionIndex,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 444 of file G4VSolid.cc.

449{
450 G4ThreeVectorList polygon;
451 polygon.reserve(4);
452 polygon.push_back((*pVertices)[pSectionIndex]);
453 polygon.push_back((*pVertices)[pSectionIndex+4]);
454 polygon.push_back((*pVertices)[pSectionIndex+5]);
455 polygon.push_back((*pVertices)[pSectionIndex+1]);
456 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
457 polygon.clear();
458
459 polygon.push_back((*pVertices)[pSectionIndex+1]);
460 polygon.push_back((*pVertices)[pSectionIndex+5]);
461 polygon.push_back((*pVertices)[pSectionIndex+6]);
462 polygon.push_back((*pVertices)[pSectionIndex+2]);
463 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
464 polygon.clear();
465
466 polygon.push_back((*pVertices)[pSectionIndex+2]);
467 polygon.push_back((*pVertices)[pSectionIndex+6]);
468 polygon.push_back((*pVertices)[pSectionIndex+7]);
469 polygon.push_back((*pVertices)[pSectionIndex+3]);
470 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
471 polygon.clear();
472
473 polygon.push_back((*pVertices)[pSectionIndex+3]);
474 polygon.push_back((*pVertices)[pSectionIndex+7]);
475 polygon.push_back((*pVertices)[pSectionIndex+4]);
476 polygon.push_back((*pVertices)[pSectionIndex]);
477 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
478 return;
479}
void CalculateClippedPolygonExtent(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
Definition: G4VSolid.cc:489

References G4VSolid::CalculateClippedPolygonExtent(), pMax, and pMin.

◆ ClipCrossSection()

void G4VSolid::ClipCrossSection ( G4ThreeVectorList pVertices,
const G4int  pSectionIndex,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 414 of file G4VSolid.cc.

419{
420
421 G4ThreeVectorList polygon;
422 polygon.reserve(4);
423 polygon.push_back((*pVertices)[pSectionIndex]);
424 polygon.push_back((*pVertices)[pSectionIndex+1]);
425 polygon.push_back((*pVertices)[pSectionIndex+2]);
426 polygon.push_back((*pVertices)[pSectionIndex+3]);
427 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
428 return;
429}

References G4VSolid::CalculateClippedPolygonExtent(), pMax, and pMin.

◆ ClipPolygon()

void G4VSolid::ClipPolygon ( G4ThreeVectorList pPolygon,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis 
) const
protectedinherited

Definition at line 539 of file G4VSolid.cc.

542{
543 G4ThreeVectorList outputPolygon;
544
545 if ( pVoxelLimit.IsLimited() )
546 {
547 if (pVoxelLimit.IsXLimited() ) // && pAxis != kXAxis)
548 {
549 G4VoxelLimits simpleLimit1;
550 simpleLimit1.AddLimit(kXAxis,pVoxelLimit.GetMinXExtent(),kInfinity);
551 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
552
553 pPolygon.clear();
554
555 if ( !outputPolygon.size() ) return;
556
557 G4VoxelLimits simpleLimit2;
558 simpleLimit2.AddLimit(kXAxis,-kInfinity,pVoxelLimit.GetMaxXExtent());
559 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
560
561 if ( !pPolygon.size() ) return;
562 else outputPolygon.clear();
563 }
564 if ( pVoxelLimit.IsYLimited() ) // && pAxis != kYAxis)
565 {
566 G4VoxelLimits simpleLimit1;
567 simpleLimit1.AddLimit(kYAxis,pVoxelLimit.GetMinYExtent(),kInfinity);
568 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
569
570 // Must always clear pPolygon - for clip to simpleLimit2 and in case of
571 // early exit
572
573 pPolygon.clear();
574
575 if ( !outputPolygon.size() ) return;
576
577 G4VoxelLimits simpleLimit2;
578 simpleLimit2.AddLimit(kYAxis,-kInfinity,pVoxelLimit.GetMaxYExtent());
579 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
580
581 if ( !pPolygon.size() ) return;
582 else outputPolygon.clear();
583 }
584 if ( pVoxelLimit.IsZLimited() ) // && pAxis != kZAxis)
585 {
586 G4VoxelLimits simpleLimit1;
587 simpleLimit1.AddLimit(kZAxis,pVoxelLimit.GetMinZExtent(),kInfinity);
588 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
589
590 // Must always clear pPolygon - for clip to simpleLimit2 and in case of
591 // early exit
592
593 pPolygon.clear();
594
595 if ( !outputPolygon.size() ) return;
596
597 G4VoxelLimits simpleLimit2;
598 simpleLimit2.AddLimit(kZAxis,-kInfinity,pVoxelLimit.GetMaxZExtent());
599 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
600
601 // Return after final clip - no cleanup
602 }
603 }
604}
void ClipPolygonToSimpleLimits(G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit) const
Definition: G4VSolid.cc:612
G4bool IsYLimited() const
G4double GetMinZExtent() const
void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax)
G4bool IsXLimited() const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4bool IsLimited() const
G4double GetMaxXExtent() const
@ kYAxis
Definition: geomdefs.hh:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57
static const G4double kInfinity
Definition: geomdefs.hh:41

References G4VoxelLimits::AddLimit(), G4VSolid::ClipPolygonToSimpleLimits(), G4VoxelLimits::GetMaxXExtent(), G4VoxelLimits::GetMaxYExtent(), G4VoxelLimits::GetMaxZExtent(), G4VoxelLimits::GetMinXExtent(), G4VoxelLimits::GetMinYExtent(), G4VoxelLimits::GetMinZExtent(), G4VoxelLimits::IsLimited(), G4VoxelLimits::IsXLimited(), G4VoxelLimits::IsYLimited(), G4VoxelLimits::IsZLimited(), kInfinity, kXAxis, kYAxis, and kZAxis.

Referenced by G4VSolid::CalculateClippedPolygonExtent().

◆ ClipPolygonToSimpleLimits()

void G4VSolid::ClipPolygonToSimpleLimits ( G4ThreeVectorList pPolygon,
G4ThreeVectorList outputPolygon,
const G4VoxelLimits pVoxelLimit 
) const
privateinherited

Definition at line 612 of file G4VSolid.cc.

615{
616 G4int i;
617 G4int noVertices=pPolygon.size();
618 G4ThreeVector vEnd,vStart;
619
620 for (i = 0 ; i < noVertices ; ++i )
621 {
622 vStart = pPolygon[i];
623 if ( i == noVertices-1 ) vEnd = pPolygon[0];
624 else vEnd = pPolygon[i+1];
625
626 if ( pVoxelLimit.Inside(vStart) )
627 {
628 if (pVoxelLimit.Inside(vEnd))
629 {
630 // vStart and vEnd inside -> output end point
631 //
632 outputPolygon.push_back(vEnd);
633 }
634 else
635 {
636 // vStart inside, vEnd outside -> output crossing point
637 //
638 pVoxelLimit.ClipToLimits(vStart,vEnd);
639 outputPolygon.push_back(vEnd);
640 }
641 }
642 else
643 {
644 if (pVoxelLimit.Inside(vEnd))
645 {
646 // vStart outside, vEnd inside -> output inside section
647 //
648 pVoxelLimit.ClipToLimits(vStart,vEnd);
649 outputPolygon.push_back(vStart);
650 outputPolygon.push_back(vEnd);
651 }
652 else // Both point outside -> no output
653 {
654 // outputPolygon.push_back(vStart);
655 // outputPolygon.push_back(vEnd);
656 }
657 }
658 }
659}
G4bool ClipToLimits(G4ThreeVector &pStart, G4ThreeVector &pEnd) const
G4bool Inside(const G4ThreeVector &pVec) const

References G4VoxelLimits::ClipToLimits(), and G4VoxelLimits::Inside().

Referenced by G4VSolid::ClipPolygon().

◆ Clone()

G4VSolid * G4EllipticalTube::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 629 of file G4EllipticalTube.cc.

630{
631 return new G4EllipticalTube(*this);
632}
G4EllipticalTube(const G4String &name, G4double Dx, G4double Dy, G4double Dz)

References G4EllipticalTube().

◆ ComputeDimensions()

void G4VSolid::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtualinherited

◆ CreatePolyhedron()

G4Polyhedron * G4EllipticalTube::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 749 of file G4EllipticalTube.cc.

750{
751 // create cylinder with radius=1...
752 //
753 G4Polyhedron* eTube = new G4PolyhedronTube(0., 1., fDz);
754
755 // apply non-uniform scaling...
756 //
757 eTube->Transform(G4Scale3D(fDx, fDy, 1.));
758 return eTube;
759}
HepGeom::Scale3D G4Scale3D
HepPolyhedron & Transform(const G4Transform3D &t)

References fDx, fDy, fDz, and HepPolyhedron::Transform().

Referenced by GetPolyhedron().

◆ DescribeYourselfTo()

void G4EllipticalTube::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 785 of file G4EllipticalTube.cc.

786{
787 scene.AddSolid (*this);
788}
virtual void AddSolid(const G4Box &)=0

References G4VGraphicsScene::AddSolid().

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 433 of file G4EllipticalTube.cc.

434{
435 // safety distance to bounding box
436 G4double distX = std::abs(p.x()) - fDx;
437 G4double distY = std::abs(p.y()) - fDy;
438 G4double distZ = std::abs(p.z()) - fDz;
439 G4double distB = std::max(std::max(distX, distY), distZ);
440 // return (distB < 0) ? 0 : distB;
441
442 // safety distance to lateral surface
443 G4double x = p.x() * fSx;
444 G4double y = p.y() * fSy;
445 G4double distR = std::sqrt(x * x + y * y) - fR;
446
447 // return SafetyToIn
448 G4double dist = std::max(distB, distR);
449 return (dist < 0) ? 0 : dist;
450}
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References fDx, fDy, fDz, fR, fSx, fSy, G4INCL::Math::max(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DistanceToIn() [2/2]

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

Implements G4VSolid.

Definition at line 349 of file G4EllipticalTube.cc.

351{
352 G4double offset = 0.;
353 G4ThreeVector pcur = p;
354
355 // Check if point is flying away
356 //
357 G4double safex = std::abs(pcur.x()) - fDx;
358 G4double safey = std::abs(pcur.y()) - fDy;
359 G4double safez = std::abs(pcur.z()) - fDz;
360
361 if (safez >= -halfTolerance && pcur.z() * v.z() >= 0.) return kInfinity;
362 if (safey >= -halfTolerance && pcur.y() * v.y() >= 0.) return kInfinity;
363 if (safex >= -halfTolerance && pcur.x() * v.x() >= 0.) return kInfinity;
364
365 // Relocate point, if required
366 //
367 G4double Dmax = 32. * fRsph;
368 if (std::max(std::max(safex, safey), safez) > Dmax)
369 {
370 offset = (1. - 1.e-08) * pcur.mag() - 2. * fRsph;
371 pcur += offset * v;
372 G4double dist = DistanceToIn(pcur, v);
373 return (dist == kInfinity) ? kInfinity : dist + offset;
374 }
375
376 // Scale elliptical tube to cylinder
377 //
378 G4double px = pcur.x() * fSx;
379 G4double py = pcur.y() * fSy;
380 G4double pz = pcur.z();
381 G4double vx = v.x() * fSx;
382 G4double vy = v.y() * fSy;
383 G4double vz = v.z();
384
385 // Set coefficients of quadratic equation: A t^2 + 2B t + C = 0
386 //
387 G4double rr = px * px + py * py;
388 G4double A = vx * vx + vy * vy;
389 G4double B = px * vx + py * vy;
390 G4double C = rr - fR * fR;
391 G4double D = B * B - A * C;
392
393 // Check if point is flying away relative to lateral surface
394 //
395 G4double distR = fQ1 * rr - fQ2;
396 G4bool parallelToZ = (A < DBL_EPSILON || std::abs(vz) >= 1.);
397 if (distR >= -halfTolerance && (B >= 0. || parallelToZ)) return kInfinity;
398
399 // Find intersection with Z planes
400 //
401 G4double invz = (vz == 0) ? DBL_MAX : -1./vz;
402 G4double dz = std::copysign(fDz, invz);
403 G4double tzmin = (pz - dz) * invz;
404 G4double tzmax = (pz + dz) * invz;
405
406 // Solve qudratic equation. There are two cases special where D <= 0:
407 // 1) trajectory parallel to Z axis (A = 0, B = 0, C - any, D = 0)
408 // 2) touch (D = 0) or no intersection (D < 0) with lateral surface
409 //
410 if (parallelToZ) return (tzmin<halfTolerance) ? offset : tzmin + offset; // 1)
411 if (D <= A * A * fScratch) return kInfinity; // 2)
412
413 // Find roots of quadratic equation
414 G4double tmp = -B - std::copysign(std::sqrt(D), B);
415 G4double t1 = tmp / A;
416 G4double t2 = C / tmp;
417 G4double trmin = std::min(t1, t2);
418 G4double trmax = std::max(t1, t2);
419
420 // Return distance
421 G4double tin = std::max(tzmin, trmin);
422 G4double tout = std::min(tzmax, trmax);
423
424 if (tout <= tin + halfTolerance) return kInfinity; // touch or no hit
425 return (tin<halfTolerance) ? offset : tin + offset;
426}
G4double C(G4double temp)
G4double B(G4double temperature)
G4double D(G4double temp)
const G4double A[17]
double mag() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
#define DBL_MAX
Definition: templates.hh:62

References A, B(), C(), D(), DBL_EPSILON, DBL_MAX, DistanceToIn(), fDx, fDy, fDz, fQ1, fQ2, fR, fRsph, fScratch, fSx, fSy, halfTolerance, kInfinity, CLHEP::Hep3Vector::mag(), G4INCL::Math::max(), G4INCL::Math::min(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToIn().

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Definition at line 585 of file G4EllipticalTube.cc.

586{
587#ifdef G4SPECDEBUG
588 if( Inside(p) == kOutside )
589 {
590 std::ostringstream message;
591 G4int oldprc = message.precision(16);
592 message << "Point p is outside (!?) of solid: " << GetName() << "\n"
593 << "Position:\n"
594 << " p.x() = " << p.x()/mm << " mm\n"
595 << " p.y() = " << p.y()/mm << " mm\n"
596 << " p.z() = " << p.z()/mm << " mm";
597 message.precision(oldprc) ;
598 G4Exception("G4ElliptocalTube::DistanceToOut(p)", "GeomSolids1002",
599 JustWarning, message);
600 DumpInfo();
601 }
602#endif
603 // safety distance to Z-bases
604 G4double distZ = fDz - std::abs(p.z());
605
606 // safety distance lateral surface
607 G4double x = p.x() * fSx;
608 G4double y = p.y() * fSy;
609 G4double distR = fR - std::sqrt(x * x + y * y);
610
611 // return SafetyToOut
612 G4double dist = std::min(distZ, distR);
613 return (dist < 0) ? 0 : dist;
614}
@ JustWarning
static constexpr double mm
Definition: G4SIunits.hh:95
EInside Inside(const G4ThreeVector &p) const
void DumpInfo() const
@ kOutside
Definition: geomdefs.hh:68

References G4VSolid::DumpInfo(), fDz, fR, fSx, fSy, G4Exception(), G4VSolid::GetName(), Inside(), JustWarning, kOutside, G4INCL::Math::min(), mm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 458 of file G4EllipticalTube.cc.

463{
464 // Check if point flying away relative to Z planes
465 //
466 G4double pz = p.z();
467 G4double vz = v.z();
468 G4double distZ = std::abs(pz) - fDz;
469 if (distZ >= -halfTolerance && pz * vz > 0)
470 {
471 if (calcNorm)
472 {
473 *validNorm = true;
474 n->set(0, 0, (pz < 0) ? -1. : 1.);
475 }
476 return 0.;
477 }
478 G4double tzmax = (vz == 0) ? DBL_MAX : (std::copysign(fDz, vz) - pz) / vz;
479
480 // Scale elliptical tube to cylinder
481 //
482 G4double px = p.x() * fSx;
483 G4double py = p.y() * fSy;
484 G4double vx = v.x() * fSx;
485 G4double vy = v.y() * fSy;
486
487 // Check if point is flying away relative to lateral surface
488 //
489 G4double rr = px * px + py * py;
490 G4double B = px * vx + py * vy;
491 G4double distR = fQ1 * rr - fQ2;
492 if (distR >= -halfTolerance && B > 0.)
493 {
494 if (calcNorm)
495 {
496 *validNorm = true;
497 *n = G4ThreeVector(px * fDDy, py * fDDx, 0.).unit();
498 }
499 return 0.;
500 }
501
502 // Just in case check if point is outside, normally it should never be
503 //
504 if (std::max(distZ, distR) > halfTolerance)
505 {
506#ifdef G4SPECDEBUG
507 std::ostringstream message;
508 G4int oldprc = message.precision(16);
509 message << "Point p is outside (!?) of solid: "
510 << GetName() << G4endl;
511 message << "Position: " << p << G4endl;;
512 message << "Direction: " << v;
513 G4cout.precision(oldprc);
514 G4Exception("G4EllipticalTube::DistanceToOut(p,v)", "GeomSolids1002",
515 JustWarning, message );
516 DumpInfo();
517#endif
518 if (calcNorm)
519 {
520 *validNorm = true;
522 }
523 return 0.;
524 }
525
526 // Set coefficients of quadratic equation: A t^2 + 2B t + C = 0
527 //
528 G4double A = vx * vx + vy * vy;
529 G4double C = rr - fR * fR;
530 G4double D = B * B - A * C;
531
532 // Solve qudratic equation. There are two special cases where D <= 0:
533 // 1) trajectory parallel to Z axis (A = 0, B = 0, C - any, D = 0)
534 // 2) touch (D = 0) or no intersection (D < 0) with lateral surface
535 //
536 G4bool parallelToZ = (A < DBL_EPSILON || std::abs(vz) >= 1.);
537 if (parallelToZ) // 1)
538 {
539 if (calcNorm)
540 {
541 *validNorm = true;
542 n->set(0, 0, (vz < 0) ? -1. : 1.);
543 }
544 return tzmax;
545 }
546 if (D <= A * A * fScratch) // 2)
547 {
548 if (calcNorm)
549 {
550 *validNorm = true;
551 *n = G4ThreeVector(px * fDDy, py * fDDx, 0.).unit();
552 }
553 return 0.;
554 }
555
556 // Find roots of quadratic equation
557 G4double tmp = -B - std::copysign(std::sqrt(D), B);
558 G4double t1 = tmp / A;
559 G4double t2 = C / tmp;
560 G4double trmax = std::max(t1, t2);
561
562 // Return distance
563 G4double tmax = std::min(tzmax, trmax);
564
565 // Set normal, if required, and return distance
566 //
567 if (calcNorm)
568 {
569 *validNorm = true;
570 G4ThreeVector pnew = p + tmax * v;
571 if (tmax == tzmax)
572 n->set(0, 0, (pnew.z() < 0) ? -1. : 1.);
573 else
574 *n = G4ThreeVector(pnew.x() * fDDy, pnew.y() * fDDx, 0.).unit();
575 }
576 return tmax;
577}
G4GLOB_DLL std::ostream G4cout
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const

References A, ApproxSurfaceNormal(), B(), C(), D(), DBL_EPSILON, DBL_MAX, G4VSolid::DumpInfo(), fDDx, fDDy, fDz, fQ1, fQ2, fR, fScratch, fSx, fSy, G4cout, G4endl, G4Exception(), G4VSolid::GetName(), halfTolerance, JustWarning, G4INCL::Math::max(), G4INCL::Math::min(), CLHEP::detail::n, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DumpInfo()

void G4VSolid::DumpInfo ( ) const
inlineinherited

Referenced by G4Cons::ApproxSurfaceNormal(), G4CutTubs::ApproxSurfaceNormal(), G4Sphere::ApproxSurfaceNormal(), G4Torus::ApproxSurfaceNormal(), G4Tubs::ApproxSurfaceNormal(), G4ReflectedSolid::BoundingLimits(), G4DisplacedSolid::BoundingLimits(), G4IntersectionSolid::BoundingLimits(), G4ScaledSolid::BoundingLimits(), G4SubtractionSolid::BoundingLimits(), G4UnionSolid::BoundingLimits(), G4Box::BoundingLimits(), G4Cons::BoundingLimits(), G4CutTubs::BoundingLimits(), G4Orb::BoundingLimits(), G4Para::BoundingLimits(), G4Sphere::BoundingLimits(), G4Torus::BoundingLimits(), G4Trap::BoundingLimits(), G4Trd::BoundingLimits(), G4Tubs::BoundingLimits(), G4EllipticalCone::BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), G4Hype::BoundingLimits(), G4Paraboloid::BoundingLimits(), G4Polycone::BoundingLimits(), G4Polyhedra::BoundingLimits(), G4TessellatedSolid::BoundingLimits(), G4TwistedTubs::BoundingLimits(), G4ParameterisationBoxX::ComputeDimensions(), G4ParameterisationBoxY::ComputeDimensions(), G4ParameterisationBoxZ::ComputeDimensions(), G4ParameterisationConsRho::ComputeDimensions(), G4ParameterisationConsPhi::ComputeDimensions(), G4ParameterisationConsZ::ComputeDimensions(), G4ParameterisationParaX::ComputeDimensions(), G4ParameterisationParaY::ComputeDimensions(), G4ParameterisationParaZ::ComputeDimensions(), G4ParameterisationPolyconeRho::ComputeDimensions(), G4ParameterisationPolyconePhi::ComputeDimensions(), G4ParameterisationPolyconeZ::ComputeDimensions(), G4ParameterisationPolyhedraRho::ComputeDimensions(), G4ParameterisationPolyhedraPhi::ComputeDimensions(), G4ParameterisationPolyhedraZ::ComputeDimensions(), G4ParameterisationTrdX::ComputeDimensions(), G4ParameterisationTrdY::ComputeDimensions(), G4ParameterisationTrdZ::ComputeDimensions(), G4ParameterisationTubsRho::ComputeDimensions(), G4ParameterisationTubsPhi::ComputeDimensions(), G4ParameterisationTubsZ::ComputeDimensions(), G4ReflectedSolid::ComputeDimensions(), G4DisplacedSolid::ComputeDimensions(), G4ScaledSolid::ComputeDimensions(), G4ParameterisedNavigation::ComputeStep(), G4ReplicaNavigation::ComputeStep(), G4DisplacedSolid::CreatePolyhedron(), G4ScaledSolid::CreatePolyhedron(), G4SubtractionSolid::DistanceToIn(), G4Box::DistanceToOut(), G4Orb::DistanceToOut(), G4Para::DistanceToOut(), G4Trap::DistanceToOut(), G4Trd::DistanceToOut(), G4Paraboloid::DistanceToOut(), G4VTwistedFaceted::DistanceToOut(), G4Cons::DistanceToOut(), G4CutTubs::DistanceToOut(), G4Sphere::DistanceToOut(), G4Torus::DistanceToOut(), G4Tubs::DistanceToOut(), G4Ellipsoid::DistanceToOut(), G4EllipticalCone::DistanceToOut(), DistanceToOut(), G4GenericTrap::DistanceToOut(), export_G4VSolid(), G4Polycone::G4Polycone(), G4Polyhedra::G4Polyhedra(), G4BooleanSolid::GetConstituentSolid(), G4NavigationLogger::PostComputeStepLog(), G4Box::SurfaceNormal(), G4Para::SurfaceNormal(), G4Trap::SurfaceNormal(), G4Trd::SurfaceNormal(), G4Ellipsoid::SurfaceNormal(), G4EllipticalCone::SurfaceNormal(), SurfaceNormal(), G4ExtrudedSolid::SurfaceNormal(), and G4Tet::SurfaceNormal().

◆ EstimateCubicVolume()

G4double G4VSolid::EstimateCubicVolume ( G4int  nStat,
G4double  epsilon 
) const
inherited

Definition at line 203 of file G4VSolid.cc.

204{
205 G4int iInside=0;
206 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,volume,halfepsilon;
208 EInside in;
209
210 // values needed for CalculateExtent signature
211
212 G4VoxelLimits limit; // Unlimited
213 G4AffineTransform origin;
214
215 // min max extents of pSolid along X,Y,Z
216
217 CalculateExtent(kXAxis,limit,origin,minX,maxX);
218 CalculateExtent(kYAxis,limit,origin,minY,maxY);
219 CalculateExtent(kZAxis,limit,origin,minZ,maxZ);
220
221 // limits
222
223 if(nStat < 100) nStat = 100;
224 if(epsilon > 0.01) epsilon = 0.01;
225 halfepsilon = 0.5*epsilon;
226
227 for(auto i = 0; i < nStat; ++i )
228 {
229 px = minX-halfepsilon+(maxX-minX+epsilon)*G4QuickRand();
230 py = minY-halfepsilon+(maxY-minY+epsilon)*G4QuickRand();
231 pz = minZ-halfepsilon+(maxZ-minZ+epsilon)*G4QuickRand();
232 p = G4ThreeVector(px,py,pz);
233 in = Inside(p);
234 if(in != kOutside) ++iInside;
235 }
236 volume = (maxX-minX+epsilon)*(maxY-minY+epsilon)
237 * (maxZ-minZ+epsilon)*iInside/nStat;
238 return volume;
239}
G4double epsilon(G4double density, G4double temperature)
static const G4int maxZ
G4double G4QuickRand()
Definition: G4QuickRand.hh:34
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
virtual EInside Inside(const G4ThreeVector &p) const =0
EInside
Definition: geomdefs.hh:67

References G4VSolid::CalculateExtent(), epsilon(), G4QuickRand(), G4VSolid::Inside(), kOutside, kXAxis, kYAxis, kZAxis, and maxZ.

Referenced by G4VSolid::GetCubicVolume(), G4BooleanSolid::GetCubicVolume(), and G4VCSGfaceted::GetCubicVolume().

◆ EstimateSurfaceArea()

G4double G4VSolid::EstimateSurfaceArea ( G4int  nStat,
G4double  ell 
) const
inherited

Definition at line 265 of file G4VSolid.cc.

266{
267 static const G4double s2 = 1./std::sqrt(2.);
268 static const G4double s3 = 1./std::sqrt(3.);
269 static const G4ThreeVector directions[64] =
270 {
271 G4ThreeVector( 0, 0, 0), G4ThreeVector( -1, 0, 0), // ( , , ) ( -, , )
272 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +, , ) (-+, , )
273 G4ThreeVector( 0, -1, 0), G4ThreeVector(-s2,-s2, 0), // ( , -, ) ( -, -, )
274 G4ThreeVector( s2, -s2, 0), G4ThreeVector( 0, -1, 0), // ( +, -, ) (-+, -, )
275
276 G4ThreeVector( 0, 1, 0), G4ThreeVector( -s2, s2, 0), // ( , +, ) ( -, +, )
277 G4ThreeVector( s2, s2, 0), G4ThreeVector( 0, 1, 0), // ( +, +, ) (-+, +, )
278 G4ThreeVector( 0, -1, 0), G4ThreeVector( -1, 0, 0), // ( ,-+, ) ( -,-+, )
279 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +,-+, ) (-+,-+, )
280
281 G4ThreeVector( 0, 0, -1), G4ThreeVector(-s2, 0,-s2), // ( , , -) ( -, , -)
282 G4ThreeVector( s2, 0,-s2), G4ThreeVector( 0, 0, -1), // ( +, , -) (-+, , -)
283 G4ThreeVector( 0,-s2,-s2), G4ThreeVector(-s3,-s3,-s3), // ( , -, -) ( -, -, -)
284 G4ThreeVector( s3,-s3,-s3), G4ThreeVector( 0,-s2,-s2), // ( +, -, -) (-+, -, -)
285
286 G4ThreeVector( 0, s2,-s2), G4ThreeVector(-s3, s3,-s3), // ( , +, -) ( -, +, -)
287 G4ThreeVector( s3, s3,-s3), G4ThreeVector( 0, s2,-s2), // ( +, +, -) (-+, +, -)
288 G4ThreeVector( 0, 0, -1), G4ThreeVector(-s2, 0,-s2), // ( ,-+, -) ( -,-+, -)
289 G4ThreeVector( s2, 0,-s2), G4ThreeVector( 0, 0, -1), // ( +,-+, -) (-+,-+, -)
290
291 G4ThreeVector( 0, 0, 1), G4ThreeVector(-s2, 0, s2), // ( , , +) ( -, , +)
292 G4ThreeVector( s2, 0, s2), G4ThreeVector( 0, 0, 1), // ( +, , +) (-+, , +)
293 G4ThreeVector( 0,-s2, s2), G4ThreeVector(-s3,-s3, s3), // ( , -, +) ( -, -, +)
294 G4ThreeVector( s3,-s3, s3), G4ThreeVector( 0,-s2, s2), // ( +, -, +) (-+, -, +)
295
296 G4ThreeVector( 0, s2, s2), G4ThreeVector(-s3, s3, s3), // ( , +, +) ( -, +, +)
297 G4ThreeVector( s3, s3, s3), G4ThreeVector( 0, s2, s2), // ( +, +, +) (-+, +, +)
298 G4ThreeVector( 0, 0, 1), G4ThreeVector(-s2, 0, s2), // ( ,-+, +) ( -,-+, +)
299 G4ThreeVector( s2, 0, s2), G4ThreeVector( 0, 0, 1), // ( +,-+, +) (-+,-+, +)
300
301 G4ThreeVector( 0, 0, -1), G4ThreeVector( -1, 0, 0), // ( , ,-+) ( -, ,-+)
302 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +, ,-+) (-+, ,-+)
303 G4ThreeVector( 0, -1, 0), G4ThreeVector(-s2,-s2, 0), // ( , -,-+) ( -, -,-+)
304 G4ThreeVector( s2, -s2, 0), G4ThreeVector( 0, -1, 0), // ( +, -,-+) (-+, -,-+)
305
306 G4ThreeVector( 0, 1, 0), G4ThreeVector( -s2, s2, 0), // ( , +,-+) ( -, +,-+)
307 G4ThreeVector( s2, s2, 0), G4ThreeVector( 0, 1, 0), // ( +, +,-+) (-+, +,-+)
308 G4ThreeVector( 0, -1, 0), G4ThreeVector( -1, 0, 0), // ( ,-+,-+) ( -,-+,-+)
309 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +,-+,-+) (-+,-+,-+)
310 };
311
312 G4ThreeVector bmin, bmax;
313 BoundingLimits(bmin, bmax);
314
315 G4double dX = bmax.x() - bmin.x();
316 G4double dY = bmax.y() - bmin.y();
317 G4double dZ = bmax.z() - bmin.z();
318
319 // Define statistics and shell thickness
320 //
321 G4int npoints = (nstat < 1000) ? 1000 : nstat;
322 G4double coeff = 0.5 / std::cbrt(G4double(npoints));
323 G4double eps = (ell > 0) ? ell : coeff * std::min(std::min(dX, dY), dZ);
324 G4double del = 1.8 * eps; // shold be more than sqrt(3.)
325
326 G4double minX = bmin.x() - eps;
327 G4double minY = bmin.y() - eps;
328 G4double minZ = bmin.z() - eps;
329
330 G4double dd = 2. * eps;
331 dX += dd;
332 dY += dd;
333 dZ += dd;
334
335 // Calculate surface area
336 //
337 G4int icount = 0;
338 for(auto i = 0; i < npoints; ++i)
339 {
340 G4double px = minX + dX*G4QuickRand();
341 G4double py = minY + dY*G4QuickRand();
342 G4double pz = minZ + dZ*G4QuickRand();
343 G4ThreeVector p = G4ThreeVector(px, py, pz);
344 EInside in = Inside(p);
345 G4double dist = 0;
346 if (in == kInside)
347 {
348 if (DistanceToOut(p) >= eps) continue;
349 G4int icase = 0;
350 if (Inside(G4ThreeVector(px-del, py, pz)) != kInside) icase += 1;
351 if (Inside(G4ThreeVector(px+del, py, pz)) != kInside) icase += 2;
352 if (Inside(G4ThreeVector(px, py-del, pz)) != kInside) icase += 4;
353 if (Inside(G4ThreeVector(px, py+del, pz)) != kInside) icase += 8;
354 if (Inside(G4ThreeVector(px, py, pz-del)) != kInside) icase += 16;
355 if (Inside(G4ThreeVector(px, py, pz+del)) != kInside) icase += 32;
356 if (icase == 0) continue;
357 G4ThreeVector v = directions[icase];
358 dist = DistanceToOut(p, v);
359 G4ThreeVector n = SurfaceNormal(p + v*dist);
360 dist *= v.dot(n);
361 }
362 else if (in == kOutside)
363 {
364 if (DistanceToIn(p) >= eps) continue;
365 G4int icase = 0;
366 if (Inside(G4ThreeVector(px-del, py, pz)) != kOutside) icase += 1;
367 if (Inside(G4ThreeVector(px+del, py, pz)) != kOutside) icase += 2;
368 if (Inside(G4ThreeVector(px, py-del, pz)) != kOutside) icase += 4;
369 if (Inside(G4ThreeVector(px, py+del, pz)) != kOutside) icase += 8;
370 if (Inside(G4ThreeVector(px, py, pz-del)) != kOutside) icase += 16;
371 if (Inside(G4ThreeVector(px, py, pz+del)) != kOutside) icase += 32;
372 if (icase == 0) continue;
373 G4ThreeVector v = directions[icase];
374 dist = DistanceToIn(p, v);
375 if (dist == kInfinity) continue;
376 G4ThreeVector n = SurfaceNormal(p + v*dist);
377 dist *= -(v.dot(n));
378 }
379 if (dist < eps) ++icount;
380 }
381 return dX*dY*dZ*icount/npoints/dd;
382}
static const G4double eps
double dot(const Hep3Vector &) const
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4VSolid.cc:665
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
@ kInside
Definition: geomdefs.hh:70

References G4VSolid::BoundingLimits(), G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), CLHEP::Hep3Vector::dot(), eps, G4QuickRand(), G4VSolid::Inside(), kInfinity, kInside, kOutside, G4INCL::Math::min(), CLHEP::detail::n, G4VSolid::SurfaceNormal(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4VSolid::GetSurfaceArea(), G4MultiUnion::GetSurfaceArea(), and G4VCSGfaceted::GetSurfaceArea().

◆ GetCachedSurfaceArea()

G4double G4EllipticalTube::GetCachedSurfaceArea ( ) const
private

Definition at line 651 of file G4EllipticalTube.cc.

652{
653 G4ThreadLocalStatic G4double cached_Dx = 0;
654 G4ThreadLocalStatic G4double cached_Dy = 0;
655 G4ThreadLocalStatic G4double cached_Dz = 0;
656 G4ThreadLocalStatic G4double cached_area = 0;
657 if (cached_Dx != fDx || cached_Dy != fDy || cached_Dz != fDz)
658 {
659 cached_Dx = fDx;
660 cached_Dy = fDy;
661 cached_Dz = fDz;
662 cached_area = 2.*(pi*fDx*fDy + G4GeomTools::EllipsePerimeter(fDx, fDy)*fDz);
663 }
664 return cached_area;
665}
static constexpr double pi
Definition: G4SIunits.hh:55
static G4double EllipsePerimeter(G4double a, G4double b)
Definition: G4GeomTools.cc:532
#define G4ThreadLocalStatic
Definition: tls.hh:76

References G4GeomTools::EllipsePerimeter(), fDx, fDy, fDz, G4ThreadLocalStatic, and pi.

Referenced by GetPointOnSurface(), and GetSurfaceArea().

◆ GetConstituentSolid() [1/2]

G4VSolid * G4VSolid::GetConstituentSolid ( G4int  no)
virtualinherited

Reimplemented in G4BooleanSolid.

Definition at line 170 of file G4VSolid.cc.

171{ return nullptr; }

◆ GetConstituentSolid() [2/2]

const G4VSolid * G4VSolid::GetConstituentSolid ( G4int  no) const
virtualinherited

Reimplemented in G4BooleanSolid.

Definition at line 167 of file G4VSolid.cc.

168{ return nullptr; }

Referenced by G4BooleanSolid::StackPolyhedron().

◆ GetCubicVolume()

G4double G4EllipticalTube::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 638 of file G4EllipticalTube.cc.

639{
640 if (fCubicVolume == 0.)
641 {
642 fCubicVolume = twopi * fDx * fDy * fDz;
643 }
644 return fCubicVolume;
645}

References fCubicVolume, fDx, fDy, fDz, and twopi.

◆ GetDisplacedSolidPtr() [1/2]

G4DisplacedSolid * G4VSolid::GetDisplacedSolidPtr ( )
virtualinherited

Reimplemented in G4DisplacedSolid.

Definition at line 176 of file G4VSolid.cc.

177{ return nullptr; }

◆ GetDisplacedSolidPtr() [2/2]

const G4DisplacedSolid * G4VSolid::GetDisplacedSolidPtr ( ) const
virtualinherited

Reimplemented in G4DisplacedSolid.

Definition at line 173 of file G4VSolid.cc.

174{ return nullptr; }

◆ GetDx()

G4double G4EllipticalTube::GetDx ( ) const
inline

◆ GetDy()

G4double G4EllipticalTube::GetDy ( ) const
inline

◆ GetDz()

G4double G4EllipticalTube::GetDz ( ) const
inline

◆ GetEntityType()

G4GeometryType G4EllipticalTube::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 620 of file G4EllipticalTube.cc.

621{
622 return G4String("G4EllipticalTube");
623}

◆ GetExtent()

G4VisExtent G4EllipticalTube::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 794 of file G4EllipticalTube.cc.

795{
796 return G4VisExtent( -fDx, fDx, -fDy, fDy, -fDz, fDz );
797}

References fDx, fDy, and fDz.

◆ GetName()

G4String G4VSolid::GetName ( ) const
inlineinherited

Referenced by G4GMocrenFileSceneHandler::AddDetector(), G4HepRepFileSceneHandler::AddHepRepInstance(), G4GMocrenFileSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), G4VtkSceneHandler::AddSolid(), G4GDMLWriteSolids::AddSolid(), G4NavigationLogger::AlongComputeStepLog(), G4GDMLWriteSolids::BooleanWrite(), G4ReflectedSolid::BoundingLimits(), G4DisplacedSolid::BoundingLimits(), G4IntersectionSolid::BoundingLimits(), G4ScaledSolid::BoundingLimits(), G4SubtractionSolid::BoundingLimits(), G4UnionSolid::BoundingLimits(), G4Box::BoundingLimits(), G4Cons::BoundingLimits(), G4CutTubs::BoundingLimits(), G4Orb::BoundingLimits(), G4Para::BoundingLimits(), G4Sphere::BoundingLimits(), G4Torus::BoundingLimits(), G4Trap::BoundingLimits(), G4Trd::BoundingLimits(), G4Tubs::BoundingLimits(), G4EllipticalCone::BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), G4Hype::BoundingLimits(), G4Paraboloid::BoundingLimits(), G4Polycone::BoundingLimits(), G4Polyhedra::BoundingLimits(), G4TessellatedSolid::BoundingLimits(), G4TwistedTubs::BoundingLimits(), G4GDMLWriteSolids::BoxWrite(), G4ExtrudedSolid::CalculateExtent(), G4GenericPolycone::CalculateExtent(), G4Polycone::CalculateExtent(), G4Polyhedra::CalculateExtent(), G4NavigationLogger::CheckDaughterEntryPoint(), G4VDivisionParameterisation::CheckNDivAndWidth(), G4VDivisionParameterisation::CheckOffset(), G4GenericTrap::CheckOrder(), G4Para::CheckParameters(), G4Trap::CheckParameters(), G4Trd::CheckParameters(), G4Ellipsoid::CheckParameters(), CheckParameters(), G4ParameterisationPolyconeRho::CheckParametersValidity(), G4ParameterisationPolyconeZ::CheckParametersValidity(), G4ParameterisationPolyhedraRho::CheckParametersValidity(), G4ParameterisationPolyhedraPhi::CheckParametersValidity(), G4ParameterisationPolyhedraZ::CheckParametersValidity(), G4PhantomParameterisation::CheckVoxelsFillContainer(), G4GenericTrap::ComputeIsTwisted(), G4VoxelNavigation::ComputeSafety(), G4VoxelSafety::ComputeSafety(), G4NavigationLogger::ComputeSafetyLog(), G4ParameterisedNavigation::ComputeStep(), G4ReplicaNavigation::ComputeStep(), G4GDMLWriteSolids::ConeWrite(), G4Polyhedra::Create(), G4GenericPolycone::Create(), G4Polycone::Create(), G4PhysicalVolumeModel::CreateCurrentAttValues(), G4ReflectedSolid::CreatePolyhedron(), G4ReflectionFactory::CreateReflectedLV(), G4GenericTrap::CreateTessellatedSolid(), G4GDMLWriteSolids::CutTubeWrite(), G4SolidStore::DeRegister(), G4PhysicalVolumeModel::DescribeSolid(), G4SubtractionSolid::DistanceToIn(), G4Paraboloid::DistanceToIn(), G4TessellatedSolid::DistanceToIn(), G4Box::DistanceToOut(), G4Orb::DistanceToOut(), G4Para::DistanceToOut(), G4Trap::DistanceToOut(), G4Trd::DistanceToOut(), G4EllipticalCone::DistanceToOut(), G4TessellatedSolid::DistanceToOut(), G4Ellipsoid::DistanceToOut(), DistanceToOut(), G4tgbGeometryDumper::DumpMultiUnionVolume(), G4tgbGeometryDumper::DumpScaledVolume(), G4tgbGeometryDumper::DumpSolid(), G4GDMLWriteSolids::ElconeWrite(), G4GDMLWriteSolids::EllipsoidWrite(), G4GDMLWriteSolids::EltubeWrite(), G4PVDivision::ErrorInAxis(), G4ReplicatedSlice::ErrorInAxis(), export_G4VSolid(), G4Box::G4Box(), G4Cons::G4Cons(), G4CutTubs::G4CutTubs(), G4EllipticalCone::G4EllipticalCone(), G4Hype::G4Hype(), G4Para::G4Para(), G4Paraboloid::G4Paraboloid(), G4Polycone::G4Polycone(), G4Polyhedra::G4Polyhedra(), G4Sphere::G4Sphere(), G4Tet::G4Tet(), G4Trap::G4Trap(), G4Tubs::G4Tubs(), G4VParameterisationCons::G4VParameterisationCons(), G4VParameterisationPara::G4VParameterisationPara(), G4VParameterisationPolycone::G4VParameterisationPolycone(), G4VParameterisationPolyhedra::G4VParameterisationPolyhedra(), G4VParameterisationTrd::G4VParameterisationTrd(), G4VTwistedFaceted::G4VTwistedFaceted(), G4GDMLWriteSolids::GenericPolyconeWrite(), G4GDMLWriteSolids::GenTrapWrite(), G4Navigator::GetGlobalExitNormal(), G4Navigator::GetLocalExitNormal(), G4ITNavigator1::GetLocalExitNormal(), G4ITNavigator2::GetLocalExitNormal(), G4BooleanSolid::GetPointOnSurface(), G4PhantomParameterisation::GetReplicaNo(), G4GDMLWriteSolids::HypeWrite(), G4TessellatedSolid::InsideNoVoxels(), G4TessellatedSolid::InsideVoxels(), G4ITNavigator1::LocateGlobalPointAndSetup(), G4ITNavigator2::LocateGlobalPointAndSetup(), G4Navigator::LocateGlobalPointAndSetup(), G4GenericTrap::MakeDownFacet(), G4Trap::MakePlanes(), G4GenericTrap::MakeUpFacet(), G4GDMLWriteSolids::MultiUnionWrite(), G4GDMLWriteSolids::OrbWrite(), G4GDMLWriteSolids::ParaboloidWrite(), G4GDMLWriteParamvol::ParametersWrite(), G4GDMLWriteSolids::ParaWrite(), G4GDMLWriteSolids::PolyconeWrite(), G4GDMLWriteSolids::PolyhedraWrite(), G4NavigationLogger::PostComputeStepLog(), G4NavigationLogger::PreComputeStepLog(), G4NavigationLogger::PrintDaughterLog(), G4PseudoScene::ProcessVolume(), G4SolidStore::Register(), G4tgbVolumeMgr::RegisterMe(), G4NavigationLogger::ReportOutsideMother(), G4ASCIITreeSceneHandler::RequestPrimitives(), G4VSceneHandler::RequestPrimitives(), G4GenericPolycone::Reset(), G4Polyhedra::Reset(), G4VoxelSafety::SafetyForVoxelNode(), G4GDMLWriteSolids::ScaledWrite(), G4Torus::SetAllParameters(), G4Tet::SetBoundingLimits(), G4Polycone::SetOriginalParameters(), G4Polyhedra::SetOriginalParameters(), G4TessellatedSolid::SetSolidClosed(), G4Tet::SetVertices(), G4Box::SetXHalfLength(), G4Box::SetYHalfLength(), G4Box::SetZHalfLength(), G4GDMLWriteSolids::SphereWrite(), G4BooleanSolid::StackPolyhedron(), G4ReflectedSolid::StreamInfo(), G4BooleanSolid::StreamInfo(), G4DisplacedSolid::StreamInfo(), G4MultiUnion::StreamInfo(), G4ScaledSolid::StreamInfo(), G4Box::StreamInfo(), G4Cons::StreamInfo(), G4CSGSolid::StreamInfo(), G4CutTubs::StreamInfo(), G4Orb::StreamInfo(), G4Para::StreamInfo(), G4Sphere::StreamInfo(), G4Torus::StreamInfo(), G4Trap::StreamInfo(), G4Trd::StreamInfo(), G4Tubs::StreamInfo(), G4Ellipsoid::StreamInfo(), G4EllipticalCone::StreamInfo(), StreamInfo(), G4ExtrudedSolid::StreamInfo(), G4GenericPolycone::StreamInfo(), G4GenericTrap::StreamInfo(), G4Hype::StreamInfo(), G4Paraboloid::StreamInfo(), G4Polycone::StreamInfo(), G4Polyhedra::StreamInfo(), G4TessellatedSolid::StreamInfo(), G4Tet::StreamInfo(), G4TwistedBox::StreamInfo(), G4TwistedTrap::StreamInfo(), G4TwistedTrd::StreamInfo(), G4TwistedTubs::StreamInfo(), G4VCSGfaceted::StreamInfo(), G4VTwistedFaceted::StreamInfo(), G4GDMLRead::StripNames(), SubstractSolids(), G4UnionSolid::SurfaceNormal(), G4Box::SurfaceNormal(), G4Para::SurfaceNormal(), G4Trap::SurfaceNormal(), G4Trd::SurfaceNormal(), G4Ellipsoid::SurfaceNormal(), G4EllipticalCone::SurfaceNormal(), SurfaceNormal(), G4ExtrudedSolid::SurfaceNormal(), G4Tet::SurfaceNormal(), G4GDMLWriteSolids::TessellatedWrite(), G4GDMLWriteSolids::TetWrite(), G4GDMLWriteSolids::TorusWrite(), G4GDMLWriteSolids::TrapWrite(), G4GDMLWriteStructure::TraverseVolumeTree(), G4GDMLWriteSolids::TrdWrite(), G4GDMLWriteSolids::TubeWrite(), G4GDMLWriteSolids::TwistedboxWrite(), G4GDMLWriteSolids::TwistedtrapWrite(), G4GDMLWriteSolids::TwistedtrdWrite(), G4GDMLWriteSolids::TwistedtubsWrite(), G4PhysicalVolumeModel::VisitGeometryAndGetVisReps(), and G4GDMLWriteSolids::XtruWrite().

◆ GetPointOnSurface()

G4ThreeVector G4EllipticalTube::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 706 of file G4EllipticalTube.cc.

707{
708 // Select surface (0 - base at -Z, 1 - base at +Z, 2 - lateral surface)
709 //
710 G4double sbase = pi * fDx * fDy;
712 G4double select = ssurf * G4UniformRand();
713
714 G4int k = 0;
715 if (select > sbase) k = 1;
716 if (select > 2. * sbase) k = 2;
717
718 // Pick random point on selected surface (rejection sampling)
719 //
721 switch (k) {
722 case 0: // base at -Z
723 {
725 p.set(rho.x(), rho.y(), -fDz);
726 break;
727 }
728 case 1: // base at +Z
729 {
731 p.set(rho.x(), rho.y(), fDz);
732 break;
733 }
734 case 2: // lateral surface
735 {
737 p.set(rho.x(), rho.y(), (2. * G4UniformRand() - 1.) * fDz);
738 break;
739 }
740 }
741 return p;
742}
G4TwoVector G4RandomPointInEllipse(G4double a, G4double b)
G4TwoVector G4RandomPointOnEllipse(G4double a, G4double b)
#define G4UniformRand()
Definition: Randomize.hh:52
double x() const
double y() const
void set(double x, double y, double z)
G4double GetCachedSurfaceArea() const

References fDx, fDy, fDz, G4RandomPointInEllipse(), G4RandomPointOnEllipse(), G4UniformRand, GetCachedSurfaceArea(), pi, CLHEP::Hep3Vector::set(), CLHEP::Hep2Vector::x(), and CLHEP::Hep2Vector::y().

◆ GetPolyhedron()

G4Polyhedron * G4EllipticalTube::GetPolyhedron ( ) const
virtual

◆ GetSurfaceArea()

G4double G4EllipticalTube::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 671 of file G4EllipticalTube.cc.

672{
673 if(fSurfaceArea == 0.)
674 {
676 }
677 return fSurfaceArea;
678}

References fSurfaceArea, and GetCachedSurfaceArea().

◆ GetTolerance()

G4double G4VSolid::GetTolerance ( ) const
inlineinherited

◆ Inside()

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

Implements G4VSolid.

Definition at line 261 of file G4EllipticalTube.cc.

262{
263 G4double x = p.x() * fSx;
264 G4double y = p.y() * fSy;
265 G4double distR = fQ1 * (x * x + y * y) - fQ2;
266 G4double distZ = std::abs(p.z()) - fDz;
267 G4double dist = std::max(distR, distZ);
268
269 if (dist > halfTolerance) return kOutside;
270 return (dist > -halfTolerance) ? kSurface : kInside;
271}
@ kSurface
Definition: geomdefs.hh:69

References fDz, fQ1, fQ2, fSx, fSy, halfTolerance, kInside, kOutside, kSurface, G4INCL::Math::max(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToOut().

◆ operator=()

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

Definition at line 109 of file G4EllipticalTube.cc.

110{
111 // Check assignment to self
112 //
113 if (this == &rhs) { return *this; }
114
115 // Copy base class data
116 //
118
119 // Copy data
120 //
122 fDx = rhs.fDx;
123 fDy = rhs.fDy;
124 fDz = rhs.fDz;
127
128 fRsph = rhs.fRsph;
129 fDDx = rhs.fDDx;
130 fDDy = rhs.fDDy;
131 fSx = rhs.fSx;
132 fSy = rhs.fSy;
133 fR = rhs.fR;
134 fQ1 = rhs.fQ1;
135 fQ2 = rhs.fQ2;
136 fScratch = rhs.fScratch;
137
138 fRebuildPolyhedron = false;
139 delete fpPolyhedron; fpPolyhedron = nullptr;
140
141 return *this;
142}
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:107

References fCubicVolume, fDDx, fDDy, fDx, fDy, fDz, fpPolyhedron, fQ1, fQ2, fR, fRebuildPolyhedron, fRsph, fScratch, fSurfaceArea, fSx, fSy, halfTolerance, and G4VSolid::operator=().

◆ operator==()

G4bool G4VSolid::operator== ( const G4VSolid s) const
inlineinherited

◆ SetDx()

void G4EllipticalTube::SetDx ( G4double  Dx)
inline

Referenced by export_G4EllipticalTube().

◆ SetDy()

void G4EllipticalTube::SetDy ( G4double  Dy)
inline

Referenced by export_G4EllipticalTube().

◆ SetDz()

void G4EllipticalTube::SetDz ( G4double  Dz)
inline

Referenced by export_G4EllipticalTube().

◆ SetName()

void G4VSolid::SetName ( const G4String name)
inherited

◆ StreamInfo()

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

Implements G4VSolid.

Definition at line 684 of file G4EllipticalTube.cc.

685{
686 G4int oldprc = os.precision(16);
687 os << "-----------------------------------------------------------\n"
688 << " *** Dump for solid - " << GetName() << " ***\n"
689 << " ===================================================\n"
690 << " Solid type: G4EllipticalTube\n"
691 << " Parameters: \n"
692 << " length Z: " << fDz/mm << " mm \n"
693 << " lateral surface equation: \n"
694 << " (X / " << fDx << ")^2 + (Y / " << fDy << ")^2 = 1 \n"
695 << "-----------------------------------------------------------\n";
696 os.precision(oldprc);
697
698 return os;
699}

References fDx, fDy, fDz, G4VSolid::GetName(), and mm.

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 277 of file G4EllipticalTube.cc.

278{
279 G4ThreeVector norm(0, 0, 0);
280 G4int nsurf = 0;
281
282 // check lateral surface
283 G4double x = p.x() * fSx;
284 G4double y = p.y() * fSy;
285 G4double distR = fQ1 * (x * x + y * y) - fQ2;
286 if (std::abs(distR) <= halfTolerance)
287 {
288 norm = G4ThreeVector(p.x() * fDDy, p.y() * fDDx, 0.).unit();
289 ++nsurf;
290 }
291
292 // check lateral bases
293 G4double distZ = std::abs(p.z()) - fDz;
294 if (std::abs(distZ) <= halfTolerance)
295 {
296 norm.setZ(p.z() < 0 ? -1. : 1.);
297 ++nsurf;
298 }
299
300 // return normal
301 if (nsurf == 1) return norm;
302 else if (nsurf > 1) return norm.unit(); // edge
303 else
304 {
305 // Point is not on the surface
306 //
307#ifdef G4SPECDEBUG
308 std::ostringstream message;
309 G4int oldprc = message.precision(16);
310 message << "Point p is not on surface (!?) of solid: "
311 << GetName() << G4endl;
312 message << "Position:\n";
313 message << " p.x() = " << p.x()/mm << " mm\n";
314 message << " p.y() = " << p.y()/mm << " mm\n";
315 message << " p.z() = " << p.z()/mm << " mm";
316 G4cout.precision(oldprc);
317 G4Exception("G4EllipticalTube::SurfaceNormal(p)", "GeomSolids1002",
318 JustWarning, message );
319 DumpInfo();
320#endif
321 return ApproxSurfaceNormal(p);
322 }
323}

References ApproxSurfaceNormal(), G4VSolid::DumpInfo(), fDDx, fDDy, fDz, fQ1, fQ2, fSx, fSy, G4cout, G4endl, G4Exception(), G4VSolid::GetName(), halfTolerance, JustWarning, mm, CLHEP::Hep3Vector::setZ(), CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Field Documentation

◆ fCubicVolume

G4double G4EllipticalTube::fCubicVolume = 0.0
private

Definition at line 156 of file G4EllipticalTube.hh.

Referenced by GetCubicVolume(), and operator=().

◆ fDDx

G4double G4EllipticalTube::fDDx
private

◆ fDDy

G4double G4EllipticalTube::fDDy
private

◆ fDx

G4double G4EllipticalTube::fDx
private

◆ fDy

G4double G4EllipticalTube::fDy
private

◆ fDz

G4double G4EllipticalTube::fDz
private

◆ fpPolyhedron

G4Polyhedron* G4EllipticalTube::fpPolyhedron = nullptr
mutableprivate

Definition at line 171 of file G4EllipticalTube.hh.

Referenced by GetPolyhedron(), operator=(), and ~G4EllipticalTube().

◆ fQ1

G4double G4EllipticalTube::fQ1
private

◆ fQ2

G4double G4EllipticalTube::fQ2
private

◆ fR

G4double G4EllipticalTube::fR
private

Definition at line 165 of file G4EllipticalTube.hh.

Referenced by CheckParameters(), DistanceToIn(), DistanceToOut(), and operator=().

◆ fRebuildPolyhedron

G4bool G4EllipticalTube::fRebuildPolyhedron = false
mutableprivate

Definition at line 170 of file G4EllipticalTube.hh.

Referenced by GetPolyhedron(), and operator=().

◆ fRsph

G4double G4EllipticalTube::fRsph
private

Definition at line 160 of file G4EllipticalTube.hh.

Referenced by CheckParameters(), DistanceToIn(), and operator=().

◆ fScratch

G4double G4EllipticalTube::fScratch
private

Definition at line 168 of file G4EllipticalTube.hh.

Referenced by CheckParameters(), DistanceToIn(), DistanceToOut(), and operator=().

◆ fshapeName

G4String G4VSolid::fshapeName
privateinherited

Definition at line 312 of file G4VSolid.hh.

Referenced by G4VSolid::operator=(), and G4VSolid::SetName().

◆ fSurfaceArea

G4double G4EllipticalTube::fSurfaceArea = 0.0
private

Definition at line 157 of file G4EllipticalTube.hh.

Referenced by GetSurfaceArea(), and operator=().

◆ fSx

G4double G4EllipticalTube::fSx
private

◆ fSy

G4double G4EllipticalTube::fSy
private

◆ halfTolerance

G4double G4EllipticalTube::halfTolerance
private

◆ kCarTolerance

G4double G4VSolid::kCarTolerance
protectedinherited

Definition at line 299 of file G4VSolid.hh.

Referenced by G4TessellatedSolid::AddFacet(), G4Polycone::CalculateExtent(), G4Polyhedra::CalculateExtent(), G4Tet::CheckDegeneracy(), G4Para::CheckParameters(), G4Trd::CheckParameters(), G4Ellipsoid::CheckParameters(), CheckParameters(), G4GenericTrap::ComputeIsTwisted(), G4Polyhedra::Create(), G4GenericPolycone::Create(), G4Polycone::Create(), G4CutTubs::CreatePolyhedron(), G4TessellatedSolid::CreateVertexList(), G4VCSGfaceted::DistanceTo(), G4Sphere::DistanceToIn(), G4Ellipsoid::DistanceToIn(), G4Hype::DistanceToIn(), G4Paraboloid::DistanceToIn(), G4VCSGfaceted::DistanceToIn(), G4TessellatedSolid::DistanceToInCore(), G4Cons::DistanceToOut(), G4CutTubs::DistanceToOut(), G4Sphere::DistanceToOut(), G4Torus::DistanceToOut(), G4Tubs::DistanceToOut(), G4GenericTrap::DistanceToOut(), G4Hype::DistanceToOut(), G4Paraboloid::DistanceToOut(), G4VCSGfaceted::DistanceToOut(), G4TessellatedSolid::DistanceToOutCandidates(), G4TessellatedSolid::DistanceToOutCore(), G4TessellatedSolid::DistanceToOutNoVoxels(), G4GenericTrap::DistToPlane(), G4GenericTrap::DistToTriangle(), G4Box::G4Box(), G4Cons::G4Cons(), G4CutTubs::G4CutTubs(), G4EllipticalCone::G4EllipticalCone(), G4ExtrudedSolid::G4ExtrudedSolid(), G4GenericTrap::G4GenericTrap(), G4Hype::G4Hype(), G4Para::G4Para(), G4Sphere::G4Sphere(), G4Tet::G4Tet(), G4Trap::G4Trap(), G4Tubs::G4Tubs(), G4UnionSolid::G4UnionSolid(), G4VSolid::G4VSolid(), G4VTwistedFaceted::G4VTwistedFaceted(), G4GenericPolycone::GetPointOnSurface(), G4Polycone::GetPointOnSurface(), G4UnionSolid::Init(), G4Orb::Initialize(), G4TessellatedSolid::Initialize(), G4SubtractionSolid::Inside(), G4Hype::Inside(), G4Paraboloid::Inside(), G4VCSGfaceted::Inside(), G4VTwistedFaceted::Inside(), G4TessellatedSolid::InsideNoVoxels(), G4GenericTrap::InsidePolygone(), G4TessellatedSolid::InsideVoxels(), G4CutTubs::IsCrossingCutPlanes(), G4GenericTrap::IsSegCrossingZ(), G4Trap::MakePlane(), G4GenericTrap::NormalToPlane(), G4VSolid::operator=(), G4TessellatedSolid::SafetyFromInside(), G4TessellatedSolid::SafetyFromOutside(), G4Torus::SetAllParameters(), G4Polycone::SetOriginalParameters(), G4Polyhedra::SetOriginalParameters(), G4Box::SetXHalfLength(), G4Box::SetYHalfLength(), G4Box::SetZHalfLength(), G4Torus::SurfaceNormal(), G4GenericTrap::SurfaceNormal(), and G4Paraboloid::SurfaceNormal().


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