66 fRequestedDepth (requestedDepth),
67 fUseFullExtent (useFullExtent),
71 fpCurrentMaterial (0),
72 fpCurrentTransform (0),
73 fCurtailDescent (
false),
75 fClippingMode (subtraction)
79 fType =
"G4PhysicalVolumeModel";
80 fTopPVName = fpTopPV -> GetName ();
81 fTopPVCopyNo = fpTopPV -> GetCopyNo ();
83 o << fpTopPV -> GetCopyNo ();
84 fGlobalTag = fpTopPV -> GetName () +
"." + o.str();
85 fGlobalDescription =
"G4PhysicalVolumeModel " + fGlobalTag;
139 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
143 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
151 VisitGeometryAndGetVisReps
154 startingTransformation,
161 fpCurrentMaterial = 0;
162 if (fFullPVPath.size() != fBaseFullPVPath.size()) {
165 (
"G4PhysicalVolumeModel::DescribeYourselfTo",
168 "Path at start of modeling not equal to base path. Something badly"
169 "\nwrong. Please contact visualisation coordinator.");
171 fDrawnPVPath.clear();
177 std::ostringstream o;
182 return "WARNING: NO CURRENT VOLUME - global tag is " +
fGlobalTag;
193 G4int requestedDepth,
210 if (!(pVPV -> IsReplicated ())) {
212 pSol = pLV -> GetSolid ();
213 pMaterial = pLV -> GetMaterial ();
214 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
215 theAT, sceneHandler);
224 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
225 if (fCurrentDepth == 0) nReplicas = 1;
228 for (
int n = 0;
n < nReplicas;
n++) {
229 pSol = pP -> ComputeSolid (
n, pVPV);
230 pP -> ComputeTransformation (
n, pVPV);
231 pSol -> ComputeDimensions (pP,
n, pVPV);
232 pVPV -> SetCopyNo (
n);
237 pMaterial = pP -> ComputeMaterial (
n, pVPV, &parentTouchable);
238 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
239 theAT, sceneHandler);
264 pSol = pLV -> GetSolid ();
265 pMaterial = pLV -> GetMaterial ();
266 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
268 G4double originalRMin = 0., originalRMax = 0.;
270 originalRMin = ((
G4Tubs*)pSol)->GetInnerRadius();
271 originalRMax = ((
G4Tubs*)pSol)->GetOuterRadius();
273 G4bool visualisable =
true;
274 for (
int n = 0;
n < nReplicas;
n++) {
281 translation =
G4ThreeVector (-width*(nReplicas-1)*0.5+
n*width,0,0);
284 translation =
G4ThreeVector (0,-width*(nReplicas-1)*0.5+
n*width,0);
287 translation =
G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+
n*width);
291 ((
G4Tubs*)pSol)->SetInnerRadius(width*
n+offset);
292 ((
G4Tubs*)pSol)->SetOuterRadius(width*(
n+1)+offset);
294 if (fpMP->IsWarning())
296 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
297 "\n built-in replicated volumes replicated in radius for "
299 "-type\n solids (your solid \""
301 "\") are not visualisable."
303 visualisable =
false;
307 rotation.
rotateZ (-(offset+(
n+0.5)*width));
310 pRotation = &rotation;
313 pVPV -> SetTranslation (translation);
314 pVPV -> SetRotation (pRotation);
315 pVPV -> SetCopyNo (
n);
317 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
318 theAT, sceneHandler);
322 pVPV -> SetTranslation (originalTranslation);
323 pVPV -> SetRotation (pOriginalRotation);
325 ((
G4Tubs*)pSol)->SetInnerRadius(originalRMin);
326 ((
G4Tubs*)pSol)->SetOuterRadius(originalRMax);
336 G4int requestedDepth,
346 fpCurrentMaterial = pMaterial;
349 const G4ThreeVector& translation = pVPV -> GetTranslation ();
360 if (fCurrentDepth != 0) theNewAT = theAT * theLT;
361 fpCurrentTransform = &theNewAT;
364 if (!pVisAttribs) pVisAttribs = fpMP->GetDefaultVisAttributes();
366 G4bool visAttsCreated =
false;
369 visAttsCreated =
true;
374 G4bool thisToBeDrawn =
true;
377 G4int copyNo = fpCurrentPV->GetCopyNo();
378 fFullPVPath.push_back
380 (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
383 G4bool copyForVAM =
false;
388 const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
389 fpMP->GetVisAttributesModifiers();
390 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
392 for (iModifier = vams.begin();
393 iModifier != vams.end();
396 iModifier->GetPVNameCopyNoPath();
397 if (vamPath.size() == fFullPVPath.size()) {
401 std::vector<G4PhysicalVolumeNodeID>::const_iterator iPVNodeId;
402 for (iVAMNameCopyNo = vamPath.begin(), iPVNodeId = fFullPVPath.begin();
403 iVAMNameCopyNo != vamPath.end();
404 ++iVAMNameCopyNo, ++iPVNodeId) {
412 iVAMNameCopyNo->GetName() ==
413 iPVNodeId->GetPhysicalVolume()->GetName() &&
414 iVAMNameCopyNo->GetCopyNo() ==
415 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
420 if (iVAMNameCopyNo == vamPath.end()) {
424 pVisAttribs = pModifiedVisAtts;
428 switch (iModifier->GetVisAttributesSignifier()) {
474 G4bool culling = fpMP->IsCulling();
475 G4bool cullingInvisible = fpMP->IsCullingInvisible();
477 G4bool cullingLowDensity = fpMP->IsDensityCulling();
479 G4double densityCut = fpMP -> GetVisibleDensity ();
484 if (cullingInvisible) {
486 if (!markedVisible) thisToBeDrawn =
false;
489 if (cullingLowDensity) {
491 if (density < densityCut) thisToBeDrawn =
false;
496 fFullPVPath.back().SetDrawn(thisToBeDrawn);
501 fDrawnPVPath.push_back
503 (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform,thisToBeDrawn));
505 if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
513 G4double explodeFactor = fpMP->GetExplodeFactor();
516 explodeFactor * oldTranslation.
dy(),
517 explodeFactor * oldTranslation.
dz());
518 theNewAT = centering * newTranslation * oldRotation * oldScale;
521 DescribeSolid (theNewAT, pSol, pVisAttribs, sceneHandler);
530 G4bool daughtersToBeDrawn =
true;
532 if (!nDaughters) daughtersToBeDrawn =
false;
534 else if (requestedDepth == 0) daughtersToBeDrawn =
false;
536 else if (fCurtailDescent) daughtersToBeDrawn =
false;
544 G4bool cullingCovered = fpMP->IsCullingCovered();
559 if (cullingInvisible) {
561 if (daughtersInvisible) daughtersToBeDrawn =
false;
564 if (cullingCovered) {
566 if (surfaceDrawing) {
570 if (opaque) daughtersToBeDrawn =
false;
579 delete pModifiedVisAtts;
580 pVisAttribs = pUnmodifiedVisAtts;
584 if (visAttsCreated)
delete pVisAttribs;
586 if (daughtersToBeDrawn) {
587 for (
G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
592 VisitGeometryAndGetVisReps
593 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
599 fCurtailDescent =
false;
602 fFullPVPath.pop_back();
604 fDrawnPVPath.pop_back();
616 G4VSolid* pSectionSolid = fpMP->GetSectionSolid();
617 G4VSolid* pCutawaySolid = fpMP->GetCutawaySolid();
619 if (!fpClippingSolid && !pSectionSolid && !pCutawaySolid) {
621 pSol -> DescribeYourselfTo (sceneHandler);
638 if (fpMP->IsWarning())
640 "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
642 "\" has no polyhedron. Cannot by clipped."
644 pSol -> DescribeYourselfTo (sceneHandler);
652 if (fpClippingSolid) {
653 switch (fClippingMode) {
657 (
"resultant_solid", pSol, fpClippingSolid, theAT.
inverse());
661 (
"resultant_solid", pSol, fpClippingSolid, theAT.
inverse());
668 (
"sectioned_solid", pSol, pSectionSolid, theAT.
inverse());
673 (
"cutaway_solid", pSol, pCutawaySolid, theAT.
inverse());
677 if (tmpResultant) resultant = *tmpResultant;
679 if (fpMP->IsWarning())
681 "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
682 "\n solid \"" << pSol->
GetName() <<
683 "\" not defined due to error during Boolean processing."
684 "\n Original will be drawn in red."
689 delete resultantSolid;
706 size_t nWorlds = transportationManager->
GetNoWorlds();
710 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
712 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
725 if (foundVolume !=
fpTopPV && warn) {
727 "G4PhysicalVolumeModel::Validate(): A volume of the same name and"
730 <<
") still exists and is being used."
731 "\n But it is not the same volume you originally specified"
732 "\n in /vis/scene/add/."
740 if (found)
return true;
744 "G4PhysicalVolumeModel::Validate(): No volume of name and"
757 std::map<G4String,G4AttDef>* store
761 G4AttDef(
"PVPath",
"Physical Volume Path",
"Physics",
"",
"G4String");
763 G4AttDef(
"LVol",
"Logical Volume",
"Physics",
"",
"G4String");
765 G4AttDef(
"Solid",
"Solid Name",
"Physics",
"",
"G4String");
767 G4AttDef(
"EType",
"Entity Type",
"Physics",
"",
"G4String");
769 G4AttDef(
"DmpSol",
"Dump of Solid properties",
"Physics",
"",
"G4String");
771 G4AttDef(
"Trans",
"Transformation of volume",
"Physics",
"",
"G4String");
772 (*store)[
"Material"] =
773 G4AttDef(
"Material",
"Material Name",
"Physics",
"",
"G4String");
774 (*store)[
"Density"] =
775 G4AttDef(
"Density",
"Material Density",
"Physics",
"G4BestUnit",
"G4double");
777 G4AttDef(
"State",
"Material State (enum undefined,solid,liquid,gas)",
"Physics",
"",
"G4String");
779 G4AttDef(
"Radlen",
"Material Radiation Length",
"Physics",
"G4BestUnit",
"G4double");
781 G4AttDef(
"Region",
"Cuts Region",
"Physics",
"",
"G4String");
782 (*store)[
"RootRegion"] =
783 G4AttDef(
"RootRegion",
"Root Region (0/1 = false/true)",
"Physics",
"",
"G4bool");
802 o << setw(w) << t.
xx() << setw(w) << t.
xy() << setw(w) << t.
xz() << setw(w) << t.
dx() << endl;
803 o << setw(w) << t.
yx() << setw(w) << t.
yy() << setw(w) << t.
yz() << setw(w) << t.
dy() << endl;
804 o << setw(w) << t.
zx() << setw(w) << t.
zy() << setw(w) << t.
zz() << setw(w) << t.
dz() << endl;
807 o <<
"= translation:" << endl;
808 o << setw(w) << tl.dx() << setw(w) << tl.dy() << setw(w) << tl.dz() << endl;
811 o <<
"* rotation:" << endl;
812 o << setw(w) <<
r.xx() << setw(w) <<
r.xy() << setw(w) <<
r.xz() << endl;
813 o << setw(w) <<
r.yx() << setw(w) <<
r.yy() << setw(w) <<
r.yz() << endl;
814 o << setw(w) <<
r.zx() << setw(w) <<
r.zy() << setw(w) <<
r.zz() << endl;
817 o <<
"* scale:" << endl;
818 o << setw(w) << sc.xx() << setw(w) << sc.yy() << setw(w) << sc.zz() << endl;
821 o <<
"Transformed axes:" << endl;
831 std::vector<G4AttValue>* values =
new std::vector<G4AttValue>;
832 std::ostringstream oss;
834 oss <<
fFullPVPath[i].GetPhysicalVolume()->GetName()
841 (
"G4PhysicalVolumeModel::CreateCurrentAttValues",
844 "Current logical volume not defined.");
848 values->push_back(
G4AttValue(
"PVPath", oss.str(),
""));
853 oss.str(
""); oss <<
'\n' << *pSol;
854 values->push_back(
G4AttValue(
"DmpSol", oss.str(),
""));
856 values->push_back(
G4AttValue(
"Trans", oss.str(),
""));
858 values->push_back(
G4AttValue(
"Material", matName,
""));
862 oss.str(
""); oss << matState;
863 values->push_back(
G4AttValue(
"State", oss.str(),
""));
868 values->push_back(
G4AttValue(
"Region", regionName,
""));
870 values->push_back(
G4AttValue(
"RootRegion", oss.str(),
""));
874 G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
877 if (fpPV <
right.fpPV)
return true;
878 if (fpPV ==
right.fpPV) {
879 if (fCopyNo <
right.fCopyNo)
return true;
880 if (fCopyNo ==
right.fCopyNo)
881 return fNonCulledDepth <
right.fNonCulledDepth;
886 std::ostream&
operator<<
892 <<
':' << node.GetCopyNo()
893 <<
'[' << node.GetNonCulledDepth() <<
']'
894 <<
':' << node.GetTransform();
895 if (!node.GetDrawn()) os <<
" Not "; os <<
"drawn";
903 (
const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
904 fFullPVPath(fullPVPath) {}
908 size_t i = fFullPVPath.size() - depth - 1;
909 if (i >= fFullPVPath.size()) {
910 G4Exception(
"G4PhysicalVolumeModelTouchable::GetTranslation",
913 "Index out of range. Asking for non-existent depth");
916 tempTranslation = fFullPVPath[i].GetTransform().getTranslation();
917 return tempTranslation;
924 G4Exception(
"G4PhysicalVolumeModelTouchable::GetRotation",
927 "Index out of range. Asking for non-existent depth");
930 tempRotation =
fFullPVPath[i].GetTransform().getRotation();
931 return &tempRotation;
938 G4Exception(
"G4PhysicalVolumeModelTouchable::GetVolume",
941 "Index out of range. Asking for non-existent depth");
950 G4Exception(
"G4PhysicalVolumeModelTouchable::GetSolid",
953 "Index out of range. Asking for non-existent depth");
955 return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
962 G4Exception(
"G4PhysicalVolumeModelTouchable::GetReplicaNumber",
965 "Index out of range. Asking for non-existent depth");