I am trying to convert point cloud to mesh using Openvdb

538 Views Asked by At
I am trying to convert point cloud to mesh using Openvdb
Using code – 

const float voxelSize = 0.50f, halfWidth = 2.0f;
openvdb::FloatGrid::Ptr grid = openvdb::createLevelSet<openvdb::FloatGrid>(voxelSize, halfWidth);
openvdb::tools::ParticlesToLevelSet<openvdb::FloatGrid> raster(*grid);

raster.setGrainSize(1);//a value of zero disables threading
raster.rasterizeSpheres(pa, 1);


std::vector<openvdb::Vec3s> points;
std::vector<openvdb::Vec4I> quads;
std::vector<openvdb::Vec3I> triangles;

openvdb::tools::volumeToMesh(*grid, points, triangles, quads, 1, 0);

Trying to create a mesh using torus point cloud, getting two-sided mesh(torus inside torus) as output. Outputimage

1

There are 1 best solutions below

1
On

Since openvdb rasterizes point cloud by converting individual points into spheres, you usually get a mesh that looks like this.

OpenVDB (on its own) is simply not the right tool to convert a point cloud to mesh in my experience. Some additional work would be required.

One suggestion would be to project the result onto the original point cloud. For starters, you can just move the mesh towards a nearest neighbor in the input point cloud.