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

#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)
 
virtual ~G4UnionSolid ()
 
G4GeometryType GetEntityType () const
 
G4VSolidClone () const
 
 G4UnionSolid (__void__ &)
 
 G4UnionSolid (const G4UnionSolid &rhs)
 
G4UnionSolidoperator= (const G4UnionSolid &rhs)
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
EInside Inside (const G4ThreeVector &p) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4PolyhedronCreatePolyhedron () const
 
G4NURBSCreateNURBS () const
 
- 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)
 
virtual ~G4BooleanSolid ()
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
G4double GetCubicVolume ()
 
G4double GetSurfaceArea ()
 
virtual G4GeometryType GetEntityType () const
 
virtual G4PolyhedronGetPolyhedron () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4int GetCubVolStatistics () const
 
G4double GetCubVolEpsilon () const
 
void SetCubVolStatistics (G4int st)
 
void SetCubVolEpsilon (G4double ep)
 
G4int GetAreaStatistics () const
 
G4double GetAreaAccuracy () const
 
void SetAreaStatistics (G4int st)
 
void SetAreaAccuracy (G4double ep)
 
G4ThreeVector GetPointOnSurface () const
 
 G4BooleanSolid (__void__ &)
 
 G4BooleanSolid (const G4BooleanSolid &rhs)
 
G4BooleanSolidoperator= (const G4BooleanSolid &rhs)
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
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
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const =0
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
virtual G4double GetCubicVolume ()
 
virtual G4double GetSurfaceArea ()
 
virtual G4GeometryType GetEntityType () const =0
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4VSolidClone () const
 
virtual std::ostream & StreamInfo (std::ostream &os) const =0
 
void DumpInfo () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const =0
 
virtual G4VisExtent GetExtent () const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4NURBSCreateNURBS () const
 
virtual G4PolyhedronGetPolyhedron () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 

Additional Inherited Members

- Protected Member Functions inherited from G4BooleanSolid
G4PolyhedronStackPolyhedron (HepPolyhedronProcessor &, const G4VSolid *) const
 
G4double GetAreaRatio () 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
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 
- Protected Attributes inherited from G4BooleanSolid
G4VSolidfPtrSolidA
 
G4VSolidfPtrSolidB
 
G4double fAreaRatio
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 52 of file G4UnionSolid.hh.

Constructor & Destructor Documentation

◆ G4UnionSolid() [1/5]

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

Definition at line 60 of file G4UnionSolid.cc.

63 : G4BooleanSolid(pName,pSolidA,pSolidB)
64{
65}

◆ G4UnionSolid() [2/5]

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

Definition at line 71 of file G4UnionSolid.cc.

76 : G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
77
78{
79}

◆ G4UnionSolid() [3/5]

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

Definition at line 85 of file G4UnionSolid.cc.

89 : G4BooleanSolid(pName,pSolidA,pSolidB,transform)
90{
91}

◆ ~G4UnionSolid()

G4UnionSolid::~G4UnionSolid ( )
virtual

Definition at line 107 of file G4UnionSolid.cc.

108{
109}

◆ G4UnionSolid() [4/5]

G4UnionSolid::G4UnionSolid ( __void__ &  a)

Definition at line 98 of file G4UnionSolid.cc.

100{
101}

◆ G4UnionSolid() [5/5]

G4UnionSolid::G4UnionSolid ( const G4UnionSolid rhs)

Definition at line 115 of file G4UnionSolid.cc.

116 : G4BooleanSolid (rhs)
117{
118}

Member Function Documentation

◆ CalculateExtent()

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

Implements G4VSolid.

Definition at line 142 of file G4UnionSolid.cc.

147{
148 G4bool touchesA, touchesB, out ;
149 G4double minA = kInfinity, minB = kInfinity,
150 maxA = -kInfinity, maxB = -kInfinity;
151
152 touchesA = fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit,
153 pTransform, minA, maxA);
154 touchesB= fPtrSolidB->CalculateExtent( pAxis, pVoxelLimit,
155 pTransform, minB, maxB);
156 if( touchesA || touchesB )
157 {
158 pMin = std::min( minA, minB );
159 pMax = std::max( maxA, maxB );
160 out = true ;
161 }
162 else out = false ;
163
164 return out ; // It exists in this slice if either one does.
165}
double G4double
Definition: G4Types.hh:64
bool G4bool
Definition: G4Types.hh:67
G4VSolid * fPtrSolidA
G4VSolid * fPtrSolidB
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0

◆ Clone()

G4VSolid * G4UnionSolid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 459 of file G4UnionSolid.cc.

460{
461 return new G4UnionSolid(*this);
462}

◆ ComputeDimensions()

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

Reimplemented from G4VSolid.

Definition at line 469 of file G4UnionSolid.cc.

472{
473}

◆ CreateNURBS()

G4NURBS * G4UnionSolid::CreateNURBS ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 506 of file G4UnionSolid.cc.

507{
508 // Take into account boolean operation - see CreatePolyhedron.
509 // return new G4NURBSbox (1.0, 1.0, 1.0);
510 return 0;
511}

◆ CreatePolyhedron()

G4Polyhedron * G4UnionSolid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 490 of file G4UnionSolid.cc.

491{
493 // Stack components and components of components recursively
494 // See G4BooleanSolid::StackPolyhedron
496 G4Polyhedron* result = new G4Polyhedron(*top);
497 if (processor.execute(*result)) { return result; }
498 else { return 0; }
499}
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
#define processor
Definition: xmlparse.cc:600

◆ DescribeYourselfTo()

void G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 480 of file G4UnionSolid.cc.

481{
482 scene.AddSolid (*this);
483}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 283 of file G4UnionSolid.cc.

284{
285#ifdef G4BOOLDEBUG
286 if( Inside(p) == kInside )
287 {
288 G4cout << "WARNING - Invalid call in "
289 << "G4UnionSolid::DistanceToIn(p)" << G4endl
290 << " Point p is inside !" << G4endl;
291 G4cout << " p = " << p << G4endl;
292 G4cerr << "WARNING - Invalid call in "
293 << "G4UnionSolid::DistanceToIn(p)" << G4endl
294 << " Point p is inside !" << G4endl;
295 G4cerr << " p = " << p << G4endl;
296 }
297#endif
298 G4double distA = fPtrSolidA->DistanceToIn(p) ;
299 G4double distB = fPtrSolidB->DistanceToIn(p) ;
300 G4double safety = std::min(distA,distB) ;
301 if(safety < 0.0) safety = 0.0 ;
302 return safety ;
303}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
@ kInside
Definition: geomdefs.hh:58

◆ DistanceToIn() [2/2]

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

Implements G4VSolid.

Definition at line 254 of file G4UnionSolid.cc.

256{
257#ifdef G4BOOLDEBUG
258 if( Inside(p) == kInside )
259 {
260 G4cout << "WARNING - Invalid call in "
261 << "G4UnionSolid::DistanceToIn(p,v)" << G4endl
262 << " Point p is inside !" << G4endl;
263 G4cout << " p = " << p << G4endl;
264 G4cout << " v = " << v << G4endl;
265 G4cerr << "WARNING - Invalid call in "
266 << "G4UnionSolid::DistanceToIn(p,v)" << G4endl
267 << " Point p is inside !" << G4endl;
268 G4cerr << " p = " << p << G4endl;
269 G4cerr << " v = " << v << G4endl;
270 }
271#endif
272
273 return std::min(fPtrSolidA->DistanceToIn(p,v),
274 fPtrSolidB->DistanceToIn(p,v) ) ;
275}

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Definition at line 400 of file G4UnionSolid.cc.

401{
402 G4double distout = 0.0;
403 if( Inside(p) == kOutside )
404 {
405#ifdef G4BOOLDEBUG
406 G4cout << "WARNING - Invalid call in "
407 << "G4UnionSolid::DistanceToOut(p)" << G4endl
408 << " Point p is outside !" << G4endl;
409 G4cout << " p = " << p << G4endl;
410 G4cerr << "WARNING - Invalid call in "
411 << "G4UnionSolid::DistanceToOut(p)" << G4endl
412 << " Point p is outside !" << G4endl;
413 G4cerr << " p = " << p << G4endl;
414#endif
415 }
416 else
417 {
418 EInside positionA = fPtrSolidA->Inside(p) ;
419 EInside positionB = fPtrSolidB->Inside(p) ;
420
421 // Is this equivalent ??
422 // if( ! ( (positionA == kOutside)) &&
423 // (positionB == kOutside)) )
424 if((positionA == kInside && positionB == kInside ) ||
425 (positionA == kInside && positionB == kSurface ) ||
426 (positionA == kSurface && positionB == kInside ) )
427 {
428 distout= std::max(fPtrSolidA->DistanceToOut(p),
430 }
431 else
432 {
433 if(positionA == kOutside)
434 {
435 distout= fPtrSolidB->DistanceToOut(p) ;
436 }
437 else
438 {
439 distout= fPtrSolidA->DistanceToOut(p) ;
440 }
441 }
442 }
443 return distout;
444}
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
EInside
Definition: geomdefs.hh:58
@ kOutside
Definition: geomdefs.hh:58
@ kSurface
Definition: geomdefs.hh:58

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 310 of file G4UnionSolid.cc.

315{
316 G4double dist = 0.0, disTmp = 0.0 ;
317 G4ThreeVector normTmp;
318 G4ThreeVector* nTmp= &normTmp;
319
320 if( Inside(p) == kOutside )
321 {
322#ifdef G4BOOLDEBUG
323 G4cout << "Position:" << G4endl << G4endl;
324 G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
325 G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
326 G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
327 G4cout << "Direction:" << G4endl << G4endl;
328 G4cout << "v.x() = " << v.x() << G4endl;
329 G4cout << "v.y() = " << v.y() << G4endl;
330 G4cout << "v.z() = " << v.z() << G4endl << G4endl;
331 G4cout << "WARNING - Invalid call in "
332 << "G4UnionSolid::DistanceToOut(p,v)" << G4endl
333 << " Point p is outside !" << G4endl;
334 G4cout << " p = " << p << G4endl;
335 G4cout << " v = " << v << G4endl;
336 G4cerr << "WARNING - Invalid call in "
337 << "G4UnionSolid::DistanceToOut(p,v)" << G4endl
338 << " Point p is outside !" << G4endl;
339 G4cerr << " p = " << p << G4endl;
340 G4cerr << " v = " << v << G4endl;
341#endif
342 }
343 else
344 {
345 EInside positionA = fPtrSolidA->Inside(p) ;
346 // EInside positionB = fPtrSolidB->Inside(p) ;
347
348 if( positionA != kOutside )
349 {
350 do
351 {
352 disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
353 validNorm,nTmp) ;
354 dist += disTmp ;
355
356 if(fPtrSolidB->Inside(p+dist*v) != kOutside)
357 {
358 disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
359 validNorm,nTmp) ;
360 dist += disTmp ;
361 }
362 }
363 // while( Inside(p+dist*v) == kInside ) ;
364 while( fPtrSolidA->Inside(p+dist*v) != kOutside &&
365 disTmp > 0.5*kCarTolerance ) ;
366 }
367 else // if( positionB != kOutside )
368 {
369 do
370 {
371 disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
372 validNorm,nTmp) ;
373 dist += disTmp ;
374
375 if(fPtrSolidA->Inside(p+dist*v) != kOutside)
376 {
377 disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
378 validNorm,nTmp) ;
379 dist += disTmp ;
380 }
381 }
382 // while( Inside(p+dist*v) == kInside ) ;
383 while( (fPtrSolidB->Inside(p+dist*v) != kOutside)
384 && (disTmp > 0.5*kCarTolerance) ) ;
385 }
386 }
387 if( calcNorm )
388 {
389 *validNorm = false ;
390 *n = *nTmp ;
391 }
392 return dist ;
393}
double z() const
double x() const
double y() const
G4double kCarTolerance
Definition: G4VSolid.hh:307

◆ GetEntityType()

G4GeometryType G4UnionSolid::GetEntityType ( ) const
virtual

Reimplemented from G4BooleanSolid.

Definition at line 450 of file G4UnionSolid.cc.

451{
452 return G4String("G4UnionSolid");
453}

◆ Inside()

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

Implements G4VSolid.

Definition at line 173 of file G4UnionSolid.cc.

174{
175 EInside positionA = fPtrSolidA->Inside(p);
176 if (positionA == kInside) { return kInside; }
177
178 EInside positionB = fPtrSolidB->Inside(p);
179
180 if( positionB == kInside ||
181 ( positionA == kSurface && positionB == kSurface &&
183 fPtrSolidB->SurfaceNormal(p) ).mag2() <
185 {
186 return kInside;
187 }
188 else
189 {
190 if( ( positionB == kSurface ) || ( positionA == kSurface ) )
191 { return kSurface; }
192 else
193 { return kOutside; }
194 }
195}
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0

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

◆ operator=()

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

Definition at line 124 of file G4UnionSolid.cc.

125{
126 // Check assignment to self
127 //
128 if (this == &rhs) { return *this; }
129
130 // Copy base class data
131 //
133
134 return *this;
135}
G4BooleanSolid & operator=(const G4BooleanSolid &rhs)

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 202 of file G4UnionSolid.cc.

203{
204 G4ThreeVector normal;
205
206#ifdef G4BOOLDEBUG
207 if( Inside(p) == kOutside )
208 {
209 G4cout << "WARNING - Invalid call in "
210 << "G4UnionSolid::SurfaceNormal(p)" << G4endl
211 << " Point p is outside !" << G4endl;
212 G4cout << " p = " << p << G4endl;
213 G4cerr << "WARNING - Invalid call in "
214 << "G4UnionSolid::SurfaceNormal(p)" << G4endl
215 << " Point p is outside !" << G4endl;
216 G4cerr << " p = " << p << G4endl;
217 }
218#endif
219
220 if(fPtrSolidA->Inside(p) == kSurface && fPtrSolidB->Inside(p) != kInside)
221 {
222 normal= fPtrSolidA->SurfaceNormal(p) ;
223 }
224 else if(fPtrSolidB->Inside(p) == kSurface &&
226 {
227 normal= fPtrSolidB->SurfaceNormal(p) ;
228 }
229 else
230 {
231 normal= fPtrSolidA->SurfaceNormal(p) ;
232#ifdef G4BOOLDEBUG
233 if(Inside(p)==kInside)
234 {
235 G4cout << "WARNING - Invalid call in "
236 << "G4UnionSolid::SurfaceNormal(p)" << G4endl
237 << " Point p is inside !" << G4endl;
238 G4cout << " p = " << p << G4endl;
239 G4cerr << "WARNING - Invalid call in "
240 << "G4UnionSolid::SurfaceNormal(p)" << G4endl
241 << " Point p is inside !" << G4endl;
242 G4cerr << " p = " << p << G4endl;
243 }
244#endif
245 }
246 return normal;
247}

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