Difference between revisions of "Documentation/Nightly/Developers/Tutorials/MigrationGuide/VTK6-to-VTK7"
(Created page with "==Migration guide== 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 s...") |
|||
Line 1: | Line 1: | ||
− | ==Migration guide== | + | <noinclude>__TOC__</noinclude> |
− | + | ==Migration guide: 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. | 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. | ||
Revision as of 22:27, 30 August 2018
Home < Documentation < Nightly < Developers < Tutorials < MigrationGuide < VTK6-to-VTK7Contents
- 1 Migration guide: Transition from VTK6 to VTK7
- 1.1 Deprecated the vtkStreamer class hierarchy
- 1.2 Deprecated vtkMatrix4x4::operator[] method
- 1.3 Removed vtksys/ios, vtksys/stl compatibility layers
- 1.4 vtkDataArray refactored
- 1.5 Deprecated pipeline update methods
- 1.6 Updated Python wrapping
- 1.7 vtkMTimeType
- 1.8 vtkStandardNewMacro expects vtkObjectFactory.h
Migration guide: 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:
- 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 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:
- 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.
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:
- 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.
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:
- 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.
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:
- 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.
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:
- 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
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>