71 :
G4VSolid(pName), createdDisplacedSolid(true)
85 :
G4VSolid(pName), createdDisplacedSolid(true)
107 if(createdDisplacedSolid)
111 delete fpPolyhedron; fpPolyhedron =
nullptr;
121 fCubVolStatistics(rhs.fCubVolStatistics),
122 fAreaStatistics(rhs.fAreaStatistics),
123 fCubVolEpsilon(rhs.fCubVolEpsilon),
124 fAreaAccuracy(rhs.fAreaAccuracy),
125 createdDisplacedSolid(rhs.createdDisplacedSolid)
127 fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
138 if (
this == &rhs) {
return *
this; }
148 fCubVolStatistics = rhs.fCubVolStatistics; fCubVolEpsilon = rhs.fCubVolEpsilon;
149 fAreaStatistics = rhs.fAreaStatistics; fAreaAccuracy = rhs.fAreaAccuracy;
150 createdDisplacedSolid= rhs.createdDisplacedSolid;
152 fRebuildPolyhedron =
false;
153 delete fpPolyhedron; fpPolyhedron =
nullptr;
154 fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
179 G4Exception(
"G4BooleanSolid::GetConstituentSolid()",
205 G4Exception(
"G4BooleanSolid::GetConstituentSolid()",
217 return {
"G4BooleanSolid"};
227 fCubVolStatistics = st;
236 if (type ==
"G4DisplacedSolid")
241 if (type ==
"G4ReflectedSolid")
246 if (type ==
"G4ScaledSolid")
251 if (type !=
"G4MultiUnion")
266 if (type ==
"G4DisplacedSolid")
271 if (type ==
"G4ReflectedSolid")
276 if (type ==
"G4ScaledSolid")
281 if (type !=
"G4MultiUnion")
306 if (type ==
"G4DisplacedSolid")
311 if (type ==
"G4ReflectedSolid")
316 if (type ==
"G4ScaledSolid")
321 if (type !=
"G4MultiUnion")
336 if (type ==
"G4DisplacedSolid")
341 if (type ==
"G4ReflectedSolid")
346 if (type ==
"G4ScaledSolid")
351 if (type !=
"G4MultiUnion")
366 os <<
"-----------------------------------------------------------\n"
367 <<
" *** Dump for Boolean solid - " <<
GetName() <<
" ***\n"
368 <<
" ===================================================\n"
370 <<
" Parameters of constituent solids: \n"
371 <<
"===========================================================\n";
374 os <<
"===========================================================\n";
384 std::vector<std::pair<G4VSolid*,G4Transform3D>>& primitives,
393 for (
auto i=0; i<2; ++i)
395 transform = curPlacement;
401 while (type ==
"G4DisplacedSolid" ||
402 type ==
"G4ReflectedSolid" ||
403 type ==
"G4ScaledSolid")
405 if (type ==
"G4DisplacedSolid")
412 else if (type ==
"G4ReflectedSolid")
417 else if (type ==
"G4ScaledSolid")
419 transform = transform * ((
G4ScaledSolid*)solid)->GetScaleTransform();
428 if (type ==
"G4UnionSolid" ||
429 type ==
"G4SubtractionSolid" ||
430 type ==
"G4IntersectionSolid" ||
431 type ==
"G4BooleanSolid")
433 ((
G4BooleanSolid *)solid)->GetListOfPrimitives(primitives,transform);
437 primitives.emplace_back(solid,transform);
449 std::size_t nprims = fPrimitives.size();
450 std::pair<G4VSolid *, G4Transform3D> prim;
457 nprims = fPrimitives.size();
458 fPrimitivesSurfaceArea = 0.;
459 for (std::size_t i=0; i<nprims; ++i)
461 fPrimitivesSurfaceArea += fPrimitives[i].first->GetSurfaceArea();
469 for (std::size_t k=0; k<100000; ++k)
473 for (std::size_t i=0; i<nprims; ++i)
475 prim = fPrimitives[i];
476 area += prim.first->GetSurfaceArea();
477 if (rand < area) {
break; }
479 p = prim.first->GetPointOnSurface();
483 std::ostringstream message;
484 message <<
"Solid - " <<
GetName() <<
"\n"
485 <<
"All 100k attempts to generate a point on the surface have failed!\n"
486 <<
"The solid created may be an invalid Boolean construct!";
516 if (fpPolyhedron ==
nullptr ||
517 fRebuildPolyhedron ||
518 fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
519 fpPolyhedron->GetNumberOfRotationSteps())
524 fRebuildPolyhedron =
false;
540 if (type ==
"G4UnionSolid")
542 else if (type ==
"G4IntersectionSolid")
544 else if (type ==
"G4SubtractionSolid")
548 std::ostringstream message;
549 message <<
"Solid - " << solid->
GetName()
550 <<
" - Unrecognised composite solid" <<
G4endl
551 <<
" Returning NULL !";
569 if (operand !=
nullptr)
571 processor.
push_back (operation, *operand);
575 std::ostringstream message;
576 message <<
"Solid - " << solid->
GetName()
577 <<
" - No G4Polyhedron for Boolean component";
G4TemplateAutoLock< G4RecursiveMutex > G4RecursiveAutoLock
G4TemplateAutoLock< G4Mutex > G4AutoLock
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
HepGeom::Point3D< G4double > G4Point3D
G4double G4QuickRand(uint32_t seed=0)
CLHEP::HepRotation G4RotationMatrix
#define G4MUTEX_INITIALIZER
std::recursive_mutex G4RecursiveMutex
CLHEP::Hep3Vector G4ThreeVector
G4double GetSurfaceArea() override
G4BooleanSolid & operator=(const G4BooleanSolid &rhs)
void SetCubVolEpsilon(G4double ep)
G4Polyhedron * GetPolyhedron() const override
const G4VSolid * GetConstituentSolid(G4int no) const override
~G4BooleanSolid() override
void GetListOfPrimitives(std::vector< std::pair< G4VSolid *, G4Transform3D > > &, const G4Transform3D &) const
G4double GetCubicVolume() override
G4GeometryType GetEntityType() const override
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
static G4VBooleanProcessor * GetExternalBooleanProcessor()
G4int GetNumOfConstituents() const override
static G4VBooleanProcessor * fExternalBoolProcessor
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
std::ostream & StreamInfo(std::ostream &os) const override
void SetCubVolStatistics(G4int st)
G4bool IsFaceted() const override
static void SetExternalBooleanProcessor(G4VBooleanProcessor *extProcessor)
G4ThreeVector GetPointOnSurface() const override
G4DisplacedSolid is a solid that has been shifted from its original frame of reference to a new one....
G4VSolid * GetConstituentMovedSolid() const
G4ReflectedSolid is a solid that has been shifted from its original frame of reference to a new refle...
G4ScaledSolid is a solid that has been scaled in dimensions in X, Y or Z, from its original descripti...
G4VBooleanProcessor is a virtual base class for Boolean solid processing.
virtual const G4VSolid * GetConstituentSolid(G4int no) const
G4double EstimateCubicVolume(G4int nStat, G4double epsilon) const
G4VSolid(const G4String &name)
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4Polyhedron * GetPolyhedron() const
virtual G4Polyhedron * CreatePolyhedron() const
G4VSolid & operator=(const G4VSolid &rhs)
G4double EstimateSurfaceArea(G4int nStat, G4double epsilon) const
virtual G4GeometryType GetEntityType() const =0
void push_back(Operation, const HepPolyhedron &)