Documentation/Labs/VTK7
This page documents the update of Slicer to use VTK 7.1.
Overview
It is planned to update the version of VTK that Slicer uses from 6.3 to 7.1. Because VTK has deprecated various headers, classes, and methods, it may be necessary to update extension code to be compatible with the new version of VTK. Additionally, because VTK has expanded the scope of code that is Python-wrapped by default, it may be necessary to add new wrapping exclusions.
The following sections describe the status of the VTK update and specific issues that may impact extensions.
Status
Merged in r25219 to r25227, or on GitHub, e0af614...929aed2.
Branches/Merge Requests
VTK:
Slicer:
Outstanding VTK issues
- Broken support for VTK_ENABLE_KITS
- MTime change requires updates in Slicer or configuring with backwards compatibility flag
- VTK merge request: https://gitlab.kitware.com/vtk/vtk/merge_requests/1790 ("ENH: Introduce vtkMTimeType")
- Build error: http://slicer.cdash.org/viewBuildError.php?buildid=876219
- Proposed fix: https://github.com/msmolens/Slicer/commit/04ecb4c377e8f2eff4a969b85502abea8529d83d
- Minimal list of extensions that will require updates:
- ModelToModelDistance
- SlicerIGT
- SlicerRT
Slicer-specific VTK commits
Slicer's VTK 7.1 branch includes fixes/changes that aren't in upstream:
- ENH: Allow selection of seed points using vtkSeedWidget
- Revert "Increase VTK OS X minimum check from 10.6.0 to 10.6.8"
GPU raycast volume rendering now supports textures larger than 1024 (see https://gitlab.kitware.com/vtk/vtk/merge_requests/1048)(added upstream in https://gitlab.kitware.com/vtk/vtk/merge_requests/1845)- BUG: WIP: fix vtkPickingManager interaction with widgets
- Ensure vtkVariant stream associated with << operator is set back to "dec".
Tests
NOTE: Following the transition to VTK7, this section is out of date.
This section lists test failures on each platform for Release builds.
Some commits that fix Slicer builds and tests have been merged upstream:
- https://gitlab.kitware.com/vtk/vtk/merge_requests/1582
- https://gitlab.kitware.com/vtk/vtk/merge_requests/1592
Windows:
- http://slicer.cdash.org/buildSummary.php?buildid=859287
- MergeModelsTestCompare: diff is specific to local configuration; see Issue 4212 ("git core.autocrlf=true option causes erroneously modified source files and test failures")
- py_nomainwindow_MRMLCreateNodeByClassWithSetReferenceCountToOne: due to VTK_DEBUG_LEAKS being enabled, also fails on master; see dashboard
Linux:
Test results:
- http://slicer.cdash.org/buildSummary.php?buildid=859295 (Ubuntu 16.04)
OS X:
Test results:
Rendering backend
Although VTK 7 changes the default setting of VTK_RENDERING_BACKEND to OpenGL2, Slicer still explicitly sets it to OpenGL. Using the OpenGL2 backend in Slicer is untested and may require updates to properly build and function. This rendering backend in Slicer is set using Slicer_VTK_RENDERING_BACKEND.
OpenGL2 backend known issues
Open
- OS X factory machine targets OS X 10.6 (CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6), so the Mac nightly builds don't find the required OpenGL version. See https://github.com/Slicer/Slicer/pull/595.
- 4252: Slicer crashes on start when started through Windows Remote Desktop
Resolved
Does code in VolumeRenderingReplacements need updates?Some of these classes could be redundant anyway; vtkOpenGLRayCastImageDisplayHelper looks identical to the version in VTK, but without VTK's bug fixes.- Resolved in https://github.com/Slicer/Slicer/commit/67c4ae61b41ea7a2382e44284d89c41c75ba2aff.
4253: VTK rendering corrupted with VTK OpenGL2 rendering backend- 4251: Ordering of 2D actors is often wrong with OpenGL2
- Issue 2165 ("Volume rendering labelmap") regresses, because the fixes in Slicer's VTK branch apply only to the OpenGL backend. For an example program that demonstrates the volume rendering problem, see https://github.com/msmolens/GPUVolumeRenderLargeLUT.
VTK team is investigating a solution; see https://gitlab.kitware.com/vtk/vtk/merge_requests/1048.Resolved in https://gitlab.kitware.com/vtk/vtk/merge_requests/1845.There may be an additional problem (specific to Slicer?) volume rendering the brain atlas dataset besides the sampling issue. In Slicer, GPU volume rendering shows nothing visible.Resolved in https://gitlab.kitware.com/vtk/vtk/merge_requests/1905.
py_RSNA2012ProstateDemo test crashes due to incorrect use of VTK classes. See https://github.com/Slicer/Slicer/pull/549.OpenGL errors followed by an access violation occurs in some cases when initializing Volume Rendering module logic. OpenGL errors are seen in same workflow with OpenGL backend. To reproduce: start Slicer, select "3D Only" layout, restart Slicer, load MRHead, enter Volume Rendering module. See https://github.com/Slicer/Slicer/pull/552.
Fixed upstream
- Incorrect clipping seen during volume rendering. Fixed by VTK 1655 (Verified, but not yet in Slicer VTK branch). To reproduce:
- Download MRHead in Sample Data.
- Volume Render MRHead.
- Rotate view with up arrow key. Observe incorrect clipping once rotated 90 degrees.
- Issue 3969, OpenGL errors due to incorrect context active during cleanup, may still be issue. The test case in the bug seems fixed, but additional problems are likely fixed by VTK 1636 (Verified, but not yet in Slicer VTK branch).
Discussion
The transition plan was announced on the slicer-devel mailing list: http://massmail.spl.harvard.edu/public-archives/slicer-devel/2016/040450.html.
Nightly/Developers/Tutorials/MigrationGuide/VTK6-to-VTK7
List of extensions that may require updates
By examining the source code of Slicer extensions, it is likely that some extensions will require changes to be compatible with VTK 7.1. This section lists categories of updates and specific files in extensions that may need to be updated.
Use https://github.com/jcfr/pys4ext to fetch the source code of all extensions in the extensions index.
A useful regular expression to help identify uses of the deprecated vtkMatrix4x4 operator[] is:
\(\*([A-Za-z0-9_])+\)\[.+\]
However, note that this results in many false positives, because that syntax is valid for many classes.
vtkDataArray:
- DTIAtlasFiberAnalyzer/Applications/dtitractstat/fiberprocessing.cxx
- DTIProcess/PrivateLibrary/fiberio.cxx
- MarginCalculator/MotionSimulatorDoubleArray/MRML/vtkMRMLMotionSimulatorDoubleArrayNode.cxx
- SPHARM-PDM/Applications/MetaMeshTools/MeshMath.cxx
Python wrapping:
- WRAP_EXCLUDE
- SlicerPathology/QuickTCGA/Logic/CMakeLists.txt
- SlicerPathology/ShortCutCore/Logic/CMakeLists.txt
- BTX/ETX
- FacetedVisualizer/Logic/vtkSlicerFacetedVisualizerLogic.h
- FacetedVisualizer/qSlicerFacetedVisualizerModuleWidget.h
- LightWeightRobotIGT/LightWeightRobotIGT/MRML/vtkIGTLToMRMLString.h
- LightWeightRobotIGT/LightWeightRobotIGT/MRML/vtkMRMLIGTLSessionManagerNode.h
- ModelClip/vtkPlaneExtend.h
- SlicerRT/DicomRtImportExport/Logic/vtkSlicerDicomRtReader.h
- SlicerRT/DicomRtImportExport/Logic/vtkSlicerDicomRtWriter.h
- SlicerRT/DicomSroImport/Logic/vtkSlicerDicomSroReader.h
- SlicerRT/SegmentationCore/vtkSegmentation.h
- SlicerRT/Segmentations/MRML/vtkMRMLSegmentationNode.h
- SlicerRT/SlicerRtCommon/SlicerRtCommon.h
- SlicerRT/SlicerRtCommon/vtkCollisionDetectionFilter.h
References to VTKv6:
- DTIPrep/SuperBuild/External_VTK.cmake
- DTIPrep/SuperBuild/External_VTK_patch.cmake
- SPHARM-PDM/SuperBuild/External_VTK.cmake
- SPHARM-PDM/SuperBuild/External_VTK_patch.cmake
- DTIAtlasBuilder/SuperBuild/FindExternalTools.cmake
- DTIProcess/SuperBuild/External_VTK.cmake
- DTIProcess/SuperBuild/External_VTK_patch.cmake
- ShapePopulationViewer/SuperBuild/External_VTK_patch.cmake
- ShapePopulationViewer/SuperBuild/External_VTK.cmake
- FiberViewerLight/SuperBuild/External_VTK.cmake
- FiberViewerLight/SuperBuild/External_VTK_patch.cmake
- DTIAtlasFiberAnalyzer/SuperBuild/External_VTK.cmake
Future work
Future work in Slicer related to VTK 7 could include:
- Remove BTX/ETX markers.
- Resolve build warnings for -Woverloaded-virtual in Slicer VTK classes.
- Check that settings in External_VTKv7.cmake are all still necessary, specifically VTK_USE_PARALLEL, and anything related to Qt.
- Test Slicer_VTK_RENDERING_BACKEND set to OpenGL2.