add vtk geant solid and scene

This commit is contained in:
AndreaRigoni
2026-03-25 18:47:52 +00:00
parent 7d4acaef6d
commit 6a65fe94c8
15 changed files with 523 additions and 26 deletions

View File

@@ -0,0 +1,87 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef U_VTKGEANTSCENE_H
#define U_VTKGEANTSCENE_H
#include "HEP/Geant/Scene.h"
#include "uLibVtkInterface.h"
#include "Vtk/Math/vtkContainerBox.h"
#include <vector>
#include <memory>
namespace uLib {
namespace Vtk {
class vtkGeantSolid;
/**
* @brief VTK Puppet representing the entire Geant::Scene.
*
* When constructed, it creates child puppets for the world box (as a
* vtkContainerBox wireframe) and for each non-world Solid in the scene
* (as vtkGeantSolid surfaces).
*
* Usage:
* @code
* Geant::Scene scene;
* scene.ConstructWorldBox(Vector3f(30_m, 30_m, 30_m), "G4_AIR");
* // ... add solids ...
* scene.Initialize();
*
* Vtk::Viewer viewer;
* Vtk::vtkGeantScene vtkScene(&scene);
* vtkScene.AddToViewer(viewer);
* viewer.Start();
* @endcode
*/
class vtkGeantScene : public Object {
public:
vtkGeantScene(Geant::Scene *scene);
~vtkGeantScene();
/// Add all puppets (world box + solids) to a viewer.
void AddToViewer(class Viewport &viewer);
/// Remove all puppets from viewport.
void RemoveFromViewer(class Viewport &viewer);
/// Get the world box puppet
vtkContainerBox* GetWorldPuppet() const { return m_WorldPuppet; }
/// Get the solid puppets
const std::vector<vtkGeantSolid*>& GetSolidPuppets() const { return m_SolidPuppets; }
private:
Geant::Scene *m_Scene;
vtkContainerBox *m_WorldPuppet;
std::vector<vtkGeantSolid*> m_SolidPuppets;
};
} // namespace Vtk
} // namespace uLib
#endif // U_VTKGEANTSCENE_H