Difference between revisions of "Documentation/Labs/VTK7"

From Slicer Wiki
Jump to: navigation, search
 
(68 intermediate revisions by 2 users not shown)
Line 8: Line 8:
  
 
==Status==
 
==Status==
 +
 +
Merged in [http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=25219 r25219] to [http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=25227 r25227], or on GitHub, [https://github.com/Slicer/Slicer/compare/e0af614...929aed2 e0af614...929aed2].
  
 
===Branches/Merge Requests===
 
===Branches/Merge Requests===
Line 13: Line 15:
 
<b>VTK:</b>
 
<b>VTK:</b>
  
* https://github.com/Slicer/VTK/tree/slicer-v7.1.0-2016-06-17-a8a28b6
+
* https://github.com/Slicer/VTK/tree/slicer-v7.1.0-2016-07-06-b824d94
  
 
<b>Slicer:</b>
 
<b>Slicer:</b>
  
 
* https://github.com/Slicer/Slicer/pull/540
 
* https://github.com/Slicer/Slicer/pull/540
* https://github.com/msmolens/Slicer/tree/update-to-vtk7
+
 
 +
====Outstanding VTK issues====
 +
* Broken support for VTK_ENABLE_KITS
 +
** https://gitlab.kitware.com/vtk/vtk/merge_requests/1511#note_135449
 +
* 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
 +
** https://github.com/Slicer/VTK/commit/0f8ed32e0b7018d776271dbf5f27968b716a9e10
 +
* Revert "Increase VTK OS X minimum check from 10.6.0 to 10.6.8"
 +
** https://github.com/Slicer/VTK/commit/8f2ca638dfcc0cecf2fb5d42d99d35d46d837dcc
 +
* <strike>GPU raycast volume rendering now supports textures larger than 1024 (see https://gitlab.kitware.com/vtk/vtk/merge_requests/1048)</strike> (added upstream in https://gitlab.kitware.com/vtk/vtk/merge_requests/1845)
 +
** https://github.com/Slicer/VTK/commit/f34413a51c380889aa9cd42b04ce4401d0ac2add
 +
** https://github.com/Slicer/VTK/commit/ea39dd40d9ff62f2b432e1488f049f1bba5198bd
 +
** https://github.com/Slicer/VTK/commit/b8c5840e69ee0a3d5ca6ce124f24434d271a9af7
 +
* BUG: WIP: fix vtkPickingManager interaction with widgets
 +
** https://github.com/Slicer/VTK/commit/a5d607a90ad65b1e6c90d5d21b7f10c4274673a1
 +
* Ensure vtkVariant stream associated with << operator is set back to "dec".
 +
** https://github.com/Slicer/VTK/commit/6db64cb73732b13e34081af2e5bbe6f51b1ac9c8
  
 
===Tests===
 
===Tests===
 +
NOTE: Following the transition to VTK7, this section is out of date.
 +
 +
This section lists test failures on each platform for Release builds.
  
This section lists test failures on each platform for Release builds with the default CMake configuration.
+
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
  
 
<b>Windows:</b>
 
<b>Windows:</b>
  
* <tt>vtkMRMLThreeDReformatDisplayableManagerTest1</tt>: baseline diff likely due to [https://github.com/Kitware/VTK/commit/f9b4ba9b029176b17fea635f6074f793594d0a3c vtkImplicitPlaneWidget2 changes]
+
* http://slicer.cdash.org/buildSummary.php?buildid=859287
* <tt>py_nomainwindow_MRMLCreateNodeByClassWithSetReferenceCountToOne</tt>: also fails on master; [http://slicer.cdash.org/testDetails.php?test=7372719&build=845809 see dashboard]
+
** <tt>MergeModelsTestCompare</tt>: diff is specific to local configuration; see [http://www.na-mic.org/Mantis/view.php?id=4212 Issue 4212 ("git core.autocrlf=true option causes erroneously modified source files and test failures")]
* <tt>EMSegCL_RunDefaultNodes</tt>
+
** <tt>py_nomainwindow_MRMLCreateNodeByClassWithSetReferenceCountToOne</tt>: due to VTK_DEBUG_LEAKS being enabled, also fails on master; [http://slicer.cdash.org/testDetails.php?test=7372719&build=845809 see dashboard]
* <tt>EMSegCL_RunSetEverything</tt>
 
* <tt>EMSegCL_IntermediateResults</tt>
 
* <tt>EMSegCL_Task_BRAINS_MRIHumanBrain_scalartype_float_very_small</tt>
 
* <tt>EMSegCL_Task_BRAINS_MRIHumanBrain_scalartype_uint_very_small</tt>
 
* <tt>EMSegCL_Task_MRIHumanBrain_2CH</tt>
 
* <tt>EMSegCL_Task_MRIHumanBrain_BRAINS_small</tt>
 
* <tt>EMSegCL_Task_HumanEye_BRAINS_small</tt>
 
* <tt>EMSegCL_Task_MRIHumanBrainExp_BRAINS_small</tt>
 
* <tt>EMSegCL_Task_MRIHumanBrainParcellation_BRAINS_small</tt>
 
* <tt>EMSegCL_Task_MRIHumanBrainFullParcellation_BRAINS_small</tt>
 
* <tt>EMSegCL_Task_NonHumanPrimate_BRAINS_small</tt>&dagger;
 
 
 
&dagger; The EMSegCL_XXX tests might be erroneous failures, as these same tests were fixed on the dashboard by [https://github.com/Slicer/Slicer/commit/33488dbc67a486ceacb8c2107366fb2930aaa0b4 Slicer/Slicer@33488db].
 
  
 
<b>Linux:</b>
 
<b>Linux:</b>
  
<i>Untested</i>
+
Test results:
 +
* http://slicer.cdash.org/buildSummary.php?buildid=859295 (Ubuntu 16.04)
  
 
<b>OS X:</b>
 
<b>OS X:</b>
  
<i>Untested</i>
+
Test results:
 +
* http://slicer.cdash.org/buildSummary.php?buildid=859288
  
 
===Rendering backend===
 
===Rendering backend===
  
Although VTK 7 changes the default setting of <tt>VTK_RENDERING_BACKEND</tt> to <tt>OpenGL2</tt>, Slicer still explicitly sets it to <tt>OpenGL</tt>. Using the <tt>OpenGL2</tt> backend in Slicer is untested and may require updates to properly build and function.
+
Although VTK 7 changes the default setting of <tt>VTK_RENDERING_BACKEND</tt> to <tt>OpenGL2</tt>, Slicer still explicitly sets it to <tt>OpenGL</tt>. Using the <tt>OpenGL2</tt> backend in Slicer is untested and may require updates to properly build and function. This rendering backend in Slicer is set using <tt>Slicer_VTK_RENDERING_BACKEND</tt>.
  
==Migration guide==
+
====OpenGL2 backend known issues====
  
This section lists categories of code changes necessary to build Slicer with VTK 7.1. Each category has a short description, an example error message, a suggested upgrade path, and references to relevant commits.
+
=====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.
 +
* [http://www.na-mic.org/Bug/view.php?id=4252 4252: Slicer crashes on start when started through Windows Remote Desktop]
  
Referencing this list might be helpful if Slicer extensions require updates to be compatible with VTK 7.1.
+
=====Resolved=====
 +
* <strike>Does code in VolumeRenderingReplacements need updates?</strike>
 +
** <strike>Some of these classes could be redundant anyway; vtkOpenGLRayCastImageDisplayHelper looks identical to the version in VTK, but without VTK's bug fixes.</strike>
 +
** Resolved in https://github.com/Slicer/Slicer/commit/67c4ae61b41ea7a2382e44284d89c41c75ba2aff.
 +
* <strike>[http://www.na-mic.org/Bug/view.php?id=4253 4253: VTK rendering corrupted with VTK OpenGL2 rendering backend]</strike>
 +
** [https://www.assembla.com/spaces/slicerrt/tickets/823-segmentation-disappears-after-deselecting-volume-in-slice-view slicerrt#823]
 +
** [https://gitlab.kitware.com/vtk/vtk/issues/15829 vtk#15829]
 +
** http://vtk.1045678.n5.nabble.com/vtkActor2D-and-layer-ordering-td5737238.html
 +
** Resolved in https://github.com/Slicer/Slicer/pull/586, https://github.com/commontk/CTK/pull/672
 +
* [http://www.na-mic.org/Bug/view.php?id=4251 4251: Ordering of 2D actors is often wrong with OpenGL2]
 +
** Resolved in https://gitlab.kitware.com/vtk/vtk/merge_requests/1995
 +
* [http://www.na-mic.org/Bug/view.php?id=2165 Issue 2165 ("Volume rendering labelmap")] regresses, because the fixes in Slicer's VTK branch apply only to the <tt>OpenGL</tt> backend. For an example program that demonstrates the volume rendering problem, see https://github.com/msmolens/GPUVolumeRenderLargeLUT.
 +
** <strike>VTK team is investigating a solution; see https://gitlab.kitware.com/vtk/vtk/merge_requests/1048.</strike> Resolved in https://gitlab.kitware.com/vtk/vtk/merge_requests/1845.
 +
** <strike>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.</strike> Resolved in https://gitlab.kitware.com/vtk/vtk/merge_requests/1905.
 +
* <strike>py_RSNA2012ProstateDemo test crashes due to incorrect use of VTK classes. See https://github.com/Slicer/Slicer/pull/549.</strike>
 +
* <strike>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.</strike>
  
===Deprecated the vtkStreamer class hierarchy===
+
=====Fixed upstream=====
 +
* Incorrect clipping seen during volume rendering. Fixed by [https://gitlab.kitware.com/vtk/vtk/merge_requests/1655/ 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.
 +
* [http://www.na-mic.org/Mantis/view.php?id=3969 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 [https://gitlab.kitware.com/vtk/vtk/merge_requests/1636 VTK 1636] (Verified, but not yet in Slicer VTK branch).
  
VTK has deprecated the vtkStreamer class hierarchy.
+
===Discussion===
  
<b>Error message similar to:</b>
+
The transition plan was announced on the slicer-devel mailing list: http://massmail.spl.harvard.edu/public-archives/slicer-devel/2016/040450.html.
  
'VTK_INTEGRATE_FORWARD' : undeclared identifier
+
{{:Documentation/Nightly/Developers/Tutorials/MigrationGuide/VTK6-to-VTK7}}
  
<b>Solution:</b>
+
==List of extensions that may require updates==
  
Replace lines like:
+
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.
 
 
#include "vtkStreamer.h"
 
 
 
with:
 
 
 
#include "vtkHyperStreamline.h"
 
 
 
<b>References:</b>
 
 
 
* https://github.com/Slicer/Slicer/commit/a78fa0dc33d7c3822bff14b0e2bc403cf6ee9b31 (COMP: Update #include of deprecated vtkStreamer.h)
 
* https://github.com/Kitware/VTK/commit/c9f7a5e (vtkStreamer: deprecate the class hierarchy)
 
 
 
===Deprecated vtkMatrix4x4::operator[] method===
 
 
 
VTK has deprecated the <tt>vtkMatrix4x4::operator[]</tt> method.
 
 
 
<b>Error message similar to:</b>
 
 
 
binary '[' : 'vtkMatrix4x4' does not define this operator or a conversion to a type acceptable to the predefined operator
 
 
 
<b>Solution:</b>
 
 
 
Replace lines like:
 
 
 
(*mat)[i][j] = val;
 
val = (*mat)[i][j];
 
 
 
with:
 
 
 
mat->SetElement(i, j, val);
 
val = mat->GetElement(i, j);
 
 
 
<b>References:</b>
 
 
 
* https://github.com/Slicer/Slicer/commit/375e69d37326d6280fea9100ba786267feae46c4 (COMP: Update usage of legacy vtkMatrix4x4 method)
 
* https://github.com/Kitware/VTK/commit/d9c5ca0 (Mark legacy methods as "legacy".)
 
 
 
===Removed vtksys/ios, vtksys/stl compatibility layers===
 
  
VTK has removed the vtksys/ios and vtksys/stl compatibility layers.
+
Use https://github.com/jcfr/pys4ext to fetch the source code of all extensions in the extensions index.
  
<b>Error message similar to:</b>
+
A useful regular expression to help identify uses of the deprecated vtkMatrix4x4 operator[] is:
  
  Cannot open include file: 'vtksys/ios/iostream': No such file or directory
+
  \(\*([A-Za-z0-9_])+\)\[.+\]
  
<b>Solution:</b>
+
However, note that this results in many false positives, because that syntax is valid for many classes.
 
 
Replace lines like:
 
 
 
#include <vtksys/ios/iostream>
 
#include <vtksys/ios/sstream>
 
 
vtksys_ios::ofstream ofs;
 
 
 
with:
 
 
 
#include <iostream>
 
#include <sstream>
 
 
std::ofstream ofs;
 
 
 
Replace lines like:
 
 
 
#include <vtksys/stl/string>
 
#include <vtksys/stl/vector>
 
 
vtksys_stl::string str;
 
vtksys_stl::vector<double> vec;
 
 
 
with:
 
 
 
#include <string>
 
#include <vector>
 
 
std::string str;
 
std::vector<double> vec;
 
 
 
<b>References:</b>
 
* https://github.com/msmolens/Slicer/commit/55731d6caa7811df346319fdbf6f1d7c6036a31a (COMP: Remove usage of #include <vtksys/stl/*>)
 
* https://github.com/Kitware/VTK/commit/eaf0f6ac1bc2f65770adf5ff6f17759485cd8072 (ENH: Remove use of include <vtksys/stl/*> and vtksys_stl::*)
 
* https://github.com/Kitware/VTK/commit/3ae7dd3a106d6b59380e35dfe6962a8c849316c8 (ENH: Remove use of include <vtksys/ios/*> and vtksys_ios::*)
 
 
 
===vtkDataArray refactored===
 
 
 
VTK has refactored the vtkDataArray class hierarchy.
 
 
 
<b>Error message similar to:</b>
 
 
 
'class XXX’ has no member named ‘SetTupleValue’
 
 
 
<b>Solution:</b>
 
 
 
Replace lines like:
 
 
 
array->GetTupleValue(0, val);
 
array->SetTupleValue(0, val);
 
array->InsertTupleValue(i, val);
 
array->InsertNextTupleValue(val);
 
 
 
with:
 
 
 
array->GetTypedTuple(0, val);
 
array->SetTypedTuple(0, val);
 
array->InsertTypedTuple(i, val);
 
array->InsertNextTypedTuple(val);
 
 
 
Replace lines like:
 
 
 
#include <vtkDataArrayTemplate.h>
 
 
<any reference to "vtkDataArrayTemplate">
 
 
 
with:
 
 
 
#include <vtkAOSDataArrayTemplate.h>
 
 
<reference to "vtkAOSDataArrayTemplate">
 
 
 
<b>References:</b>
 
* https://github.com/msmolens/Slicer/commit/fedb69d0e622d00c81102461ab13909f96341528 (COMP: Update usage of deprecated vtkDataArrayTemplate)
 
* https://github.com/Kitware/VTK/commit/06e98d0 (Replace vtkDataArrayTemplate with vtkAoSDataArrayTemplate.)
 
* https://github.com/Kitware/VTK/commit/893fb6e (Refactor data array APIs.)
 
* http://public.kitware.com/pipermail/vtkusers/2016-May/095388.html ([vtkusers] Wiki examples fail to build due to no InsertNextTypedTuple)
 
* https://github.com/Kitware/VTK/blob/master/Documentation/Doxygen/ChangesVTK-7-1.md#vtkdataarray-refactor-vtkarraydispatch-and-related-tools
 
 
 
===Deprecated pipeline update methods===
 
 
 
VTK has deprecated and replaced certain pipeline update methods.
 
 
 
<b>Error message similar to:</b>
 
 
 
'class XXX’ has no member named ‘SetUpdateExtent’
 
 
 
<b>Solution:</b>
 
 
 
Follow suggestions in VTK changelog: https://github.com/Kitware/VTK/blob/master/Documentation/Doxygen/ChangesVTK-7-1.md#pipeline-update-methods
 
 
 
<b>References:</b>
 
 
 
* https://github.com/msmolens/Slicer/commit/f1b93c432dd9ab3f93987c656e3947b90a7cdb45 (COMP: Update usage of deprecated SetUpdateExtent methods)
 
* https://github.com/Kitware/VTK/commit/f020ebb
 
 
 
===Updated Python wrapping===
 
 
 
VTK has updated its Python wrapping to support Python 3 and to wrap more code by default.
 
 
 
<b>Symptoms:</b>
 
 
 
Compile or link error while building a Python-wrapped class or library.
 
 
 
<b>Solution 1:</b>
 
 
 
In <tt>CMakeLists.txt</tt>, add the <tt>WRAP_EXCLUDE_PYTHON</tt> property anywhere that the <tt>WRAP_EXCLUDE</tt> property is defined on source files.
 
 
 
<b>Solution 2:</b>
 
 
 
Replace lines of code like:
 
 
 
//BTX
 
...
 
//ETX
 
 
 
with:
 
 
 
#ifndef __VTK_WRAP__
 
...
 
#endif // __VTK_WRAP__
 
 
 
<b>References:</b>
 
 
 
* https://github.com/msmolens/Slicer/commit/10a69c987dcdd4abdbaa74afad22f4af3c16b417 (COMP: Update usage of WRAP_EXCLUDE for Python)
 
* https://github.com/msmolens/Slicer/commit/d5ca934951cf411c2a4b9b56de533a07e265dcaf (COMP: Update excluding singleton intializers for wrapping)
 
* https://github.com/Kitware/VTK/commit/e6f75b9 (Wrap many more classes with python.)
 
* https://github.com/Kitware/VTK/commit/55878a2 (Manual search & destroy of (B|E)TX)
 
* http://www.vtk.org/Wiki/VTK/Python_Wrapper_Enhancement
 
* http://www.vtk.org/Wiki/VTK/Python_Wrapping_FAQ
 
 
 
==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.
 
  
 
<b>vtkDataArray:</b>
 
<b>vtkDataArray:</b>
Line 293: Line 166:
 
* <tt>FiberViewerLight/SuperBuild/External_VTK_patch.cmake</tt>
 
* <tt>FiberViewerLight/SuperBuild/External_VTK_patch.cmake</tt>
 
* <tt>DTIAtlasFiberAnalyzer/SuperBuild/External_VTK.cmake</tt>
 
* <tt>DTIAtlasFiberAnalyzer/SuperBuild/External_VTK.cmake</tt>
 +
 +
==Future work==
 +
 +
Future work in Slicer related to VTK 7 could include:
 +
* Remove BTX/ETX markers.
 +
* Resolve build warnings for <tt>-Woverloaded-virtual</tt> in Slicer VTK classes.
 +
* Check that settings in <tt>External_VTKv7.cmake</tt> are all still necessary, specifically <tt>VTK_USE_PARALLEL</tt>, and anything related to Qt.
 +
* Test <tt>Slicer_VTK_RENDERING_BACKEND</tt> set to <tt>OpenGL2</tt>.

Latest revision as of 15:56, 16 October 2017

Home < 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

Slicer-specific VTK commits

Slicer's VTK 7.1 branch includes fixes/changes that aren't in upstream:

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:

Windows:

Linux:

Test results:

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
Resolved
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.


Transition from VTK6 to VTK7

This section lists categories of code changes necessary to build Slicer with VTK 7.1. Each category has a short description, an example error message, a suggested upgrade path, and references to relevant commits.

Referencing this list might be helpful if Slicer extensions require updates to be compatible with VTK 7.1.

Deprecated the vtkStreamer class hierarchy

VTK has deprecated the vtkStreamer class hierarchy.

Error message similar to:

'VTK_INTEGRATE_FORWARD' : undeclared identifier

Solution:

Replace lines like:

#include "vtkStreamer.h"

with:

#include "vtkHyperStreamline.h"

References:

Deprecated vtkMatrix4x4::operator[] method

VTK has deprecated the vtkMatrix4x4::operator[] method.

Error message similar to:

binary '[' : 'vtkMatrix4x4' does not define this operator or a conversion to a type acceptable to the predefined operator

Solution:

Replace lines like:

(*mat)[i][j] = val;
val = (*mat)[i][j];

with:

mat->SetElement(i, j, val);
val = mat->GetElement(i, j);

References:

Removed vtksys/ios, vtksys/stl compatibility layers

VTK has removed the vtksys/ios and vtksys/stl compatibility layers.

Error message similar to:

Cannot open include file: 'vtksys/ios/iostream': No such file or directory

Solution:

Replace lines like:

#include <vtksys/ios/iostream>
#include <vtksys/ios/sstream>

vtksys_ios::ofstream ofs;

with:

#include <iostream>
#include <sstream>

std::ofstream ofs;

Replace lines like:

#include <vtksys/stl/string>
#include <vtksys/stl/vector>

vtksys_stl::string str;
vtksys_stl::vector<double> vec;

with:

#include <string>
#include <vector>

std::string str;
std::vector<double> vec;

References:

vtkDataArray refactored

VTK has refactored the vtkDataArray class hierarchy.

Error message similar to:

'class XXX’ has no member named ‘SetTupleValue’

Solution:

Replace lines like:

array->GetTupleValue(0, val);
array->SetTupleValue(0, val);
array->InsertTupleValue(i, val);
array->InsertNextTupleValue(val);

with:

array->GetTypedTuple(0, val);
array->SetTypedTuple(0, val);
array->InsertTypedTuple(i, val);
array->InsertNextTypedTuple(val);

Replace lines like:

#include <vtkDataArrayTemplate.h>

<any reference to "vtkDataArrayTemplate">

with:

#include <vtkAOSDataArrayTemplate.h>

<reference to "vtkAOSDataArrayTemplate">

References:

Deprecated pipeline update methods

VTK has deprecated and replaced certain pipeline update methods.

Error message similar to:

'class XXX’ has no member named ‘SetUpdateExtent’

Solution:

Follow suggestions in VTK changelog: https://github.com/Kitware/VTK/blob/master/Documentation/Doxygen/ChangesVTK-7-1.md#pipeline-update-methods

References:

Updated Python wrapping

VTK has updated its Python wrapping to support Python 3 and to wrap more code by default.

Symptoms:

Compile or link error while building a Python-wrapped class or library.

Solution 1:

In CMakeLists.txt, add the WRAP_EXCLUDE_PYTHON property anywhere that the WRAP_EXCLUDE property is defined on source files.

Solution 2:

Replace lines of code like:

//BTX
...
//ETX

with:

#ifndef __VTK_WRAP__
...
#endif // __VTK_WRAP__

References:

vtkMTimeType

VTK introduced a specific type—vtkMTimeType—to be used for vtkObject modified time (MTime).

Error message similar to:

vtkDiffusionTensorGlyph::GetMTime': overriding virtual function return type differs and is not covariant from 'vtkObject::GetMTime'

Solution:

Update code that uses unsigned long or unsigned long int for modified times to use vtkMTimeType.

References:

vtkStandardNewMacro expects vtkObjectFactory.h

Error message similar to:

 expected constructor, destructor, or type conversion before ‘;’ token
   vtkStandardNewMacro(vtkSlicerModelClipLogic);

Solution:

Add:

 #include <vtkObjectFactory.h>

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.