mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
Compare commits
4 Commits
b0240dc807
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c526f61f8c | |||
|
|
54997fe0ac | ||
| 94bad596ed | |||
|
|
fc909da400 |
@@ -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); }
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ void Abstract::VoxImage::ExportToVti (const char *file, bool density_type, bool
|
|||||||
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
|
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
|
||||||
image->SetDimensions(voxels->GetDims()(0), voxels->GetDims()(1), voxels->GetDims()(2));
|
image->SetDimensions(voxels->GetDims()(0), voxels->GetDims()(1), voxels->GetDims()(2));
|
||||||
image->SetSpacing(voxels->GetSpacing()(0), voxels->GetSpacing()(1), voxels->GetSpacing()(2));
|
image->SetSpacing(voxels->GetSpacing()(0), voxels->GetSpacing()(1), voxels->GetSpacing()(2));
|
||||||
image->SetOrigin(voxels->GetOrigin()(0), voxels->GetOrigin()(1), voxels->GetOrigin()(2));
|
image->SetOrigin(voxels->GetPosition()(0), voxels->GetPosition()(1), voxels->GetPosition()(2));
|
||||||
image->AllocateScalars(VTK_FLOAT, 1);
|
image->AllocateScalars(VTK_FLOAT, 1);
|
||||||
|
|
||||||
float norm;
|
float norm;
|
||||||
@@ -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
|
||||||
@@ -161,7 +164,7 @@ int Abstract::VoxImage::ImportFromVti(const char *file, bool density_type) {
|
|||||||
|
|
||||||
voxels->SetDims(Vector3i(nx,ny,nz));
|
voxels->SetDims(Vector3i(nx,ny,nz));
|
||||||
voxels->SetSpacing(Vector3f(image->GetSpacing()[0],image->GetSpacing()[1],image->GetSpacing()[2]));
|
voxels->SetSpacing(Vector3f(image->GetSpacing()[0],image->GetSpacing()[1],image->GetSpacing()[2]));
|
||||||
voxels->SetOrigin(Vector3f(image->GetOrigin()[0],image->GetOrigin()[1],image->GetOrigin()[2]));
|
voxels->SetPosition(Vector3f(image->GetOrigin()[0],image->GetOrigin()[1],image->GetOrigin()[2]));
|
||||||
|
|
||||||
float norm;
|
float norm;
|
||||||
if (density_type) {
|
if (density_type) {
|
||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user