65 ,
G4int requestedDepth
69 ,
const std::vector<G4PhysicalVolumeNodeID>& baseFullPVPath)
72, fTopPVCopyNo (pVPV? pVPV->GetCopyNo(): 0)
73, fRequestedDepth (requestedDepth)
74, fUseFullExtent (useFullExtent)
75, fTransform (modelTransform)
77, fpCurrentPV (fpTopPV)
78, fCurrentPVCopyNo (fpTopPV? fpTopPV->GetCopyNo(): 0)
79, fpCurrentLV (fpTopPV? fpTopPV->GetLogicalVolume(): 0)
80, fpCurrentMaterial (fpCurrentLV? fpCurrentLV->GetMaterial(): 0)
81, fCurrentTransform (modelTransform)
82, fBaseFullPVPath (baseFullPVPath)
84, fCurtailDescent (false)
86, fClippingMode (subtraction)
88 fType =
"G4PhysicalVolumeModel";
108 std::ostringstream oss;
123(
const std::vector<G4PhysicalVolumeNodeID>& path)
126 for (
const auto& node: path) {
127 PVNameCopyNoPath.push_back
129 (node.GetPhysicalVolume()->GetName(),node.GetCopyNo()));
131 return PVNameCopyNoPath;
183 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
187 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
197 startingTransformation,
220 std::ostringstream o;
225 return "WARNING: NO CURRENT VOLUME - global tag is " +
fGlobalTag;
236 G4int requestedDepth,
252 if (!(pVPV -> IsReplicated ())) {
254 pSol = pLV -> GetSolid ();
255 pMaterial = pLV -> GetMaterial ();
257 theAT, sceneHandler);
266 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
268 G4int nEnd = nReplicas;
275 for (
int n = nBegin;
n < nEnd;
n++) {
276 pSol = pP -> ComputeSolid (
n, pVPV);
277 pP -> ComputeTransformation (
n, pVPV);
278 pSol -> ComputeDimensions (pP,
n, pVPV);
279 pVPV -> SetCopyNo (
n);
285 pMaterial = pP -> ComputeMaterial (
n, pVPV, &parentTouchable);
287 theAT, sceneHandler);
312 pSol = pLV -> GetSolid ();
313 pMaterial = pLV -> GetMaterial ();
314 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
316 G4double originalRMin = 0., originalRMax = 0.;
318 originalRMin = ((
G4Tubs*)pSol)->GetInnerRadius();
319 originalRMax = ((
G4Tubs*)pSol)->GetOuterRadius();
321 G4bool visualisable =
true;
322 for (
int n = nBegin;
n < nEnd;
n++) {
329 translation =
G4ThreeVector (-width*(nReplicas-1)*0.5+
n*width,0,0);
332 translation =
G4ThreeVector (0,-width*(nReplicas-1)*0.5+
n*width,0);
335 translation =
G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+
n*width);
339 ((
G4Tubs*)pSol)->SetInnerRadius(width*
n+offset);
340 ((
G4Tubs*)pSol)->SetOuterRadius(width*(
n+1)+offset);
344 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
345 "\n built-in replicated volumes replicated in radius for "
347 "-type\n solids (your solid \""
349 "\") are not visualisable."
351 visualisable =
false;
355 rotation.
rotateZ (-(offset+(
n+0.5)*width));
358 pRotation = &rotation;
361 pVPV -> SetTranslation (translation);
362 pVPV -> SetRotation (pRotation);
363 pVPV -> SetCopyNo (
n);
367 theAT, sceneHandler);
371 pVPV -> SetTranslation (originalTranslation);
372 pVPV -> SetRotation (pOriginalRotation);
374 ((
G4Tubs*)pSol)->SetInnerRadius(originalRMin);
375 ((
G4Tubs*)pSol)->SetOuterRadius(originalRMax);
383 G4int requestedDepth,
405 const G4ThreeVector& translation = pVPV -> GetTranslation ();
432 G4Exception(
"G4PhysicalVolumeModelTouchable::DescribeAndDescend",
435 "Algorithm-parameter mismatch for Colour By Density");
446 red = (
d1-d)/(
d1-d0); green = (d-d0)/(
d1-d0); blue = 0.;
448 red = 0.; green = (
d2-d)/(
d2-
d1); blue = (d-
d1)/(
d2-
d1);
450 red = 0.; green = 0.; blue = 1.;
459 pVisAttribs = tempVisAtts;
468 for (
const auto& vam: vams) {
469 const auto& vamPath = vam.GetPVNameCopyNoPath();
473 auto iVAMNameCopyNo = vamPath.begin();
475 for (; iVAMNameCopyNo != vamPath.end(); ++iVAMNameCopyNo, ++iPVNodeId) {
477 iVAMNameCopyNo->GetName() ==
478 iPVNodeId->GetPhysicalVolume()->GetName() &&
479 iVAMNameCopyNo->GetCopyNo() ==
480 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
486 if (iVAMNameCopyNo == vamPath.end()) {
492 modifiedVisAtts = *pVisAttribs;
493 pVisAttribs = &modifiedVisAtts;
495 switch (vam.GetVisAttributesSignifier()) {
563 if (pVPV->
GetName() == pvNameCopyNo.GetName()) {
565 if (pvNameCopyNo.GetCopyNo() < 0) {
569 if (pVPV->
GetCopyNo() == pvNameCopyNo.GetCopyNo()) {
577 goto continue_processing;
582 G4Mesh mesh(pVPV,theNewAT);
596 G4bool thisToBeDrawn =
true;
611 if (cullingInvisible) {
613 if (!markedVisible) thisToBeDrawn =
false;
616 if (cullingLowDensity) {
618 if (density < densityCut) thisToBeDrawn =
false;
622 if (
fAbort) thisToBeDrawn =
false;
625 nodeID.SetDrawn(thisToBeDrawn);
643 explodeFactor * oldTranslation.
dy(),
644 explodeFactor * oldTranslation.
dz());
645 theNewAT = centering * newTranslation * oldRotation * oldScale;
658 G4bool daughtersToBeDrawn =
true;
660 if (!nDaughters) daughtersToBeDrawn =
false;
662 else if (requestedDepth == 0) daughtersToBeDrawn =
false;
664 else if (
fAbort) daughtersToBeDrawn =
false;
689 if (cullingInvisible) {
691 if (daughtersInvisible) daughtersToBeDrawn =
false;
694 if (cullingCovered) {
696 if (surfaceDrawing) {
700 if (opaque) daughtersToBeDrawn =
false;
707 if (daughtersToBeDrawn) {
708 for (
G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
714 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
760 if (!pOriginalPolyhedron) {
764 "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
766 "\" has no polyhedron. Cannot by clipped."
790 (
"sectioned_solid", pSol, pSectionSolid, theAT.
inverse());
796 (
"cutaway_solid", pSol, pCutawaySolid, theAT.
inverse());
800 if (!pResultantPolyhedron) {
803 "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
804 "\n solid \"" << pSol->
GetName() <<
805 "\" not defined due to error during Boolean processing."
818 pResultantPolyhedron =
nullptr;
822 if (pResultantPolyhedron) {
830 delete pResultantSolid;
844 auto iterator = find(pvStore->begin(),pvStore->end(),
fpTopPV);
845 if (iterator == pvStore->end()) {
848 ed <<
"Attempt to validate a volume that is no longer in the physical volume store.";
910 std::map<G4String,G4AttDef>* store
914 G4AttDef(
"PVPath",
"Physical Volume Path",
"Physics",
"",
"G4String");
915 (*store)[
"BasePVPath"] =
916 G4AttDef(
"BasePVPath",
"Base Physical Volume Path",
"Physics",
"",
"G4String");
918 G4AttDef(
"LVol",
"Logical Volume",
"Physics",
"",
"G4String");
920 G4AttDef(
"Solid",
"Solid Name",
"Physics",
"",
"G4String");
922 G4AttDef(
"EType",
"Entity Type",
"Physics",
"",
"G4String");
924 G4AttDef(
"DmpSol",
"Dump of Solid properties",
"Physics",
"",
"G4String");
925 (*store)[
"LocalTrans"] =
926 G4AttDef(
"LocalTrans",
"Local transformation of volume",
"Physics",
"",
"G4String");
927 (*store)[
"GlobalTrans"] =
928 G4AttDef(
"GlobalTrans",
"Global transformation of volume",
"Physics",
"",
"G4String");
929 (*store)[
"Material"] =
930 G4AttDef(
"Material",
"Material Name",
"Physics",
"",
"G4String");
931 (*store)[
"Density"] =
932 G4AttDef(
"Density",
"Material Density",
"Physics",
"G4BestUnit",
"G4double");
934 G4AttDef(
"State",
"Material State (enum undefined,solid,liquid,gas)",
"Physics",
"",
"G4String");
936 G4AttDef(
"Radlen",
"Material Radiation Length",
"Physics",
"G4BestUnit",
"G4double");
938 G4AttDef(
"Region",
"Cuts Region",
"Physics",
"",
"G4String");
939 (*store)[
"RootRegion"] =
940 G4AttDef(
"RootRegion",
"Root Region (0/1 = false/true)",
"Physics",
"",
"G4bool");
957 o << setw(w) << t.
xx() << setw(w) << t.
xy() << setw(w) << t.
xz() << setw(w) << t.
dx() << endl;
958 o << setw(w) << t.
yx() << setw(w) << t.
yy() << setw(w) << t.
yz() << setw(w) << t.
dy() << endl;
959 o << setw(w) << t.
zx() << setw(w) << t.
zy() << setw(w) << t.
zz() << setw(w) << t.
dz() << endl;
962 o <<
"= translation:" << endl;
963 o << setw(w) << tl.
dx() << setw(w) << tl.
dy() << setw(w) << tl.
dz() << endl;
966 o <<
"* rotation:" << endl;
967 o << setw(w) << r.
xx() << setw(w) << r.
xy() << setw(w) << r.
xz() << endl;
968 o << setw(w) << r.
yx() << setw(w) << r.
yy() << setw(w) << r.
yz() << endl;
969 o << setw(w) << r.
zx() << setw(w) << r.
zy() << setw(w) << r.
zz() << endl;
972 o <<
"* scale:" << endl;
973 o << setw(w) << sc.
xx() << setw(w) << sc.
yy() << setw(w) << sc.
zz() << endl;
976 o <<
"Transformed axes:" << endl;
977 o <<
"x': " << r *
G4Vector3D(1., 0., 0.) << endl;
978 o <<
"y': " << r *
G4Vector3D(0., 1., 0.) << endl;
979 o <<
"z': " << r *
G4Vector3D(0., 0., 1.) << endl;
986 std::vector<G4AttValue>* values =
new std::vector<G4AttValue>;
990 (
"G4PhysicalVolumeModel::CreateCurrentAttValues",
993 "Current logical volume not defined.");
998 values->push_back(
G4AttValue(
"PVPath", oss.str(),
""));
1000 values->push_back(
G4AttValue(
"BasePVPath", oss.str(),
""));
1005 oss.str(
""); oss <<
'\n' << *pSol;
1006 values->push_back(
G4AttValue(
"DmpSol", oss.str(),
""));
1009 oss.str(
""); oss <<
'\n' <<
G4Transform3D(localRotation,localTranslation);
1010 values->push_back(
G4AttValue(
"LocalTrans", oss.str(),
""));
1012 values->push_back(
G4AttValue(
"GlobalTrans", oss.str(),
""));
1014 values->push_back(
G4AttValue(
"Material", matName,
""));
1018 oss.str(
""); oss << matState;
1019 values->push_back(
G4AttValue(
"State", oss.str(),
""));
1024 values->push_back(
G4AttValue(
"Region", regionName,
""));
1026 values->push_back(
G4AttValue(
"RootRegion", oss.str(),
""));
1030G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
1033 if (fpPV < right.fpPV)
return true;
1034 if (fpPV == right.fpPV) {
1035 if (fCopyNo < right.fCopyNo)
return true;
1036 if (fCopyNo == right.fCopyNo)
1037 return fNonCulledDepth < right.fNonCulledDepth;
1042G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator!=
1045 if (fpPV != right.fpPV ||
1046 fCopyNo != right.fCopyNo ||
1047 fNonCulledDepth != right.fNonCulledDepth ||
1048 fTransform != right.fTransform ||
1049 fDrawn != right.fDrawn)
return true;
1053std::ostream&
operator<<
1059 <<
' ' << node.GetCopyNo()
1067 os <<
" (Null PV node)";
1072std::ostream&
operator<<
1073(std::ostream& os,
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path)
1078 for (
const auto& nodeID: path) {
1079 os <<
' ' << nodeID;
1086(
const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
1087 fFullPVPath(fullPVPath) {}
1093 G4Exception(
"G4PhysicalVolumeModelTouchable::GetTranslation",
1096 "Index out of range. Asking for non-existent depth");
1099 tempTranslation =
fFullPVPath[i].GetTransform().getTranslation();
1100 return tempTranslation;
1107 G4Exception(
"G4PhysicalVolumeModelTouchable::GetRotation",
1110 "Index out of range. Asking for non-existent depth");
1113 tempRotation =
fFullPVPath[i].GetTransform().getRotation();
1114 return &tempRotation;
1121 G4Exception(
"G4PhysicalVolumeModelTouchable::GetVolume",
1124 "Index out of range. Asking for non-existent depth");
1133 G4Exception(
"G4PhysicalVolumeModelTouchable::GetSolid",
1136 "Index out of range. Asking for non-existent depth");
1138 return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
1145 G4Exception(
"G4PhysicalVolumeModelTouchable::GetReplicaNumber",
1148 "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
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
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
G4int GetNoOfSides() 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
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 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
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
G4VisExtent & Transform(const G4Transform3D &)
void SetVisAttributes(const G4VisAttributes *)
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
static void SetNumberOfRotationSteps(G4int n)
G4int GetNoFacets() const
static void ResetNumberOfRotationSteps()
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)