Here is a basic sample converting them and dumping the result into a mesh:
// FloatGrid to Vec3SGrid
openvdb::Vec3SGrid::Ptr Vec3SGrid = openvdb::Vec3SGrid::create();
Vec3SGrid->setTransform( floatGridA->transformPtr());
Vec3SGrid->tree().root().setBackground(openvdb::Vec3f(floatGridA->background()),true);
for (auto itAll = floatGridA ->cbeginValueOn(); itAll; ++itAll) {
auto pos = itAll.getCoord();
auto valueAll = itAll.getValue();
auto Vec3s = Vec3SGrid->tree().getValue(pos);
Vec3s[0] = valueAll;
Vec3SGrid->tree().setValue(pos, Vec3s);
}
// Back to FloatGrid
openvdb::FloatGrid::Ptr floatGridB = openvdb::FloatGrid::create();
floatGridB->setTransform( Vec3SGrid->transformPtr());
floatGridB->tree().root().setBackground(Vec3SGrid->background()[0], true);
for (auto it = grid->cbeginValueOn(); it; ++it) {
auto pos = it.getCoord();
auto Vec3s = it.getValue();
floatGridB->tree().setValue(pos, Vec3s[0]);
}
OpenVDBMesh meshA, meshB;
openvdb::tools::volumeToMesh(*floatGridA , meshA.points, meshA.faces, meshA.quads, iso, adapt, flag_relax);
openvdb::tools::volumeToMesh(*floatGridB , meshB.points, meshB.faces, meshB.quads, iso, adapt, flag_relax);
Unfortunately the besides I've copied transform too, the result on both meshes are different.
Any idea on that? thank you!