refactor: update Geant scene visualization to use PhysicalVolumes instead of raw Solids for improved placement and context handling.
This commit is contained in:
@@ -75,13 +75,23 @@ int main(int argc, char** argv) {
|
||||
Geant::Scene scene;
|
||||
scene.ConstructWorldBox(Vector3f(30_m, 30_m, 30_m), "G4_AIR");
|
||||
|
||||
ContainerBox iron_box;
|
||||
iron_box.Scale(Vector3f(10_m, 10_m, 10_m));
|
||||
iron_box.SetPosition(Vector3f(0, 0, 0));
|
||||
Geant::BoxSolid* iron_cube = new Geant::BoxSolid("IronCube", &iron_box);
|
||||
iron_cube->SetNistMaterial("G4_Fe");
|
||||
iron_cube->Update();
|
||||
scene.AddSolid(iron_cube);
|
||||
// Iron Cube
|
||||
SmartPointer<ContainerBox> iron_box(new ContainerBox());
|
||||
iron_box->Scale(Vector3f(10_m, 10_m, 10_m));
|
||||
iron_box->SetPosition(Vector3f(0, 0, 0));
|
||||
|
||||
SmartPointer<Geant::BoxSolid> iron_solid(new Geant::BoxSolid("IronSolid", iron_box));
|
||||
iron_solid->Update();
|
||||
|
||||
SmartPointer<Geant::Material> iron_mat(new Geant::Material("IronMat"));
|
||||
iron_mat->SetFromNist("G4_Fe");
|
||||
|
||||
SmartPointer<Geant::LogicalVolume> iron_lv(new Geant::LogicalVolume("IronLV"));
|
||||
iron_lv->SetSolid(iron_solid);
|
||||
iron_lv->SetMaterial(iron_mat);
|
||||
|
||||
SmartPointer<Geant::PhysicalVolume> iron_pv(new Geant::PhysicalVolume("IronPV", iron_lv));
|
||||
scene.AddVolume(iron_pv);
|
||||
|
||||
// Use CylinderEmitterPrimary
|
||||
Geant::CylinderEmitterPrimary* emitter = new Geant::CylinderEmitterPrimary();
|
||||
@@ -103,7 +113,7 @@ int main(int argc, char** argv) {
|
||||
vtkWorld->SetSelectable(false);
|
||||
viewer.AddProp3D(*vtkWorld);
|
||||
|
||||
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
|
||||
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(iron_box.Get());
|
||||
vtkIron->SetOpacity(0.2);
|
||||
vtkIron->SetRepresentation(Vtk::Prop3D::Surface);
|
||||
viewer.AddProp3D(*vtkIron);
|
||||
|
||||
Reference in New Issue
Block a user