85 lines
2.4 KiB
C++
85 lines
2.4 KiB
C++
/*//////////////////////////////////////////////////////////////////////////////
|
|
// 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 "Core/Monitor.h"
|
|
#include <vtkCubeSource.h>
|
|
#include <vtkPolyDataMapper.h>
|
|
#include <vtkActor.h>
|
|
#include <vtkProperty.h>
|
|
#include <vtkAssembly.h>
|
|
#include <vtkTransform.h>
|
|
#include <vtkMatrix4x4.h>
|
|
#include <Geant4/G4VPhysicalVolume.hh>
|
|
#include "Vtk/Math/vtkDense.h"
|
|
|
|
namespace uLib {
|
|
namespace Vtk {
|
|
|
|
BoxSolid::BoxSolid(Geant::BoxSolid *content)
|
|
: GeantSolid(content), m_BoxContent(content) {
|
|
this->InstallPipe();
|
|
|
|
// Connect the model's Updated event to updateTransform to ensure VTK sync
|
|
m_UpdateConnection = Object::connect(m_BoxContent, &uLib::Object::Updated, this, &BoxSolid::Update);
|
|
|
|
// Initial sync
|
|
this->Update();
|
|
}
|
|
|
|
BoxSolid::~BoxSolid() {
|
|
}
|
|
|
|
void BoxSolid::Update() {
|
|
ConnectionBlock blocker(m_UpdateConnection);
|
|
this->UpdateGeometry();
|
|
// Ensure base Prop3D properties (color, opacity, etc) and transform are applied
|
|
this->Prop3D::Update();
|
|
}
|
|
|
|
void BoxSolid::SyncFromVtk() {
|
|
this->Prop3D::SyncFromVtk();
|
|
if (auto* proxy = vtkProp3D::SafeDownCast(this->GetProxyProp())) {
|
|
if (vtkMatrix4x4* mat = proxy->GetUserMatrix()) {
|
|
m_BoxContent->SetTransform(VtkToMatrix4f(mat));
|
|
}
|
|
}
|
|
}
|
|
|
|
void BoxSolid::UpdateGeometry() {
|
|
// Sync geometry from G4VSolid provided by GeantSolid (tessellation)
|
|
GeantSolid::UpdateGeometry();
|
|
}
|
|
|
|
void BoxSolid::UpdateTransform() {
|
|
// Take transform from Prop3D base (which uses GetContent() -> ContainerBox TRS)
|
|
this->Prop3D::Update();
|
|
}
|
|
|
|
void BoxSolid::serialize_display(uLib::Archive::display_properties_archive &ar,
|
|
const unsigned int version) {
|
|
// Expose Geant solid properties and underlying Box/TRS properties
|
|
this->Prop3D::serialize_display(ar, version);
|
|
if (m_BoxContent) {
|
|
ar & NVP("Box", *m_BoxContent);
|
|
if (m_BoxContent->GetObject()) {
|
|
ar & NVP("Container", *m_BoxContent->GetObject());
|
|
}
|
|
}
|
|
}
|
|
|
|
void BoxSolid::InstallPipe() {
|
|
GeantSolid::InstallPipe();
|
|
}
|
|
|
|
} // namespace Vtk
|
|
} // namespace uLib
|