MCPcopy Create free account
hub / github.com/Geant4/geant4 / Draw3DRectMeshAsDots

Method Draw3DRectMeshAsDots

source/visualization/management/src/G4VSceneHandler.cc:1473–1614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1471}
1472
1473void G4VSceneHandler::Draw3DRectMeshAsDots(const G4Mesh& mesh)
1474// For a rectangular 3-D mesh, draw as coloured dots by colour and material,
1475// one dot randomly placed in each visible mesh cell.
1476{
1477 // Check
1478 if (mesh.GetMeshType() != G4Mesh::rectangle &&
1479 mesh.GetMeshType() != G4Mesh::nested3DRectangular) {
1480 G4ExceptionDescription ed;
1481 ed << "Called with a mesh that is not rectangular:" << mesh;
1482 G4Exception("G4VSceneHandler::Draw3DRectMeshAsDots","visman0108",JustWarning,ed);
1483 return;
1484 }
1485
1486 static G4bool firstPrint = true;
1487 const auto& verbosity = G4VisManager::GetVerbosity();
1488 G4bool print = firstPrint && verbosity >= G4VisManager::errors;
1489 if (print) {
1490 G4cout
1491 << "Special case drawing of 3D rectangular G4VNestedParameterisation as dots:"
1492 << '\n' << mesh
1493 << G4endl;
1494 }
1495
1496 const auto& container = mesh.GetContainerVolume();
1497
1498 // This map is static so that once filled it stays filled.
1499 static std::map<G4String,std::map<const G4Material*,G4Polymarker>> dotsByMaterialAndMesh;
1500 auto& dotsByMaterial = dotsByMaterialAndMesh[mesh.GetContainerVolume()->GetName()];
1501
1502 // Fill map if not already filled
1503 if (dotsByMaterial.empty()) {
1504
1505 // Get positions and material one cell at a time (using PseudoSceneFor3DRectMeshPositions).
1506 // The pseudo scene allows a "private" descent into the parameterisation.
1507 // Instantiate a temporary G4PhysicalVolumeModel
1508 G4ModelingParameters tmpMP;
1509 tmpMP.SetCulling(true); // This avoids drawing transparent...
1510 tmpMP.SetCullingInvisible(true); // ... or invisble volumes.
1511 const G4bool useFullExtent = true; // To avoid calculating the extent
1512 G4PhysicalVolumeModel tmpPVModel
1513 (container,
1514 G4PhysicalVolumeModel::UNLIMITED,
1515 G4Transform3D(), // so that positions are in local coordinates
1516 &tmpMP,
1517 useFullExtent);
1518 // Accumulate information in temporary maps by material
1519 std::multimap<const G4Material*,const G4ThreeVector> positionByMaterial;
1520 std::map<const G4Material*,G4VSceneHandler::NameAndVisAtts> nameAndVisAttsByMaterial;
1521 // Instantiate the pseudo scene
1522 PseudoSceneFor3DRectMeshPositions pseudoScene
1523 (&tmpPVModel,&mesh,positionByMaterial,nameAndVisAttsByMaterial);
1524 // Make private descent into the parameterisation
1525 tmpPVModel.DescribeYourselfTo(pseudoScene);
1526 // Now we have a map of positions by material.
1527 // Also a map of name and colour by material.
1528
1529 const auto& prms = mesh.GetThreeDRectParameters();
1530 const auto& halfX = prms.fHalfX;

Callers

nothing calls this directly

Calls 15

G4ExceptionFunction · 0.85
GetMeshTypeMethod · 0.80
GetContainerVolumeMethod · 0.80
substrMethod · 0.80
backMethod · 0.80
GetTransformMethod · 0.80
GetNameMethod · 0.45
emptyMethod · 0.45
DescribeYourselfToMethod · 0.45
SetVisAttributesMethod · 0.45
push_backMethod · 0.45
GetColourMethod · 0.45

Tested by

no test coverage detected