<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<div><br></div><div>We are currently upgrading an application from VTK 5.10 to VTK 6.</div><div><br></div><div>We have a piece of code that uses vtkPolyDataToImageStencil and vtkImageStencil, which worked perfectly when using VTK 5.10.</div><div>However, it now crashes in some cases since we upgraded to VTK 6.</div><div><br></div><div>Here is a summary of the workflow and code:</div><div><br></div><div>1) We load a polydata (output from another algorithm).</div><div><br></div><div>2) We create an image and fill its data with a constant value (0xFF).</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(112, 61, 170);">vtkSmartPointer<span style="color: #000000"><</span>vtkImageData<span style="color: #000000">> image = </span>vtkSmartPointer<span style="color: #000000"><</span>vtkImageData<span style="color: #000000">>::</span><span style="color: #3d1d81">New</span><span style="color: #000000">();</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">image-><span style="color: #3d1d81">SetDimensions</span>(sizeX, sizeY, sizeZ);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">image-><span style="color: #3d1d81">SetSpacing</span>(spacingX, spacingY, spacingZ);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">image-><span style="color: #3d1d81">SetOrigin</span>(<span style="color: #272ad8">0.0</span>, <span style="color: #272ad8">0.0</span>, <span style="color: #272ad8">0.0</span>);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(120, 73, 42);"><span style="color: #000000">image-></span><span style="color: #3d1d81">AllocateScalars</span><span style="color: #000000">(</span>VTK_UNSIGNED_CHAR<span style="color: #000000">, </span><span style="color: #272ad8">1</span><span style="color: #000000">);</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span style="color: #bb2ca2">void</span>* dataPtr = image-><span style="color: #3d1d81">GetScalarPointer</span>();</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;"><span style="color: #3d1d81">memset</span>(dataPtr, <span style="color: #272ad8">0xFF</span>, sizeX * sizeY * sizeZ);</div></div><div><br></div><div>3) We apply the polydata to image stencil:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(0, 132, 0);"><span style="color: rgb(112, 61, 170);">vtkSmartPointer</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(112, 61, 170);">vtkPolyDataToImageStencil</span><span style="color: rgb(0, 0, 0);">> dataStencil = </span><span style="color: rgb(112, 61, 170);">vtkSmartPointer</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(112, 61, 170);">vtkPolyDataToImageStencil</span><span style="color: rgb(0, 0, 0);">>::</span><span style="color: rgb(61, 29, 129);">New</span><span style="color: rgb(0, 0, 0);">();</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">dataStencil-><span style="color: #78492a">SetInputData</span>(polydata);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">dataStencil-><span style="color: #3d1d81">SetInformationInput</span>(image);</div></div><div><br></div><div>4) We apply the image stencil.</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(112, 61, 170);">vtkSmartPointer<span style="color: #000000"><</span>vtkImageStencil<span style="color: #000000">> stencil = </span>vtkSmartPointer<span style="color: #000000"><</span>vtkImageStencil<span style="color: #000000">>::</span><span style="color: #3d1d81">New</span><span style="color: #000000">();</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(120, 73, 42);"><div style="margin: 0px;"><div style="margin: 0px; color: rgb(61, 29, 129);"><span style="color: #000000">stencil-></span>SetStencilConnection<span style="color: #000000">(dataStencil-></span>GetOutputPort<span style="color: #000000">());</span></div></div></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">stencil-><span style="color: rgb(120, 73, 42);">SetInputData</span>(image);</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(61, 29, 129);"><span style="color: #000000">stencil-></span>SetBackgroundValue<span style="color: #000000">(</span><span style="color: #272ad8">0</span><span style="color: #000000">);</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">stencil-><span style="color: #3d1d81">Update</span>();</div><p style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;"><span style="color: rgb(112, 61, 170);">vtkSmartPointer</span><<span style="color: rgb(112, 61, 170);">vtkImageData</span>> mask = stencil-><span style="color: rgb(61, 29, 129);">GetOutput</span>();</p></div><div><br></div><div>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.</div><div><br></div><div>One thing I noticed is that the polydata for which it fails has its bounds very close to the edge of the image.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>Thank you for you help,</div><div><br></div><div>Mathieu</div><div><br></div><div>_________________________<br>Mathieu Coursolle, Eng., M.Eng.<br>R&D Manager<br>Rogue Research Inc.<br><a href="http://www.rogue-research.com">www.rogue-research.com</a><br>+1 514 284 3888</div><div><br></div><div><br></div></body></html>