A question
Older versions of VTK require Get() or GetPointer() to access a vtkNew<vtkClass> element. Newer versions do not, as used on the Vtk example web sight.
What version did this change in?
Would it be helpful for people to know about this change? rhetorical
It does make the samples easier to read. Hopefully this question is helpful to someone.
Background
This is helpful to using the VTK examples website.
I am compiling a VTK example on Ubuntu 20.04 with the vtk7 packages and have the following compile errors,
ProteinRibbons.cxx:37:20: error: cannot convert ‘vtkNew’ to ‘vtkMapper*’
I came across this discourse post when searching for this error.
At first, I thought this was due to differences is the vtkChemistry module. However, I later discovered that I needed to replace the lines,
- actor->SetMapper(polyDataMapper);
+actor->SetMapper(polyDataMapper.Get());
with some motivating information from the Discourse post (after being discourage that people think everyone in the world is using a duck-typed language).
Below is a list of packages,
$ sudo dpkg -l | grep -i vtk7
ii libvtk7-dev 7.1.1+dfsg2-2ubuntu1 amd64 VTK header files
ii libvtk7-java 7.1.1+dfsg2-2ubuntu1 amd64 Visualization Toolkit - A high level 3D visualization library - java
ii libvtk7-jni 7.1.1+dfsg2-2ubuntu1 amd64 Visualization Toolkit - A high level 3D visualization library - java
ii libvtk7-qt-dev 7.1.1+dfsg2-2ubuntu1 amd64 VTK header files, containing Qt files
ii libvtk7.1p 7.1.1+dfsg2-2ubuntu1 amd64 VTK libraries
ii libvtk7.1p-qt 7.1.1+dfsg2-2ubuntu1 amd64 VTK libraries, Qt files
ii python3-vtk7 7.1.1+dfsg2-2ubuntu1 amd64 Python bindings for VTK
ii tcl-vtk7 7.1.1+dfsg2-2ubuntu1 amd64 Tcl bindings for VTK
ii vtk7 7.1.1+dfsg2-2ubuntu1 amd64 Binaries for VTK7
ii vtk7-doc 7.1.1+dfsg2-2ubuntu1 all VTK class reference documentation
ii vtk7-examples 7.1.1+dfsg2-2ubuntu1 all VTK examples
I then investigated the vtkNew.h in Ubuntu 20.04 (version 7) and a git copy I have (version 9).
vtkNew.h v7.1.1
* Automatic casting is intentionally unavailable, calling GetPointer() will
* return a raw pointer. Users of this method should ensure that they do not
* return this pointer if the vtkNew will go out of scope without
* incrementing its reference count using vtkSmartPointer or similar.
vtkNew.h v9.0.0-3086-gd3fe17811e
* Automatic casting to raw pointer is available for convenience, but
* users of this method should ensure that they do not
* return this pointer if the vtkNew will go out of scope without
* incrementing its reference count.
