fixed vtk containerbox handler

This commit is contained in:
AndreaRigoni
2026-03-18 21:32:33 +00:00
parent 0e8ac47fcf
commit cca29ef837
16 changed files with 279 additions and 272 deletions

54
src/Vtk/Math/vtkDense.h Normal file
View File

@@ -0,0 +1,54 @@
#ifndef U_VTK_DENSE_H
#define U_VTK_DENSE_H
#include "Math/Dense.h"
#include <vtkMatrix4x4.h>
namespace uLib {
namespace Vtk {
/**
* @brief Converts a uLib::Matrix4f to an existing vtkMatrix4x4.
* @param src The source Eigen matrix.
* @param dst The destination vtkMatrix4x4.
*/
inline void Matrix4fToVtk(const Matrix4f& src, vtkMatrix4x4* dst) {
if (!dst)
return;
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 4; ++j)
dst->SetElement(i, j, src(i, j));
}
/**
* @brief Converts a uLib::Matrix4f to a new vtkMatrix4x4.
* @param src The source Eigen matrix.
* @return A new vtkMatrix4x4 (caller is responsible for management/deletion).
*/
inline vtkMatrix4x4* Matrix4fToVtk(const Matrix4f& src) {
vtkMatrix4x4* dst = vtkMatrix4x4::New();
Matrix4fToVtk(src, dst);
return dst;
}
/**
* @brief Converts a vtkMatrix4x4 to a uLib::Matrix4f.
* @param src The source vtkMatrix4x4.
* @return The converted uLib::Matrix4f matrix.
*/
inline Matrix4f VtkToMatrix4f(vtkMatrix4x4* src) {
Matrix4f dst;
if (!src) {
dst.setIdentity();
return dst;
}
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 4; ++j)
dst(i, j) = src->GetElement(i, j);
return dst;
}
} // namespace Vtk
} // namespace uLib
#endif // U_VTK_DENSE_H