Hello,
I hope that I send this email to the right place and that my question will be clear enough.
I am currently working on a plugin where I cut some triangles, for some reasons I choose to code my own split function to split faces correctly when the splitting point is on one edge.
Basically, the function delete the face to split (but not the vertices because I use “mesh->delete_face(fh,false);” and then create 2 or 3 new faces depending on the case ( with “mesh->add_face(vh[1],vh[2],vh_split);”
, I reuse the vertex handles of the old vertices and use the vertex handle of the new vertex that was added to the mesh with “mesh->add_vertex(p0);”. I do this several times in my algorithm.
At the end I call “mesh->garbage_collection(); » and it seems to work fine. I then emit the updatedObject signal for topology update and create a backup. If I stop here the result is fine visually . But when I delete faces one by one, the last one won’t delete
but trigger a segfault :
Assertion failed!
Program: C:\Programmes_Perso\msys64\home\philip\OpenFlipper-2.1\build\Build\OpenFlipper.exe
File: C:/Programmes_Perso/msys64/home/philip/OpenFlipper-2.1/libs_required/OpenMesh/src/OpenMesh/Core/Mesh/ArrayKernel.hh, Line 176
Expression: is_valid_handle(_fh)
So it seems that there is an issue with the half edge structure. If I understand well it must be a boundary halfedge that try to access to his face which is invalid. I checked and none of my remaining or created faces is invalid. I also request correctly
the halfedge status and texcoords2D.
Moreover I have a function that computes per face per vertex texture coordinates. So for all faces I iterate over halfedges and do this :
if(mesh->is_valid_handle(*f_it))
for (typename T::FaceHalfedgeIter fh_it = mesh->fh_iter(*f_it); fh_it!=mesh->fh_end(*f_it); ++fh_it)
{
Vec2f uv = … (computation here);
mesh->set_texcoord2D(*fh_it,uv);
}
If I call this function directly after the garbage_collection() of the triangle cutting, it also triggers a seg fault. If I call it later in another function it fails too. What is strange is that the function
will go to its end and then send the segfault.
From what I read it really seems that one of the boundary halfedge that is not on a face try to access his face. But I don’t know which function is doing that and why. It may be one of the updatedObject(object->id(),
UPDATE_GEOMETRY); or updatedObject(object->id(), UPDATE_TOPOLOGY); but I am not sure and don’t know what I am doing wrong.
Could you please help me with this issue ?
Best regards,
Julien PHILIP