I’m working on a VTK based program that has a fixed vtkPolyData model (points/triangles), with changing point (or cell) data. The polydata is then colored according to the point data field.
The data is generated elsewhere, and delivered live.
Current implementation is in python (windows 10 - Anaconda python, VTK 8.0), but this is eventually going to be ported to C++.
in principle, the following is run in a loop on a separate worker thread:
field = self._getnewdata() field.SetName(self._fieldname) # self._output.GetPointData().SetScalars(field) # self._output.GetPointData().SetActiveScalars(self._fieldname) self._output.GetCellData().SetScalars(field) self._output.Modified() self._needsRender = True
Meanwhile, on a vtk-timer running on 1ms intervals on the VTK main thread:
if self._needsRender: renderwindow.Render() self._needsRender = False
(The thread trick is to keep the rendering window responsive. If everything is run in the vtk main thread, I cannot interact with the model with the mouse cursor)
The actual “issue”:
I’m having trouble getting the frame rate above 15fps, where frame rate refers to the actual frames generation on the worker thread, not the rendering. The CPU load during the animation is very high. Immediately after Render(), I (occasionally, and not after the first render) check
which gives more than 300fps of actual render time.
After reading through this thread , I’ve come to the conclusion, that the rendering part is not the problem, but rather,
GetPointData().SetScalars(), I tried both) is the bottleneck.
The geometry of the displayed polydata never changes, only the scalar field values. I can produce values either for the points or the cells (centers) in the polydata model, whichever results in the more efficient pipeline.
Are there any tricks that I could use to speed up the update of the polydata model, so that I can render more frequently, or at least prevent the loop from chewing on my CPU? I have been reading about the new VTK-m framework, which seems to be very performance oriented, but been somewhat confused about that (it seems to be a bit “supercomputer”-focused). Is it possible, that I could use VTK-m for the rendering part to achieve higher framerates.