Hello everyone,
I’ve been using Binvox which is a tool that voxelizes 3D models and outputs the result in a Binary Structured Points VTK file. I wanted to some treatments on the voxels, so I used the vtkStructuredPointsReader and the vtkStructuredPoints classes. But when I parse the file, it tells me that I have 250047 voxels instead of the 4475 that I’m supposed to have. So basically, I have a huge 64x64x64 (which is the ‘DIMENSIONS’ is the header) cube made of voxels instead of the voxelized 3D model.
I feel like it has something to do with the SCALARS defined in the header because when i visualize the model on Paraview, every voxel of the 3D model is colored with the ‘voxel_data’ value.
So my question is, how do I only get the voxels of the 3D model instead of every voxel inside the 64x64x64 box ?
Here is my code :
vtkNew reader;
reader->SetFileName(“FinalBaseMesh.vtk”);
reader->Update();
vtkStructuredPoints* structuredPoints = reader->GetOutput();
cout << structuredPoints->GetNumberOfPoints() << endl; //262144
cout << structuredPoints->GetNumberOfCells() << endl; //250047
Here is the header of the VTK file (I can’t upload it) :
vtk DataFile Version 3.0
#generated by [binvox], http://www.google.com/search?q=binvox
BINARY
DATASET STRUCTURED_POINTS
DIMENSIONS 64 64 64
ORIGIN 0 0 0
SPACING 1 1 1
POINT_DATA 262144
SCALARS voxel_data unsigned_char
LOOKUP_TABLE default
The body is only spaces and ‘#’.
Thank you for your time,
Wassim.