Difference between revisions of "Documentation/Labs/VTK8"

From Slicer Wiki
Jump to: navigation, search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This page documents the update of Slicer to use VTK 8.0.
 
This page documents the update of Slicer to use VTK 8.0.
 +
 +
{{documentation/banner
 +
| text  = Status on this page is out-of-date. Since VTK8 transition will happen in conjunction with Qt5, see detailed TODO lists on [[Documentation/Labs/Qt5-and-VTK8]]}}
 +
  
 
==Overview==
 
==Overview==
  
 
It is planned to update the version of VTK that Slicer uses from 7.1 to 8.0.
 
It is planned to update the version of VTK that Slicer uses from 7.1 to 8.0.
 
WARNING: Status on this page is out-of-date. Since VTK8 transition will happen in conjunction with Qt5, see detailed TODO lists on [[Documentation/Labs/Qt5]].
 
  
 
==Status==
 
==Status==
Line 91: Line 93:
  
 
The transition plan was announced on the Slicer forum: https://discourse.slicer.org/t/transition-to-vtk-8-0/379.
 
The transition plan was announced on the Slicer forum: https://discourse.slicer.org/t/transition-to-vtk-8-0/379.
 
==Migration guide==
 
 
This section lists categories of code changes necessary to build and run Slicer with VTK 8.0. Each category has a short description, a suggested upgrade path, and references to relevant commits (TBD once merged).
 
 
===Use hierarchy files for VTK Python wrapping===
 
 
In VTK8 it's necessary to generate hierarchy files for proper wrapping VTK classes in Python. Without the information provided by the hierarchy files, the Python wrapping tool lacks complete information about classes and types. In this case, the generated classes contain methods that shouldn't be wrapped and fail to compile, and include references to types such as <tt>vtkTypeBool</tt>. Once the hierarchy files are generated and provided to the Python wrapping tool, the generated classes compile and typedefs like <tt>vtkTypeBool</tt> are correctly resolved.
 
 
Once the VTK8 changes are merged, generating hierarchy files is handled by https://github.com/Slicer/Slicer/blob/master/CMake/vtkMacroKitPythonWrap.cmake.
 
 
<b>References:</b>
 
* http://www.vtk.org/Wiki/VTK/WrapHierarchy
 
 
===Call InitializeObjectBase() in vtkObject New() methods===
 
 
In VTK8 it's necessary for <tt>vtkObject</tt> <tt>New()</tt> methods to call <tt>InitializeObjectBase()</tt> on the new object for proper tracking with <tt>vtkDebugLeaks</tt>. The standard macros (<tt>vtkStandardNewMacro</tt>, <tt>vtkObjectFactoryNewMacro</tt>) handle this. For those classes that don't use the macros, add a call to <tt>InitializeObjectBase()</tt> immediately after constructing the object by <tt>new vtkXXX()</tt>.
 
 
Additionally, <tt>vtkObjectFactory::CreateInstance()</tt> now doesn't register the class name with vtkDebugLeaks if the factory fails to create the object. Therefore, it's no longer necessary to unregister the class name with vtkDebugLeaks. Remove calls to <tt>vtkDebugLeaks::DestructClass(className)</tt> following <tt>vtkObjectFactory::CreateInstance()</tt>.
 
 
To support both VTK8 and earlier versions of VTK, wrap these changes in preprocessor checks for whether <tt>VTK_HAS_INITIALIZE_OBJECT_BASE</tt> is defined.
 
 
<b>References:</b>
 
 
* https://github.com/Kitware/VTK/commit/e5c793dbdf87e838bb2b60c6a5905ced0e5548f9
 
* http://public.kitware.com/pipermail/vtk-developers/2016-September/034332.html
 
 
===Add C++11 keywords===
 
 
VTK8 requires C++11. Subclasses of VTK classes must mark overridden methods with <tt>VTK_OVERRIDE</tt>.
 
 
===Qt5: QVTKOpenGLWidget===
 
 
When using Qt5, [https://github.com/Kitware/VTK/blob/9393774ff9b3d735a40eb445ff6c045e55c90eae/GUISupport/Qt/QVTKOpenGLWidget.h QVTKOpenGLWidget] should be used in place of QVTKGLWidget. To ensure that QVTKOpenGLWidget receives a properly configured OpenGL context it's necessary to call QSurfaceFormat::setDefaultFormat() before constructing the QApplication instance. QVTKOpenGLWidget::defaultFormat() supplies a suitable format, although it's recommended to disable multisampling for full compatibility with advanced rendering techniques. See http://doc.qt.io/qt-5/qopenglwidget.html.
 
 
===vtkWindowToImageFilter::SetMagnification() is deprecated===
 
 
VTK8.1 deprecated vtkWindowToImageFilter::SetMagnification() and vtkWindowToImageFilter::GetMagnification(). Replace calls to those methods with SetScale() and GetScale(). See https://github.com/Kitware/VTK/commit/af0a95fa7dd4e25ef869a0bc6077e547f18baa29.
 
 
===Enable C++11 in extensions===
 
 
SuperBuild extensions may have to enable C++11 for their external projects. Add the following lines to <tt>CMAKE_CACHE_ARGS</tt> in <tt>ExternalProject_Add</tt>
 
 
    -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
 
    -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED}
 
    -DCMAKE_CXX_EXTENSIONS:BOOL=${CMAKE_CXX_EXTENSIONS}
 
  
 
==Future work==
 
==Future work==

Latest revision as of 21:32, 14 August 2017

Home < Documentation < Labs < VTK8

This page documents the update of Slicer to use VTK 8.0.

Status on this page is out-of-date. Since VTK8 transition will happen in conjunction with Qt5, see detailed TODO lists on Documentation/Labs/Qt5-and-VTK8


Overview

It is planned to update the version of VTK that Slicer uses from 7.1 to 8.0.

Status

   Generic Warning: In C:\path\to\S\VTKv7\Rendering\OpenGL\vtkOpenGLDisplayListPainter.cxx, line 52
   failed after ReleaseAllLists 16 OpenGL errors detected
   0 : (1282) Invalid operation
   1 : (1282) Invalid operation
   ...
   15 : (1282) Invalid operation
  • VTK8 requires C++11. Because Slicer includes custom VTK classes, Slicer should also be compiled with C++11.
  • On Mac, if targeting 10.7 or 10.8, likely will need to set CMAKE_CXX_FLAGS=-stdlib=libc++ for C++11 support. Note that this would require Qt build with libc++, which is officially supported by Qt5. Note: Qt 5.7.1 minimum officially supported deployment target is 10.8. Resolution: target 10.9.
  • There may be picking issues with widgets. For example, the slice view ROI handles don't work correctly.
  • * Windows (VS2013) may have a dependency issue related to Python wrapping. At first, wrapping seems to not use the hierarchy files or runs before they are available. Building again generates the wrapped classes correctly. (resolved)
  • Update "VTKv7" project name to "VTKv8".
  • Add Slicer_VTK_VERSION_MAJOR option to support building with VTK7 and VTK8, as was done for VTK5/6 in https://github.com/Slicer/Slicer/commit/50281153c57c683106498295ea82472eaa20eee4. VTK7 wrapping should not build the hierarchy files.
  • EMSegment remote module will require updates to fix vtkDebugLeaks output. (updated in r17131)

Branches/Merge Requests

VTK:

Slicer:

Outstanding VTK issues

Slicer-specific VTK commits

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

Test results

Windows:

Test results:

Linux:

Test results:

OS X:

Test results:

  • TBD

Rendering backend

Although VTK 7 changed the default setting of VTK_RENDERING_BACKEND to OpenGL2, Slicer still explicitly sets it to OpenGL. The rendering backend in Slicer is set using Slicer_VTK_RENDERING_BACKEND.

OpenGL2 backend known issues

Discussion

The transition plan was announced on the Slicer forum: https://discourse.slicer.org/t/transition-to-vtk-8-0/379.

Future work

Future work in Slicer related to VTK 8 could include:

  • Remove BTX/ETX markers.
  • Check for and resolve build warnings in Slicer VTK classes.
  • Check that settings in External_VTKv8.cmake are all still necessary, specifically VTK_USE_PARALLEL, and anything related to Qt.