fix display of cylinder

This commit is contained in:
AndreaRigoni
2026-03-27 15:23:59 +00:00
parent e40cc77a5f
commit fa7c0f670e
3 changed files with 33 additions and 21 deletions

View File

@@ -55,17 +55,12 @@ void vtkCylinder::contentUpdate() {
vtkProp3D* root = vtkProp3D::SafeDownCast(this->GetProp());
if (!root) return;
// 1. Placement (Position/Rotation/Model-level Scale) goes to the root prop
vtkMatrix4x4* vmat = root->GetUserMatrix();
if (!vmat) {
vtkNew<vtkMatrix4x4> mat;
root->SetUserMatrix(mat);
vmat = mat;
}
Matrix4f transform = m_Content->GetMatrix();
Matrix4fToVtk(transform, vmat);
// 1. Placement handled by base Puppet class via Sync / Update logic
// Update internal pd->m_Transform from content
Puppet::Update();
// 2. Shape-local properties (Radius, Height, Axis alignment) go to the internal actor
// These are relative to the root assembly
vtkTransform* alignment = vtkTransform::SafeDownCast(m_Actor->GetUserTransform());
if (alignment) {
alignment->Identity();
@@ -83,23 +78,29 @@ void vtkCylinder::contentUpdate() {
}
root->Modified();
Puppet::Update();
}
void vtkCylinder::Update() {
this->contentUpdate();
}
void vtkCylinder::SyncFromVtk() {
if (!m_Content) return;
vtkProp3D* root = vtkProp3D::SafeDownCast(this->GetProp());
if (!root) return;
vtkMatrix4x4* vmat = root->GetUserMatrix();
if (!vmat) return;
// Pull the placement matrix directly from VTK
Matrix4f transform = VtkToMatrix4f(vmat);
m_Content->SetMatrix(transform);
vtkProp3D* assembly = vtkProp3D::SafeDownCast(this->GetProp());
if (!assembly) return;
m_Content->Updated();
double pos[3], ori[3], scale[3];
assembly->GetPosition(pos);
assembly->GetOrientation(ori);
assembly->GetScale(scale);
m_Content->SetPosition(Vector3f(pos[0], pos[1], pos[2]));
// Convert VTK degrees to model radians
m_Content->SetOrientation(Vector3f(ori[0], ori[1], ori[2]) * CLHEP::degree);
m_Content->SetScale(Vector3f(scale[0], scale[1], scale[2]));
m_Content->Updated(); // Notify change
}
void vtkCylinder::InstallPipe() {