Search code examples
pythonvtk

Taking a list of points and making them vtk.Points and vtk.CellArray and trying to transform into vtkPolyData


I am taking a list of points and insert them into polydata. While also transferring the topology of the points by using vtkCellArray. This was the example I was following:

https://vtk.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/Point

I keep getting this error:

vertices.InsertNextCell(1) TypeError: no overloads of InsertNextCell() take 0 arguments

import vtk

transformed_values = [[1,2,3],[3,4,5],[5,9,3]]

points = vtk.vtkPoints()
vertices = vtk.vtkCellArray
pd = vtk.vtkPolyData()

for row in transformed_values:
    id = points.InsertNextPoint(row)
    vertices.InsertNextCell(1)
    vertices.InsertCellPoint(id)

pd.SetPoints(points)
pd.SetVerts(vertices)

Any help would be greatly appreciated! Thank you so much.


Solution

  • You missed the parenthesis:

    vertices = vtk.vtkCellArray

    vertices = vtk.vtkCellArray()