Make vtk filter update only certain aspects of output

I’m making a “source” object, similar to vtkSphereSource, so I have set up the requestData method to construct and return a vtkPolyData (“return” in the sense of filling the output parameter outData)

Now every time I modify the source object, it rebuilds that vtkPolyData completely. But I only need it to update the points array. It doesn’t need to rebuild topology or normals.

What’s the proper vtk way to make requestData build everything initially, but then only rebuild the points array when the object gets modified?

(This is vtk.js, btw)


EDIT: One thought I had is to make two filters. One source object generates a vtkPolyData with topology and normals, but no points (or a zero-initialized points array). Then a filter that takes a vtkPolyData and just populates it with points. The properties that only affect the points array can be managed by the second filter, and updating those would only update the points array.

But is this the correct vtk way of thinking? :thinking:

I don’t see it done elsewhere. For example, if I’m reading the code correctly, calling setRadius on vtkSphereSource causes it to rebuild an entire vtkPolyData, even though it’s only the points array that changes, while normals and topology remain the same.

This is too specific to your use case to have it generalized in vtk.js.

I would check the mtime of the input arrays (polys, pointdata, celldata…) in requestData and decide to reuse the previous output arrays.

Hth,
Julien.

This is too specific to your use case to have it generalized in vtk.js.

My question is about my use case; I’m not trying to generalize something to vtk.js

I would check the mtime of the input arrays …

Thanks, I will look into this approach!