<div dir="ltr">Thanks David for your answer!<div><br></div><div>I just saw on the vtkPolyDataToImageStencil documentation that the contour must be align throw the Z planes.<br></div><div><br></div><div>I use vtkCutter to cut my mesh along Z-axis but all the pictures saved are black. I attached my code and the CMakeLists.txt.</div><div><br></div><div>Is there another way to "project" my filled contour on an image?</div><div><br></div><div>Thanks again.</div><div><br></div><div>Romain</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-11-06 14:15 GMT+01:00 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Romain,<div><br></div><div>The vtkPolyDataToImageStencil class needs a "hollow" shape as input,</div><div>either a 3D surface or a 2D contour. If you fill the contour, then it can't</div><div>be used by vtkPolyDataToImageStencil.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div> - David</div></font></span><div><div class="h5"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 6, 2015 at 2:22 AM, Romain LEGUAY <span dir="ltr"><<a href="mailto:romain.leguay@gmail.com" target="_blank">romain.leguay@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello everyone,<div><br></div><div>In purpose to create a series of pictures (with the same size 512*512 for example), I cut a mesh along an axis (X, Y or Z) with vtkCutter, then I triangulate those contours with vtkContourTriangulator. I obtain some "flat" vtkPolydata<i>s</i> (one per cut). Now, I want to save all those "flat" meshes to 2D images with fixed size.</div><div>I saw on the wiki (<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataToImageData</a>) how to convert a vtkPolydata in vtkImageData, but in this case, my vtkPolydata is in a plane (the output of vtkContourTriangulator) so the dimension of the white image is 0 or negative because of this part of code:</div><br><div><div>vtkSmartPointer<vtkImageData> whiteImage = vtkSmartPointer<vtkImageData>::New(); </div><div>double bounds[6];</div><div>polydata->GetBounds(bounds);</div><div>double spacing[3]; // desired volume spacing</div><div>spacing[0] = 0.5;</div><div>spacing[1] = 0.5;</div><div>spacing[2] = 0.5;</div><div>whiteImage->SetSpacing(spacing);</div><div><br></div><div>// compute dimensions</div><div>int dim[3];</div><div>for (int i = 0; i < 3; i++)</div><div>{</div><div> dim[i] = static_cast<int>(ceil((bounds[i * 2 + 1] - bounds[i * 2]) / spacing[i])); // One of the dimension is 0</div><div>}</div><div>whiteImage->SetDimensions(dim);</div><div>whiteImage->SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1); // Here </div></div><div><br></div><div><br></div><div><div>I don't know if there is other choice to convert a polydata to an image but this code always give some black pictures.</div></div><div>I'm not sure if I use the good filter to convert my polydata to a 2D image but I don't find anything.</div><div><br></div><div>Do you have any clues?</div><div><br></div><div>Thanks,</div><div><br></div><div>Romain</div></div></blockquote></div></div></div></div></div></div>
</blockquote></div><br></div>