Goodbye GetVoidPointer: Using ArrayDispatch and DataArrayRanges

One of the topics discussed at the hackathon involved deprecating vtkDataArray::GetVoidPointer. While this is not likely to happen for a while, we’ve agreed to stop using GetVoidPointer and vtkTemplateMacro in new code, and start phasing it out of existing code.

A new blog post just went up detailing how to use the replacements, vtkArrayDispatch and vtk::DataArray[Tuple|Value]Range. This is a short intro to what these utilities do and how to use them, and includes some example code along with links to find out more information about using these techniques. There are also some links to MRs from @RobertMaynard showing how to port existing filters (including SMP filters) to use these techniques.

1 Like

I noticed the new code uses a vtk namespace such as vtk::GetAPIType could that just as easily have been vtkGetAPIType? Is there some standard for when we should be using vtk:: versus just vtk?

The vtk:: namespace is used to store C++ metaprogramming utilities. I started using it when adding vtk::Range and I didn’t want to hog the generally useful name vtkRange when this was just a helper for writing C++ code.

I’ve found it to be a helpful separation to indicate that the tools inside are C++ specific and can’t / don’t need to be wrapped into other languages.