62 ,
G4int requestedDepth
66 ,
const std::vector<G4PhysicalVolumeNodeID>& baseFullPVPath)
69, fTopPVCopyNo (pVPV? pVPV->GetCopyNo(): 0)
70, fRequestedDepth (requestedDepth)
71, fUseFullExtent (useFullExtent)
72, fTransform (modelTransform)
74, fpCurrentPV (fpTopPV)
75, fCurrentPVCopyNo (fpTopPV? fpTopPV->GetCopyNo(): 0)
76, fpCurrentLV (fpTopPV? fpTopPV->GetLogicalVolume(): 0)
77, fpCurrentMaterial (fpCurrentLV? fpCurrentLV->GetMaterial(): 0)
78, fCurrentTransform (modelTransform)
79, fBaseFullPVPath (baseFullPVPath)
80, fFullPVPath (fBaseFullPVPath)
82, fCurtailDescent (false)
84, fClippingMode (subtraction)
87 fType =
"G4PhysicalVolumeModel";
107 std::ostringstream oss;
122(
const std::vector<G4PhysicalVolumeNodeID>& path)
125 for (
const auto& node: path) {
126 PVNameCopyNoPath.push_back
128 (node.GetPhysicalVolume()->GetName(),node.GetCopyNo()));
130 return PVNameCopyNoPath;
134(
const std::vector<G4PhysicalVolumeNodeID>& path)
138 std::ostringstream oss;
194 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
201 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
214 ed <<
"More than one solid cutter/clipper:";
216 if (pSectionSolid) ed <<
"\nsectioner in force";
217 if (pCutawaySolid) ed <<
"\ncutaway in force";
228 startingTransformation,
246 std::ostringstream o;
251 return "WARNING: NO CURRENT VOLUME - global tag is " +
fGlobalTag;
262 G4int requestedDepth,
278 if (!(pVPV -> IsReplicated ())) {
280 pSol = pLV -> GetSolid ();
281 pMaterial = pLV -> GetMaterial ();
283 theAT, sceneHandler);
292 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
294 G4int nEnd = nReplicas;
301 for (
int n = nBegin; n < nEnd; n++) {
302 pSol = pP -> ComputeSolid (n, pVPV);
303 pP -> ComputeTransformation (n, pVPV);
304 pSol -> ComputeDimensions (pP, n, pVPV);
305 pVPV -> SetCopyNo (n);
311 pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
313 theAT, sceneHandler);
338 pSol = pLV -> GetSolid ();
339 pMaterial = pLV -> GetMaterial ();
340 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
342 G4double originalRMin = 0., originalRMax = 0.;
344 originalRMin = ((
G4Tubs*)pSol)->GetInnerRadius();
345 originalRMax = ((
G4Tubs*)pSol)->GetOuterRadius();
347 G4bool visualisable =
true;
348 for (
int n = nBegin; n < nEnd; n++) {
355 translation =
G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
358 translation =
G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
361 translation =
G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
365 ((
G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
366 ((
G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
370 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
371 "\n built-in replicated volumes replicated in radius for "
373 "-type\n solids (your solid \""
375 "\") are not visualisable."
377 visualisable =
false;
381 rotation.
rotateZ (-(offset+(n+0.5)*width));
384 pRotation = &rotation;
387 pVPV -> SetTranslation (translation);
388 pVPV -> SetRotation (pRotation);
389 pVPV -> SetCopyNo (n);
393 theAT, sceneHandler);
397 pVPV -> SetTranslation (originalTranslation);
398 pVPV -> SetRotation (pOriginalRotation);
400 ((
G4Tubs*)pSol)->SetInnerRadius(originalRMin);
401 ((
G4Tubs*)pSol)->SetOuterRadius(originalRMax);
409 G4int requestedDepth,
431 const G4ThreeVector& translation = pVPV -> GetTranslation ();
458 G4Exception(
"G4PhysicalVolumeModelTouchable::DescribeAndDescend",
461 "Algorithm-parameter mismatch for Colour By Density");
472 red = (d1-d)/(d1-d0); green = (d-d0)/(d1-d0); blue = 0.;
474 red = 0.; green = (d2-d)/(d2-d1); blue = (d-d1)/(d2-d1);
476 red = 0.; green = 0.; blue = 1.;
485 pVisAttribs = tempVisAtts;
494 for (
const auto& vam: vams) {
495 const auto& vamPath = vam.GetPVNameCopyNoPath();
499 auto iVAMNameCopyNo = vamPath.begin();
501 for (; iVAMNameCopyNo != vamPath.end(); ++iVAMNameCopyNo, ++iPVNodeId) {
503 iVAMNameCopyNo->GetName() ==
504 iPVNodeId->GetPhysicalVolume()->GetName() &&
505 iVAMNameCopyNo->GetCopyNo() ==
506 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
512 if (iVAMNameCopyNo == vamPath.end()) {
518 modifiedVisAtts = *pVisAttribs;
519 pVisAttribs = &modifiedVisAtts;
521 switch (vam.GetVisAttributesSignifier()) {
584 G4bool potentialG4Mesh =
false;
587 potentialG4Mesh =
true;
591 if (pVPV->
GetName() == pvNameCopyNo.GetName()) {
593 if (pvNameCopyNo.GetCopyNo() < 0) {
595 potentialG4Mesh =
true;
597 if (pVPV->
GetCopyNo() == pvNameCopyNo.GetCopyNo()) {
599 potentialG4Mesh =
true;
605 if (potentialG4Mesh) {
608 G4Mesh mesh(pVPV,theNewAT);
627 G4bool thisToBeDrawn =
true;
642 if (cullingInvisible) {
644 if (!markedVisible) thisToBeDrawn =
false;
647 if (cullingLowDensity) {
649 if (density < densityCut) thisToBeDrawn =
false;
653 if (
fAbort) thisToBeDrawn =
false;
656 nodeID.SetDrawn(thisToBeDrawn);
674 explodeFactor * oldTranslation.
dy(),
675 explodeFactor * oldTranslation.
dz());
676 theNewAT = centering * newTranslation * oldRotation * oldScale;
691 G4bool daughtersToBeDrawn =
true;
693 if (!nDaughters) daughtersToBeDrawn =
false;
695 else if (requestedDepth == 0) daughtersToBeDrawn =
false;
697 else if (
fAbort) daughtersToBeDrawn =
false;
722 if (cullingInvisible) {
724 if (daughtersInvisible) daughtersToBeDrawn =
false;
727 if (cullingCovered) {
729 if (surfaceDrawing) {
733 if (opaque) daughtersToBeDrawn =
false;
740 if (daughtersToBeDrawn) {
741 for (
G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
747 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
773 const auto& pSolA = target;
776 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z()) {
789 const auto& pSolA = target;
790 const auto& pSolB = intersector;
792 pSolB->BoundingLimits(minB,maxB);
793 pMin.
set(std::max(minA.
x(),minB.
x()),
794 std::max(minA.
y(),minB.
y()),
795 std::max(minA.
z(),minB.
z()));
796 pMax.
set(std::min(maxA.
x(),maxB.
x()),
797 std::min(maxA.
y(),maxB.
y()),
798 std::min(maxA.
z(),maxB.
z()));
799 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z()) {
826 G4VSolid* pResultantSolid =
nullptr;
833 if (SubtractionBoundingLimits(pSol)) {
835 (
"subtracted_clipped_solid", pSol, pDisplacedSolid);
839 if (IntersectionBoundingLimits(pSol, pDisplacedSolid)) {
841 (
"intersected_clipped_solid", pSol, pDisplacedSolid);
846 }
else if (pSectionSolid) {
848 if (IntersectionBoundingLimits(pSol, pDisplacedSolid)) {
852 }
else if (pCutawaySolid) {
856 if (SubtractionBoundingLimits(pSol)) {
861 if (IntersectionBoundingLimits(pSol, pDisplacedSolid)) {
868 if (pResultantSolid) {
874 delete pResultantSolid;
875 delete pDisplacedSolid;
887 auto iterator = find(pvStore->begin(),pvStore->end(),
fpTopPV);
888 if (iterator == pvStore->end()) {
891 ed <<
"Attempt to validate a volume that is no longer in the physical volume store.";
903 std::map<G4String,G4AttDef>* store
907 G4AttDef(
"PVPath",
"Physical Volume Path",
"Physics",
"",
"G4String");
908 (*store)[
"BasePVPath"] =
909 G4AttDef(
"BasePVPath",
"Base Physical Volume Path",
"Physics",
"",
"G4String");
911 G4AttDef(
"LVol",
"Logical Volume",
"Physics",
"",
"G4String");
913 G4AttDef(
"Solid",
"Solid Name",
"Physics",
"",
"G4String");
915 G4AttDef(
"EType",
"Entity Type",
"Physics",
"",
"G4String");
917 G4AttDef(
"DmpSol",
"Dump of Solid properties",
"Physics",
"",
"G4String");
918 (*store)[
"LocalTrans"] =
919 G4AttDef(
"LocalTrans",
"Local transformation of volume",
"Physics",
"",
"G4String");
920 (*store)[
"LocalExtent"] =
921 G4AttDef(
"LocalExtent",
"Local extent of volume",
"Physics",
"",
"G4String");
922 (*store)[
"GlobalTrans"] =
923 G4AttDef(
"GlobalTrans",
"Global transformation of volume",
"Physics",
"",
"G4String");
924 (*store)[
"GlobalExtent"] =
925 G4AttDef(
"GlobalExtent",
"Global extent of volume",
"Physics",
"",
"G4String");
926 (*store)[
"Material"] =
927 G4AttDef(
"Material",
"Material Name",
"Physics",
"",
"G4String");
928 (*store)[
"Density"] =
929 G4AttDef(
"Density",
"Material Density",
"Physics",
"G4BestUnit",
"G4double");
931 G4AttDef(
"State",
"Material State (enum undefined,solid,liquid,gas)",
"Physics",
"",
"G4String");
933 G4AttDef(
"Radlen",
"Material Radiation Length",
"Physics",
"G4BestUnit",
"G4double");
935 G4AttDef(
"Region",
"Cuts Region",
"Physics",
"",
"G4String");
936 (*store)[
"RootRegion"] =
937 G4AttDef(
"RootRegion",
"Root Region (0/1 = false/true)",
"Physics",
"",
"G4bool");
942static std::ostream& operator<< (std::ostream& o,
const G4Transform3D t)
954 o << setw(w) << t.
xx() << setw(w) << t.
xy() << setw(w) << t.
xz() << setw(w) << t.
dx() << endl;
955 o << setw(w) << t.
yx() << setw(w) << t.
yy() << setw(w) << t.
yz() << setw(w) << t.
dy() << endl;
956 o << setw(w) << t.
zx() << setw(w) << t.
zy() << setw(w) << t.
zz() << setw(w) << t.
dz() << endl;
959 o <<
"= translation:" << endl;
960 o << setw(w) << tl.
dx() << setw(w) << tl.
dy() << setw(w) << tl.
dz() << endl;
963 o <<
"* rotation:" << endl;
964 o << setw(w) << r.
xx() << setw(w) << r.
xy() << setw(w) << r.
xz() << endl;
965 o << setw(w) << r.
yx() << setw(w) << r.
yy() << setw(w) << r.
yz() << endl;
966 o << setw(w) << r.
zx() << setw(w) << r.
zy() << setw(w) << r.
zz() << endl;
969 o <<
"* scale:" << endl;
970 o << setw(w) << sc.
xx() << setw(w) << sc.
yy() << setw(w) << sc.
zz() << endl;
973 o <<
"Transformed axes:" << endl;
974 o <<
"x': " << r *
G4Vector3D(1., 0., 0.) << endl;
975 o <<
"y': " << r *
G4Vector3D(0., 1., 0.) << endl;
976 o <<
"z': " << r *
G4Vector3D(0., 0., 1.) << endl;
983 std::vector<G4AttValue>* values =
new std::vector<G4AttValue>;
987 (
"G4PhysicalVolumeModel::CreateCurrentAttValues",
990 "Current logical volume not defined.");
995 values->push_back(
G4AttValue(
"PVPath", oss.str(),
""));
998 values->push_back(
G4AttValue(
"BasePVPath", oss.str(),
""));
1007 oss.str(
""); oss <<
'\n' << *pSol;
1008 values->push_back(
G4AttValue(
"DmpSol", oss.str(),
""));
1012 oss.str(
""); oss <<
'\n' <<
G4Transform3D(localRotation,localTranslation);
1013 values->push_back(
G4AttValue(
"LocalTrans", oss.str(),
""));
1015 oss.str(
""); oss <<
'\n' << pSol->
GetExtent() << std::endl;
1016 values->push_back(
G4AttValue(
"LocalExtent", oss.str(),
""));
1019 values->push_back(
G4AttValue(
"GlobalTrans", oss.str(),
""));
1022 values->push_back(
G4AttValue(
"GlobalExtent", oss.str(),
""));
1025 values->push_back(
G4AttValue(
"Material", matName,
""));
1031 oss.str(
""); oss << matState;
1032 values->push_back(
G4AttValue(
"State", oss.str(),
""));
1039 values->push_back(
G4AttValue(
"Region", regionName,
""));
1042 values->push_back(
G4AttValue(
"RootRegion", oss.str(),
""));
1047G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
1050 if (fpPV < right.fpPV)
return true;
1051 if (fpPV == right.fpPV) {
1052 if (fCopyNo < right.fCopyNo)
return true;
1053 if (fCopyNo == right.fCopyNo)
1054 return fNonCulledDepth < right.fNonCulledDepth;
1059G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator!=
1062 if (fpPV != right.fpPV ||
1063 fCopyNo != right.fCopyNo ||
1064 fNonCulledDepth != right.fNonCulledDepth ||
1065 fTransform != right.fTransform ||
1066 fDrawn != right.fDrawn)
return true;
1070std::ostream&
operator<<
1076 <<
' ' << node.GetCopyNo()
1084 os <<
" (Null PV node)";
1089std::ostream&
operator<<
1090(std::ostream& os,
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path)
1095 for (
const auto& nodeID: path) {
1096 os <<
' ' << nodeID;
1103(
const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
1104 fFullPVPath(fullPVPath) {}
1110 G4Exception(
"G4PhysicalVolumeModelTouchable::GetTranslation",
1113 "Index out of range. Asking for non-existent depth");
1116 tempTranslation =
fFullPVPath[i].GetTransform().getTranslation();
1117 return tempTranslation;
1124 G4Exception(
"G4PhysicalVolumeModelTouchable::GetRotation",
1127 "Index out of range. Asking for non-existent depth");
1130 tempRotation =
fFullPVPath[i].GetTransform().getRotation();
1131 return &tempRotation;
1138 G4Exception(
"G4PhysicalVolumeModelTouchable::GetVolume",
1141 "Index out of range. Asking for non-existent depth");
1150 G4Exception(
"G4PhysicalVolumeModelTouchable::GetSolid",
1153 "Index out of range. Asking for non-existent depth");
1155 return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
1162 G4Exception(
"G4PhysicalVolumeModelTouchable::GetReplicaNumber",
1165 "Index out of range. Asking for non-existent depth");
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Vector3D< G4double > G4Vector3D
void set(double x, double y, double z)
HepRotation & rotateZ(double delta)
const G4VisExtent & GetBoundingExtent() const
G4double GetAlpha() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4VSolid * GetSolid() const
const G4VisAttributes * GetVisAttributes() const
std::size_t GetNoDaughters() const
G4bool IsRootRegion() const
G4Region * GetRegion() const
G4Material * GetMaterial() const
const G4String & GetName() const
G4double GetDensity() const
G4double GetRadlen() const
const G4String & GetName() const
G4VPhysicalVolume * GetParameterisedVolume() const
MeshType GetMeshType() const
const G4VisAttributes * GetDefaultVisAttributes() const
const std::vector< VisAttributesModifier > & GetVisAttributesModifiers() const
std::vector< PVNameCopyNo > PVNameCopyNoPath
CutawayMode GetCutawayMode() const
const G4Point3D & GetExplodeCentre() const
G4bool IsCullingInvisible() const
const std::vector< PVNameCopyNo > & GetSpecialMeshVolumes() const
const std::vector< G4double > & GetCBDParameters() const
@ VASForceNumberOfCloudPoints
@ VASForceLineSegmentsPerCircle
G4bool IsDensityCulling() const
G4bool IsSpecialMeshRendering() const
DrawingStyle GetDrawingStyle() const
G4DisplacedSolid * GetSectionSolid() const
G4double GetExplodeFactor() const
G4DisplacedSolid * GetCutawaySolid() const
G4bool IsCullingCovered() const
G4int GetCBDAlgorithmNumber() const
void SetSpecialMeshRendering(G4bool)
G4VSolid * GetSolid(G4int depth) const
G4VPhysicalVolume * GetVolume(G4int depth) const
G4int GetReplicaNumber(G4int depth) const
const G4RotationMatrix * GetRotation(G4int depth) const
G4PhysicalVolumeModelTouchable(const std::vector< G4PhysicalVolumeNodeID > &fullPVPath)
const G4ThreeVector & GetTranslation(G4int depth) const
void DescribeAndDescend(G4VPhysicalVolume *, G4int requestedDepth, G4LogicalVolume *, G4VSolid *, G4Material *, const G4Transform3D &, G4VGraphicsScene &)
std::vector< G4PhysicalVolumeNodeID > fFullPVPath
G4VPhysicalVolume * fpTopPV
void VisitGeometryAndGetVisReps(G4VPhysicalVolume *, G4int requestedDepth, const G4Transform3D &, G4VGraphicsScene &)
std::vector< G4AttValue > * CreateCurrentAttValues() const
G4PhysicalVolumeModel(G4VPhysicalVolume *=0, G4int requestedDepth=UNLIMITED, const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0, G4bool useFullExtent=false, const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath=std::vector< G4PhysicalVolumeNodeID >())
G4VSolid * fpClippingSolid
G4Material * fpCurrentMaterial
virtual ~G4PhysicalVolumeModel()
G4String GetCurrentTag() const
std::vector< G4PhysicalVolumeNodeID > fDrawnPVPath
G4Transform3D fCurrentTransform
G4bool Validate(G4bool warn)
virtual void DescribeSolid(const G4Transform3D &theAT, G4VSolid *pSol, const G4VisAttributes *pVisAttribs, G4VGraphicsScene &sceneHandler)
ClippingMode fClippingMode
static G4String GetPVNamePathString(const std::vector< G4PhysicalVolumeNodeID > &)
G4String GetCurrentDescription() const
void DescribeYourselfTo(G4VGraphicsScene &)
std::vector< G4PhysicalVolumeNodeID > fBaseFullPVPath
G4VPhysicalVolume * fpCurrentPV
std::map< G4int, G4int > fNTouchables
const std::map< G4String, G4AttDef > * GetAttDefs() const
static G4ModelingParameters::PVNameCopyNoPath GetPVNameCopyNoPath(const std::vector< G4PhysicalVolumeNodeID > &)
G4LogicalVolume * fpCurrentLV
static G4PhysicalVolumeStore * GetInstance()
const G4String & GetName() const
virtual void AddCompound(const G4VTrajectory &)=0
virtual void PostAddSolid()=0
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
G4String fGlobalDescription
const G4VisExtent & GetExtent() const
const G4ModelingParameters * fpMP
const G4ThreeVector GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
G4RotationMatrix GetObjectRotationValue() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
virtual G4VisExtent GetExtent() const
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
virtual G4GeometryType GetEntityType() const =0
G4int GetForcedNumberOfCloudPoints() const
G4double GetLineWidth() const
G4bool IsDaughtersInvisible() const
void SetColour(const G4Colour &)
void SetVisibility(G4bool=true)
void SetForceAuxEdgeVisible(G4bool=true)
void SetForceCloud(G4bool=true)
G4int GetForcedLineSegmentsPerCircle() const
void SetForceWireframe(G4bool=true)
void SetLineWidth(G4double)
LineStyle GetLineStyle() const
const G4Colour & GetColour() const
G4bool IsForceAuxEdgeVisible() const
G4bool IsForcedAuxEdgeVisible() const
ForcedDrawingStyle GetForcedDrawingStyle() const
void SetForceSolid(G4bool=true)
void SetLineStyle(LineStyle)
void SetForceLineSegmentsPerCircle(G4int nSegments)
void SetDaughtersInvisible(G4bool=true)
void SetForceNumberOfCloudPoints(G4int nPoints)
G4bool IsForceDrawingStyle() const
G4double GetExtentRadius() const
G4VisExtent & Transform(const G4Transform3D &)
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)