48 fmany(pMany), fcopyNo(pCopyNo)
53 if (pLogical == motherLogical)
55 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
75 Transform3D.getTranslation(), pName, pLogical, pMother),
76 fmany(pMany), fcopyNo(pCopyNo)
82 if (pLogical == motherLogical)
83 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
105 fmany(pMany), fcopyNo(pCopyNo)
107 if (pCurrentLogical == pMotherLogical)
109 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
113 if (pMotherLogical) { pMotherLogical->
AddDaughter(
this); }
129 pName, pCurrentLogical, nullptr),
130 fmany(pMany), fcopyNo(pCopyNo)
132 if (pCurrentLogical == pMotherLogical)
134 G4Exception(
"G4PVPlacement::G4PVPlacement()",
"GeomVol0002",
140 if (pMotherLogical) { pMotherLogical->
AddDaughter(
this); }
158 if( fallocatedRotM ){
delete this->
GetRotation() ; }
246 if (res <= 0) {
return false; }
250 if (motherLog ==
nullptr) {
return false; }
267 std::ostringstream message;
268 message <<
"Sample point is not on the surface !" <<
G4endl
269 <<
" The issue is detected for volume "
272 <<
" generated point " << ptmp
283 std::vector<G4ThreeVector> points(res);
284 G4double xmin = kInfinity, ymin = kInfinity, zmin = kInfinity;
285 G4double xmax = -kInfinity, ymax = -kInfinity, zmax = -kInfinity;
287 for (
G4int i = 0; i < res; ++i)
290 xmin = std::min(xmin, points[i].x());
291 ymin = std::min(ymin, points[i].y());
292 zmin = std::min(zmin, points[i].z());
293 xmax = std::max(xmax, points[i].x());
294 ymax = std::max(ymax, points[i].y());
295 zmax = std::max(zmax, points[i].z());
297 G4ThreeVector scenter(0.5*(xmax+xmin), 0.5*(ymax+ymin), 0.5*(zmax+zmin));
303 for (
G4int i = 0; i < res; ++i)
312 std::ostringstream message;
313 message <<
"Overlap with mother volume !" <<
G4endl
314 <<
" Overlap is detected for volume "
317 <<
" with its mother volume " << motherLog->
GetName()
319 <<
" at mother local point " << mp <<
", "
320 <<
"overlapping by at least: "
322 if (trials >= maxErr)
325 <<
"NOTE: Reached maximum fixed number -" << maxErr
326 <<
"- of overlaps reports for this volume !";
330 if (trials >= maxErr) {
return true; }
343 if (daughter ==
this)
continue;
347 if (previous != daughterSolid)
350 previous = daughterSolid;
358 if (pmin.
x() >= xmax)
continue;
359 if (pmin.
y() >= ymax)
continue;
360 if (pmin.
z() >= zmax)
continue;
361 if (pmax.
x() <= xmin)
continue;
362 if (pmax.
y() <= ymin)
continue;
363 if (pmax.
z() <= zmin)
continue;
364 for (
G4int i = 0; i < res; ++i)
367 if (p.
x() <= pmin.
x())
continue;
368 if (p.
x() >= pmax.
x())
continue;
369 if (p.
y() <= pmin.
y())
continue;
370 if (p.
y() >= pmax.
y())
continue;
371 if (p.
z() <= pmin.
z())
continue;
372 if (p.
z() >= pmax.
z())
continue;
377 if (dtmp <= tol)
continue;
388 G4double dradius = 0.5*((pmax - pmin).mag());
389 if ((scenter - dcenter).mag2() >= (sradius + dradius)*(sradius + dradius))
continue;
390 if (dcenter.
x() - dradius >= xmax)
continue;
391 if (dcenter.
y() - dradius >= ymax)
continue;
392 if (dcenter.
z() - dradius >= zmax)
continue;
393 if (dcenter.
x() + dradius <= xmin)
continue;
394 if (dcenter.
y() + dradius <= ymin)
continue;
395 if (dcenter.
z() + dradius <= zmin)
continue;
407 G4double dxmin = kInfinity, dymin = kInfinity, dzmin = kInfinity;
408 G4double dxmax = -kInfinity, dymax = -kInfinity, dzmax = -kInfinity;
409 for (
G4int i = 0; i < 8; ++i)
412 dxmin = std::min(dxmin, p.
x());
413 dymin = std::min(dymin, p.
y());
414 dzmin = std::min(dzmin, p.
z());
415 dxmax = std::max(dxmax, p.
x());
416 dymax = std::max(dymax, p.
y());
417 dzmax = std::max(dzmax, p.
z());
419 if (dxmin >= xmax)
continue;
420 if (dymin >= ymax)
continue;
421 if (dzmin >= zmax)
continue;
422 if (dxmax <= xmin)
continue;
423 if (dymax <= ymin)
continue;
424 if (dzmax <= zmin)
continue;
425 for (
G4int i = 0; i < res; ++i)
428 if (p.
x() >= dxmax)
continue;
429 if (p.
x() <= dxmin)
continue;
430 if (p.
y() >= dymax)
continue;
431 if (p.
y() <= dymin)
continue;
432 if (p.
z() >= dzmax)
continue;
433 if (p.
z() <= dzmin)
continue;
438 if (dtmp <= tol)
continue;
450 std::ostringstream message;
451 message <<
"Overlap with volume already placed !" <<
G4endl
452 <<
" Overlap is detected for volume "
455 <<
" with " << daughter->
GetName()
459 <<
" local point " << plocal <<
", "
460 <<
"overlapping by at least: "
462 if (trials >= maxErr)
465 <<
"NOTE: Reached maximum fixed number -" << maxErr
466 <<
"- of overlaps reports for this volume !";
470 if (trials >= maxErr) {
return true; }
472 else if (distout == kInfinity)
491 std::ostringstream message;
492 message <<
"Overlap with volume already placed !" <<
G4endl
493 <<
" Overlap is detected for volume "
496 <<
" apparently fully encapsulating volume "
499 <<
" at the same level !";
500 if (trials >= maxErr)
503 <<
"NOTE: Reached maximum fixed number -" << maxErr
504 <<
"- of overlaps reports for this volume !";
508 if (trials >= maxErr) {
return true; }
513 if (verbose && trials == 0) {
G4cout <<
"OK! " <<
G4endl; }
533 pRotMatrix =
nullptr;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
HepRotation inverse() const
G4VSolid * GetSolid() const
void AddDaughter(G4VPhysicalVolume *p)
size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
const G4String & GetName() const
EVolume VolumeType() const
G4bool IsRegularStructure() const
G4bool IsParameterised() const
void SetCopyNo(G4int CopyNo)
G4VPVParameterisation * GetParameterisation() const
G4PVPlacement(G4RotationMatrix *pRot, const G4ThreeVector &tlate, G4LogicalVolume *pCurrentLogical, const G4String &pName, G4LogicalVolume *pMotherLogical, G4bool pMany, G4int pCopyNo, G4bool pSurfChk=false)
G4bool IsReplicated() const
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4int GetRegularStructureId() const
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int maxErr=1)
G4LogicalVolume * GetMotherLogical() const
const G4RotationMatrix * GetRotation() const
const G4ThreeVector GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
void SetRotation(G4RotationMatrix *)
void SetMotherLogical(G4LogicalVolume *pMother)
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 void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
virtual G4GeometryType GetEntityType() const =0