# How to filled my surface in vtk

**URL:** <https://discourse.vtk.org/t/how-to-filled-my-surface-in-vtk/12615>\
**Category:** Development\
**Tags:** python, code\
**Created:** [November 3, 2023, 3:56pm UTC](https://discourse.vtk.org/t/how-to-filled-my-surface-in-vtk/12615 "2023-11-03T15:56:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic\_Azegha](https://discourse.vtk.org/user_avatar/discourse.vtk.org/loic_azegha/32/7952_2.png) [@Loic\_Azegha](https://discourse.vtk.org/u/Loic_Azegha)\
**Post date:** [November 3, 2023, 3:56pm UTC](https://discourse.vtk.org/t/how-to-filled-my-surface-in-vtk/12615/1 "2023-11-03T15:56:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)\
**Post date:** [November 3, 2023, 7:01pm UTC](https://discourse.vtk.org/t/how-to-filled-my-surface-in-vtk/12615/2 "2023-11-03T19:01:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Loic\_Azegha](https://discourse.vtk.org/user_avatar/discourse.vtk.org/loic_azegha/32/7952_2.png) [@Loic\_Azegha](https://discourse.vtk.org/u/Loic_Azegha)\
**Post date:** [November 6, 2023, 11:04am UTC](https://discourse.vtk.org/t/how-to-filled-my-surface-in-vtk/12615/3 "2023-11-06T11:04:31Z")

</div>

> [@Sebastien\_Jourdain](#):
>
> Polys as cells rather than Verts.

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

 ![before](https://discourse.vtk.org/uploads/default/original/2X/3/3502ba488ac218af55537fb5b60a5987568e6e20.png)  
 ![now](https://discourse.vtk.org/uploads/default/original/2X/1/1068d5a07d6b202d907adf8c2101eb7b53b87c51.png)

---

<div class="post-metadata">

**Author:** ![Loic\_Azegha](https://discourse.vtk.org/user_avatar/discourse.vtk.org/loic_azegha/32/7952_2.png) [@Loic\_Azegha](https://discourse.vtk.org/u/Loic_Azegha)\
**Post date:** [November 6, 2023, 11:19am UTC](https://discourse.vtk.org/t/how-to-filled-my-surface-in-vtk/12615/4 "2023-11-06T11:19:49Z")

</div>

Thanks you for your feedback.

---

<div class="post-metadata">

**Author:** ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)\
**Post date:** [November 6, 2023, 4:25pm UTC](https://discourse.vtk.org/t/how-to-filled-my-surface-in-vtk/12615/5 "2023-11-06T16:25:12Z")

</div>

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).
