For a plugin I am trying to write, I need to create a surface consisting of about 300k quads. These quads are regularly spaced on the x & y axes, but have varying z levels.
The surface is also not rectangular, but has irregular edges, like this:
(the outer black border indicates NODATA, the inner grey fields are height data)
I have a native module that generates two numpy arrays for me,
Positions ========== x y z ....
Quads ============ id id id id ....
where the rows of ids from the quads array indicate rows from the positions array to use as vertex coordinates.
Currently I am generating a vtkUnstructuredGrid by first creating vtkPoints:
coordinates = algs.make_vector(positions[:,0], positions[:,1],positions[:,2]) points = vtkPoints() points.SetData(dsa.numpyTovtkDataArray(coordinates, 'Points')) output.SetPoints(points)
and then individually inserting vtkIdLists to create the quads
for i in range(quads.shape): pids = vtkIdList() pids.InsertId(0,quads[i,0]) pids.InsertId(1,quads[i,1]) pids.InsertId(2,quads[i,2]) pids.InsertId(3,quads[i,3]) output.InsertNextCell(VTK_QUAD, pointIds)
This is of course really slow and manages to fill up my RAM rather quickly.
Is there a faster way to do this?
Is a vtkUnstructuredGrid even the correct data structure for this task?
Thanks in advance!