Hello,
I have a set of points which define the outline of an arbitrary shape. The shape is closed and contains no holes. Now I want to create the corresponding surface in VTK.
My current approach is to create a vtkPolyData as follows:
// Create the points
auto points = vtkSmartPointer::New();
for (int i = 0; i < shape.count(); i++)
{
points->InsertNextPoint(shape.at(i).x(), shape.at(i).y(), 0);
}
// Create a polygon
vtkSmartPointer polygon = vtkSmartPointer::New();
polygon->GetPointIds()->SetNumberOfIds(shape.count());
for (int i = 0; i < shape.count(); i++)
{
polygon->GetPointIds()->SetId(i, i);
}
// Add the polygon to a list of polygons
vtkSmartPointer polygons = vtkSmartPointer::New();
polygons->InsertNextCell(polygon);
// Create a PolyData
vtkSmartPointer polydata = vtkSmartPointer::New();
polydata ->SetPoints(points);
polydata ->SetPolys(polygons);
The resulting shape is correct when using the “Wireframe” representation. Nevertheless, the “Surface” representation is wrong.
I tried to triangulate the polygon using vtkTriangleFilter, but the result contains a rectangular hole (vtkFillHolesFilter does not help).
Any ideas how to create a simple vtkPolyData surface based on some points defining the outline of the shape?
Thank you.