<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><br></div><div><br></div><div><br></div></div>