Hi everyone,<br><br>I finally managed to get it working.<br><br>The main key was use SetPolys instead of SetStripes with the vtkPolyData.<br><br>So, the code looks as follows:<br><br>//-----------------------------------------------------------------------------------
<br>vtkFloatArray* pcoords = vtkFloatArray::New();<br>pcoords-&gt;SetNumberOfComponents(3);<br>// My polygon vertices<br>pcoords-&gt;SetNumberOfTuples(myimagePoints.size());<br>float * ptArray = pts;<br>for (int i=0; i&lt;m_imagePoints.size(); i++)
<br>{<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; pcoords-&gt;SetTuple(i, ptArray);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ptArray += 3;<br>}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>// Create vtkPoints and assign pcoords as the internal data array.<br>vtkPoints* points = vtkPoints::New();
<br>points-&gt;SetData(pcoords);<br>vtkPolyData* polydata = vtkPolyData::New();<br>polydata-&gt;SetPoints(points);<br><br>vtkCellArray* polys = vtkCellArray::New();<br>polys-&gt;InsertNextCell(m_imagePoints.size());<br>for (int i = 0; i &lt; 
myimagePoints.size(); i++)<br>{<br>&nbsp;&nbsp;&nbsp; polys-&gt;InsertCellPoint(i);<br>}<br><br>// vertices connect a polygon &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  <br>polydata-&gt;SetPolys(polys);<br><br>vtkLinearExtrusionFilter* extrude = vtkLinearExtrusionFilter::New();
<br>extrude-&gt;SetInput(polydata);<br>extrude-&gt;SetScaleFactor(1);<br>extrude-&gt;SetExtrusionTypeToNormalExtrusion();<br>extrude-&gt;SetVector(0, 0, 1);<br><br>vtkPolyDataToImageStencil* dataToStencil = vtkPolyDataToImageStencil::New();
<br>dataToStencil-&gt;SetInput(extrude-&gt;GetOutput());<br><br>vtkImageStencil* stencil = vtkImageStencil::New();<br>stencil-&gt;SetInput(m_viewer-&gt;GetOutput());<br>stencil-&gt;SetStencil(dataToStencil-&gt;GetOutput());
<br>stencil-&gt;ReverseStencilOff();<br>stencil-&gt;SetBackgroundValue(0);<br><br>stencil-&gt;Update();<br><br>//-----------------------------------------------------------------------------------<br><br>Also, the cell data does not need to be closed as VTK closes it with the first cell automatically. Of course, probably it is always a good idea to close it though!
<br><br>The one nagging thing is that the extracted boundaries look pretty jagged. Is there a way to set some sort of anti aliasing filter on the stencil output?<br><br>I hope someone will find this of some use.<br clear="all">
<br>Cheers,<br><br>Anja