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

David Gobbi david.gobbi at gmail.com
Tue Dec 9 15:45:31 EST 2014


Hi Mathieu,

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
vtkPolyDataToImageStencil.

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.

 - David



On Tue, Dec 9, 2014 at 11:24 AM, Mathieu Coursolle <
mathieu at rogue-research.com> wrote:

> 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/vtkusers/attachments/20141209/6a5d17d8/attachment.html>


More information about the vtkusers mailing list