refactor: update Geant scene visualization to use PhysicalVolumes instead of raw Solids for improved placement and context handling.
This commit is contained in:
@@ -69,31 +69,56 @@ 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(-5_m, -5_m, -5_m));
|
||||
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(-5_m, -5_m, -5_m));
|
||||
|
||||
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);
|
||||
|
||||
// Top Detector Chamber
|
||||
DetectorChamber* top_chamber_box = new DetectorChamber();
|
||||
SmartPointer<DetectorChamber> top_chamber_box(new DetectorChamber());
|
||||
top_chamber_box->Scale(Vector3f(10_m, 10_m, 40_cm));
|
||||
top_chamber_box->SetPosition(Vector3f(-5_m, -5_m, 7_m));
|
||||
Geant::BoxSolid* top_chamber = new Geant::BoxSolid("TopChamber", top_chamber_box);
|
||||
top_chamber->SetNistMaterial("G4_AIR");
|
||||
top_chamber->Update();
|
||||
scene.AddSolid(top_chamber);
|
||||
|
||||
SmartPointer<Geant::BoxSolid> top_solid(new Geant::BoxSolid("TopSolid", top_chamber_box));
|
||||
top_solid->Update();
|
||||
|
||||
SmartPointer<Geant::Material> air_mat(new Geant::Material("AirMat"));
|
||||
air_mat->SetFromNist("G4_AIR");
|
||||
|
||||
SmartPointer<Geant::LogicalVolume> top_lv(new Geant::LogicalVolume("TopLV"));
|
||||
top_lv->SetSolid(top_solid);
|
||||
top_lv->SetMaterial(air_mat);
|
||||
|
||||
SmartPointer<Geant::PhysicalVolume> top_pv(new Geant::PhysicalVolume("TopPV", top_lv));
|
||||
scene.AddVolume(top_pv);
|
||||
|
||||
// Bottom Detector Chamber
|
||||
DetectorChamber* bottom_chamber_box = new DetectorChamber();
|
||||
SmartPointer<DetectorChamber> bottom_chamber_box(new DetectorChamber());
|
||||
bottom_chamber_box->Scale(Vector3f(10_m, 10_m, 40_cm));
|
||||
bottom_chamber_box->SetPosition(Vector3f(-5_m, -5_m, -7.1_m));
|
||||
Geant::BoxSolid* bottom_chamber = new Geant::BoxSolid("BottomChamber", bottom_chamber_box);
|
||||
bottom_chamber->SetNistMaterial("G4_AIR");
|
||||
bottom_chamber->Update();
|
||||
scene.AddSolid(bottom_chamber);
|
||||
|
||||
SmartPointer<Geant::BoxSolid> bottom_solid(new Geant::BoxSolid("BottomSolid", bottom_chamber_box));
|
||||
bottom_solid->Update();
|
||||
|
||||
SmartPointer<Geant::LogicalVolume> bottom_lv(new Geant::LogicalVolume("BottomLV"));
|
||||
bottom_lv->SetSolid(bottom_solid);
|
||||
bottom_lv->SetMaterial(air_mat);
|
||||
|
||||
SmartPointer<Geant::PhysicalVolume> bottom_pv(new Geant::PhysicalVolume("BottomPV", bottom_lv));
|
||||
scene.AddVolume(bottom_pv);
|
||||
|
||||
Geant::EmitterPrimary* emitter = new Geant::EmitterPrimary();
|
||||
emitter->SetPosition(Vector3f(0, 0, 14_m));
|
||||
@@ -112,20 +137,20 @@ int main(int argc, char** argv) {
|
||||
viewer.AddProp3D(*vtkWorld);
|
||||
|
||||
// Visualize iron cube
|
||||
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);
|
||||
|
||||
// Visualize Top Chamber
|
||||
Vtk::DetectorChamber* vtkTop = new Vtk::DetectorChamber(top_chamber_box);
|
||||
Vtk::DetectorChamber* vtkTop = new Vtk::DetectorChamber(top_chamber_box.Get());
|
||||
vtkTop->SetOpacity(0.5);
|
||||
vtkTop->SetColor(0.2, 0.8, 0.2);
|
||||
vtkTop->SetRepresentation(Vtk::Prop3D::Surface);
|
||||
viewer.AddProp3D(*vtkTop);
|
||||
|
||||
// Visualize Bottom Chamber
|
||||
Vtk::DetectorChamber* vtkBottom = new Vtk::DetectorChamber(bottom_chamber_box);
|
||||
Vtk::DetectorChamber* vtkBottom = new Vtk::DetectorChamber(bottom_chamber_box.Get());
|
||||
vtkBottom->SetOpacity(0.5);
|
||||
vtkBottom->SetColor(0.2, 0.8, 0.2);
|
||||
vtkBottom->SetRepresentation(Vtk::Prop3D::Surface);
|
||||
|
||||
Reference in New Issue
Block a user