49 fmany(pMany), fcopyNo(pCopyNo)
51 if (pMother !=
nullptr)
54 if (pLogical == motherLogical)
56 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
76 Transform3D.getTranslation(), pName, pLogical, pMother),
77 fmany(pMany), fcopyNo(pCopyNo)
80 if (pMother !=
nullptr)
83 if (pLogical == motherLogical)
85 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
108 fmany(pMany), fcopyNo(pCopyNo)
110 if (pCurrentLogical == pMotherLogical)
112 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
116 if (pMotherLogical !=
nullptr) { pMotherLogical->
AddDaughter(
this); }
117 if ((pSurfChk) && ((pMotherLogical) !=
nullptr)) {
CheckOverlaps(); }
131 pName, pCurrentLogical, nullptr),
132 fmany(pMany), fcopyNo(pCopyNo)
134 if (pCurrentLogical == pMotherLogical)
136 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
142 if (pMotherLogical !=
nullptr) { pMotherLogical->
AddDaughter(
this); }
143 if ((pSurfChk) && ((pMotherLogical) !=
nullptr)) {
CheckOverlaps(); }
160 if( fallocatedRotM ){
delete this->
GetRotation() ; }
248 if (res <= 0) {
return false; }
252 if (motherLog ==
nullptr) {
return false; }
259 G4cout <<
"Checking overlaps for volume "
270 std::ostringstream message;
271 message <<
"Sample point is not on the surface !" <<
G4endl
272 <<
" The issue is detected for volume "
275 <<
" generated point " << ptmp
286 std::vector<G4ThreeVector> points(res);
294 for (
G4int i = 0; i < res; ++i)
297 xmin = std::min(xmin, points[i].x());
298 ymin = std::min(ymin, points[i].y());
299 zmin = std::min(zmin, points[i].z());
300 xmax = std::max(xmax, points[i].x());
301 ymax = std::max(ymax, points[i].y());
302 zmax = std::max(zmax, points[i].z());
304 G4ThreeVector scenter(0.5*(xmax+xmin), 0.5*(ymax+ymin), 0.5*(zmax+zmin));
309 G4int overlapCount = 0;
313 for (
G4int i = 0; i < res; ++i)
318 if (distin < tol) {
continue; }
320 if (distin <= overlapSize) {
continue; }
321 overlapSize = distin;
327 if (overlapCount > 0)
331 std::ostringstream message;
332 message <<
"Overlap with mother volume !" <<
G4endl
333 <<
" Overlap is detected for volume "
336 <<
" with its mother volume " << motherLog->
GetName()
338 <<
" protrusion at mother local point " << overlapPoint
339 <<
" by " <<
G4BestUnit(overlapSize,
"Length")
340 <<
" (max of " << overlapCount <<
" cases)";
341 if (trials >= maxErr)
344 <<
"NOTE: Reached maximum fixed number -" << maxErr
345 <<
"- of overlaps reports for this volume !";
349 if (trials >= maxErr) {
return true; }
361 if (daughter ==
this) {
continue; }
362 G4bool check_encapsulation =
true;
366 if (previous != daughterSolid)
369 previous = daughterSolid;
372 overlapSize = -kInfinity;
377 if (pmin.
x() >= xmax) {
continue; }
378 if (pmin.
y() >= ymax) {
continue; }
379 if (pmin.
z() >= zmax) {
continue; }
380 if (pmax.
x() <= xmin) {
continue; }
381 if (pmax.
y() <= ymin) {
continue; }
382 if (pmax.
z() <= zmin) {
continue; }
383 for (
G4int i = 0; i < res; ++i)
386 if (p.
x() <= pmin.
x()) {
continue; }
387 if (p.
x() >= pmax.
x()) {
continue; }
388 if (p.
y() <= pmin.
y()) {
continue; }
389 if (p.
y() >= pmax.
y()) {
continue; }
390 if (p.
z() <= pmin.
z()) {
continue; }
391 if (p.
z() >= pmax.
z()) {
continue; }
395 check_encapsulation =
false;
397 if (distout < tol) {
continue; }
399 if (distout <= overlapSize) {
continue; }
400 overlapSize = distout;
410 G4double dradius = 0.5*((pmax - pmin).mag());
411 if ((scenter - dcenter).mag2() >= (sradius + dradius)*(sradius + dradius)) {
continue; }
412 if (dcenter.
x() - dradius >= xmax) {
continue; }
413 if (dcenter.
y() - dradius >= ymax) {
continue; }
414 if (dcenter.
z() - dradius >= zmax) {
continue; }
415 if (dcenter.
x() + dradius <= xmin) {
continue; }
416 if (dcenter.
y() + dradius <= ymin) {
continue; }
417 if (dcenter.
z() + dradius <= zmin) {
continue; }
436 for (
const auto & i : pbox)
439 dxmin = std::min(dxmin, p.
x());
440 dymin = std::min(dymin, p.
y());
441 dzmin = std::min(dzmin, p.
z());
442 dxmax = std::max(dxmax, p.
x());
443 dymax = std::max(dymax, p.
y());
444 dzmax = std::max(dzmax, p.
z());
446 if (dxmin >= xmax) {
continue; }
447 if (dymin >= ymax) {
continue; }
448 if (dzmin >= zmax) {
continue; }
449 if (dxmax <= xmin) {
continue; }
450 if (dymax <= ymin) {
continue; }
451 if (dzmax <= zmin) {
continue; }
452 for (
G4int i = 0; i < res; ++i)
455 if (p.
x() >= dxmax) {
continue; }
456 if (p.
x() <= dxmin) {
continue; }
457 if (p.
y() >= dymax) {
continue; }
458 if (p.
y() <= dymin) {
continue; }
459 if (p.
z() >= dzmax) {
continue; }
460 if (p.
z() <= dzmin) {
continue; }
464 check_encapsulation =
false;
466 if (distout < tol) {
continue; }
468 if (distout <= overlapSize) {
continue; }
469 overlapSize = distout;
477 if (overlapCount > 0)
481 std::ostringstream message;
482 message <<
"Overlap with volume already placed !" <<
G4endl
483 <<
" Overlap is detected for volume "
488 <<
" overlap at local point " << overlapPoint
489 <<
" by " <<
G4BestUnit(overlapSize,
"Length")
490 <<
" (max of " << overlapCount <<
" cases)";
491 if (trials >= maxErr)
494 <<
"NOTE: Reached maximum fixed number -" << maxErr
495 <<
"- of overlaps reports for this volume !";
499 if (trials >= maxErr) {
return true; }
501 else if (check_encapsulation)
524 std::ostringstream message;
525 message <<
"Overlap with volume already placed !" <<
G4endl
526 <<
" Overlap is detected for volume "
529 <<
" apparently fully encapsulating volume "
532 <<
" at the same level!";
533 if (trials >= maxErr)
536 <<
"NOTE: Reached maximum fixed number -" << maxErr
537 <<
"- of overlaps reports for this volume !";
541 if (trials >= maxErr) {
return true; }
546 if (verbose && trials == 0) {
G4cout <<
"OK! " <<
G4endl; }
566 pRotMatrix =
nullptr;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4ThreadLocal T * G4GeomSplitter< T >::offset
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
HepRotation inverse() const
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
G4VSolid * GetSolid() const
void AddDaughter(G4VPhysicalVolume *p)
std::size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const std::size_t i) const
const G4String & GetName() const
G4VPVParameterisation * GetParameterisation() const override
~G4PVPlacement() override
G4bool IsMany() const override
void SetCopyNo(G4int CopyNo) override
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int maxErr=1) override
G4PVPlacement(G4RotationMatrix *pRot, const G4ThreeVector &tlate, G4LogicalVolume *pCurrentLogical, const G4String &pName, G4LogicalVolume *pMotherLogical, G4bool pMany, G4int pCopyNo, G4bool pSurfChk=false)
EVolume VolumeType() const override
G4int GetRegularStructureId() const override
G4bool IsReplicated() const override
G4int GetCopyNo() const override
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const override
G4bool IsParameterised() const override
G4bool IsRegularStructure() const override
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
G4LogicalVolume * GetMotherLogical() const
const G4RotationMatrix * GetRotation() const
const G4ThreeVector GetTranslation() const
G4VPhysicalVolume(G4RotationMatrix *pRot, const G4ThreeVector &tlate, const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother)
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
void SetRotation(G4RotationMatrix *)
void SetMotherLogical(G4LogicalVolume *pMother)
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4ThreeVector GetPointOnSurface() const
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
virtual G4GeometryType GetEntityType() const =0