Merge pull request #2 from OpenCMT/andrea-dev

fix export to Vti
This commit is contained in:
2025-09-23 18:52:54 +02:00
committed by GitHub
2 changed files with 20 additions and 2 deletions

View File

@@ -110,6 +110,17 @@ public:
inline void Rotate(const Matrix3f &m) { this->m_T.rotate(m); }
inline void Rotate(const float angle, Vector3f axis)
{
axis.normalize(); // prehaps not necessary ( see eigens )
Eigen::AngleAxisf ax(angle,axis);
this->m_T.rotate(Eigen::Quaternion<float>(ax));
}
inline void Rotate(const Vector3f euler_axis) {
float angle = euler_axis.norm();
Rotate(angle,euler_axis);
}
inline void PreRotate(const Matrix3f &m) { this->m_T.prerotate(m); }

View File

@@ -114,8 +114,11 @@ void Abstract::VoxImage::ExportToVti (const char *file, bool density_type, bool
size_t npoints = nx*ny*nz;
float *scalar = static_cast<float*>(image->GetScalarPointer());
StructuredData unwrap(*voxels);
unwrap.SetDataOrder(StructuredData::XYZ); // move to XYZ order (VTK)
for (size_t i = 0; i < npoints; i++) {
scalar[i] = static_cast<float>(voxels->GetValue(i) * norm);
Vector3i idx = unwrap.UnMap(i);
scalar[i] = static_cast<float>(voxels->GetValue(idx) * norm);
}
// Create a custom string key
@@ -170,8 +173,12 @@ int Abstract::VoxImage::ImportFromVti(const char *file, bool density_type) {
size_t npoints = nx*ny*nz;
float *scalar = static_cast<float*>(image->GetScalarPointer());
StructuredData wrap(*voxels);
wrap.SetDataOrder(StructuredData::XYZ);
for (size_t i = 0; i < npoints; i++) {
voxels->SetValue(i, scalar[i] / norm);
Vector3i idx = wrap.UnMap(i);
voxels->SetValue(idx, scalar[i] / norm);
}
return true;