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
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
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)
The VDB files I am currently using are as follows.
volume_00005.vdb (21.3 KB)
data.zip (33.3 KB)
mwestphal
(Mathieu Westphal (Kitware))
February 20, 2024, 9:33am
5
your files are indeed incorrect:
=== 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.
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?
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!!
mwestphal
(Mathieu Westphal (Kitware))
February 29, 2024, 4:15pm
8
I have no idea how blender do it but vdb_view only shows empty blocks
Here is how armadillo looks in vdb_view:
and in VTK:
from OpenVDB - Download
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?
mwestphal
(Mathieu Westphal (Kitware))
March 4, 2024, 8:44am
10
I just used this:
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.
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