Import 2017-06-07 23:51:09: master 22301ab2

Author Committer Branch Timestamp Parent
lassoan lassoan master 2015-02-07 14:24:07 master b077f996
Changeset

ENH: Make annotation ROI display about 10x faster (from a few 100 to a few 10 milliseconds)

Annotation ROI rendering was very very slow (several hundreds of milliseconds), mainly due to the slow performance of vtkCutter. This became an issue while doing real-time volume rendering of 4D ultrasound data. The volume rendering speed dropped from 15fps to a few fps when a transform is applied to the volume because of the ROI node that the volume renderer associates with each volume.

Solution: Replaced vtkCutter with a specific plane/plane intersection line computation and optimized the pipeline to only compute data when it is actually used.

How to see the speed improvement:

  • Create a ROI
  • Create a linear transform, apply it to the ROI
  • Change the transform and measure the rendering time using the script below:

def roitest():
transform = slicer.util.getNode('LinearTransform_3')
transformYmin=-100
transformYmax=100
transformYinc=5
matrix=vtk.vtkMatrix4x4()
timer=vtk.vtkTimerLog()
timer.StartTimer()
for i in xrange(10):
transform.GetMatrixTransformToParent(matrix)
oldElem=matrix.GetElement(0 ,3)
matrix.SetElement(0 ,3, -oldElem)
oldElem=matrix.GetElement(1 ,3)
oldElem=oldElem+transformYinc
matrix.SetElement(1 ,3, oldElem)
if oldElem > transformYmax or oldElem < transformYmin:
transformYinc=-transformYinc
transform.SetMatrixTransformToParent(matrix)
slicer.app.processEvents()
timer.StopTimer()
print timer.GetElapsedTime()

roitest()

git-svn-id: http://svn.slicer.org/Slicer4/trunk@23965 3bd1e089-480b-0410-8dfb-8563597acbee

mod - Modules/Loadable/Annotations/MRMLDM/vtkMRMLAnnotationROIDisplayableManager.cxx Diff File
mod - Modules/Loadable/Annotations/VTKWidgets/vtkAnnotationROIRepresentation2D.cxx Diff File
mod - Modules/Loadable/Annotations/VTKWidgets/vtkAnnotationROIRepresentation2D.h Diff File