refactor: update Geant scene visualization to use PhysicalVolumes instead of raw Solids for improved placement and context handling.
This commit is contained in:
@@ -45,25 +45,29 @@ GeantScene::GeantScene(Geant::Scene *scene)
|
||||
m_WorldProp3D->ShowScaleMeasures(true);
|
||||
}
|
||||
|
||||
// 2. Create prop3ds for each non-world solid
|
||||
const Geant::Solid *world = m_Scene->GetWorld();
|
||||
const Vector<Geant::Solid *> &solids = m_Scene->GetSolids();
|
||||
// 2. Create prop3ds for each physical volume in the scene
|
||||
const Vector<SmartPointer<Geant::PhysicalVolume>> &volumes = m_Scene->GetVolumes();
|
||||
|
||||
for (auto &volume : volumes) {
|
||||
if (!volume || !volume->GetLogical() || !volume->GetLogical()->GetSolid())
|
||||
continue;
|
||||
|
||||
Geant::PhysicalVolume *pv = volume.Get();
|
||||
Geant::Solid *solid = pv->GetLogical()->GetSolid();
|
||||
|
||||
for (Geant::Solid *solid : solids) {
|
||||
// Skip the world volume itself — it's already shown as the wireframe box
|
||||
if (solid == world)
|
||||
if (solid == m_Scene->GetWorld())
|
||||
continue;
|
||||
|
||||
// Only create a prop3d if the solid has a valid G4VSolid
|
||||
if (solid->GetG4Solid()) {
|
||||
GeantSolid *vtkSolid = nullptr;
|
||||
if (auto *box = dynamic_cast<Geant::BoxSolid *>(solid)) {
|
||||
vtkSolid = new BoxSolid(box);
|
||||
vtkSolid = new BoxSolid(pv);
|
||||
} else if (auto *tess = dynamic_cast<Geant::TessellatedSolid *>(solid)) {
|
||||
vtkSolid = new TessellatedSolid(tess);
|
||||
vtkSolid = new TessellatedSolid(pv);
|
||||
} else {
|
||||
vtkSolid = new GeantSolid(solid);
|
||||
vtkSolid->Update();
|
||||
vtkSolid = new GeantSolid(pv);
|
||||
}
|
||||
|
||||
if (vtkSolid) {
|
||||
|
||||
Reference in New Issue
Block a user