Pretty much the title I am trying to delete a few faces of a mesh using open mesh, like this:
MyMesh mesh;
char fname[1024];
sprintf(fname, "box_%i.obj", 0);
if (!OpenMesh::IO::read_mesh(mesh, std::string(fname)))
{
std::cerr << "read error\n";
exit(1);
}
MyMesh::FaceIter v_it, v_end(mesh.faces_end());
uint count = 0;
for (v_it=mesh.faces_begin(); v_it!=v_end; ++v_it)
{
mesh.delete_face(*v_it, true);
}
This is segfaulting on the first call to delete_face.
However, writing this mesh (without trying to delete faces):
if (!OpenMesh::IO::write_mesh(mesh, std::string("open_mesh.obj")))
{
std::cerr << "write error\n";
exit(1);
}
Works perfectly fine and blender can open the obj. So the issue very much seems to be with how I am trying to delete the faces.
std::list
via iterator in a for loop. Try to collect the iterators related in astd::list
orstd::vector
, iterate through those for deletion and see what happens. $\endgroup$while(mesh.numFaces > 0) { mesh.delete(mesh.faces_begin(),true)); }
$\endgroup$