Skip to content

Add VTK rendering improvements

Alexis Girault requested to merge alexis-girault/iMSTK:fastVTKnormals into master

ENH: Use vtkTriangleMeshPointNormals

The main bottleneck with real-time VTK rendering so far appeared to be the normals computation. This commit addresses that issue by making use of the latest normals computation filter in VTK: vtkTriangleMeshPointNormals.

While this filter is much (5 to 16 times) faster than vtkPolyDataNormals, it does not check for consistency in the cell orientations that could cause inverted normals, which is why the vtkPolyDataNormals is called once in the surfacemesh renderdelegate to retrieve consistent cells for the input mesh.

See VTK merge request for more information : vtk/vtk!2271 (merged)

PS: That MR requires the latest commits from VTK master, which does not include work made on texture wrap mode nor on multi texture attributes yet:

BUG: fix VTK rendering when framerate not fixed

When the framerate was not fixed, the next render pass would be called using CreateOneShotTimer(0) while its parameter minimum value is 1 (in milliseconds). 0 would set it up for the default value of 10 ms.

ENH: Display framerate in window

Press the P key (for "Print text", since f should be for fullscreen) to display the rendering framerate in the left bottom corner.

Needed to override SetCurrentRenderer to add the textActor.

Only update the displayed framerate value every second, which requires the variables m_lastFpsUpdate (last time since the value was updated), and m_nbrOfFrames (number of frames that were rendered since the last update).

ENH: Allow debug rendering while simulation runs

Addresses suggestions made here: a63f98b5 (comment 212643)

It would be great to have the option of using pan-zoom-rotate when simulation is running for certain applications. I keep pressing 'S' and 'E' in succession to see if everything is good for an example i was working on. It need not be a default run mode option. - @sreekanth-arikatla

  • Rename VTKRenderer::setup into VTKRenderer::setMode
  • Add VTKRenderer::getMode
  • Add VTKViewer::getRenderingMode wrapping the one above
  • Consider Rendering Mode in Mouse event callbacks instead of simulation status
  • Allow to switch to Debug rendering and back with the d key

ENH: Triangulate polydata in VTK reader

Ensure the surface mesh read will only have triangles and no triangle strips or other cells. Fixes #115 (closed).

Merge request reports