Eliminate memory leaks from hollowing code
This commit is contained in:
parent
06bf02df69
commit
195b39bb5b
@ -54,18 +54,20 @@ openvdb::FloatGrid::Ptr mesh_to_grid(const TriangleMesh & mesh,
|
|||||||
{
|
{
|
||||||
openvdb::initialize();
|
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(),
|
auto it = std::remove_if(meshparts.begin(), meshparts.end(), [](auto &m) {
|
||||||
[](TriangleMesh *m){
|
m->require_shared_vertices();
|
||||||
m->require_shared_vertices();
|
return m->volume() < EPSILON;
|
||||||
return !m->is_manifold() || m->volume() < EPSILON;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
meshparts.erase(it, meshparts.end());
|
meshparts.erase(it, meshparts.end());
|
||||||
|
|
||||||
openvdb::FloatGrid::Ptr grid;
|
openvdb::FloatGrid::Ptr grid;
|
||||||
for (TriangleMesh *m : meshparts) {
|
for (auto &m : meshparts) {
|
||||||
auto subgrid = openvdb::tools::meshToVolume<openvdb::FloatGrid>(
|
auto subgrid = openvdb::tools::meshToVolume<openvdb::FloatGrid>(
|
||||||
TriangleMeshDataAdapter{*m, voxel_scale}, tr, exteriorBandWidth,
|
TriangleMeshDataAdapter{*m, voxel_scale}, tr, exteriorBandWidth,
|
||||||
interiorBandWidth, flags);
|
interiorBandWidth, flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user