Difference between revisions of "Documentation/Nightly/Developers/Tutorials/MigrationGuide/VTK8-to-VTK9"
From Slicer Wiki
(Created page with "==Transition from VTK 8.0 to VTK 9.0 == This section lists categories of code changes necessary to build Slicer with VTK 9.0. Each category has a short description, an exampl...") Tag: 2017 source edit |
Tag: 2017 source edit |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Transition from VTK 8.0 to VTK 9.0 == | ==Transition from VTK 8.0 to VTK 9.0 == | ||
This section lists categories of code changes necessary to build Slicer with VTK 9.0. 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 9.0. Each category has a short description, an example error message, a suggested upgrade path, and references to relevant commits. | ||
+ | |||
+ | |||
+ | |||
+ | === VTK9: Use const vtkIdType* === | ||
+ | |||
+ | <b>To fix error messages similar to:</b> | ||
+ | |||
+ | <pre> | ||
+ | /tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/vtkPolyDataToitkMesh.cxx:82:70: error: invalid initialization of non-const reference of type ‘const vtkIdType*& {aka const long long int*&}’ from an rvalue of type ‘const vtkIdType* {aka const long long int*}’ | ||
+ | while( triangleStrips->GetNextCell( numberOfCellPoints, cellPoints ) ) | ||
+ | ^ | ||
+ | [...] | ||
+ | /path/to/Slicer-Release/VTK/Common/DataModel/vtkCellArray.h:1497:12: note: initializing argument 2 of ‘int vtkCellArray::GetNextCell(vtkIdType&, const vtkIdType*&)’ | ||
+ | inline int vtkCellArray::GetNextCell(vtkIdType& npts, vtkIdType const*& pts) VTK_SIZEHINT(pts, npts) | ||
+ | ^ | ||
+ | /tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/vtkPolyDataToitkMesh.cxx:91:64: error: invalid initialization of non-const reference of type ‘const vtkIdType*& {aka const long long int*&}’ from an rvalue of type ‘const vtkIdType* {aka const long long int*}’ | ||
+ | while( polygons->GetNextCell( numberOfCellPoints, cellPoints ) ) | ||
+ | ^ ^ | ||
+ | </pre> | ||
+ | |||
+ | <b>Replace code like this:</b> | ||
+ | |||
+ | <pre> | ||
+ | vtkIdType* cellPoints; | ||
+ | </pre> | ||
+ | |||
+ | <b>By this:</b> | ||
+ | |||
+ | <pre> | ||
+ | #if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) | ||
+ | const vtkIdType* cellPoints; | ||
+ | #else | ||
+ | vtkIdType* cellPoints; | ||
+ | #endif | ||
+ | </pre> | ||
+ | |||
+ | <b>References:</b> | ||
+ | |||
+ | * https://gitlab.kitware.com/vtk/vtk/-/merge_requests/5682 | ||
+ | |||
+ | === VTK9: Add missing std namespace identifier === | ||
+ | |||
+ | <b>To fix error messages similar to:</b> | ||
+ | |||
+ | <pre> | ||
+ | /usr/include/c++/5/iosfwd:162:34: note: ‘std::ifstream’ | ||
+ | /tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/MeshMath.cxx:4082:5: error: ‘ofstream’ was not declared in this scope | ||
+ | ofstream output; | ||
+ | ^ | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | /usr/include/c++/5/iosfwd:162:34: note: ‘std::ifstream’ | ||
+ | /tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/MeshMath.cxx:4117:5: error: ‘ofstream’ was not declared in this scope | ||
+ | ofstream output; | ||
+ | ^ | ||
+ | </pre> | ||
+ | |||
+ | <b>Replace code like this:</b> | ||
+ | |||
+ | <pre> | ||
+ | ifstream input; | ||
+ | ofstream output; | ||
+ | </pre> | ||
+ | |||
+ | <b>By this:</b> | ||
+ | |||
+ | <pre> | ||
+ | std::ifstream input; | ||
+ | std::ofstream output; | ||
+ | </pre> | ||
+ | |||
+ | <b>References:</b> | ||
+ | |||
+ | * https://gitlab.kitware.com/vtk/vtk/-/issues/17740 |
Latest revision as of 21:12, 18 May 2021
Home < Documentation < Nightly < Developers < Tutorials < MigrationGuide < VTK8-to-VTK9Transition from VTK 8.0 to VTK 9.0
This section lists categories of code changes necessary to build Slicer with VTK 9.0. Each category has a short description, an example error message, a suggested upgrade path, and references to relevant commits.
VTK9: Use const vtkIdType*
To fix error messages similar to:
/tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/vtkPolyDataToitkMesh.cxx:82:70: error: invalid initialization of non-const reference of type ‘const vtkIdType*& {aka const long long int*&}’ from an rvalue of type ‘const vtkIdType* {aka const long long int*}’ while( triangleStrips->GetNextCell( numberOfCellPoints, cellPoints ) ) ^ [...] /path/to/Slicer-Release/VTK/Common/DataModel/vtkCellArray.h:1497:12: note: initializing argument 2 of ‘int vtkCellArray::GetNextCell(vtkIdType&, const vtkIdType*&)’ inline int vtkCellArray::GetNextCell(vtkIdType& npts, vtkIdType const*& pts) VTK_SIZEHINT(pts, npts) ^ /tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/vtkPolyDataToitkMesh.cxx:91:64: error: invalid initialization of non-const reference of type ‘const vtkIdType*& {aka const long long int*&}’ from an rvalue of type ‘const vtkIdType* {aka const long long int*}’ while( polygons->GetNextCell( numberOfCellPoints, cellPoints ) ) ^ ^
Replace code like this:
vtkIdType* cellPoints;
By this:
#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90) const vtkIdType* cellPoints; #else vtkIdType* cellPoints; #endif
References:
VTK9: Add missing std namespace identifier
To fix error messages similar to:
/usr/include/c++/5/iosfwd:162:34: note: ‘std::ifstream’ /tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/MeshMath.cxx:4082:5: error: ‘ofstream’ was not declared in this scope ofstream output; ^
/usr/include/c++/5/iosfwd:162:34: note: ‘std::ifstream’ /tmp/SPHARM-PDM/Modules/CLI/MetaMeshTools/MeshMath.cxx:4117:5: error: ‘ofstream’ was not declared in this scope ofstream output; ^
Replace code like this:
ifstream input; ofstream output;
By this:
std::ifstream input; std::ofstream output;
References: