[vtkusers] Construct UnstructuredGrid from numpy connectivity array

Dominik Szczerba dominik at itis.ethz.ch
Tue Oct 14 02:54:26 EDT 2014


Hi,

I am still unable to resolve this issue. Is anyone able to help?

Thanks
Dominik

2014-06-07 13:29 GMT+02:00 Dominik Szczerba <dominik at itis.ethz.ch>:
> I read my point and cell datasets as numpy arrays:
>
> points = numpy.array(file1["/Points"])
> cells = numpy.array(file1["/Cells"]) #, dtype=numpy.int32)
> cellTypes = numpy.array(file1["/CellTypes"])
>
> Without any problems I can set the points:
>
> grid = vtk.vtkUnstructuredGrid()
> vpoints = vtk.vtkPoints()
> vpoints.SetData(numpy_support.numpy_to_vtk(points))
> grid.SetPoints(vpoints)
>
> but not cells:
>
> grid.GetCells().SetCells(NC, numpy_support.numpy_to_vtk(cells))
>
>
> I get the error:
>
> TypeError: SetCells argument 2: method requires a vtkIdTypeArray, a
> vtkLongArray was provided
>
> I tried to cast/convert it, but had no luck. Is there a way to do it? Please
> help.
>
> Regards,
> Dominik


More information about the vtkusers mailing list