2 Commits

Author SHA1 Message Date
AndreaRigoni
fc909da400 fix export to Vti 2025-09-23 18:21:11 +02:00
b0240dc807 Merge pull request #1 from OpenCMT/andrea-dev
Andrea dev
2025-09-18 13:12:12 +02:00
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 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); } 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; size_t npoints = nx*ny*nz;
float *scalar = static_cast<float*>(image->GetScalarPointer()); 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++) { 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 // 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; size_t npoints = nx*ny*nz;
float *scalar = static_cast<float*>(image->GetScalarPointer()); float *scalar = static_cast<float*>(image->GetScalarPointer());
StructuredData wrap(*voxels);
wrap.SetDataOrder(StructuredData::XYZ);
for (size_t i = 0; i < npoints; i++) { 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; return true;