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

G4UnionSolid is a solid describing the Boolean union of two solids. More...

#include <G4UnionSolid.hh>

Inheritance diagram for G4UnionSolid:

Public Member Functions

 G4UnionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
 G4UnionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
 G4UnionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, const G4Transform3D &transform)
 ~G4UnionSolid () override=default
 G4UnionSolid (__void__ &)
 G4UnionSolid (const G4UnionSolid &rhs)
G4UnionSolidoperator= (const G4UnionSolid &rhs)
G4GeometryType GetEntityType () const override
G4VSolidClone () const override
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
EInside Inside (const G4ThreeVector &p) const override
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const override
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double DistanceToIn (const G4ThreeVector &p) const override
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double DistanceToOut (const G4ThreeVector &p) const override
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
void DescribeYourselfTo (G4VGraphicsScene &scene) const override
G4PolyhedronCreatePolyhedron () const override
G4double GetCubicVolume () final
Public Member Functions inherited from G4BooleanSolid
 G4BooleanSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
 G4BooleanSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
 G4BooleanSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, const G4Transform3D &transform)
 ~G4BooleanSolid () override
 G4BooleanSolid (__void__ &)
 G4BooleanSolid (const G4BooleanSolid &rhs)
G4BooleanSolidoperator= (const G4BooleanSolid &rhs)
const G4VSolidGetConstituentSolid (G4int no) const override
G4VSolidGetConstituentSolid (G4int no) override
G4double GetSurfaceArea () override
G4PolyhedronGetPolyhedron () const override
std::ostream & StreamInfo (std::ostream &os) const override
G4int GetCubVolStatistics () const
void SetCubVolStatistics (G4int st)
G4double GetCubVolEpsilon () const
void SetCubVolEpsilon (G4double ep)
G4int GetAreaStatistics () const
void SetAreaStatistics (G4int st)
G4double GetAreaAccuracy () const
void SetAreaAccuracy (G4double ep)
G4ThreeVector GetPointOnSurface () const override
G4int GetNumOfConstituents () const override
G4bool IsFaceted () const override
Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
virtual ~G4VSolid ()
 G4VSolid (const G4VSolid &rhs)
G4VSolidoperator= (const G4VSolid &rhs)
G4bool operator== (const G4VSolid &s) const
G4String GetName () const
void SetName (const G4String &name)
G4double GetTolerance () const
void DumpInfo () const
virtual G4VisExtent GetExtent () const
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 G4VSolid (__void__ &)
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
G4double EstimateSurfaceArea (G4int nStat, G4double epsilon) const

Additional Inherited Members

Static Public Member Functions inherited from G4BooleanSolid
static G4VBooleanProcessorGetExternalBooleanProcessor ()
static void SetExternalBooleanProcessor (G4VBooleanProcessor *extProcessor)
Protected Member Functions inherited from G4BooleanSolid
void GetListOfPrimitives (std::vector< std::pair< G4VSolid *, G4Transform3D > > &, const G4Transform3D &) const
G4PolyhedronStackPolyhedron (HepPolyhedronProcessor &, const G4VSolid *) 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 inherited from G4BooleanSolid
G4VSolidfPtrSolidA = nullptr
G4VSolidfPtrSolidB = nullptr
G4double fCubicVolume = -1.0
G4double fSurfaceArea = -1.0
Protected Attributes inherited from G4VSolid
G4double kCarTolerance
Static Protected Attributes inherited from G4BooleanSolid
static G4VBooleanProcessorfExternalBoolProcessor = nullptr

Detailed Description

G4UnionSolid is a solid describing the Boolean union of two solids.

Definition at line 49 of file G4UnionSolid.hh.

Constructor & Destructor Documentation

◆ G4UnionSolid() [1/5]

G4UnionSolid::G4UnionSolid ( const G4String & pName,
G4VSolid * pSolidA,
G4VSolid * pSolidB )

Constructor of a Boolean union between two solids with no displacement.

Parameters
[in]pNameThe name of the Boolean composition.
[in]pSolidAPointer to the first reference solid.
[in]pSolidBPointer to the second solid to form the composition.

Definition at line 60 of file G4UnionSolid.cc.

63 : G4BooleanSolid(pName,pSolidA,pSolidB)
64{
65 Init();
66}
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)

Referenced by Clone(), G4UnionSolid(), operator=(), and ~G4UnionSolid().

◆ G4UnionSolid() [2/5]

G4UnionSolid::G4UnionSolid ( const G4String & pName,
G4VSolid * pSolidA,
G4VSolid * pSolidB,
G4RotationMatrix * rotMatrix,
const G4ThreeVector & transVector )

Constructor of a Boolean union between two solids with rotation and translation, used to transform the coordinate system of the second solid to the coordinate system of the first solid.

Parameters
[in]pNameThe name of the Boolean composition.
[in]pSolidAPointer to the first reference solid.
[in]pSolidBPointer to the second solid to form the composition.
[in]rotMatrixPointer to the rotation vector.
[in]transVectorThe translation vector.

Definition at line 72 of file G4UnionSolid.cc.

77 : G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
78
79{
80 Init();
81}

◆ G4UnionSolid() [3/5]

G4UnionSolid::G4UnionSolid ( const G4String & pName,
G4VSolid * pSolidA,
G4VSolid * pSolidB,
const G4Transform3D & transform )

Constructor of a Boolean union between two solids with a transformation that moves the second solid from its desired position to its standard position.

Parameters
[in]pNameThe name of the Boolean composition.
[in]pSolidAPointer to the first reference solid.
[in]pSolidBPointer to the second solid to form the composition.
[in]transformThe composed 3D transformation.

Definition at line 87 of file G4UnionSolid.cc.

91 : G4BooleanSolid(pName,pSolidA,pSolidB,transform)
92{
93 Init();
94}

◆ ~G4UnionSolid()

G4UnionSolid::~G4UnionSolid ( )
overridedefault

Default destructor.

◆ G4UnionSolid() [4/5]

G4UnionSolid::G4UnionSolid ( __void__ & a)

Fake default constructor for usage restricted to direct object persistency for clients requiring preallocation of memory for persistifiable objects.

Definition at line 101 of file G4UnionSolid.cc.

102 : G4BooleanSolid(a)
103{
104}

◆ G4UnionSolid() [5/5]

G4UnionSolid::G4UnionSolid ( const G4UnionSolid & rhs)

Copy constructor and assignment operator.

Definition at line 110 of file G4UnionSolid.cc.

111 : G4BooleanSolid (rhs)
112{
113 fPMin = rhs.fPMin;
114 fPMax = rhs.fPMax;
115 halfCarTolerance = 0.5*kCarTolerance;
116}
G4double kCarTolerance
Definition G4VSolid.hh:418

Member Function Documentation

◆ BoundingLimits()

void G4UnionSolid::BoundingLimits ( G4ThreeVector & pMin,
G4ThreeVector & pMax ) const
overridevirtual

Computes the bounding limits of the solid.

Parameters
[out]pMinThe minimum bounding limit point.
[out]pMaxThe maximum bounding limit point.

Reimplemented from G4VSolid.

Definition at line 157 of file G4UnionSolid.cc.

159{
160 G4ThreeVector minA,maxA, minB,maxB;
161 fPtrSolidA->BoundingLimits(minA,maxA);
162 fPtrSolidB->BoundingLimits(minB,maxB);
163
164 pMin.set(std::min(minA.x(),minB.x()),
165 std::min(minA.y(),minB.y()),
166 std::min(minA.z(),minB.z()));
167
168 pMax.set(std::max(maxA.x(),maxB.x()),
169 std::max(maxA.y(),maxB.y()),
170 std::max(maxA.z(),maxB.z()));
171
172 // Check correctness of the bounding box
173 //
174 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
175 {
176 std::ostringstream message;
177 message << "Bad bounding box (min >= max) for solid: "
178 << GetName() << " !"
179 << "\npMin = " << pMin
180 << "\npMax = " << pMax;
181 G4Exception("G4UnionSolid::BoundingLimits()", "GeomMgt0001",
182 JustWarning, message);
183 DumpInfo();
184 }
185}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
double z() const
double x() const
double y() const
void set(double x, double y, double z)
G4VSolid * fPtrSolidA
G4VSolid * fPtrSolidB
G4String GetName() const
void DumpInfo() const

◆ CalculateExtent()

G4bool G4UnionSolid::CalculateExtent ( const EAxis pAxis,
const G4VoxelLimits & pVoxelLimit,
const G4AffineTransform & pTransform,
G4double & pMin,
G4double & pMax ) const
overridevirtual

Calculates the minimum and maximum extent of the solid, when under the specified transform, and within the specified limits.

Parameters
[in]pAxisThe axis along which compute the extent.
[in]pVoxelLimitThe limiting space dictated by voxels.
[in]pTransformThe internal transformation applied to the solid.
[out]pMinThe minimum extent value.
[out]pMaxThe maximum extent value.
Returns
True if the solid is intersected by the extent region.

Implements G4VSolid.

Definition at line 192 of file G4UnionSolid.cc.

197{
198 G4bool touchesA, touchesB, out ;
199 G4double minA = kInfinity, minB = kInfinity,
200 maxA = -kInfinity, maxB = -kInfinity;
201
202 touchesA = fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit,
203 pTransform, minA, maxA);
204 touchesB = fPtrSolidB->CalculateExtent( pAxis, pVoxelLimit,
205 pTransform, minB, maxB);
206 if( touchesA || touchesB )
207 {
208 pMin = std::min( minA, minB );
209 pMax = std::max( maxA, maxB );
210 out = true ;
211 }
212 else
213 {
214 out = false ;
215 }
216
217 return out ; // It exists in this slice if either one does.
218}
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86

◆ Clone()

G4VSolid * G4UnionSolid::Clone ( ) const
overridevirtual

Makes a clone of the object for use in multi-treading.

Returns
A pointer to the new cloned allocated solid.

Reimplemented from G4VSolid.

Definition at line 494 of file G4UnionSolid.cc.

495{
496 return new G4UnionSolid(*this);
497}
G4UnionSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)

◆ ComputeDimensions()

void G4UnionSolid::ComputeDimensions ( G4VPVParameterisation * p,
const G4int n,
const G4VPhysicalVolume * pRep )
overridevirtual

Throws an exception as paramterisations are not allowed for these solids.

Reimplemented from G4VSolid.

Definition at line 504 of file G4UnionSolid.cc.

507{
508 DumpInfo();
509 G4Exception("G4UnionSolid::ComputeDimensions()",
510 "GeomSolids0001", FatalException,
511 "Method not applicable in this context!");
512}
@ FatalException

◆ CreatePolyhedron()

G4Polyhedron * G4UnionSolid::CreatePolyhedron ( ) const
overridevirtual

Creates a Polyhedron used for Visualisation. It is the caller's responsibility to delete it. A null pointer means "not created".

Reimplemented from G4VSolid.

Definition at line 529 of file G4UnionSolid.cc.

530{
531 if (fExternalBoolProcessor == nullptr)
532 {
533 HepPolyhedronProcessor processor;
534 // Stack components and components of components recursively
535 // See G4BooleanSolid::StackPolyhedron
536 G4Polyhedron* top = StackPolyhedron(processor, this);
537 auto result = new G4Polyhedron(*top);
538 if (processor.execute(*result))
539 {
540 return result;
541 }
542 return nullptr;
543 }
544 else
545 {
546 return fExternalBoolProcessor->Process(this);
547 }
548}
static G4VBooleanProcessor * fExternalBoolProcessor
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
bool execute(HepPolyhedron &)

◆ DescribeYourselfTo()

void G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene & scene) const
overridevirtual

Methods for creating graphical representations (i.e. for visualisation).

Implements G4VSolid.

Definition at line 519 of file G4UnionSolid.cc.

520{
521 scene.AddSolid (*this);
522}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

G4double G4UnionSolid::DistanceToIn ( const G4ThreeVector & p) const
overridevirtual

Calculates the safety distance to the nearest surface of a shape from an outside point. The distance can be an underestimate.

Implements G4VSolid.

Definition at line 321 of file G4UnionSolid.cc.

322{
323#ifdef G4BOOLDEBUG
324 if( Inside(p) == kInside )
325 {
326 G4cout << "WARNING - Invalid call in "
327 << "G4UnionSolid::DistanceToIn(p)" << G4endl
328 << " Point p is inside !" << G4endl;
329 G4cout << " p = " << p << G4endl;
330 G4cerr << "WARNING - Invalid call in "
331 << "G4UnionSolid::DistanceToIn(p)" << G4endl
332 << " Point p is inside !" << G4endl;
333 G4cerr << " p = " << p << G4endl;
334 }
335#endif
336 G4double distA = fPtrSolidA->DistanceToIn(p) ;
337 G4double distB = fPtrSolidB->DistanceToIn(p) ;
338 G4double safety = std::min(distA,distB) ;
339 if(safety < 0.0) { safety = 0.0 ; }
340 return safety ;
341}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
EInside Inside(const G4ThreeVector &p) const override
@ kInside
Definition geomdefs.hh:70

◆ DistanceToIn() [2/2]

G4double G4UnionSolid::DistanceToIn ( const G4ThreeVector & p,
const G4ThreeVector & v ) const
overridevirtual

Returns the distance along the normalised vector "v" to the shape, from the point at offset "p". If there is no intersection, return kInfinity. The first intersection resulting from leaving a surface/volume is discarded. Hence, it is tolerant of points on the surface of the shape.

Implements G4VSolid.

Definition at line 292 of file G4UnionSolid.cc.

294{
295#ifdef G4BOOLDEBUG
296 if( Inside(p) == kInside )
297 {
298 G4cout << "WARNING - Invalid call in "
299 << "G4UnionSolid::DistanceToIn(p,v)" << G4endl
300 << " Point p is inside !" << G4endl;
301 G4cout << " p = " << p << G4endl;
302 G4cout << " v = " << v << G4endl;
303 G4cerr << "WARNING - Invalid call in "
304 << "G4UnionSolid::DistanceToIn(p,v)" << G4endl
305 << " Point p is inside !" << G4endl;
306 G4cerr << " p = " << p << G4endl;
307 G4cerr << " v = " << v << G4endl;
308 }
309#endif
310
311 return std::min(fPtrSolidA->DistanceToIn(p,v),
312 fPtrSolidB->DistanceToIn(p,v) ) ;
313}

◆ DistanceToOut() [1/2]

G4double G4UnionSolid::DistanceToOut ( const G4ThreeVector & p) const
overridevirtual

Calculates the safety distance to the nearest surface of a shape from an inside point "p". The distance can be an underestimate.

Implements G4VSolid.

Definition at line 435 of file G4UnionSolid.cc.

436{
437 G4double distout = 0.0;
438 if( Inside(p) == kOutside )
439 {
440#ifdef G4BOOLDEBUG
441 G4cout << "WARNING - Invalid call in "
442 << "G4UnionSolid::DistanceToOut(p)" << G4endl
443 << " Point p is outside !" << G4endl;
444 G4cout << " p = " << p << G4endl;
445 G4cerr << "WARNING - Invalid call in "
446 << "G4UnionSolid::DistanceToOut(p)" << G4endl
447 << " Point p is outside !" << G4endl;
448 G4cerr << " p = " << p << G4endl;
449#endif
450 }
451 else
452 {
453 EInside positionA = fPtrSolidA->Inside(p) ;
454 EInside positionB = fPtrSolidB->Inside(p) ;
455
456 // Is this equivalent ??
457 // if( ! ( (positionA == kOutside)) &&
458 // (positionB == kOutside)) )
459 if((positionA == kInside && positionB == kInside ) ||
460 (positionA == kInside && positionB == kSurface ) ||
461 (positionA == kSurface && positionB == kInside ) )
462 {
463 distout= std::max(fPtrSolidA->DistanceToOut(p),
464 fPtrSolidB->DistanceToOut(p) ) ;
465 }
466 else
467 {
468 if(positionA == kOutside)
469 {
470 distout= fPtrSolidB->DistanceToOut(p) ;
471 }
472 else
473 {
474 distout= fPtrSolidA->DistanceToOut(p) ;
475 }
476 }
477 }
478 return distout;
479}
EInside
Definition geomdefs.hh:67
@ kOutside
Definition geomdefs.hh:68
@ kSurface
Definition geomdefs.hh:69

◆ DistanceToOut() [2/2]

G4double G4UnionSolid::DistanceToOut ( const G4ThreeVector & p,
const G4ThreeVector & v,
const G4bool calcNorm = false,
G4bool * validNorm = nullptr,
G4ThreeVector * n = nullptr ) const
overridevirtual

Returns the distance along the normalised vector "v" to the shape, from a point at an offset "p" inside or on the surface of the shape. Intersections with surfaces, when the point is < Tolerance/2 from a surface must be ignored. Must be called as solid.DistanceToOut(p,v) or by specifying all the parameters.

Parameters
[in]pThe reference point in space.
[in]vThe normalised direction.
[in]calcNormFlag to enable the normal computation or not.
[out]validNormSet to true if the solid lies entirely behind or on the exiting surface (calcNorm must be true, otherwise it is unused).
[out]nThe exiting outwards normal vector (undefined Magnitude). (calcNorm must be true, otherwise it is unused).
Returns
The distance value to exit the volume.

Implements G4VSolid.

Definition at line 348 of file G4UnionSolid.cc.

353{
354 G4double dist = 0.0, disTmp = 0.0 ;
355 G4ThreeVector normTmp;
356 G4ThreeVector* nTmp = &normTmp;
357
358 if( Inside(p) == kOutside )
359 {
360#ifdef G4BOOLDEBUG
361 G4cout << "Position:" << G4endl << G4endl;
362 G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
363 G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
364 G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
365 G4cout << "Direction:" << G4endl << G4endl;
366 G4cout << "v.x() = " << v.x() << G4endl;
367 G4cout << "v.y() = " << v.y() << G4endl;
368 G4cout << "v.z() = " << v.z() << G4endl << G4endl;
369 G4cout << "WARNING - Invalid call in "
370 << "G4UnionSolid::DistanceToOut(p,v)" << G4endl
371 << " Point p is outside !" << G4endl;
372 G4cout << " p = " << p << G4endl;
373 G4cout << " v = " << v << G4endl;
374 G4cerr << "WARNING - Invalid call in "
375 << "G4UnionSolid::DistanceToOut(p,v)" << G4endl
376 << " Point p is outside !" << G4endl;
377 G4cerr << " p = " << p << G4endl;
378 G4cerr << " v = " << v << G4endl;
379#endif
380 }
381 else
382 {
383 EInside positionA = fPtrSolidA->Inside(p) ;
384
385 if( positionA != kOutside )
386 {
387 do // Loop checking, 13.08.2015, G.Cosmo
388 {
389 disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
390 validNorm,nTmp);
391 dist += disTmp ;
392
393 if(fPtrSolidB->Inside(p+dist*v) != kOutside)
394 {
395 disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
396 validNorm,nTmp);
397 dist += disTmp ;
398 }
399 }
400 while( (fPtrSolidA->Inside(p+dist*v) != kOutside)
401 && (disTmp > halfCarTolerance) );
402 }
403 else // if( positionB != kOutside )
404 {
405 do // Loop checking, 13.08.2015, G.Cosmo
406 {
407 disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
408 validNorm,nTmp);
409 dist += disTmp ;
410
411 if(fPtrSolidA->Inside(p+dist*v) != kOutside)
412 {
413 disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
414 validNorm,nTmp);
415 dist += disTmp ;
416 }
417 }
418 while( (fPtrSolidB->Inside(p+dist*v) != kOutside)
419 && (disTmp > halfCarTolerance) );
420 }
421 }
422 if( calcNorm )
423 {
424 *validNorm = false ;
425 *n = *nTmp ;
426 }
427 return dist ;
428}

◆ GetCubicVolume()

G4double G4UnionSolid::GetCubicVolume ( )
finalvirtual

Returns an estimate of the capacity of the Boolean composition.

Reimplemented from G4BooleanSolid.

Definition at line 554 of file G4UnionSolid.cc.

555{
556 if( fCubicVolume >= 0. )
557 {
558 return fCubicVolume;
559 }
560 G4RecursiveAutoLock l(&unionMutex);
561 G4ThreeVector bminA, bmaxA, bminB, bmaxB;
562 fPtrSolidA->BoundingLimits(bminA, bmaxA);
563 fPtrSolidB->BoundingLimits(bminB, bmaxB);
564 G4bool noIntersection =
565 bminA.x() >= bmaxB.x() || bminA.y() >= bmaxB.y() || bminA.z() >= bmaxB.z() ||
566 bminB.x() >= bmaxA.x() || bminB.y() >= bmaxA.y() || bminB.z() >= bmaxA.z();
567
568 if (noIntersection)
569 {
570 fCubicVolume = fPtrSolidA->GetCubicVolume() + fPtrSolidB->GetCubicVolume();
571 }
572 else
573 {
574 if (GetNumOfConstituents() > 10)
575 {
577 }
578 else
579 {
580 G4IntersectionSolid intersectVol("Temporary-Intersection-for-Union",
582 intersectVol.SetCubVolStatistics(GetCubVolStatistics());
583 intersectVol.SetCubVolEpsilon(GetCubVolEpsilon());
584
585 fCubicVolume = fPtrSolidA->GetCubicVolume() + fPtrSolidB->GetCubicVolume()
586 - intersectVol.GetCubicVolume();
587 }
588 }
589 l.unlock();
590 return fCubicVolume;
591}
G4TemplateAutoLock< G4RecursiveMutex > G4RecursiveAutoLock
G4double GetCubVolEpsilon() const
G4double GetCubicVolume() override
G4int GetCubVolStatistics() const
G4int GetNumOfConstituents() const override

◆ GetEntityType()

G4GeometryType G4UnionSolid::GetEntityType ( ) const
overridevirtual

Returns the type ID, "G4UnionSolid" of the solid.

Reimplemented from G4BooleanSolid.

Definition at line 485 of file G4UnionSolid.cc.

486{
487 return {"G4UnionSolid"};
488}

◆ Inside()

EInside G4UnionSolid::Inside ( const G4ThreeVector & p) const
overridevirtual

Returns if the given point "p" is inside or not the solid.

Implements G4VSolid.

Definition at line 226 of file G4UnionSolid.cc.

227{
228 if (std::max(p.z()-fPMax.z(), fPMin.z()-p.z()) > 0) { return kOutside; }
229
230 EInside positionA = fPtrSolidA->Inside(p);
231 if (positionA == kInside) { return positionA; } // inside A
232 EInside positionB = fPtrSolidB->Inside(p);
233 if (positionA == kOutside) { return positionB; }
234
235 if (positionB == kInside) { return positionB; } // inside B
236 if (positionB == kOutside) { return positionA; } // surface A
237
238 // Both points are on surface
239 //
240 static const G4double rtol
242
243 return ((fPtrSolidA->SurfaceNormal(p) +
244 fPtrSolidB->SurfaceNormal(p)).mag2() < rtol) ? kInside : kSurface;
245}
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()

Referenced by DistanceToIn(), DistanceToIn(), DistanceToOut(), DistanceToOut(), and SurfaceNormal().

◆ operator=()

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

Definition at line 122 of file G4UnionSolid.cc.

123{
124 // Check assignment to self
125 //
126 if (this == &rhs) { return *this; }
127
128 // Copy base class data
129 //
131
132 fPMin = rhs.fPMin;
133 fPMax = rhs.fPMax;
134 halfCarTolerance = rhs.halfCarTolerance;
135
136 return *this;
137}
G4BooleanSolid & operator=(const G4BooleanSolid &rhs)

◆ SurfaceNormal()

G4ThreeVector G4UnionSolid::SurfaceNormal ( const G4ThreeVector & p) const
overridevirtual

Returns the outwards pointing unit normal of the shape for the surface closest to the point at offset "p".

Implements G4VSolid.

Definition at line 252 of file G4UnionSolid.cc.

253{
254 EInside positionA = fPtrSolidA->Inside(p);
255 EInside positionB = fPtrSolidB->Inside(p);
256
257 if (positionA == kSurface &&
258 positionB == kOutside) { return fPtrSolidA->SurfaceNormal(p); }
259
260 if (positionA == kOutside &&
261 positionB == kSurface) { return fPtrSolidB->SurfaceNormal(p); }
262
263 if (positionA == kSurface &&
264 positionB == kSurface)
265 {
266 if (Inside(p) == kSurface)
267 {
268 G4ThreeVector normalA = fPtrSolidA->SurfaceNormal(p);
269 G4ThreeVector normalB = fPtrSolidB->SurfaceNormal(p);
270 return (normalA + normalB).unit();
271 }
272 }
273#ifdef G4BOOLDEBUG
274 G4String surf[3] = { "OUTSIDE", "SURFACE", "INSIDE" };
275 std::ostringstream message;
276 G4int oldprc = message.precision(16);
277 message << "Invalid call of SurfaceNormal(p) for union solid: "
278 << GetName() << " !"
279 << "\nPoint p" << p << " is " << surf[Inside(p)] << " !!!";
280 message.precision(oldprc);
281 G4Exception("G4UnionSolid::SurfaceNormal()", "GeomMgt0001",
282 JustWarning, message);
283#endif
284 return fPtrSolidA->SurfaceNormal(p);
285}
int G4int
Definition G4Types.hh:85

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