66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
/*//////////////////////////////////////////////////////////////////////////////
|
|
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
|
All rights reserved
|
|
|
|
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
|
|
|
//////////////////////////////////////////////////////////////////////////////*/
|
|
|
|
#include "Geant/Solid.h"
|
|
#include "HEP/Geant/Scene.h"
|
|
#include "Vtk/Math/vtkContainerBox.h"
|
|
#include "Vtk/Math/vtkDense.h"
|
|
#include "Math/Units.h"
|
|
#include "Vtk/uLibVtkViewer.h"
|
|
#include "Vtk/HEP/Geant/vtkGeantScene.h"
|
|
|
|
#include <vtkSmartPointer.h>
|
|
#include <vtkRenderer.h>
|
|
#include <vtkRenderWindow.h>
|
|
|
|
#include <iostream>
|
|
|
|
using namespace uLib;
|
|
|
|
int main(int argc, char** argv) {
|
|
bool interactive = (argc > 1 && std::string(argv[1]) == "-i");
|
|
|
|
// 1. Setup Geant4 Scene
|
|
Geant::Scene scene;
|
|
scene.ConstructWorldBox(Vector3f(30_m, 30_m, 30_m), "G4_AIR");
|
|
|
|
// Add an iron cube inside the world
|
|
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);
|
|
scene.Initialize();
|
|
|
|
// 2. Build VTK scene representation
|
|
Vtk::Viewer viewer;
|
|
viewer.GetRenderer()->SetBackground(0.05, 0.05, 0.1);
|
|
|
|
Vtk::GeantScene vtkScene(&scene);
|
|
vtkScene.AddToViewer(viewer);
|
|
|
|
std::cout << "==================================================" << std::endl;
|
|
std::cout << " GeantScene Test" << std::endl;
|
|
std::cout << " World box + 1 iron cube displayed" << std::endl;
|
|
std::cout << "==================================================" << std::endl;
|
|
|
|
if (interactive) {
|
|
viewer.ZoomAuto();
|
|
viewer.Start();
|
|
} else {
|
|
std::cout << "Non-interactive test: scene initialized successfully" << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|