[vtkusers] Crash in vtkImageStencil after update to VTK 6
mathieu at rogue-research.com
Tue Dec 9 13:24:36 EST 2014
We are currently upgrading an application from VTK 5.10 to VTK 6.
We have a piece of code that uses vtkPolyDataToImageStencil and vtkImageStencil, which worked perfectly when using VTK 5.10.
However, it now crashes in some cases since we upgraded to VTK 6.
Here is a summary of the workflow and code:
1) We load a polydata (output from another algorithm).
2) We create an image and fill its data with a constant value (0xFF).
vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
image->SetDimensions(sizeX, sizeY, sizeZ);
image->SetSpacing(spacingX, spacingY, spacingZ);
image->SetOrigin(0.0, 0.0, 0.0);
void* dataPtr = image->GetScalarPointer();
memset(dataPtr, 0xFF, sizeX * sizeY * sizeZ);
3) We apply the polydata to image stencil:
vtkSmartPointer<vtkPolyDataToImageStencil> dataStencil = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
4) We apply the image stencil.
vtkSmartPointer<vtkImageStencil> stencil = vtkSmartPointer<vtkImageStencil>::New();
vtkSmartPointer<vtkImageData> mask = stencil->GetOutput();
It still works fine with some of the polydata, but now crashes in vtkImageStencil execution, more precisely in vtkCopyPixel, with at least one of the polydata that worked fine before.
One thing I noticed is that the polydata for which it fails has its bounds very close to the edge of the image.
I changed the tolerance (dataStencil->SetTolerance()) to 0 and it seems to fix the issue, but I have to admit that I don't understand why.
That being said, anyone have an idea of why it would crash with VTK 6 and not before? I saw that there was a change in the way the tolerance was managed, but couldn't track it down specifically to our issue.
Thank you for you help,
Mathieu Coursolle, Eng., M.Eng.
Rogue Research Inc.
+1 514 284 3888
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers