Dear Haegin
Thnakyou so much for this feedback. I really appreciate it - it finds bugs and leads to improvements.
- Yes, I see it. There are several issues:
i) There is a problem with mesh identification in the G4Mesh constructor. It was incorrectly finding the world as a two-deep parameterisation:
G4Mesh:
Container: worldPhysical
Type: tetrahedron
Depth: 2
Translation: (0.000000,0.000000,0.000000)
Rotation:
[ ( 1.000000 0.000000 0.000000)
( 0.000000 1.000000 0.000000)
( 0.000000 0.000000 1.000000) ]
I attach a patch to G4Mesh.cc that should fix it. Now it says:
G4Mesh:
Container: PhantomPhysical
Type: tetrahedron
Depth: 1
Translation: (0.000000,0.000000,0.000000)
Rotation:
[ ( 1.000000 0.000000 0.000000)
( 0.000000 1.000000 0.000000)
( 0.000000 0.000000 1.000000) ]
ii) The PhantomPhysical cannot be drawn on its own. When /vis/viewer/specialMeshRendering is on it is intercepted by the vis manager (actually by G4PhysicalVolumeModel) and passed for special mesh rendering. So "/vis/scene/add/volume PhantomPhysical” does not work.
iii) My proposed solution is to draw it in G4VSceneHandler::StandardSpecialMeshRendering unless the volume is marked invisible.
iv) PhantomPhysical is marked invisible in vis.mac:
/vis/geometry/set/visibility phantomLogical 0 false
Remove this or comment it out.
v) The default is white, so you need
/vis/viewer/set/background black
With all these changes you get the attached image. I have chosen to force wireframe mode - does this make sense?
- Mmmm. This is not easy for me to test. When you change geometry you must close the geometry and re-close it. Also notify the vis manager, I believe.
G4GeometryManager* geomMgr = G4GeometryManager::GetInstance();
geomMgr->OpenGeometry();
///////CHANGE YOUR GEOMETRY
geomMgr->CloseGeometry();
// Notify the VisManager as well
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (pVVisManager) pVVisManager->GeometryHasChanged();
Note one can close and open just a subtree. Also choose to optimise or not. See function prototypes in G4GeometryManager.hh
.
But…there is a further issue that is particular to special mesh rendering - once established the map of G4Polyhedron objects once create, as things stand, cannot be changed. This is the code in G4VScenehandler.cc:
// This map is static so that once filled it stays filled.
static std::map<G4String,std::map<**const** G4Material*,G4Polyhedron>> surfacesByMaterialAndMesh;
auto& surfacesByMaterial = surfacesByMaterialAndMesh[mesh.GetContainerVolume()->GetName()];
// Fill map if not already filled
if (surfacesByMaterial.empty()) { // Fill it
I wrote it this way to speed redrawing. I did not imagine anyone would want to change the geometry. What is your use case? Of course, it can be changed, perhaps to respect GeometryHasChanged(). Let me know what you think and I can do this.
To get the polyhedron map to re-build you could simply remove the keyword “static” on line 1716. Let me know if this helps.
Again, thankyou for your feedback. Please try the attached versions.
John
G4Mesh.cc (7.0 KB)
G4VSceneHandler.cc (65.6 KB)