HalfEge Issue and segmentation fault.
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 *************************************************************** Ce courriel (incluant ses eventuelles pieces jointes) peut contenir des informations confidentielles et/ou protegees ou dont la diffusion est restreinte. Si vous avez recu ce courriel par erreur, vous ne devez ni le copier, ni l'utiliser, ni en divulguer le contenu a quiconque. Merci d'en avertir immediatement l'expediteur et d'effacer ce courriel de votre systeme. Airbus Defence and Space et les sociétés Airbus Group declinent toute responsabilite en cas de corruption par virus, d'alteration ou de falsification de ce courriel lors de sa transmission par voie electronique. This email (including any attachments) may contain confidential and/or privileged information or information otherwise protected from disclosure. If you are not the intended recipient, please notify the sender immediately, do not copy this message or any attachments and do not use it for any purpose or disclose its content to any person, but delete this message and any attachments from your system. Airbus Defence and Space and Airbus Group companies disclaim any and all liability if this email transmission was virus corrupted, altered or falsified. --------------------------------------------------------------------- Airbus Defence and Space SAS (393 341 516 RCS Versailles) - Capital: 16.587.728 EUR - Siege social: 51-61 Route de Verneuil, 78130 Les Mureaux, France
Hi, can you checkout OpenFlipper from our git repository (master)? We are close to releasing 3.0 so the branch is stable and also contains the latest OpenMesh version. Furthermore, a trace which code is calling the function triggering the is_valid_handle assertion would be great. Something is trying to retrieve an edge handle without checking it first. Best, Jan Möbius On 06.06.2016 14:56, PHILIP, Julien wrote:
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
*************************************************************** Ce courriel (incluant ses eventuelles pieces jointes) peut contenir des informations confidentielles et/ou protegees ou dont la diffusion est restreinte. Si vous avez recu ce courriel par erreur, vous ne devez ni le copier, ni l'utiliser, ni en divulguer le contenu a quiconque. Merci d'en avertir immediatement l'expediteur et d'effacer ce courriel de votre systeme. Airbus Defence and Space et les sociétés Airbus Group declinent toute responsabilite en cas de corruption par virus, d'alteration ou de falsification de ce courriel lors de sa transmission par voie electronique. This email (including any attachments) may contain confidential and/or privileged information or information otherwise protected from disclosure. If you are not the intended recipient, please notify the sender immediately, do not copy this message or any attachments and do not use it for any purpose or disclose its content to any person, but delete this message and any attachments from your system. Airbus Defence and Space and Airbus Group companies disclaim any and all liability if this email transmission was virus corrupted, altered or falsified. --------------------------------------------------------------------- Airbus Defence and Space SAS (393 341 516 RCS Versailles) - Capital: 16.587.728 EUR - Siege social: 51-61 Route de Verneuil, 78130 Les Mureaux, France
_______________________________________________ Openflipper mailing list Openflipper@lists.rwth-aachen.de http://mailman.rwth-aachen.de/mailman/listinfo/openflipper
-- Dipl.Inform. Jan Möbius Department of Computer Science VIII Aachen University of Technology (RWTH) Ahornstrasse 55, 52074 Aachen, Germany Phone ++49 (0)241 80-21802 Fax ++49 (0)241 80-22899 mailto:moebius@cs.rwth-aachen.de http://www.rwth-graphics.de
participants (2)
-
Jan Möbius
-
PHILIP, Julien