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

G4IntersectionSolid is a solid describing the Boolean intersection of two solids. More...

#include <G4IntersectionSolid.hh>

Inheritance diagram for G4IntersectionSolid:

Public Member Functions

 G4IntersectionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
 G4IntersectionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
 G4IntersectionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, const G4Transform3D &transform)
 ~G4IntersectionSolid () override=default
 G4IntersectionSolid (__void__ &)
 G4IntersectionSolid (const G4IntersectionSolid &rhs)
G4IntersectionSolidoperator= (const G4IntersectionSolid &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
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 GetCubicVolume () 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

G4IntersectionSolid is a solid describing the Boolean intersection of two solids.

Definition at line 50 of file G4IntersectionSolid.hh.

Constructor & Destructor Documentation

◆ G4IntersectionSolid() [1/5]

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

Constructor of a Boolean intersection 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 50 of file G4IntersectionSolid.cc.

53 : G4BooleanSolid(pName,pSolidA,pSolidB)
54{
55}
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)

Referenced by Clone(), G4IntersectionSolid(), and operator=().

◆ G4IntersectionSolid() [2/5]

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

Constructor of a Boolean intersection 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 60 of file G4IntersectionSolid.cc.

65 : G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
66{
67}

◆ G4IntersectionSolid() [3/5]

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

Constructor of a Boolean intersection 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 73 of file G4IntersectionSolid.cc.

77 : G4BooleanSolid(pName,pSolidA,pSolidB,transform)
78{
79}

◆ ~G4IntersectionSolid()

G4IntersectionSolid::~G4IntersectionSolid ( )
overridedefault

Default destructor.

◆ G4IntersectionSolid() [4/5]

G4IntersectionSolid::G4IntersectionSolid ( __void__ & a)

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

Definition at line 86 of file G4IntersectionSolid.cc.

88{
89}

◆ G4IntersectionSolid() [5/5]

G4IntersectionSolid::G4IntersectionSolid ( const G4IntersectionSolid & rhs)
default

Copy constructor and assignment operator.

Member Function Documentation

◆ BoundingLimits()

void G4IntersectionSolid::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 120 of file G4IntersectionSolid.cc.

122{
123 G4ThreeVector minA,maxA, minB,maxB;
124 fPtrSolidA->BoundingLimits(minA,maxA);
125 fPtrSolidB->BoundingLimits(minB,maxB);
126
127 pMin.set(std::max(minA.x(),minB.x()),
128 std::max(minA.y(),minB.y()),
129 std::max(minA.z(),minB.z()));
130
131 pMax.set(std::min(maxA.x(),maxB.x()),
132 std::min(maxA.y(),maxB.y()),
133 std::min(maxA.z(),maxB.z()));
134
135 // Check correctness of the bounding box
136 //
137 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
138 {
139 std::ostringstream message;
140 message << "Bad bounding box (min >= max) for solid: "
141 << GetName() << " !"
142 << "\npMin = " << pMin
143 << "\npMax = " << pMax;
144 G4Exception("G4IntersectionSolid::BoundingLimits()", "GeomMgt0001",
145 JustWarning, message);
146 DumpInfo();
147 }
148}
@ 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 G4IntersectionSolid::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 155 of file G4IntersectionSolid.cc.

160{
161 G4bool retA, retB, out;
162 G4double minA, minB, maxA, maxB;
163
164 retA = fPtrSolidA
165 ->CalculateExtent( pAxis, pVoxelLimit, pTransform, minA, maxA);
166 retB = fPtrSolidB
167 ->CalculateExtent( pAxis, pVoxelLimit, pTransform, minB, maxB);
168
169 if( retA && retB )
170 {
171 pMin = std::max( minA, minB );
172 pMax = std::min( maxA, maxB );
173 out = (pMax > pMin); // true;
174 }
175 else
176 {
177 out = false;
178 }
179
180 return out; // It exists in this slice only if both exist in it.
181}
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86

◆ Clone()

G4VSolid * G4IntersectionSolid::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 524 of file G4IntersectionSolid.cc.

525{
526 return new G4IntersectionSolid(*this);
527}
G4IntersectionSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)

◆ ComputeDimensions()

void G4IntersectionSolid::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 501 of file G4IntersectionSolid.cc.

504{
505 DumpInfo();
506 G4Exception("G4IntersectionSolid::ComputeDimensions()",
507 "GeomSolids0001", FatalException,
508 "Method not applicable in this context!");
509}
@ FatalException

◆ CreatePolyhedron()

G4Polyhedron * G4IntersectionSolid::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 544 of file G4IntersectionSolid.cc.

545{
546 if (fExternalBoolProcessor == nullptr)
547 {
548 HepPolyhedronProcessor processor;
549 // Stack components and components of components recursively
550 // See G4BooleanSolid::StackPolyhedron
551 G4Polyhedron* top = StackPolyhedron(processor, this);
552 auto result = new G4Polyhedron(*top);
553 if (processor.execute(*result))
554 {
555 return result;
556 }
557 return nullptr;
558 }
559 else
560 {
561 return fExternalBoolProcessor->Process(this);
562 }
563}
static G4VBooleanProcessor * fExternalBoolProcessor
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
bool execute(HepPolyhedron &)

◆ DescribeYourselfTo()

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

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

Implements G4VSolid.

Definition at line 534 of file G4IntersectionSolid.cc.

535{
536 scene.AddSolid (*this);
537}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

G4double G4IntersectionSolid::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 373 of file G4IntersectionSolid.cc.

374{
375#ifdef G4BOOLDEBUG
376 if( Inside(p) == kInside )
377 {
378 G4cout << "WARNING - Invalid call in "
379 << "G4IntersectionSolid::DistanceToIn(p)" << G4endl
380 << " Point p is inside !" << G4endl;
381 G4cout << " p = " << p << G4endl;
382 G4cerr << "WARNING - Invalid call in "
383 << "G4IntersectionSolid::DistanceToIn(p)" << G4endl
384 << " Point p is inside !" << G4endl;
385 G4cerr << " p = " << p << G4endl;
386 }
387#endif
388 EInside sideA = fPtrSolidA->Inside(p) ;
389 EInside sideB = fPtrSolidB->Inside(p) ;
390 G4double dist=0.0 ;
391
392 if( sideA != kInside && sideB != kOutside )
393 {
394 dist = fPtrSolidA->DistanceToIn(p) ;
395 }
396 else
397 {
398 if( sideB != kInside && sideA != kOutside )
399 {
400 dist = fPtrSolidB->DistanceToIn(p) ;
401 }
402 else
403 {
404 dist = std::min(fPtrSolidA->DistanceToIn(p),
405 fPtrSolidB->DistanceToIn(p) ) ;
406 }
407 }
408 return dist ;
409}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
EInside Inside(const G4ThreeVector &p) const override
EInside
Definition geomdefs.hh:67
@ kInside
Definition geomdefs.hh:70
@ kOutside
Definition geomdefs.hh:68

◆ DistanceToIn() [2/2]

G4double G4IntersectionSolid::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 266 of file G4IntersectionSolid.cc.

268{
269 G4double dist = 0.0;
270 if( Inside(p) == kInside )
271 {
272#ifdef G4BOOLDEBUG
273 G4cout << "WARNING - Invalid call in "
274 << "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl
275 << " Point p is inside !" << G4endl;
276 G4cout << " p = " << p << G4endl;
277 G4cout << " v = " << v << G4endl;
278 G4cerr << "WARNING - Invalid call in "
279 << "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl
280 << " Point p is inside !" << G4endl;
281 G4cerr << " p = " << p << G4endl;
282 G4cerr << " v = " << v << G4endl;
283#endif
284 }
285 else // if( Inside(p) == kSurface )
286 {
287 EInside wA = fPtrSolidA->Inside(p);
288 EInside wB = fPtrSolidB->Inside(p);
289
290 G4ThreeVector pA = p, pB = p;
291 G4double dA = 0., dA1=0., dA2=0.;
292 G4double dB = 0., dB1=0., dB2=0.;
293 G4bool doA = true, doB = true;
294
295 static const std::size_t max_trials=10000;
296 for (std::size_t trial=0; trial<max_trials; ++trial)
297 {
298 if(doA)
299 {
300 // find next valid range for A
301
302 dA1 = 0.;
303
304 if( wA != kInside )
305 {
306 dA1 = fPtrSolidA->DistanceToIn(pA, v);
307
308 if( dA1 == kInfinity ) { return kInfinity; }
309
310 pA += dA1*v;
311 }
312 dA2 = dA1 + fPtrSolidA->DistanceToOut(pA, v);
313 }
314 dA1 += dA;
315 dA2 += dA;
316
317 if(doB)
318 {
319 // find next valid range for B
320
321 dB1 = 0.;
322 if(wB != kInside)
323 {
324 dB1 = fPtrSolidB->DistanceToIn(pB, v);
325
326 if(dB1 == kInfinity) { return kInfinity; }
327
328 pB += dB1*v;
329 }
330 dB2 = dB1 + fPtrSolidB->DistanceToOut(pB, v);
331 }
332 dB1 += dB;
333 dB2 += dB;
334
335 // check if they overlap
336
337 if( dA1 < dB1 )
338 {
339 if( dB1 < dA2 ) { return dB1; }
340
341 dA = dA2;
342 pA = p + dA*v; // continue from here
343 wA = kSurface;
344 doA = true;
345 doB = false;
346 }
347 else
348 {
349 if( dA1 < dB2 ) { return dA1; }
350
351 dB = dB2;
352 pB = p + dB*v; // continue from here
353 wB = kSurface;
354 doB = true;
355 doA = false;
356 }
357 }
358 }
359#ifdef G4BOOLDEBUG
360 G4Exception("G4IntersectionSolid::DistanceToIn(p,v)",
361 "GeomSolids0001", JustWarning,
362 "Reached maximum number of iterations! Returning zero.");
363#endif
364 return dist ;
365}
@ kSurface
Definition geomdefs.hh:69

◆ DistanceToOut() [1/2]

G4double G4IntersectionSolid::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 475 of file G4IntersectionSolid.cc.

476{
477#ifdef G4BOOLDEBUG
478 if( Inside(p) == kOutside )
479 {
480 G4cout << "WARNING - Invalid call in "
481 << "G4IntersectionSolid::DistanceToOut(p)" << G4endl
482 << " Point p is outside !" << G4endl;
483 G4cout << " p = " << p << G4endl;
484 G4cerr << "WARNING - Invalid call in "
485 << "G4IntersectionSolid::DistanceToOut(p)" << G4endl
486 << " Point p is outside !" << G4endl;
487 G4cerr << " p = " << p << G4endl;
488 }
489#endif
490
491 return std::min(fPtrSolidA->DistanceToOut(p),
492 fPtrSolidB->DistanceToOut(p) ) ;
493
494}

◆ DistanceToOut() [2/2]

G4double G4IntersectionSolid::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 416 of file G4IntersectionSolid.cc.

421{
422 G4bool validNormA, validNormB;
423 G4ThreeVector nA, nB;
424
425#ifdef G4BOOLDEBUG
426 if( Inside(p) == kOutside )
427 {
428 G4cout << "Position:" << G4endl << G4endl;
429 G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
430 G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
431 G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
432 G4cout << "Direction:" << G4endl << G4endl;
433 G4cout << "v.x() = " << v.x() << G4endl;
434 G4cout << "v.y() = " << v.y() << G4endl;
435 G4cout << "v.z() = " << v.z() << G4endl << G4endl;
436 G4cout << "WARNING - Invalid call in "
437 << "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl
438 << " Point p is outside !" << G4endl;
439 G4cout << " p = " << p << G4endl;
440 G4cout << " v = " << v << G4endl;
441 G4cerr << "WARNING - Invalid call in "
442 << "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl
443 << " Point p is outside !" << G4endl;
444 G4cerr << " p = " << p << G4endl;
445 G4cerr << " v = " << v << G4endl;
446 }
447#endif
448 G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,&validNormA,&nA) ;
449 G4double distB = fPtrSolidB->DistanceToOut(p,v,calcNorm,&validNormB,&nB) ;
450
451 G4double dist = std::min(distA,distB) ;
452
453 if( calcNorm )
454 {
455 if ( distA < distB )
456 {
457 *validNorm = validNormA;
458 *n = nA;
459 }
460 else
461 {
462 *validNorm = validNormB;
463 *n = nB;
464 }
465 }
466
467 return dist ;
468}

◆ GetEntityType()

G4GeometryType G4IntersectionSolid::GetEntityType ( ) const
overridevirtual

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

Reimplemented from G4BooleanSolid.

Definition at line 515 of file G4IntersectionSolid.cc.

516{
517 return {"G4IntersectionSolid"};
518}

◆ Inside()

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

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

Implements G4VSolid.

Definition at line 187 of file G4IntersectionSolid.cc.

188{
189 EInside positionA = fPtrSolidA->Inside(p);
190 if(positionA == kOutside) { return positionA; } // outside A
191
192 EInside positionB = fPtrSolidB->Inside(p);
193 if(positionA == kInside) { return positionB; }
194
195 if(positionB == kOutside) { return positionB; } // outside B
196
197 return kSurface; // surface A & B
198}

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

◆ operator=()

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

Definition at line 102 of file G4IntersectionSolid.cc.

103{
104 // Check assignment to self
105 //
106 if (this == &rhs) { return *this; }
107
108 // Copy base class data
109 //
111
112 return *this;
113}
G4BooleanSolid & operator=(const G4BooleanSolid &rhs)

◆ SurfaceNormal()

G4ThreeVector G4IntersectionSolid::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 204 of file G4IntersectionSolid.cc.

205{
206 G4ThreeVector normal;
207 EInside insideA, insideB;
208
209 insideA = fPtrSolidA->Inside(p);
210 insideB = fPtrSolidB->Inside(p);
211
212#ifdef G4BOOLDEBUG
213 if( (insideA == kOutside) || (insideB == kOutside) )
214 {
215 G4cout << "WARNING - Invalid call in "
216 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
217 << " Point p is outside !" << G4endl;
218 G4cout << " p = " << p << G4endl;
219 G4cerr << "WARNING - Invalid call in "
220 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
221 << " Point p is outside !" << G4endl;
222 G4cerr << " p = " << p << G4endl;
223 }
224#endif
225
226 // On the surface of both is difficult ... treat it like on A now!
227 //
228 if( insideA == kSurface )
229 {
230 normal = fPtrSolidA->SurfaceNormal(p) ;
231 }
232 else if( insideB == kSurface )
233 {
234 normal = fPtrSolidB->SurfaceNormal(p) ;
235 }
236 else // We are on neither surface, so we should generate an exception
237 {
238 if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
239 {
240 normal= fPtrSolidA->SurfaceNormal(p) ;
241 }
242 else
243 {
244 normal= fPtrSolidB->SurfaceNormal(p) ;
245 }
246#ifdef G4BOOLDEBUG
247 G4cout << "WARNING - Invalid call in "
248 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
249 << " Point p is out of surface !" << G4endl;
250 G4cout << " p = " << p << G4endl;
251 G4cerr << "WARNING - Invalid call in "
252 << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
253 << " Point p is out of surface !" << G4endl;
254 G4cerr << " p = " << p << G4endl;
255#endif
256 }
257
258 return normal;
259}

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