This post was created to summarize current status of possibilities to convert/export VTK 3D image data into OpenVDB volumetric voxel data / grid format (.vdb). This is getting to be a frequently asked question, so I hope to redirect people to this thread in future.
Please feel free to post with updates and corrections, I hope somebody will work to improve the situation at some point.
No native VTK exporter for OpenVDB exists AFAIK.
C++ solution: Install OpenVDB and VTK libraries, then create a customized C++ program yourself to export your data to OpenVDB.
Python solution: Use VTK via Python and pyopenvdb. This requires that you can both import vtk and import pyopenvdb in your Python environment.
AFAIK pyopenvdb is not universally accessible via pip. Please reply below if you got it working, on which platform, how, etc. However, VTK is available via pip install vtk.
pyopenvdb is available at least in Ubuntu Linux by package python3-openvdb.
Currently no code examples (please post below if you can share some!).
Yes, you can now write out OpenVDB files from VTK using the VTK master. In my opinion it works best for vtkImageData but should work for most other vtkDataSets as well. If you try the vtkOpenVDBWriter out and have issues or recommended improvements, please let me know so that I can improve upon it. It does require third party libraries such as OpenVDB and all of its dependencies (Boost, OpenEXR, etc.).
Great news! So it is just a matter of building it (and dependencies) now already. Is there a ready built installation package available somewhere (with dependencies)? This is what most users wil ask for.
I’m not aware of an installation package. VTK has a diverse set of options with a diverse set of dependencies (OpenVDB, NetCDF, MPI, HDF5, …) that are continually being updated. Supporting all of these simultaneously and continually for a package manager could be a significant undertaking.
It will need maybe a month before the OpenVDB writer is available in ParaView in order to get that extra work done. To enable the OpenVDB writer in VTK you’ll need to enable the VTK_ENABLE_OPENVDB option, which is an advanced CMake option.