[vtk-developers] Crash in vtkImageStencil after update to VTK 6

Mathieu Coursolle mathieu at rogue-research.com
Tue Dec 9 13:24:36 EST 2014


Hi,

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);
image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
void* dataPtr = image->GetScalarPointer();
memset(dataPtr, 0xFF, sizeX * sizeY * sizeZ);

3) We apply the polydata to image stencil:

vtkSmartPointer<vtkPolyDataToImageStencil> dataStencil = vtkSmartPointer<vtkPolyDataToImageStencil>::New();
dataStencil->SetInputData(polydata);
dataStencil->SetInformationInput(image);

4) We apply the image stencil.

vtkSmartPointer<vtkImageStencil> stencil = vtkSmartPointer<vtkImageStencil>::New();
stencil->SetStencilConnection(dataStencil->GetOutputPort());
stencil->SetInputData(image);
stencil->SetBackgroundValue(0);
stencil->Update();
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

_________________________
Mathieu Coursolle, Eng., M.Eng.
R&D Manager
Rogue Research Inc.
www.rogue-research.com
+1 514 284 3888


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20141209/d3e0352b/attachment.html>


More information about the vtk-developers mailing list