61 G4int volumeCount = 0;
66 ,
G4int requestedDepth
70 ,
const std::vector<G4PhysicalVolumeNodeID>& baseFullPVPath)
73, fTopPVCopyNo (pVPV? pVPV->GetCopyNo(): 0)
74, fRequestedDepth (requestedDepth)
75, fUseFullExtent (useFullExtent)
76, fTransform (modelTransform)
78, fpCurrentPV (fpTopPV)
79, fCurrentPVCopyNo (fpTopPV? fpTopPV->GetCopyNo(): 0)
80, fpCurrentLV (fpTopPV? fpTopPV->GetLogicalVolume(): 0)
81, fpCurrentMaterial (fpCurrentLV? fpCurrentLV->GetMaterial(): 0)
82, fCurrentTransform (modelTransform)
83, fBaseFullPVPath (baseFullPVPath)
85, fCurtailDescent (false)
87, fClippingMode (subtraction)
89 fType =
"G4PhysicalVolumeModel";
109 std::ostringstream oss;
124(
const std::vector<G4PhysicalVolumeNodeID>& path)
127 for (
const auto& node: path) {
128 PVNameCopyNoPath.push_back
130 (node.GetPhysicalVolume()->GetName(),node.GetCopyNo()));
132 return PVNameCopyNoPath;
185 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
189 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
199 startingTransformation,
222 std::ostringstream o;
227 return "WARNING: NO CURRENT VOLUME - global tag is " +
fGlobalTag;
238 G4int requestedDepth,
254 if (!(pVPV -> IsReplicated ())) {
256 pSol = pLV -> GetSolid ();
257 pMaterial = pLV -> GetMaterial ();
259 theAT, sceneHandler);
268 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
270 G4int nEnd = nReplicas;
277 for (
int n = nBegin; n < nEnd; n++) {
278 pSol = pP -> ComputeSolid (n, pVPV);
279 pP -> ComputeTransformation (n, pVPV);
280 pSol -> ComputeDimensions (pP, n, pVPV);
281 pVPV -> SetCopyNo (n);
287 pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
289 theAT, sceneHandler);
314 pSol = pLV -> GetSolid ();
315 pMaterial = pLV -> GetMaterial ();
316 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
318 G4double originalRMin = 0., originalRMax = 0.;
320 originalRMin = ((
G4Tubs*)pSol)->GetInnerRadius();
321 originalRMax = ((
G4Tubs*)pSol)->GetOuterRadius();
323 G4bool visualisable =
true;
324 for (
int n = nBegin; n < nEnd; n++) {
331 translation =
G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
334 translation =
G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
337 translation =
G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
341 ((
G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
342 ((
G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
346 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
347 "\n built-in replicated volumes replicated in radius for "
349 "-type\n solids (your solid \""
351 "\") are not visualisable."
353 visualisable =
false;
357 rotation.
rotateZ (-(offset+(n+0.5)*width));
360 pRotation = &rotation;
363 pVPV -> SetTranslation (translation);
364 pVPV -> SetRotation (pRotation);
365 pVPV -> SetCopyNo (n);
369 theAT, sceneHandler);
373 pVPV -> SetTranslation (originalTranslation);
374 pVPV -> SetRotation (pOriginalRotation);
376 ((
G4Tubs*)pSol)->SetInnerRadius(originalRMin);
377 ((
G4Tubs*)pSol)->SetOuterRadius(originalRMax);
385 G4int requestedDepth,
407 const G4ThreeVector& translation = pVPV -> GetTranslation ();
434 G4Exception(
"G4PhysicalVolumeModelTouchable::DescribeAndDescend",
437 "Algorithm-parameter mismatch for Colour By Density");
448 red = (d1-d)/(d1-d0); green = (d-d0)/(d1-d0); blue = 0.;
450 red = 0.; green = (d2-d)/(d2-d1); blue = (d-d1)/(d2-d1);
452 red = 0.; green = 0.; blue = 1.;
461 pVisAttribs = tempVisAtts;
470 for (
const auto& vam: vams) {
471 const auto& vamPath = vam.GetPVNameCopyNoPath();
475 auto iVAMNameCopyNo = vamPath.begin();
477 for (; iVAMNameCopyNo != vamPath.end(); ++iVAMNameCopyNo, ++iPVNodeId) {
479 iVAMNameCopyNo->GetName() ==
480 iPVNodeId->GetPhysicalVolume()->GetName() &&
481 iVAMNameCopyNo->GetCopyNo() ==
482 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
488 if (iVAMNameCopyNo == vamPath.end()) {
494 modifiedVisAtts = *pVisAttribs;
495 pVisAttribs = &modifiedVisAtts;
497 switch (vam.GetVisAttributesSignifier()) {
560 G4bool potentialG4Mesh =
false;
563 potentialG4Mesh =
true;
567 if (pVPV->
GetName() == pvNameCopyNo.GetName()) {
569 if (pvNameCopyNo.GetCopyNo() < 0) {
571 potentialG4Mesh =
true;
573 if (pVPV->
GetCopyNo() == pvNameCopyNo.GetCopyNo()) {
575 potentialG4Mesh =
true;
581 if (potentialG4Mesh) {
584 G4Mesh mesh(pVPV,theNewAT);
603 G4bool thisToBeDrawn =
true;
618 if (cullingInvisible) {
620 if (!markedVisible) thisToBeDrawn =
false;
623 if (cullingLowDensity) {
625 if (density < densityCut) thisToBeDrawn =
false;
629 if (
fAbort) thisToBeDrawn =
false;
632 nodeID.SetDrawn(thisToBeDrawn);
650 explodeFactor * oldTranslation.
dy(),
651 explodeFactor * oldTranslation.
dz());
652 theNewAT = centering * newTranslation * oldRotation * oldScale;
665 G4bool daughtersToBeDrawn =
true;
667 if (!nDaughters) daughtersToBeDrawn =
false;
669 else if (requestedDepth == 0) daughtersToBeDrawn =
false;
671 else if (
fAbort) daughtersToBeDrawn =
false;
696 if (cullingInvisible) {
698 if (daughtersInvisible) daughtersToBeDrawn =
false;
701 if (cullingCovered) {
703 if (surfaceDrawing) {
707 if (opaque) daughtersToBeDrawn =
false;
714 if (daughtersToBeDrawn) {
715 for (
G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
721 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
756 G4VSolid* pResultantSolid =
nullptr;
774 (
"sectioned_solid", pSol, pSectionSolid, theAT.
inverse());
779 (
"cutaway_solid", pSol, pCutawaySolid, theAT.
inverse());
786 delete pResultantSolid;
798 auto iterator = find(pvStore->begin(),pvStore->end(),
fpTopPV);
799 if (iterator == pvStore->end()) {
802 ed <<
"Attempt to validate a volume that is no longer in the physical volume store.";
814 std::map<G4String,G4AttDef>* store
818 G4AttDef(
"PVPath",
"Physical Volume Path",
"Physics",
"",
"G4String");
819 (*store)[
"BasePVPath"] =
820 G4AttDef(
"BasePVPath",
"Base Physical Volume Path",
"Physics",
"",
"G4String");
822 G4AttDef(
"LVol",
"Logical Volume",
"Physics",
"",
"G4String");
824 G4AttDef(
"Solid",
"Solid Name",
"Physics",
"",
"G4String");
826 G4AttDef(
"EType",
"Entity Type",
"Physics",
"",
"G4String");
828 G4AttDef(
"DmpSol",
"Dump of Solid properties",
"Physics",
"",
"G4String");
829 (*store)[
"LocalTrans"] =
830 G4AttDef(
"LocalTrans",
"Local transformation of volume",
"Physics",
"",
"G4String");
831 (*store)[
"LocalExtent"] =
832 G4AttDef(
"LocalExtent",
"Local extent of volume",
"Physics",
"",
"G4String");
833 (*store)[
"GlobalTrans"] =
834 G4AttDef(
"GlobalTrans",
"Global transformation of volume",
"Physics",
"",
"G4String");
835 (*store)[
"GlobalExtent"] =
836 G4AttDef(
"GlobalExtent",
"Global extent of volume",
"Physics",
"",
"G4String");
837 (*store)[
"Material"] =
838 G4AttDef(
"Material",
"Material Name",
"Physics",
"",
"G4String");
839 (*store)[
"Density"] =
840 G4AttDef(
"Density",
"Material Density",
"Physics",
"G4BestUnit",
"G4double");
842 G4AttDef(
"State",
"Material State (enum undefined,solid,liquid,gas)",
"Physics",
"",
"G4String");
844 G4AttDef(
"Radlen",
"Material Radiation Length",
"Physics",
"G4BestUnit",
"G4double");
846 G4AttDef(
"Region",
"Cuts Region",
"Physics",
"",
"G4String");
847 (*store)[
"RootRegion"] =
848 G4AttDef(
"RootRegion",
"Root Region (0/1 = false/true)",
"Physics",
"",
"G4bool");
853static std::ostream& operator<< (std::ostream& o,
const G4Transform3D t)
865 o << setw(w) << t.
xx() << setw(w) << t.
xy() << setw(w) << t.
xz() << setw(w) << t.
dx() << endl;
866 o << setw(w) << t.
yx() << setw(w) << t.
yy() << setw(w) << t.
yz() << setw(w) << t.
dy() << endl;
867 o << setw(w) << t.
zx() << setw(w) << t.
zy() << setw(w) << t.
zz() << setw(w) << t.
dz() << endl;
870 o <<
"= translation:" << endl;
871 o << setw(w) << tl.
dx() << setw(w) << tl.
dy() << setw(w) << tl.
dz() << endl;
874 o <<
"* rotation:" << endl;
875 o << setw(w) << r.
xx() << setw(w) << r.
xy() << setw(w) << r.
xz() << endl;
876 o << setw(w) << r.
yx() << setw(w) << r.
yy() << setw(w) << r.
yz() << endl;
877 o << setw(w) << r.
zx() << setw(w) << r.
zy() << setw(w) << r.
zz() << endl;
880 o <<
"* scale:" << endl;
881 o << setw(w) << sc.
xx() << setw(w) << sc.
yy() << setw(w) << sc.
zz() << endl;
884 o <<
"Transformed axes:" << endl;
885 o <<
"x': " << r *
G4Vector3D(1., 0., 0.) << endl;
886 o <<
"y': " << r *
G4Vector3D(0., 1., 0.) << endl;
887 o <<
"z': " << r *
G4Vector3D(0., 0., 1.) << endl;
894 std::vector<G4AttValue>* values =
new std::vector<G4AttValue>;
898 (
"G4PhysicalVolumeModel::CreateCurrentAttValues",
901 "Current logical volume not defined.");
906 values->push_back(
G4AttValue(
"PVPath", oss.str(),
""));
909 values->push_back(
G4AttValue(
"BasePVPath", oss.str(),
""));
918 oss.str(
""); oss <<
'\n' << *pSol;
919 values->push_back(
G4AttValue(
"DmpSol", oss.str(),
""));
923 oss.str(
""); oss <<
'\n' <<
G4Transform3D(localRotation,localTranslation);
924 values->push_back(
G4AttValue(
"LocalTrans", oss.str(),
""));
926 oss.str(
""); oss <<
'\n' << pSol->
GetExtent() << std::endl;
927 values->push_back(
G4AttValue(
"LocalExtent", oss.str(),
""));
930 values->push_back(
G4AttValue(
"GlobalTrans", oss.str(),
""));
933 values->push_back(
G4AttValue(
"GlobalExtent", oss.str(),
""));
936 values->push_back(
G4AttValue(
"Material", matName,
""));
942 oss.str(
""); oss << matState;
943 values->push_back(
G4AttValue(
"State", oss.str(),
""));
950 values->push_back(
G4AttValue(
"Region", regionName,
""));
953 values->push_back(
G4AttValue(
"RootRegion", oss.str(),
""));
958G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
961 if (fpPV < right.fpPV)
return true;
962 if (fpPV == right.fpPV) {
963 if (fCopyNo < right.fCopyNo)
return true;
964 if (fCopyNo == right.fCopyNo)
965 return fNonCulledDepth < right.fNonCulledDepth;
970G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator!=
973 if (fpPV != right.fpPV ||
974 fCopyNo != right.fCopyNo ||
975 fNonCulledDepth != right.fNonCulledDepth ||
976 fTransform != right.fTransform ||
977 fDrawn != right.fDrawn)
return true;
981std::ostream&
operator<<
987 <<
' ' << node.GetCopyNo()
995 os <<
" (Null PV node)";
1000std::ostream&
operator<<
1001(std::ostream& os,
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path)
1006 for (
const auto& nodeID: path) {
1007 os <<
' ' << nodeID;
1014(
const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
1015 fFullPVPath(fullPVPath) {}
1021 G4Exception(
"G4PhysicalVolumeModelTouchable::GetTranslation",
1024 "Index out of range. Asking for non-existent depth");
1027 tempTranslation =
fFullPVPath[i].GetTransform().getTranslation();
1028 return tempTranslation;
1035 G4Exception(
"G4PhysicalVolumeModelTouchable::GetRotation",
1038 "Index out of range. Asking for non-existent depth");
1041 tempRotation =
fFullPVPath[i].GetTransform().getRotation();
1042 return &tempRotation;
1049 G4Exception(
"G4PhysicalVolumeModelTouchable::GetVolume",
1052 "Index out of range. Asking for non-existent depth");
1061 G4Exception(
"G4PhysicalVolumeModelTouchable::GetSolid",
1064 "Index out of range. Asking for non-existent depth");
1066 return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
1073 G4Exception(
"G4PhysicalVolumeModelTouchable::GetReplicaNumber",
1076 "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
HepRotation & rotateZ(double delta)
const G4VisExtent & GetBoundingExtent() const
G4double GetAlpha() const
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
const G4Point3D & GetExplodeCentre() const
std::vector< PVNameCopyNo > PVNameCopyNoPath
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
G4String GetCurrentDescription() const
void DescribeYourselfTo(G4VGraphicsScene &)
std::vector< G4PhysicalVolumeNodeID > fBaseFullPVPath
G4VPhysicalVolume * fpCurrentPV
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 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)