How to filled my surface in vtk

I’d like to generate a solid surface on vtk but when I enter the following code ctrl_points, color_points = get_data()
surface_polydata = vtk.vtkPolyData()
surface_points = vtk.vtkPoints()
surface_cells = vtk.vtkCellArray()
color_scalars = vtk.vtkUnsignedCharArray()

color_scalars.SetNumberOfComponents(4)
for i, point in enumerate(ctrl_points):
surface_points.InsertNextPoint(point)
color_scalars.InsertNextTuple4(color_points[i * 4], color_points[i * 4 + 1], color_points[i * 4 + 2], color_points[i * 4 + 3])

surface_polydata.SetPoints(surface_points)
surface_polydata.GetPointData().SetScalars(color_scalars)
bezier_surface = vtk.vtkCellArray()
bezier_surface.InsertNextCell(len(ctrl_points))
for i in range(len(ctrl_points)):
bezier_surface.InsertCellPoint(i)

surface_polydata.SetVerts(bezier_surface) I only get a visual rendering with points, my surface is not filled. Can you help me solve this problem?my get_data() function extracts data from a file and returns control points and point colors.I’d like to have a filled surface, not just the control points that appear on the screen when my programme is launched.

Thanks you for your feedback.

If you don’t want to render points, you should create Polys as cells rather than Verts.
Polys define a surface (triangle, quads, convex polygon), while Verts define points.

2 Likes

thanks Sebastien yes it fills my surface but it changes its shape. I would like the same rendering as the bezier surfaces. Here the screenshot


Thanks you for your feedback.

Well it is up to you to properly connect the points that need to be connected. I can’t do it for you.
At least now, using polys, you can define (triangles, quads, and convex polygons).

1 Like