Difference between revisions of "Documentation/Labs/VTK7"

From Slicer Wiki
Jump to: navigation, search
Line 177: Line 177:
 
<b>References:</b>
 
<b>References:</b>
 
* https://github.com/msmolens/Slicer/commit/fedb69d0e622d00c81102461ab13909f96341528 (COMP: Update usage of deprecated vtkDataArrayTemplate)
 
* https://github.com/msmolens/Slicer/commit/fedb69d0e622d00c81102461ab13909f96341528 (COMP: Update usage of deprecated vtkDataArrayTemplate)
* https://github.com/Kitware/VTK/commit/06e98d0
+
* https://github.com/Kitware/VTK/commit/06e98d0 (Replace vtkDataArrayTemplate with vtkAoSDataArrayTemplate.)
* https://github.com/Kitware/VTK/commit/893fb6e
+
* https://github.com/Kitware/VTK/commit/893fb6e (Refactor data array APIs.)
* http://public.kitware.com/pipermail/vtkusers/2016-May/095388.html
+
* 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
 
* https://github.com/Kitware/VTK/blob/master/Documentation/Doxygen/ChangesVTK-7-1.md#vtkdataarray-refactor-vtkarraydispatch-and-related-tools
  

Revision as of 17:08, 17 June 2016

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

Branches

VTK:

Slicer:

Tests

This section lists test failures on each platform for Release builds with the default CMake configuration.

Windows:

Linux:

Untested

OS X:

Untested

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.

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

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.

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