refactor: rename Puppet class to Prop3D across the codebase

This commit is contained in:
AndreaRigoni
2026-04-08 15:47:33 +00:00
parent 77f00a2b8a
commit f7ba4b1a17
63 changed files with 412 additions and 413 deletions

View File

@@ -45,8 +45,8 @@ BOOST_AUTO_TEST_CASE(vtkDetectorChamberTest) {
Vtk::DetectorChamber v_d1(&d1);
Vtk::DetectorChamber v_d2(&d2);
v_d1.SetRepresentation(Vtk::Puppet::Surface);
v_d2.SetRepresentation(Vtk::Puppet::Surface);
v_d1.SetRepresentation(Vtk::Prop3D::Surface);
v_d2.SetRepresentation(Vtk::Prop3D::Surface);
if (!v_d1.GetProp()) {
BOOST_FAIL("DetectorChamber::GetProp() returned NULL");
@@ -55,8 +55,8 @@ BOOST_AUTO_TEST_CASE(vtkDetectorChamberTest) {
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
Vtk::Viewer viewer;
viewer.SetGridAxis(Vtk::Viewport::Y);
viewer.AddPuppet(v_d1);
viewer.AddPuppet(v_d2);
viewer.AddProp3D(v_d1);
viewer.AddProp3D(v_d2);
viewer.Start();
}

View File

@@ -42,10 +42,10 @@
using namespace uLib;
// A simple puppet class to represent an arrow indicative of a projected muon hit
class vtkArrowPuppet : public Vtk::Puppet {
// A simple prop3d class to represent an arrow indicative of a projected muon hit
class vtkArrowProp3D : public Vtk::Prop3D {
public:
vtkArrowPuppet() : m_Actor(vtkActor::New()) {
vtkArrowProp3D() : m_Actor(vtkActor::New()) {
vtkNew<vtkArrowSource> arrow;
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(arrow->GetOutputPort());
@@ -54,7 +54,7 @@ public:
m_Actor->GetProperty()->SetColor(1, 1, 0); // Yellow color for visibility
}
virtual ~vtkArrowPuppet() { m_Actor->Delete(); }
virtual ~vtkArrowProp3D() { m_Actor->Delete(); }
void SetProjection(const HLine3f &line) {
HPoint3f p = line.origin;
@@ -131,24 +131,24 @@ BOOST_AUTO_TEST_CASE(vtkDetectorMuonProjectionTest) {
v_event.AddPocaPoint(HPoint3f(0, 0, 0));
v_event.SetColor(1, 0, 0); // Red muon event
v_d1.SetRepresentation(Vtk::Puppet::Surface);
v_d1.SetRepresentation(Vtk::Prop3D::Surface);
v_d1.SetOpacity(0.3);
v_d2.SetRepresentation(Vtk::Puppet::Surface);
v_d2.SetRepresentation(Vtk::Prop3D::Surface);
v_d2.SetOpacity(0.3);
// 5. Add two arrows to mark where the projection is located on the chambers
vtkArrowPuppet v_p1, v_p2;
vtkArrowProp3D v_p1, v_p2;
v_p1.SetProjection(mu_proj1.LineIn());
v_p2.SetProjection(mu_proj2.LineIn());
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
Vtk::Viewer viewer;
viewer.SetGridAxis(Vtk::Viewport::Z);
viewer.AddPuppet(v_d1);
viewer.AddPuppet(v_d2);
viewer.AddPuppet(v_event);
viewer.AddPuppet(v_p1);
viewer.AddPuppet(v_p2);
viewer.AddProp3D(v_d1);
viewer.AddProp3D(v_d2);
viewer.AddProp3D(v_event);
viewer.AddProp3D(v_p1);
viewer.AddProp3D(v_p2);
viewer.Start();
}

View File

@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(vtkMuonScatterTest) {
// Vtk::Tie<Vtk::Viewer> vms;
// vms.DoAction();
viewer.AddPuppet(v_event);
viewer.AddProp3D(v_event);
viewer.Start();
}

View File

@@ -50,7 +50,7 @@
namespace uLib {
namespace Vtk {
class MuonEvent : public Puppet, public Polydata {
class MuonEvent : public Prop3D, public Polydata {
typedef MuonEventData Content;
public:

View File

@@ -54,7 +54,7 @@ class vtkRenderWindowInteractor;
namespace uLib {
namespace Vtk {
class MuonScatter : public Puppet, public Polydata {
class MuonScatter : public Prop3D, public Polydata {
typedef uLib::MuonScatter Content;
public:
@@ -66,9 +66,9 @@ public:
Content &GetModel();
uLib::Object* GetContent() const override { return (uLib::Object*)m_Content; }
void PrintSelf(std::ostream &o) const;
void PrintSelf(std::ostream &o) const override;
virtual vtkPolyData *GetPolyData() const;
virtual vtkPolyData *GetPolyData() const override;
void AddPocaPoint(HPoint3f poca);
@@ -77,7 +77,7 @@ public:
void vtkStartInteractive();
protected:
void ConnectInteractor(vtkRenderWindowInteractor *interactor);
void ConnectInteractor(vtkRenderWindowInteractor *interactor) override;
private:
void InstallPipe();

View File

@@ -59,7 +59,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
<< " with " << lastEvent->Path().size() << " steps." << std::endl;
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
state->viewer->AddProp3D(*vtkEvent);
state->viewer->GetRenderer()->Render();
state->viewer->GetRenderWindow()->Render();
@@ -99,19 +99,19 @@ int main(int argc, char** argv) {
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
vtkWorld->ShowScaleMeasures(true);
vtkWorld->SetRepresentation(Vtk::Puppet::Wireframe);
vtkWorld->SetRepresentation(Vtk::Prop3D::Wireframe);
vtkWorld->SetSelectable(false);
viewer.AddPuppet(*vtkWorld);
viewer.AddProp3D(*vtkWorld);
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);
vtkIron->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkIron);
// Use vtkCylinderEmitterPrimary
Vtk::vtkCylinderEmitterPrimary* vtkEmitter = new Vtk::vtkCylinderEmitterPrimary(*emitter);
vtkEmitter->SetSelectable(false);
viewer.AddPuppet(*vtkEmitter);
viewer.AddProp3D(*vtkEmitter);
// 3. Event Handling
AppState state = { &scene, &viewer, {} };

View File

@@ -52,7 +52,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
// Wrap it for VTK
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
state->viewer->AddProp3D(*vtkEvent);
// Re-render
state->viewer->GetRenderer()->Render();
@@ -107,33 +107,33 @@ int main(int argc, char** argv) {
// Visualize world box
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
vtkWorld->ShowScaleMeasures(true);
vtkWorld->SetRepresentation(Vtk::Puppet::Wireframe);
vtkWorld->SetRepresentation(Vtk::Prop3D::Wireframe);
vtkWorld->SetSelectable(false);
viewer.AddPuppet(*vtkWorld);
viewer.AddProp3D(*vtkWorld);
// Visualize iron cube
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);
vtkIron->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkIron);
// Visualize Top Chamber
Vtk::DetectorChamber* vtkTop = new Vtk::DetectorChamber(top_chamber_box);
vtkTop->SetOpacity(0.5);
vtkTop->SetColor(0.2, 0.8, 0.2);
vtkTop->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkTop);
vtkTop->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkTop);
// Visualize Bottom Chamber
Vtk::DetectorChamber* vtkBottom = new Vtk::DetectorChamber(bottom_chamber_box);
vtkBottom->SetOpacity(0.5);
vtkBottom->SetColor(0.2, 0.8, 0.2);
vtkBottom->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkBottom);
vtkBottom->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkBottom);
// Visualize Emitter
Vtk::EmitterPrimary* vtkEmitter = new Vtk::EmitterPrimary(*emitter);
viewer.AddPuppet(*vtkEmitter);
viewer.AddProp3D(*vtkEmitter);
// 3. Event Handling
AppState state = { &scene, &viewer, {} };

View File

@@ -83,7 +83,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
// Wrap it for VTK
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
state->viewer->AddProp3D(*vtkEvent);
// Re-render
state->viewer->GetRenderer()->Render();
@@ -120,13 +120,13 @@ int main(int argc, char** argv) {
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
// vtkWorld->ShowBoundingBox(true);
vtkWorld->ShowScaleMeasures(true);
viewer.AddPuppet(*vtkWorld);
viewer.AddProp3D(*vtkWorld);
// Visualize iron cube
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);
vtkIron->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkIron);
// 3. Event Handling
AppState state = { &scene, &viewer, {} };

View File

@@ -50,7 +50,7 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
<< " with " << lastEvent->Path().size() << " steps." << std::endl;
Vtk::GeantEvent* vtkEvent = new Vtk::GeantEvent(lastEvent);
state->viewer->AddPuppet(*vtkEvent);
state->viewer->AddProp3D(*vtkEvent);
state->viewer->GetRenderer()->Render();
state->viewer->GetRenderWindow()->Render();
@@ -109,33 +109,33 @@ int main(int argc, char** argv) {
Vtk::ContainerBox* vtkWorld = new Vtk::ContainerBox(scene.GetWorldBox());
vtkWorld->ShowScaleMeasures(true);
vtkWorld->SetRepresentation(Vtk::Puppet::Wireframe);
vtkWorld->SetRepresentation(Vtk::Prop3D::Wireframe);
vtkWorld->SetSelectable(false);
viewer.AddPuppet(*vtkWorld);
viewer.AddProp3D(*vtkWorld);
Vtk::ContainerBox* vtkIron = new Vtk::ContainerBox(&iron_box);
vtkIron->SetOpacity(0.2);
vtkIron->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkIron);
vtkIron->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkIron);
// Visualize Top Chamber
Vtk::DetectorChamber* vtkTop = new Vtk::DetectorChamber(top_chamber_box);
vtkTop->SetOpacity(0.5);
vtkTop->SetColor(0.2, 0.8, 0.2);
vtkTop->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkTop);
vtkTop->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkTop);
// Visualize Bottom Chamber
Vtk::DetectorChamber* vtkBottom = new Vtk::DetectorChamber(bottom_chamber_box);
vtkBottom->SetOpacity(0.5);
vtkBottom->SetColor(0.2, 0.8, 0.2);
vtkBottom->SetRepresentation(Vtk::Puppet::Surface);
viewer.AddPuppet(*vtkBottom);
vtkBottom->SetRepresentation(Vtk::Prop3D::Surface);
viewer.AddProp3D(*vtkBottom);
// Use vtkSkyPlaneEmitterPrimary instead of EmitterPrimary
Vtk::vtkSkyPlaneEmitterPrimary* vtkEmitter = new Vtk::vtkSkyPlaneEmitterPrimary(*emitter);
vtkEmitter->SetSelectable(false);
viewer.AddPuppet(*vtkEmitter);
viewer.AddProp3D(*vtkEmitter);
// 3. Event Handling
AppState state = { &scene, &viewer, {} };

View File

@@ -41,12 +41,12 @@ BoxSolid::~BoxSolid() {
void BoxSolid::Update() {
ConnectionBlock blocker(m_UpdateConnection);
this->UpdateGeometry();
// Ensure base Puppet properties (color, opacity, etc) and transform are applied
this->Puppet::Update();
// Ensure base Prop3D properties (color, opacity, etc) and transform are applied
this->Prop3D::Update();
}
void BoxSolid::SyncFromVtk() {
this->Puppet::SyncFromVtk();
this->Prop3D::SyncFromVtk();
if (auto* proxy = vtkProp3D::SafeDownCast(this->GetProxyProp())) {
if (vtkMatrix4x4* mat = proxy->GetUserMatrix()) {
m_BoxContent->SetTransform(VtkToMatrix4f(mat));
@@ -60,14 +60,14 @@ void BoxSolid::UpdateGeometry() {
}
void BoxSolid::UpdateTransform() {
// Take transform from Puppet base (which uses GetContent() -> ContainerBox TRS)
this->Puppet::Update();
// 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->Puppet::serialize_display(ar, version);
this->Prop3D::serialize_display(ar, version);
if (m_BoxContent) {
ar & NVP("Box", *m_BoxContent);
if (m_BoxContent->GetObject()) {

View File

@@ -39,7 +39,7 @@ namespace uLib {
namespace Vtk {
/**
* @brief VTK Puppet for visualizing a Geant::BoxSolid.
* @brief VTK Prop3D for visualizing a Geant::BoxSolid.
*/
class BoxSolid : public GeantSolid {
uLibTypeMacro(BoxSolid, uLib::Vtk::GeantSolid)

View File

@@ -63,7 +63,7 @@ void EmitterPrimary::contentUpdate() {
Matrix4f transform = m_emitter.GetWorldMatrix();
Matrix4fToVtk(transform, vmat);
Puppet::Update();
Prop3D::Update();
}
void EmitterPrimary::Update() {

View File

@@ -14,7 +14,7 @@ class vtkCylinderSource;
namespace uLib {
namespace Vtk {
class EmitterPrimary : public Puppet {
class EmitterPrimary : public Prop3D {
public:
EmitterPrimary(Geant::EmitterPrimary &emitter);
virtual ~EmitterPrimary();

View File

@@ -34,7 +34,7 @@
namespace uLib {
namespace Vtk {
class GeantEvent : public Puppet, public Polydata {
class GeantEvent : public Prop3D, public Polydata {
typedef Geant::GeantEvent Content;
public:

View File

@@ -33,19 +33,19 @@ namespace uLib {
namespace Vtk {
GeantScene::GeantScene(Geant::Scene *scene)
: m_Scene(scene), m_WorldPuppet(nullptr) {
: m_Scene(scene), m_WorldProp3D(nullptr) {
if (!m_Scene)
return;
// 1. Create the world box wireframe puppet
// 1. Create the world box wireframe prop3d
uLib::ContainerBox *worldBox = m_Scene->GetWorldBox();
if (worldBox) {
m_WorldPuppet = new ContainerBox(worldBox);
m_WorldPuppet->SetRepresentation(Puppet::Wireframe);
m_WorldPuppet->ShowScaleMeasures(true);
m_WorldProp3D = new ContainerBox(worldBox);
m_WorldProp3D->SetRepresentation(Prop3D::Wireframe);
m_WorldProp3D->ShowScaleMeasures(true);
}
// 2. Create puppets for each non-world solid
// 2. Create prop3ds for each non-world solid
const Geant::Solid *world = m_Scene->GetWorld();
const Vector<Geant::Solid *> &solids = m_Scene->GetSolids();
@@ -54,7 +54,7 @@ GeantScene::GeantScene(Geant::Scene *scene)
if (solid == world)
continue;
// Only create a puppet if the solid has a valid G4VSolid
// Only create a prop3d if the solid has a valid G4VSolid
if (solid->GetG4Solid()) {
GeantSolid *vtkSolid = nullptr;
if (auto *box = dynamic_cast<Geant::BoxSolid *>(solid)) {
@@ -67,34 +67,34 @@ GeantScene::GeantScene(Geant::Scene *scene)
}
if (vtkSolid) {
m_SolidPuppets.push_back(vtkSolid);
m_SolidProp3Ds.push_back(vtkSolid);
}
}
}
}
GeantScene::~GeantScene() {
delete m_WorldPuppet;
for (auto *p : m_SolidPuppets) {
delete m_WorldProp3D;
for (auto *p : m_SolidProp3Ds) {
delete p;
}
}
void GeantScene::AddToViewer(Viewport &viewer) {
if (m_WorldPuppet) {
viewer.AddPuppet(*m_WorldPuppet);
if (m_WorldProp3D) {
viewer.AddProp3D(*m_WorldProp3D);
}
for (auto *p : m_SolidPuppets) {
viewer.AddPuppet(*p);
for (auto *p : m_SolidProp3Ds) {
viewer.AddProp3D(*p);
}
}
void GeantScene::RemoveFromViewer(Viewport &viewer) {
if (m_WorldPuppet) {
viewer.RemovePuppet(*m_WorldPuppet);
if (m_WorldProp3D) {
viewer.RemoveProp3D(*m_WorldProp3D);
}
for (auto *p : m_SolidPuppets) {
viewer.RemovePuppet(*p);
for (auto *p : m_SolidProp3Ds) {
viewer.RemoveProp3D(*p);
}
}

View File

@@ -39,9 +39,9 @@ namespace Vtk {
class GeantSolid;
/**
* @brief VTK Puppet representing the entire Geant::Scene.
* @brief VTK Prop3D representing the entire Geant::Scene.
*
* When constructed, it creates child puppets for the world box (as a
* When constructed, it creates child prop3ds for the world box (as a
* ContainerBox wireframe) and for each non-world Solid in the scene
* (as GeantSolid surfaces).
*
@@ -63,22 +63,22 @@ public:
GeantScene(Geant::Scene *scene);
~GeantScene();
/// Add all puppets (world box + solids) to a viewer.
/// Add all prop3ds (world box + solids) to a viewer.
void AddToViewer(class Viewport &viewer);
/// Remove all puppets from viewport.
/// Remove all prop3ds from viewport.
void RemoveFromViewer(class Viewport &viewer);
/// Get the world box puppet
ContainerBox* GetWorldPuppet() const { return m_WorldPuppet; }
/// Get the world box prop3d
ContainerBox* GetWorldProp3D() const { return m_WorldProp3D; }
/// Get the solid puppets
const std::vector<GeantSolid*>& GetSolidPuppets() const { return m_SolidPuppets; }
/// Get the solid prop3ds
const std::vector<GeantSolid*>& GetSolidProp3Ds() const { return m_SolidProp3Ds; }
private:
Geant::Scene *m_Scene;
ContainerBox *m_WorldPuppet;
std::vector<GeantSolid*> m_SolidPuppets;
ContainerBox *m_WorldProp3D;
std::vector<GeantSolid*> m_SolidProp3Ds;
};
} // namespace Vtk

View File

@@ -36,13 +36,13 @@ namespace uLib {
namespace Vtk {
/**
* @brief VTK Puppet for visualizing a Geant::Solid.
* @brief VTK Prop3D for visualizing a Geant::Solid.
*
* Renders the G4VSolid geometry as a tessellated polydata surface.
* Works with BoxSolid, TessellatedSolid, or any Solid that provides
* a valid G4VSolid via GetG4Solid().
*/
class GeantSolid : public Puppet, public Polydata {
class GeantSolid : public Prop3D, public Polydata {
typedef Geant::Solid Content;
public:

View File

@@ -18,7 +18,7 @@ namespace uLib {
namespace Vtk {
/**
* @brief VTK Puppet for visualizing a Geant::TessellatedSolid.
* @brief VTK Prop3D for visualizing a Geant::TessellatedSolid.
*/
class TessellatedSolid : public GeantSolid {
public:

View File

@@ -110,12 +110,12 @@ BOOST_AUTO_TEST_CASE(vtkVoxRaytracerRepresentationTest) {
// renderer //
Vtk::Viewer viewer;
viewer.AddPuppet(v_grid);
viewer.AddPuppet(v_rt);
viewer.AddPuppet(v_muon);
viewer.AddProp3D(v_grid);
viewer.AddProp3D(v_rt);
viewer.AddProp3D(v_muon);
// Select grid to show handler widget
viewer.SelectPuppet(&v_grid);
viewer.SelectProp3D(&v_grid);
viewer.Start();
}

View File

@@ -58,7 +58,7 @@ class vtkActor;
namespace uLib {
namespace Vtk {
class VoxRaytracerRepresentation : public Puppet {
class VoxRaytracerRepresentation : public Prop3D {
typedef VoxRaytracer Content;
public: