addface::complex edge error in OpenMesh

后端 未结 1 346
[愿得一人]
[愿得一人] 2020-12-21 10:33

I\'ve been following the OpenMesh tutorial First Steps - Building a Cube with a few modifications, I\'m using a TriMesh instead of a PolyMesh and am building a pyramid inste

相关标签:
1条回答
  • 2020-12-21 11:30

    This error results from some of the faces' vertices being added in the wrong order.

    OpenMesh uses a halfedge structure for describing the 3d structure of the mesh. Halfedges are directional edges between vertices. This allows the vertices on a face to be transversed by following the halfedges belonging to the face. However, for this reason the order in which vertices are added to a face is very important.

    Typically, vertices should always be added in a counter-clockwise order. This results in the halfedges of adjacent faces pointing in opposite directions as in the picture below left. If the ordering of the vertices is not consistant, there is ambiguity as to which edge follows the halfedge, the bottom edge of 'A' or the bottom edge of 'B', as in the picture below right.

    Illustration of directed halfedges

    In the code from the question, faces 1 and 4 are ordered counter-clockwise and faces 2 and 3 are ordered clockwise. The simple fix is to switch the first and third vertices for these two faces.

    face_vhandles.clear();
    face_vhandles.push_back(vhandle[3]);
    face_vhandles.push_back(vhandle[1]);
    face_vhandles.push_back(vhandle[0]);
    tin.add_face(face_vhandles);
    
    face_vhandles.clear();
    face_vhandles.push_back(vhandle[2]);
    face_vhandles.push_back(vhandle[3]);
    face_vhandles.push_back(vhandle[0]);
    tin.add_face(face_vhandles);
    
    0 讨论(0)
提交回复
热议问题