60 ,
G4int requestedDepth
64 :
G4VModel (modelTransformation, pMP)
67 , fRequestedDepth (requestedDepth)
68 , fUseFullExtent (useFullExtent)
72 , fpCurrentMaterial (0)
73 , fpCurrentTransform (0)
75 , fCurtailDescent (
false)
77 , fClippingMode (subtraction)
79 fType =
"G4PhysicalVolumeModel";
94 fGlobalDescription =
"G4PhysicalVolumeModel " + fGlobalTag;
98 fTopPVName = fpTopPV -> GetName ();
99 fTopPVCopyNo = fpTopPV -> GetCopyNo ();
100 std::ostringstream o;
101 o << fpTopPV -> GetCopyNo ();
102 fGlobalTag = fpTopPV -> GetName () +
"." + o.str();
103 fGlobalDescription =
"G4PhysicalVolumeModel " + fGlobalTag;
105 fpCurrentPV = fpTopPV;
106 if (fpCurrentPV) fpCurrentLV = fpCurrentPV->GetLogicalVolume();
107 if (fpCurrentLV) fpCurrentMaterial = fpCurrentLV->GetMaterial();
108 fpCurrentTransform =
const_cast<G4Transform3D*
>(&modelTransformation);
162 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
166 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
174 VisitGeometryAndGetVisReps
177 startingTransformation,
184 fpCurrentMaterial = 0;
185 if (fFullPVPath.size() != fBaseFullPVPath.size()) {
188 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
191 "Path at start of modeling not equal to base path. Something badly"
192 "\nwrong. Please contact visualisation coordinator.");
194 fDrawnPVPath.clear();
196 fCurtailDescent =
false;
202 std::ostringstream o;
207 return "WARNING: NO CURRENT VOLUME - global tag is " +
fGlobalTag;
218 G4int requestedDepth,
235 if (!(pVPV -> IsReplicated ())) {
237 pSol = pLV -> GetSolid ();
238 pMaterial = pLV -> GetMaterial ();
239 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
240 theAT, sceneHandler);
249 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
250 if (fCurrentDepth == 0) nReplicas = 1;
253 for (
int n = 0;
n < nReplicas;
n++) {
254 pSol = pP -> ComputeSolid (
n, pVPV);
255 pP -> ComputeTransformation (
n, pVPV);
256 pSol -> ComputeDimensions (pP,
n, pVPV);
257 pVPV -> SetCopyNo (
n);
262 pMaterial = pP -> ComputeMaterial (
n, pVPV, &parentTouchable);
263 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
264 theAT, sceneHandler);
289 pSol = pLV -> GetSolid ();
290 pMaterial = pLV -> GetMaterial ();
291 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
293 G4double originalRMin = 0., originalRMax = 0.;
295 originalRMin = ((
G4Tubs*)pSol)->GetInnerRadius();
296 originalRMax = ((
G4Tubs*)pSol)->GetOuterRadius();
298 G4bool visualisable =
true;
299 for (
int n = 0;
n < nReplicas;
n++) {
306 translation =
G4ThreeVector (-width*(nReplicas-1)*0.5+
n*width,0,0);
309 translation =
G4ThreeVector (0,-width*(nReplicas-1)*0.5+
n*width,0);
312 translation =
G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+
n*width);
316 ((
G4Tubs*)pSol)->SetInnerRadius(width*
n+offset);
317 ((
G4Tubs*)pSol)->SetOuterRadius(width*(
n+1)+offset);
319 if (fpMP->IsWarning())
321 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
322 "\n built-in replicated volumes replicated in radius for "
324 "-type\n solids (your solid \""
326 "\") are not visualisable."
328 visualisable =
false;
332 rotation.
rotateZ (-(offset+(
n+0.5)*width));
335 pRotation = &rotation;
338 pVPV -> SetTranslation (translation);
339 pVPV -> SetRotation (pRotation);
340 pVPV -> SetCopyNo (
n);
342 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
343 theAT, sceneHandler);
347 pVPV -> SetTranslation (originalTranslation);
348 pVPV -> SetRotation (pOriginalRotation);
350 ((
G4Tubs*)pSol)->SetInnerRadius(originalRMin);
351 ((
G4Tubs*)pSol)->SetOuterRadius(originalRMax);
359 G4int requestedDepth,
369 fpCurrentMaterial = pMaterial;
372 const G4ThreeVector& translation = pVPV -> GetTranslation ();
383 if (fCurrentDepth != 0) theNewAT = theAT * theLT;
384 fpCurrentTransform = &theNewAT;
392 if (fpMP->GetCBDAlgorithmNumber() == 1) {
394 if (fpMP->GetCBDParameters().size() != 3) {
395 G4Exception(
"G4PhysicalVolumeModelTouchable::DescribeAndDescend",
398 "Algorithm-parameter mismatch for Colour By Density");
401 const G4double d0 = fpMP->GetCBDParameters()[0];
402 const G4double d1 = fpMP->GetCBDParameters()[1];
403 const G4double d2 = fpMP->GetCBDParameters()[2];
409 red = (d1-
d)/(d1-d0); green = (d-d0)/(d1-d0); blue = 0.;
411 red = 0.; green = (d2-
d)/(d2-d1); blue = (d-
d1)/(d2-d1);
413 red = 0.; green = 0.; blue = 1.;
418 }
else if (fpMP->GetCBDAlgorithmNumber() == 2) {
422 pVisAttribs = tempVisAtts;
428 G4bool thisToBeDrawn =
true;
431 G4int copyNo = fpCurrentPV->GetCopyNo();
432 fFullPVPath.push_back
434 (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
437 const auto& vams = fpMP->GetVisAttributesModifiers();
440 for (
const auto& vam: vams) {
441 const auto& vamPath = vam.GetPVNameCopyNoPath();
442 if (vamPath.size() == fFullPVPath.size()) {
445 auto iVAMNameCopyNo = vamPath.begin();
446 auto iPVNodeId = fFullPVPath.begin();
447 for (; iVAMNameCopyNo != vamPath.end(); ++iVAMNameCopyNo, ++iPVNodeId) {
449 iVAMNameCopyNo->GetName() ==
450 iPVNodeId->GetPhysicalVolume()->GetName() &&
451 iVAMNameCopyNo->GetCopyNo() ==
452 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
458 if (iVAMNameCopyNo == vamPath.end()) {
464 modifiedVisAtts = *pVisAttribs;
465 pVisAttribs = &modifiedVisAtts;
467 switch (vam.GetVisAttributesSignifier()) {
518 G4bool culling = fpMP->IsCulling();
519 G4bool cullingInvisible = fpMP->IsCullingInvisible();
521 G4bool cullingLowDensity = fpMP->IsDensityCulling();
523 G4double densityCut = fpMP -> GetVisibleDensity ();
528 if (cullingInvisible) {
530 if (!markedVisible) thisToBeDrawn =
false;
533 if (cullingLowDensity) {
535 if (density < densityCut) thisToBeDrawn =
false;
539 if (fAbort) thisToBeDrawn =
false;
542 fFullPVPath.back().SetDrawn(thisToBeDrawn);
547 fDrawnPVPath.push_back
549 (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform,thisToBeDrawn));
551 if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
559 G4double explodeFactor = fpMP->GetExplodeFactor();
562 explodeFactor * oldTranslation.
dy(),
563 explodeFactor * oldTranslation.
dz());
564 theNewAT = centering * newTranslation * oldRotation * oldScale;
567 DescribeSolid (theNewAT, pSol, pVisAttribs, sceneHandler);
576 G4bool daughtersToBeDrawn =
true;
578 if (!nDaughters) daughtersToBeDrawn =
false;
580 else if (requestedDepth == 0) daughtersToBeDrawn =
false;
582 else if (fAbort) daughtersToBeDrawn =
false;
584 else if (fCurtailDescent) daughtersToBeDrawn =
false;
592 G4bool cullingCovered = fpMP->IsCullingCovered();
607 if (cullingInvisible) {
609 if (daughtersInvisible) daughtersToBeDrawn =
false;
612 if (cullingCovered) {
614 if (surfaceDrawing) {
618 if (opaque) daughtersToBeDrawn =
false;
625 if (daughtersToBeDrawn) {
626 for (
G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
631 VisitGeometryAndGetVisReps
632 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
640 fCurtailDescent =
false;
643 fFullPVPath.pop_back();
645 fDrawnPVPath.pop_back();
657 G4VSolid* pSectionSolid = fpMP->GetSectionSolid();
658 G4VSolid* pCutawaySolid = fpMP->GetCutawaySolid();
660 if (!fpClippingSolid && !pSectionSolid && !pCutawaySolid) {
662 pSol -> DescribeYourselfTo (sceneHandler);
679 if (fpMP->IsWarning())
681 "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
683 "\" has no polyhedron. Cannot by clipped."
685 pSol -> DescribeYourselfTo (sceneHandler);
693 if (fpClippingSolid) {
694 switch (fClippingMode) {
698 (
"resultant_solid", pSol, fpClippingSolid, theAT.
inverse());
702 (
"resultant_solid", pSol, fpClippingSolid, theAT.
inverse());
709 (
"sectioned_solid", pSol, pSectionSolid, theAT.
inverse());
714 (
"cutaway_solid", pSol, pCutawaySolid, theAT.
inverse());
718 if (tmpResultant) resultant = *tmpResultant;
720 if (fpMP->IsWarning())
722 "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
723 "\n solid \"" << pSol->
GetName() <<
724 "\" not defined due to error during Boolean processing."
725 "\n Original will be drawn in red."
730 delete resultantSolid;
747 size_t nWorlds = transportationManager->
GetNoWorlds();
751 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
753 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
768 if (foundVolume !=
fpTopPV && warn) {
770 "G4PhysicalVolumeModel::Validate(): A volume of the same name and"
773 <<
") still exists and is being used."
774 "\n But it is not the same volume you originally specified"
775 "\n in /vis/scene/add/."
783 if (found)
return true;
787 "G4PhysicalVolumeModel::Validate(): No volume of name and"
800 std::map<G4String,G4AttDef>* store
804 G4AttDef(
"PVPath",
"Physical Volume Path",
"Physics",
"",
"G4String");
806 G4AttDef(
"LVol",
"Logical Volume",
"Physics",
"",
"G4String");
808 G4AttDef(
"Solid",
"Solid Name",
"Physics",
"",
"G4String");
810 G4AttDef(
"EType",
"Entity Type",
"Physics",
"",
"G4String");
812 G4AttDef(
"DmpSol",
"Dump of Solid properties",
"Physics",
"",
"G4String");
813 (*store)[
"LocalTrans"] =
814 G4AttDef(
"LocalTrans",
"Local transformation of volume",
"Physics",
"",
"G4String");
815 (*store)[
"GlobalTrans"] =
816 G4AttDef(
"GlobalTrans",
"Global transformation of volume",
"Physics",
"",
"G4String");
817 (*store)[
"Material"] =
818 G4AttDef(
"Material",
"Material Name",
"Physics",
"",
"G4String");
819 (*store)[
"Density"] =
820 G4AttDef(
"Density",
"Material Density",
"Physics",
"G4BestUnit",
"G4double");
822 G4AttDef(
"State",
"Material State (enum undefined,solid,liquid,gas)",
"Physics",
"",
"G4String");
824 G4AttDef(
"Radlen",
"Material Radiation Length",
"Physics",
"G4BestUnit",
"G4double");
826 G4AttDef(
"Region",
"Cuts Region",
"Physics",
"",
"G4String");
827 (*store)[
"RootRegion"] =
828 G4AttDef(
"RootRegion",
"Root Region (0/1 = false/true)",
"Physics",
"",
"G4bool");
847 o << setw(
w) << t.
xx() << setw(
w) << t.
xy() << setw(
w) << t.
xz() << setw(
w) << t.
dx() << endl;
848 o << setw(
w) << t.
yx() << setw(
w) << t.
yy() << setw(
w) << t.
yz() << setw(
w) << t.
dy() << endl;
849 o << setw(
w) << t.
zx() << setw(
w) << t.
zy() << setw(
w) << t.
zz() << setw(
w) << t.
dz() << endl;
852 o <<
"= translation:" << endl;
853 o << setw(
w) << tl.dx() << setw(
w) << tl.dy() << setw(
w) << tl.dz() << endl;
856 o <<
"* rotation:" << endl;
857 o << setw(
w) << r.xx() << setw(
w) << r.xy() << setw(
w) << r.xz() << endl;
858 o << setw(
w) << r.yx() << setw(
w) << r.yy() << setw(
w) << r.yz() << endl;
859 o << setw(
w) << r.zx() << setw(
w) << r.zy() << setw(
w) << r.zz() << endl;
862 o <<
"* scale:" << endl;
863 o << setw(
w) << sc.xx() << setw(
w) << sc.yy() << setw(
w) << sc.zz() << endl;
866 o <<
"Transformed axes:" << endl;
867 o <<
"x': " << r *
G4Vector3D(1., 0., 0.) << endl;
868 o <<
"y': " << r *
G4Vector3D(0., 1., 0.) << endl;
869 o <<
"z': " << r *
G4Vector3D(0., 0., 1.) << endl;
876 std::vector<G4AttValue>* values =
new std::vector<G4AttValue>;
877 std::ostringstream oss;
879 oss <<
fFullPVPath[i].GetPhysicalVolume()->GetName()
886 (
"G4PhysicalVolumeModel::CreateCurrentAttValues",
889 "Current logical volume not defined.");
893 values->push_back(
G4AttValue(
"PVPath", oss.str(),
""));
898 oss.str(
""); oss <<
'\n' << *pSol;
899 values->push_back(
G4AttValue(
"DmpSol", oss.str(),
""));
902 oss.str(
""); oss <<
'\n' <<
G4Transform3D(localRotation,localTranslation);
903 values->push_back(
G4AttValue(
"LocalTrans", oss.str(),
""));
905 values->push_back(
G4AttValue(
"GlobalTrans", oss.str(),
""));
907 values->push_back(
G4AttValue(
"Material", matName,
""));
911 oss.str(
""); oss << matState;
912 values->push_back(
G4AttValue(
"State", oss.str(),
""));
917 values->push_back(
G4AttValue(
"Region", regionName,
""));
919 values->push_back(
G4AttValue(
"RootRegion", oss.str(),
""));
923 G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
926 if (fpPV <
right.fpPV)
return true;
927 if (fpPV ==
right.fpPV) {
928 if (fCopyNo <
right.fCopyNo)
return true;
929 if (fCopyNo ==
right.fCopyNo)
930 return fNonCulledDepth <
right.fNonCulledDepth;
935 std::ostream&
operator<<
941 <<
' ' << node.GetCopyNo()
949 os <<
" (Null node)";
954 std::ostream&
operator<<
955 (std::ostream& os,
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path)
957 for (
const auto& nodeID: path) {
964 (
const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
965 fFullPVPath(fullPVPath) {}
971 G4Exception(
"G4PhysicalVolumeModelTouchable::GetTranslation",
974 "Index out of range. Asking for non-existent depth");
977 tempTranslation =
fFullPVPath[i].GetTransform().getTranslation();
978 return tempTranslation;
985 G4Exception(
"G4PhysicalVolumeModelTouchable::GetRotation",
988 "Index out of range. Asking for non-existent depth");
991 tempRotation =
fFullPVPath[i].GetTransform().getRotation();
992 return &tempRotation;
999 G4Exception(
"G4PhysicalVolumeModelTouchable::GetVolume",
1002 "Index out of range. Asking for non-existent depth");
1011 G4Exception(
"G4PhysicalVolumeModelTouchable::GetSolid",
1014 "Index out of range. Asking for non-existent depth");
1016 return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
1023 G4Exception(
"G4PhysicalVolumeModelTouchable::GetReplicaNumber",
1026 "Index out of range. Asking for non-existent depth");
G4Transform3D * fpCurrentTransform
void SetDefaultVisAttributes(const G4VisAttributes *pDefaultVisAttributes)
CLHEP::Hep3Vector G4ThreeVector
void SetForceAuxEdgeVisible(G4bool=true)
const G4RotationMatrix * GetRotation(G4int depth) const
G4VPhysicalVolume * fpTopPV
void DescribeYourselfTo(G4VGraphicsScene &)
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
virtual G4Polyhedron * GetPolyhedron() const
void SetLineStyle(LineStyle)
G4VPhysicalVolume * fpCurrentPV
static void ResetNumberOfRotationSteps()
virtual ~G4PhysicalVolumeModel()
const G4String & GetName() const
virtual void EndPrimitives()=0
G4double GetRadlen() const
ForcedDrawingStyle GetForcedDrawingStyle() const
void VisitGeometryAndGetVisReps(G4VPhysicalVolume *, G4int requestedDepth, const G4Transform3D &, G4VGraphicsScene &)
G4VPhysicalVolume * GetFoundVolume() const
G4int GetNoDaughters() const
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
const std::vector< G4PhysicalVolumeNodeID > & fFullPVPath
const G4ThreeVector & GetTranslation() const
G4bool IsForceLineSegmentsPerCircle() const
static void SetNumberOfRotationSteps(G4int n)
G4double GetRadius() const
G4bool IsForceAuxEdgeVisible() const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
G4String GetCurrentDescription() const
void SetModelingParameters(const G4ModelingParameters *)
const G4String & GetName() const
G4bool IsForcedAuxEdgeVisible() const
void SetForceLineSegmentsPerCircle(G4int nSegments)
const G4VisExtent & GetExtent() const
G4int GetReplicaNumber(G4int depth) const
G4bool Validate(G4bool warn)
G4VPhysicalVolume * GetVolume(G4int depth) const
const G4Point3D & GetCentre() const
G4VSolid * fpClippingSolid
G4String GetCurrentTag() const
G4double GetLineWidth() const
const G4ModelingParameters * fpMP
G4RotationMatrix GetObjectRotationValue() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
const G4VisAttributes * GetVisAttributes() const
G4Material * fpCurrentMaterial
size_t GetNoWorlds() const
virtual void AddPrimitive(const G4Polyline &)=0
G4bool IsRootRegion() const
HepGeom::Vector3D< G4double > G4Vector3D
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4VisAttributes * GetDefaultVisAttributes() const
static G4TransportationManager * GetTransportationManager()
void SetForceSolid(G4bool=true)
const G4ThreeVector & GetTranslation(G4int depth) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void SetVisibility(G4bool=true)
G4VSolid * GetSolid(G4int depth) const
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)
G4PhysicalVolumeModel(G4VPhysicalVolume *=0, G4int requestedDepth=UNLIMITED, const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0, G4bool useFullExtent=false)
G4bool IsForceDrawingStyle() const
virtual void PostAddSolid()=0
void SetDaughtersInvisible(G4bool=true)
G4double GetAlpha() const
void DescribeAndDescend(G4VPhysicalVolume *, G4int requestedDepth, G4LogicalVolume *, G4VSolid *, G4Material *, const G4Transform3D &, G4VGraphicsScene &)
HepRotation & rotateZ(double delta)
G4GLOB_DLL std::ostream G4cout
std::vector< G4PhysicalVolumeNodeID > fFullPVPath
void SetLineWidth(G4double)
G4VSolid * GetSolid() const
void SetColour(const G4Colour &)
void SetForceWireframe(G4bool=true)
virtual G4GeometryType GetEntityType() const =0
virtual void DescribeSolid(const G4Transform3D &theAT, G4VSolid *pSol, const G4VisAttributes *pVisAttribs, G4VGraphicsScene &sceneHandler)
LineStyle GetLineStyle() const
G4int GetForcedLineSegmentsPerCircle() const
G4PhysicalVolumeModelTouchable(const std::vector< G4PhysicalVolumeNodeID > &fullPVPath)
G4Region * GetRegion() const
std::vector< G4AttValue > * CreateCurrentAttValues() const
void SetVisAttributes(const G4VisAttributes *)
const G4Colour & GetColour() const
const G4String & GetName() const
const G4String & GetName() const
G4bool IsDaughtersInvisible() const
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
G4double GetDensity() const
G4LogicalVolume * fpCurrentLV