Commit 3b018bbf57991cac73272e68faca09f8739bc1b5

Authored by tatiana
1 parent a3104e14

ENH: Improvement on surface rendering (#238)

Showing 1 changed file with 5 additions and 4 deletions   Show diff stats
invesalius/data/surface.py
@@ -235,7 +235,7 @@ class SurfaceManager(): @@ -235,7 +235,7 @@ class SurfaceManager():
235 mapper = vtk.vtkPolyDataMapper() 235 mapper = vtk.vtkPolyDataMapper()
236 mapper.SetInput(normals.GetOutput()) 236 mapper.SetInput(normals.GetOutput())
237 mapper.ScalarVisibilityOff() 237 mapper.ScalarVisibilityOff()
238 - mapper.ImmediateModeRenderingOn() 238 + mapper.ImmediateModeRenderingOn() # improve performance
239 239
240 actor = vtk.vtkActor() 240 actor = vtk.vtkActor()
241 actor.SetMapper(mapper) 241 actor.SetMapper(mapper)
@@ -325,13 +325,13 @@ class SurfaceManager(): @@ -325,13 +325,13 @@ class SurfaceManager():
325 for key in surface_dict: 325 for key in surface_dict:
326 surface = surface_dict[key] 326 surface = surface_dict[key]
327 # Map polygonal data (vtkPolyData) to graphics primitives. 327 # Map polygonal data (vtkPolyData) to graphics primitives.
328 -  
329 normals = vtk.vtkPolyDataNormals() 328 normals = vtk.vtkPolyDataNormals()
330 normals.SetInput(surface.polydata) 329 normals.SetInput(surface.polydata)
331 normals.SetFeatureAngle(80) 330 normals.SetFeatureAngle(80)
332 normals.AutoOrientNormalsOn() 331 normals.AutoOrientNormalsOn()
333 normals.GetOutput().ReleaseDataFlagOn() 332 normals.GetOutput().ReleaseDataFlagOn()
334 333
  334 + # Improve performance
335 stripper = vtk.vtkStripper() 335 stripper = vtk.vtkStripper()
336 stripper.SetInput(normals.GetOutput()) 336 stripper.SetInput(normals.GetOutput())
337 stripper.PassThroughCellIdsOn() 337 stripper.PassThroughCellIdsOn()
@@ -340,7 +340,7 @@ class SurfaceManager(): @@ -340,7 +340,7 @@ class SurfaceManager():
340 mapper = vtk.vtkPolyDataMapper() 340 mapper = vtk.vtkPolyDataMapper()
341 mapper.SetInput(stripper.GetOutput()) 341 mapper.SetInput(stripper.GetOutput())
342 mapper.ScalarVisibilityOff() 342 mapper.ScalarVisibilityOff()
343 - mapper.ImmediateModeRenderingOn() 343 + mapper.ImmediateModeRenderingOn() # improve performance
344 344
345 # Represent an object (geometry & properties) in the rendered scene 345 # Represent an object (geometry & properties) in the rendered scene
346 actor = vtk.vtkActor() 346 actor = vtk.vtkActor()
@@ -461,6 +461,7 @@ class SurfaceManager(): @@ -461,6 +461,7 @@ class SurfaceManager():
461 normals.AutoOrientNormalsOn() 461 normals.AutoOrientNormalsOn()
462 normals.GetOutput().ReleaseDataFlagOn() 462 normals.GetOutput().ReleaseDataFlagOn()
463 463
  464 + # Improve performance
464 stripper = vtk.vtkStripper() 465 stripper = vtk.vtkStripper()
465 stripper.AddObserver("ProgressEvent", lambda obj,evt: 466 stripper.AddObserver("ProgressEvent", lambda obj,evt:
466 UpdateProgress(obj, _("Generating 3D surface..."))) 467 UpdateProgress(obj, _("Generating 3D surface...")))
@@ -472,7 +473,7 @@ class SurfaceManager(): @@ -472,7 +473,7 @@ class SurfaceManager():
472 mapper = vtk.vtkPolyDataMapper() 473 mapper = vtk.vtkPolyDataMapper()
473 mapper.SetInput(stripper.GetOutput()) 474 mapper.SetInput(stripper.GetOutput())
474 mapper.ScalarVisibilityOff() 475 mapper.ScalarVisibilityOff()
475 - mapper.ImmediateModeRendering() 476 + mapper.ImmediateModeRendering() # improve performance
476 477
477 # Represent an object (geometry & properties) in the rendered scene 478 # Represent an object (geometry & properties) in the rendered scene
478 actor = vtk.vtkActor() 479 actor = vtk.vtkActor()