[vtkusers] [vtk-developers] Crash in vtkImageStencil after update to VTK 6
david.gobbi at gmail.com
Tue Dec 9 15:45:31 EST 2014
The vtkImageStencilData filter had some bugs relating to the way it handled
tolerance, and these were fixed only a few weeks ago. Setting Tolerance to
zero will keep the bugs from manifesting. But I definitely recommend that
you use the latest VTK master if possible, if you are depending on
However, they weren't the kind of bugs that would cause a crash, so the
crash surprises me. I'll look at vtkImageStencil for clues. As far as I
understand, vtkImageStencil itself hasn't changed since VTK 5.
On Tue, Dec 9, 2014 at 11:24 AM, Mathieu Coursolle <
mathieu at rogue-research.com> wrote:
> 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<
> 4) We apply the image stencil.
> vtkSmartPointer<vtkImageStencil> stencil = vtkSmartPointer<vtkImageStencil
> 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.
> R&D Manager
> Rogue Research Inc.
> +1 514 284 3888
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers