Eliminate memory leaks from hollowing code

This commit is contained in:
tamasmeszaros 2021-02-24 18:56:01 +01:00
parent 06bf02df69
commit 195b39bb5b

View File

@ -54,18 +54,20 @@ openvdb::FloatGrid::Ptr mesh_to_grid(const TriangleMesh & mesh,
{
openvdb::initialize();
TriangleMeshPtrs meshparts = mesh.split();
TriangleMeshPtrs meshparts_raw = mesh.split();
auto meshparts = reserve_vector<std::unique_ptr<TriangleMesh>>(meshparts_raw.size());
for (auto *p : meshparts_raw)
meshparts.emplace_back(p);
auto it = std::remove_if(meshparts.begin(), meshparts.end(),
[](TriangleMesh *m){
m->require_shared_vertices();
return !m->is_manifold() || m->volume() < EPSILON;
});
auto it = std::remove_if(meshparts.begin(), meshparts.end(), [](auto &m) {
m->require_shared_vertices();
return m->volume() < EPSILON;
});
meshparts.erase(it, meshparts.end());
openvdb::FloatGrid::Ptr grid;
for (TriangleMesh *m : meshparts) {
for (auto &m : meshparts) {
auto subgrid = openvdb::tools::meshToVolume<openvdb::FloatGrid>(
TriangleMeshDataAdapter{*m, voxel_scale}, tr, exteriorBandWidth,
interiorBandWidth, flags);