add vtk solids

This commit is contained in:
AndreaRigoni
2026-03-25 21:03:13 +00:00
parent e4a8499104
commit 422113a0e9
17 changed files with 353 additions and 16 deletions

View File

@@ -0,0 +1,57 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
//////////////////////////////////////////////////////////////////////////////*/
#include "vtkBoxSolid.h"
#include <vtkCubeSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
namespace uLib {
namespace Vtk {
vtkBoxSolid::vtkBoxSolid(Geant::BoxSolid *content)
: vtkGeantSolid(content), m_BoxContent(content) {
// Re-run Update for box-specific pipe
this->Update();
}
vtkBoxSolid::~vtkBoxSolid() {}
void vtkBoxSolid::Update() {
this->UpdateGeometry();
this->UpdateTransform();
}
void vtkBoxSolid::UpdateGeometry() {
if (!m_BoxContent || !m_BoxContent->GetObject()) {
// Fallback to base tessellation if no model object
vtkGeantSolid::UpdateGeometry();
return;
}
// Use the underlying ContainerBox for precise geometry
Vector3f size = m_BoxContent->GetObject()->GetSize();
vtkNew<vtkCubeSource> cube;
cube->SetXLength(size(0));
cube->SetYLength(size(1));
cube->SetZLength(size(2));
cube->Update();
vtkPolyData *poly = GetPolyData();
if (poly) {
poly->ShallowCopy(cube->GetOutput());
poly->Modified();
}
}
} // namespace Vtk
} // namespace uLib