# vtkOpenVDBRead Function

**URL:** https://discourse.vtk.org/t/vtkopenvdbread-function/13313
**Category:** Development
**Created:** [February 14, 2024, 3:47am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313 "2024-02-14T03:47:37Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![enderby\_matherror](https://discourse.vtk.org/user_avatar/discourse.vtk.org/enderby_matherror/32/6724_2.png) [@enderby\_matherror](https://discourse.vtk.org/u/enderby_matherror)
#### Post date: [February 14, 2024, 3:47am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/1 "2024-02-14T03:47:37Z")

</div>

I’m trying to read an openVDB file and display the volume using the function above. When I print the `outputblock`, the size of the volume and other data are read correctly, but all the voxel values are read as 0.

[https://artifacts.aswf.io/io/aswf/openvdb/models/bunny\_cloud.vdb/1.0.0/bunny\_cloud.vdb-1.0.0.zip](https://artifacts.aswf.io/io/aswf/openvdb/models/bunny_cloud.vdb/1.0.0/bunny_cloud.vdb-1.0.0.zip)

> void ReadVDBToVolume(const std::string& filepath)  
> {  
> vtkSmartPointer\<vtkOpenVDBReader\> vdbReader = vtkSmartPointer\<vtkOpenVDBReader\>::New();  
> vdbReader-\>SetFileName(filepath.c\_str());  
> vdbReader-\>Update();  
> vtkDataObject\* vDObj = vdbReader-\>GetOutputDataObject(0);  
> vDObj-\>PrintSelf(std::cout, vtkIndent(0));  
> vtkPartitionedDataSetCollection\* output =  
> vtkPartitionedDataSetCollection::SafeDownCast(vDObj);
> 
> ```
> vtkImageData* outputblock = nullptr;
> outputblock = vtkImageData::SafeDownCast(output->GetPartitionAsDataObject(0, 0));
> 
> addVolumeActor(outputblock);
> 
> ```
> 
> }

What could be the problem?  
I have applied vtk9.3

thank you

---

<div class="post-metadata">

### Author: ![enderby\_matherror](https://discourse.vtk.org/user_avatar/discourse.vtk.org/enderby_matherror/32/6724_2.png) [@enderby\_matherror](https://discourse.vtk.org/u/enderby_matherror)
#### Post date: [February 16, 2024, 7:34am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/2 "2024-02-16T07:34:28Z")

</div>

I read the VDB file and printed the data using PrintSelf.  
I think I need “Scalars” to create a volume, but it is set to none.  
Please help me.

// read bunny\_cloud.vdb

> Debug: Off  
> Modified Time: 596983  
> Reference Count: 2  
> Registered Events: (none)  
> Executive: 000001896A644110  
> ErrorCode: No error  
> Information: 000001896A624D40  
> AbortExecute: Off  
> Progress: 1  
> Progress Text: (None)  
> FileName: D:/work/Application/AirSpace/lib/Data/vdbTest/bunny\_cloud.vdb-1.0.0/bunny\_cloud.vdb  
> DownsamplingFactor: 1  
> MergeImageVolumes: 0  
> MergePointSets: 0  
> Debug: Off  
> Modified Time: 596961  
> Reference Count: 1  
> Registered Events: (none)  
> UnknownArraySetting: 0  
> **Number of Arrays: 1**  
> Array: density (image) is: enabled (1)  
> /////////////////////////////////////////////////////////////////////////

/////////////////////////////// Read Array0

> Image Dimensions: 576 x 571 x 437  
> Scalar Range: 0 to 1  
> Dimension 576 571 437  
> Debug: Off  
> Modified Time: 597280  
> Reference Count: 5  
> Registered Events: (none)  
> Information: 000001D8580DF8C0  
> Data Released: False  
> Global Release Data: Off  
> UpdateTime: 0  
> Field Data:  
> Debug: Off  
> Modified Time: 597278  
> Reference Count: 1  
> Registered Events: (none)  
> Number Of Arrays: 0  
> Number Of Components: 0  
> Number Of Tuples: 0  
> Number Of Points: 143727552  
> Number Of Cells: 142899000  
> Cell Data:  
> Debug: Off  
> Modified Time: 597268  
> Reference Count: 1  
> Registered Events:  
> Registered Observers:  
> vtkObserver (000001D8580E1C30)  
> Event: 33  
> EventName: ModifiedEvent  
> Command: 000001D858015310  
> Priority: 0  
> Tag: 1  
> Number Of Arrays: 0  
> Number Of Components: 0  
> Number Of Tuples: 0  
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 1 )  
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 0 )  
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 1 )  
> Scalars: (none)  
> Vectors: (none)  
> Normals: (none)  
> TCoords: (none)  
> Tensors: (none)  
> GlobalIds: (none)  
> PedigreeIds: (none)  
> EdgeFlag: (none)  
> Tangents: (none)  
> RationalWeights: (none)  
> HigherOrderDegrees: (none)  
> ProcessIds: (none)  
> Point Data:  
> Debug: Off  
> Modified Time: 597276  
> Reference Count: 1  
> Registered Events:  
> Registered Observers:  
> vtkObserver (000001D8580E1CC0)  
> Event: 33  
> EventName: ModifiedEvent  
> Command: 000001D858015310  
> Priority: 0  
> Tag: 1  
> Number Of Arrays: 1  
> Array 0 name = density  
> Number Of Components: 1  
> Number Of Tuples: 143727552  
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 1 )  
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 0 )  
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 1 )  
> **Scalars: (none)**  
> **Vectors: (none)**  
> Normals: (none)  
> TCoords: (none)  
> Tensors: (none)  
> GlobalIds: (none)  
> PedigreeIds: (none)  
> EdgeFlag: (none)  
> Tangents: (none)  
> RationalWeights: (none)  
> HigherOrderDegrees: (none)  
> ProcessIds: (none)  
> Bounds:  
> Xmin,Xmax: (-24, 22)  
> Ymin,Ymax: (-3.76, 41.84)  
> Zmin,Zmax: (-16.64, 18.24)  
> Compute Time: 597281  
> Spacing: (0.08, 0.08, 0.08)  
> Origin: (-24, -3.76, -16.64)  
> Direction: (1, 0, 0, 0, 1, 0, 0, 0, 1)  
> Dimensions: (576, 571, 437)  
> Increments: (0, 0, 0)  
> Extent: (0, 575, 0, 570, 0, 436)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 19, 2024, 12:24pm UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/3 "2024-02-19T12:24:12Z")

</div>

please share your data

---

<div class="post-metadata">

### Author: ![enderby\_matherror](https://discourse.vtk.org/user_avatar/discourse.vtk.org/enderby_matherror/32/6724_2.png) [@enderby\_matherror](https://discourse.vtk.org/u/enderby_matherror)
#### Post date: [February 20, 2024, 7:33am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/4 "2024-02-20T07:33:25Z")

</div>

The VDB files I am currently using are as follows.

1. [volume\_00005.vdb](https://discourse.vtk.org/uploads/short-url/5IXNyxAe1oNgFqQm0eFuZK4BUuj.vdb) (21.3 KB)
2. [data.zip](https://discourse.vtk.org/uploads/short-url/29spLQ1f3UG33qdZNGRtnmUONJY.zip) (33.3 KB)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 20, 2024, 9:33am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/5 "2024-02-20T09:33:56Z")

</div>

your files are indeed incorrect:

```auto
=== fluid_data_0010.vdb ===
PartitionedDataSet: 0
  Partition: 0
    Number of points: 0
    Number of cells: 0
    8 point data array(s):
      color_b : float : [1e+299, -1e+299] 
      color_g : float : [1e+299, -1e+299] 
      color_r : float : [1e+299, -1e+299] 
      density : float : [1e+299, -1e+299] 
      flame : float : [1e+299, -1e+299] 
      shadow : float : [1e+299, -1e+299] 
      temperature : float : [1e+299, -1e+299] 
      velocity : float : [1e+299, -1e+299] [1e+299, -1e+299] [1e+299, -1e+299] 

```

As you can see, the data is not correctly defined.

---

<div class="post-metadata">

### Author: ![enderby\_matherror](https://discourse.vtk.org/user_avatar/discourse.vtk.org/enderby_matherror/32/6724_2.png) [@enderby\_matherror](https://discourse.vtk.org/u/enderby_matherror)
#### Post date: [February 21, 2024, 1:25am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/6 "2024-02-21T01:25:12Z")

</div>

Thank you for analyzing. However, in Blender, the volume is displayed correctly as shown in the image below. Could the values be in different locations?

 ![image](https://discourse.vtk.org/uploads/default/original/2X/e/e114e15f32e1d75ea0d64f8550dc99d58ed3f3ea.jpeg)

---

<div class="post-metadata">

### Author: ![enderby\_matherror](https://discourse.vtk.org/user_avatar/discourse.vtk.org/enderby_matherror/32/6724_2.png) [@enderby\_matherror](https://discourse.vtk.org/u/enderby_matherror)
#### Post date: [February 28, 2024, 7:43am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/7 "2024-02-28T07:43:31Z")

</div>

Could you please confirm whether it’s possible to load the volume of a VDB file using the vtkOpenVDBReader function?  
It seems that loading mesh data is possible, but there might be an issue with the volume data, as it appears to be incorrect.

If possible, could you provide an example?

thank you!!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [February 29, 2024, 4:15pm UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/8 "2024-02-29T16:15:37Z")

</div>

I have no idea how blender do it but vdb\_view only shows empty blocks

 ![a](https://discourse.vtk.org/uploads/default/original/2X/a/a49b76ac6ad7672cbf8ffb87472545a9966b69f7.png)

Here is how armadillo looks in vdb\_view:

 ![a](https://discourse.vtk.org/uploads/default/original/2X/0/003ac308235d6598243b2400a934c481c5642662.png)

and in VTK:

 ![a](https://discourse.vtk.org/uploads/default/original/2X/2/2392d871ac230f92d3fc53b66e36d846f438e758.png)

from [OpenVDB - Download](https://www.openvdb.org/download/)

---

<div class="post-metadata">

### Author: ![enderby\_matherror](https://discourse.vtk.org/user_avatar/discourse.vtk.org/enderby_matherror/32/6724_2.png) [@enderby\_matherror](https://discourse.vtk.org/u/enderby_matherror)
#### Post date: [March 4, 2024, 8:40am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/9 "2024-03-04T08:40:10Z")

</div>

I think there might be an issue with my code because Armadillo isn’t opening.  
Could I get the source code for creating a volume from an Armadillo.vdb file?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [March 4, 2024, 8:44am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/10 "2024-03-04T08:44:05Z")

</div>

I just used this:  
[https://gitlab.kitware.com/vtk/vtk/-/blob/v9.3.0/IO/OpenVDB/Testing/Cxx/TestOpenVDBReader.cxx](https://gitlab.kitware.com/vtk/vtk/-/blob/v9.3.0/IO/OpenVDB/Testing/Cxx/TestOpenVDBReader.cxx)

And also set `SetDownsamplingFactor` to 0.1 because VTK is not optimized for big VDB files yet.

---

<div class="post-metadata">

### Author: ![enderby\_matherror](https://discourse.vtk.org/user_avatar/discourse.vtk.org/enderby_matherror/32/6724_2.png) [@enderby\_matherror](https://discourse.vtk.org/u/enderby_matherror)
#### Post date: [March 4, 2024, 8:48am UTC](https://discourse.vtk.org/t/vtkopenvdbread-function/13313/11 "2024-03-04T08:48:53Z")

</div>

I see. It’s the same source code that I’ve already used, and it worked well with polydata, but it seems to have failed when I tried changing it to imagedata. Thank you
