Skip to content
Snippets Groups Projects
Commit ed668ea2 authored by Karsten Rink's avatar Karsten Rink
Browse files

[bugfix] fixed issue where raster to mesh conversion would fail if all all...

[bugfix] fixed issue where raster to mesh conversion would fail if all all intensity values were negative
parent 3e3fe345
No related branches found
No related tags found
No related merge requests found
...@@ -89,7 +89,7 @@ MeshLib::Mesh* VtkMeshConverter::convertImgToMesh(vtkImageData* img, ...@@ -89,7 +89,7 @@ MeshLib::Mesh* VtkMeshConverter::convertImgToMesh(vtkImageData* img,
// is current pixel visible // is current pixel visible
if (nTuple == 2 || nTuple == 4) if (nTuple == 2 || nTuple == 4)
visNodes[index] = (colour[nTuple-1] > 0); visNodes[index] = (colour[nTuple-1] != 0);
else else
visNodes[index] = true; visNodes[index] = true;
...@@ -239,6 +239,9 @@ MeshLib::Mesh* VtkMeshConverter::constructMesh(const double* pixVal, ...@@ -239,6 +239,9 @@ MeshLib::Mesh* VtkMeshConverter::constructMesh(const double* pixVal,
} }
} }
if (elements.empty())
return nullptr;
return new MeshLib::Mesh("RasterDataMesh", nodes, elements); // the name is only a temp-name, the name given in the dialog is set later return new MeshLib::Mesh("RasterDataMesh", nodes, elements); // the name is only a temp-name, the name given in the dialog is set later
} }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
// ** INCLUDES ** // ** INCLUDES **
#include "VtkVisPipelineView.h" #include "VtkVisPipelineView.h"
#include "OGSError.h"
#include "CheckboxDelegate.h" #include "CheckboxDelegate.h"
#include "VtkVisPipeline.h" #include "VtkVisPipeline.h"
#include "VtkVisPipelineItem.h" #include "VtkVisPipelineItem.h"
...@@ -211,8 +213,13 @@ void VtkVisPipelineView::constructMeshFromImage(QString msh_name, MeshElemType e ...@@ -211,8 +213,13 @@ void VtkVisPipelineView::constructMeshFromImage(QString msh_name, MeshElemType e
imageSource->GetOutput()->GetSpacing(spacing); imageSource->GetOutput()->GetSpacing(spacing);
MeshLib::Mesh* mesh = VtkMeshConverter::convertImgToMesh(imageSource->GetOutput(), origin, spacing[0], element_type, intensity_type); MeshLib::Mesh* mesh = VtkMeshConverter::convertImgToMesh(imageSource->GetOutput(), origin, spacing[0], element_type, intensity_type);
mesh->setName(msh_name.toStdString()); if (mesh)
emit meshAdded(mesh); {
mesh->setName(msh_name.toStdString());
emit meshAdded(mesh);
}
else
OGSError::box("Error creating mesh.");
} }
void VtkVisPipelineView::convertVTKToOGSMesh() void VtkVisPipelineView::convertVTKToOGSMesh()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment