58 G4int volumeCount = 0;
63 ,
G4int requestedDepth
67 ,
const std::vector<G4PhysicalVolumeNodeID>& baseFullPVPath)
70, fTopPVCopyNo (pVPV? pVPV->GetCopyNo(): 0)
71, fRequestedDepth (requestedDepth)
72, fUseFullExtent (useFullExtent)
74, fpCurrentPV (fpTopPV)
75, fCurrentPVCopyNo (fpTopPV? fpTopPV->GetCopyNo(): 0)
76, fpCurrentLV (fpTopPV? fpTopPV->GetLogicalVolume(): 0)
77, fpCurrentMaterial (fpCurrentLV? fpCurrentLV->GetMaterial(): 0)
78, fpCurrentTransform (const_cast<
G4Transform3D*>(&modelTransformation))
79, fBaseFullPVPath (baseFullPVPath)
81, fCurtailDescent (false)
83, fClippingMode (subtraction)
85 fType =
"G4PhysicalVolumeModel";
105 std::ostringstream oss;
120(
const std::vector<G4PhysicalVolumeNodeID>& path)
123 for (
const auto& node: path) {
124 PVNameCopyNoPath.push_back
126 (node.GetPhysicalVolume()->GetName(),node.GetCopyNo()));
128 return PVNameCopyNoPath;
179 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
183 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
193 startingTransformation,
216 std::ostringstream o;
221 return "WARNING: NO CURRENT VOLUME - global tag is " +
fGlobalTag;
232 G4int requestedDepth,
249 if (!(pVPV -> IsReplicated ())) {
251 pSol = pLV -> GetSolid ();
252 pMaterial = pLV -> GetMaterial ();
254 theAT, sceneHandler);
263 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
265 G4int nEnd = nReplicas;
272 for (
int n = nBegin; n < nEnd; n++) {
273 pSol = pP -> ComputeSolid (n, pVPV);
274 pP -> ComputeTransformation (n, pVPV);
275 pSol -> ComputeDimensions (pP, n, pVPV);
276 pVPV -> SetCopyNo (n);
282 pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
284 theAT, sceneHandler);
309 pSol = pLV -> GetSolid ();
310 pMaterial = pLV -> GetMaterial ();
311 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
313 G4double originalRMin = 0., originalRMax = 0.;
315 originalRMin = ((
G4Tubs*)pSol)->GetInnerRadius();
316 originalRMax = ((
G4Tubs*)pSol)->GetOuterRadius();
318 G4bool visualisable =
true;
319 for (
int n = nBegin; n < nEnd; n++) {
326 translation =
G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
329 translation =
G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
332 translation =
G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
336 ((
G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
337 ((
G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
341 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
342 "\n built-in replicated volumes replicated in radius for "
344 "-type\n solids (your solid \""
346 "\") are not visualisable."
348 visualisable =
false;
352 rotation.
rotateZ (-(offset+(n+0.5)*width));
355 pRotation = &rotation;
358 pVPV -> SetTranslation (translation);
359 pVPV -> SetRotation (pRotation);
360 pVPV -> SetCopyNo (n);
364 theAT, sceneHandler);
368 pVPV -> SetTranslation (originalTranslation);
369 pVPV -> SetRotation (pOriginalRotation);
371 ((
G4Tubs*)pSol)->SetInnerRadius(originalRMin);
372 ((
G4Tubs*)pSol)->SetOuterRadius(originalRMax);
380 G4int requestedDepth,
394 const G4ThreeVector& translation = pVPV -> GetTranslation ();
421 G4Exception(
"G4PhysicalVolumeModelTouchable::DescribeAndDescend",
424 "Algorithm-parameter mismatch for Colour By Density");
435 red = (d1-d)/(d1-d0); green = (d-d0)/(d1-d0); blue = 0.;
437 red = 0.; green = (d2-d)/(d2-d1); blue = (d-d1)/(d2-d1);
439 red = 0.; green = 0.; blue = 1.;
448 pVisAttribs = tempVisAtts;
454 G4bool thisToBeDrawn =
true;
466 for (
const auto& vam: vams) {
467 const auto& vamPath = vam.GetPVNameCopyNoPath();
471 auto iVAMNameCopyNo = vamPath.begin();
473 for (; iVAMNameCopyNo != vamPath.end(); ++iVAMNameCopyNo, ++iPVNodeId) {
475 iVAMNameCopyNo->GetName() ==
476 iPVNodeId->GetPhysicalVolume()->GetName() &&
477 iVAMNameCopyNo->GetCopyNo() ==
478 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
484 if (iVAMNameCopyNo == vamPath.end()) {
490 modifiedVisAtts = *pVisAttribs;
491 pVisAttribs = &modifiedVisAtts;
493 switch (vam.GetVisAttributesSignifier()) {
566 if (cullingInvisible) {
568 if (!markedVisible) thisToBeDrawn =
false;
571 if (cullingLowDensity) {
573 if (density < densityCut) thisToBeDrawn =
false;
577 if (
fAbort) thisToBeDrawn =
false;
600 explodeFactor * oldTranslation.
dy(),
601 explodeFactor * oldTranslation.
dz());
602 theNewAT = centering * newTranslation * oldRotation * oldScale;
615 G4bool daughtersToBeDrawn =
true;
617 if (!nDaughters) daughtersToBeDrawn =
false;
619 else if (requestedDepth == 0) daughtersToBeDrawn =
false;
621 else if (
fAbort) daughtersToBeDrawn =
false;
646 if (cullingInvisible) {
648 if (daughtersInvisible) daughtersToBeDrawn =
false;
651 if (cullingCovered) {
653 if (surfaceDrawing) {
657 if (opaque) daughtersToBeDrawn =
false;
664 if (daughtersToBeDrawn) {
665 for (
G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
671 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
716 if (!pOriginalPolyhedron) {
720 "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
722 "\" has no polyhedron. Cannot by clipped."
746 (
"sectioned_solid", pSol, pSectionSolid, theAT.
inverse());
752 (
"cutaway_solid", pSol, pCutawaySolid, theAT.
inverse());
756 if (!pResultantPolyhedron) {
759 "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
760 "\n solid \"" << pSol->
GetName() <<
761 "\" not defined due to error during Boolean processing."
774 pResultantPolyhedron =
nullptr;
778 if (pResultantPolyhedron) {
785 delete pResultantSolid;
795 size_t nWorlds = transportationManager->
GetNoWorlds();
799 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
801 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
816 if (foundVolume !=
fpTopPV && warn) {
818 "G4PhysicalVolumeModel::Validate(): A volume of the same name and"
821 <<
") still exists and is being used."
822 "\n But it is not the same volume you originally specified"
823 "\n in /vis/scene/add/."
831 if (found)
return true;
835 "G4PhysicalVolumeModel::Validate(): No volume of name and"
848 std::map<G4String,G4AttDef>* store
852 G4AttDef(
"PVPath",
"Physical Volume Path",
"Physics",
"",
"G4String");
853 (*store)[
"BasePVPath"] =
854 G4AttDef(
"BasePVPath",
"Base Physical Volume Path",
"Physics",
"",
"G4String");
856 G4AttDef(
"LVol",
"Logical Volume",
"Physics",
"",
"G4String");
858 G4AttDef(
"Solid",
"Solid Name",
"Physics",
"",
"G4String");
860 G4AttDef(
"EType",
"Entity Type",
"Physics",
"",
"G4String");
862 G4AttDef(
"DmpSol",
"Dump of Solid properties",
"Physics",
"",
"G4String");
863 (*store)[
"LocalTrans"] =
864 G4AttDef(
"LocalTrans",
"Local transformation of volume",
"Physics",
"",
"G4String");
865 (*store)[
"GlobalTrans"] =
866 G4AttDef(
"GlobalTrans",
"Global transformation of volume",
"Physics",
"",
"G4String");
867 (*store)[
"Material"] =
868 G4AttDef(
"Material",
"Material Name",
"Physics",
"",
"G4String");
869 (*store)[
"Density"] =
870 G4AttDef(
"Density",
"Material Density",
"Physics",
"G4BestUnit",
"G4double");
872 G4AttDef(
"State",
"Material State (enum undefined,solid,liquid,gas)",
"Physics",
"",
"G4String");
874 G4AttDef(
"Radlen",
"Material Radiation Length",
"Physics",
"G4BestUnit",
"G4double");
876 G4AttDef(
"Region",
"Cuts Region",
"Physics",
"",
"G4String");
877 (*store)[
"RootRegion"] =
878 G4AttDef(
"RootRegion",
"Root Region (0/1 = false/true)",
"Physics",
"",
"G4bool");
883static std::ostream& operator<< (std::ostream& o,
const G4Transform3D t)
895 o << setw(w) << t.
xx() << setw(w) << t.
xy() << setw(w) << t.
xz() << setw(w) << t.
dx() << endl;
896 o << setw(w) << t.
yx() << setw(w) << t.
yy() << setw(w) << t.
yz() << setw(w) << t.
dy() << endl;
897 o << setw(w) << t.
zx() << setw(w) << t.
zy() << setw(w) << t.
zz() << setw(w) << t.
dz() << endl;
900 o <<
"= translation:" << endl;
901 o << setw(w) << tl.
dx() << setw(w) << tl.
dy() << setw(w) << tl.
dz() << endl;
904 o <<
"* rotation:" << endl;
905 o << setw(w) << r.
xx() << setw(w) << r.
xy() << setw(w) << r.
xz() << endl;
906 o << setw(w) << r.
yx() << setw(w) << r.
yy() << setw(w) << r.
yz() << endl;
907 o << setw(w) << r.
zx() << setw(w) << r.
zy() << setw(w) << r.
zz() << endl;
910 o <<
"* scale:" << endl;
911 o << setw(w) << sc.
xx() << setw(w) << sc.
yy() << setw(w) << sc.
zz() << endl;
914 o <<
"Transformed axes:" << endl;
915 o <<
"x': " << r *
G4Vector3D(1., 0., 0.) << endl;
916 o <<
"y': " << r *
G4Vector3D(0., 1., 0.) << endl;
917 o <<
"z': " << r *
G4Vector3D(0., 0., 1.) << endl;
924 std::vector<G4AttValue>* values =
new std::vector<G4AttValue>;
928 (
"G4PhysicalVolumeModel::CreateCurrentAttValues",
931 "Current logical volume not defined.");
936 values->push_back(
G4AttValue(
"PVPath", oss.str(),
""));
938 values->push_back(
G4AttValue(
"BasePVPath", oss.str(),
""));
943 oss.str(
""); oss <<
'\n' << *pSol;
944 values->push_back(
G4AttValue(
"DmpSol", oss.str(),
""));
947 oss.str(
""); oss <<
'\n' <<
G4Transform3D(localRotation,localTranslation);
948 values->push_back(
G4AttValue(
"LocalTrans", oss.str(),
""));
950 values->push_back(
G4AttValue(
"GlobalTrans", oss.str(),
""));
952 values->push_back(
G4AttValue(
"Material", matName,
""));
956 oss.str(
""); oss << matState;
957 values->push_back(
G4AttValue(
"State", oss.str(),
""));
962 values->push_back(
G4AttValue(
"Region", regionName,
""));
964 values->push_back(
G4AttValue(
"RootRegion", oss.str(),
""));
968G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
971 if (fpPV < right.fpPV)
return true;
972 if (fpPV == right.fpPV) {
973 if (fCopyNo < right.fCopyNo)
return true;
974 if (fCopyNo == right.fCopyNo)
975 return fNonCulledDepth < right.fNonCulledDepth;
980G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator!=
983 if (fpPV != right.fpPV ||
984 fCopyNo != right.fCopyNo ||
985 fNonCulledDepth != right.fNonCulledDepth ||
986 fTransform != right.fTransform ||
987 fDrawn != right.fDrawn)
return true;
991std::ostream&
operator<<
997 <<
' ' << node.GetCopyNo()
1005 os <<
" (Null PV node)";
1010std::ostream&
operator<<
1011(std::ostream& os,
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path)
1016 for (
const auto& nodeID: path) {
1017 os <<
' ' << nodeID;
1024(
const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
1025 fFullPVPath(fullPVPath) {}
1031 G4Exception(
"G4PhysicalVolumeModelTouchable::GetTranslation",
1034 "Index out of range. Asking for non-existent depth");
1037 tempTranslation =
fFullPVPath[i].GetTransform().getTranslation();
1038 return tempTranslation;
1045 G4Exception(
"G4PhysicalVolumeModelTouchable::GetRotation",
1048 "Index out of range. Asking for non-existent depth");
1051 tempRotation =
fFullPVPath[i].GetTransform().getRotation();
1052 return &tempRotation;
1059 G4Exception(
"G4PhysicalVolumeModelTouchable::GetVolume",
1062 "Index out of range. Asking for non-existent depth");
1071 G4Exception(
"G4PhysicalVolumeModelTouchable::GetSolid",
1074 "Index out of range. Asking for non-existent depth");
1076 return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
1083 G4Exception(
"G4PhysicalVolumeModelTouchable::GetReplicaNumber",
1086 "Index out of range. Asking for non-existent depth");
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Vector3D< G4double > G4Vector3D
G4GLOB_DLL std::ostream G4cout
HepRotation & rotateZ(double delta)
const G4VisExtent & GetBoundingExtent() const
G4double GetAlpha() const
G4VSolid * GetSolid() const
const G4VisAttributes * GetVisAttributes() const
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
const G4VisAttributes * GetDefaultVisAttributes() const
const std::vector< VisAttributesModifier > & GetVisAttributesModifiers() const
const G4Point3D & GetExplodeCentre() const
std::vector< PVNameCopyNo > PVNameCopyNoPath
G4bool IsCullingInvisible() const
const std::vector< G4double > & GetCBDParameters() const
G4int GetNoOfSides() const
@ VASForceNumberOfCloudPoints
@ VASForceLineSegmentsPerCircle
G4bool IsDensityCulling() const
void SetDefaultVisAttributes(const G4VisAttributes *pDefaultVisAttributes)
DrawingStyle GetDrawingStyle() const
G4DisplacedSolid * GetSectionSolid() const
G4double GetExplodeFactor() const
G4DisplacedSolid * GetCutawaySolid() const
G4bool IsCullingCovered() const
G4int GetCBDAlgorithmNumber() const
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()
G4Transform3D * fpCurrentTransform
G4String GetCurrentTag() const
std::vector< G4PhysicalVolumeNodeID > fDrawnPVPath
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
G4VPhysicalVolume * GetFoundVolume() const
const G4String & GetName() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void PostAddSolid()=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
void SetModelingParameters(const G4ModelingParameters *)
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 G4Polyhedron * GetPolyhedron() const
virtual G4GeometryType GetEntityType() const =0
G4bool IsForceLineSegmentsPerCircle() const
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
static void SetNumberOfRotationSteps(G4int n)
G4int GetNoFacets() const
static void ResetNumberOfRotationSteps()
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)