VTK to OpenVDB file format

Hi,

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!).
  • BVTKNodes add-on for Blender: There is VTK To OpenVDB Exporter node, but you must learn how to use it. It’s using the Python solution above, using JSON as an intermediate data export format.

BR,
Tuomo

1 Like

Believe https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8024 was just merged to master last week. Requires some legwork with boost+openvdb.

1 Like

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.).

2 Likes

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.

hi,I builded paraview from the updated source can’t find openvdb file converting output.
https://discourse.paraview.org/t/vdb-files/640/10
Should I let VTK_ENABLE_OPENVDB ON when build VTK?

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.

1 Like

hi tkeskitalo,can you add this file volume_00001.json? Thanks.
https://bvtknodes.readthedocs.io/en/latest/BVTKNodes.html#vtk-to-blender-volume

Sounds like you are trying to use VTK To OpenVDB Exporter Node in BVTKNodes? It should create the JSON file upon running Export. Please, if you have BVTKNodes problem (and not a VTK question), kindly post it to BVTKNodes github issues (please also read instructions) and not here.

hi tkeskita,
How to convert this data:
json2vdb.json - Google Drive ?
I got this error:


How to convert to vdb from json data?
No title (8_26_2021 3_51_43 PM).html (4.1 KB)
Thank you very much.

Kindly post this question to BVTKNodes github issues .