diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc index e2eaf45c..9811b43a 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc @@ -304,6 +304,14 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size SmartFaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3) { + // Check if we have been given a degenerate configuration (2 vertices are identical) + assert(_vh0!=_vh1); + assert(_vh0!=_vh2); + assert(_vh1!=_vh2); + assert(_vh0!=_vh3); + assert(_vh1!=_vh3); + assert(_vh2!=_vh3); + VertexHandle vhs[4] = { _vh0, _vh1, _vh2, _vh3 }; return add_face(vhs, 4); } @@ -312,6 +320,11 @@ SmartFaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, SmartFaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2) { + // Check if we have been given a degenerate configuration (2 vertices are identical) + assert(_vh0!=_vh1); + assert(_vh0!=_vh2); + assert(_vh1!=_vh2); + VertexHandle vhs[3] = { _vh0, _vh1, _vh2 }; return add_face(vhs, 3); } diff --git a/src/Unittests/unittests_convert_meshes.cc b/src/Unittests/unittests_convert_meshes.cc index a86a78d9..2cd5cf7a 100644 --- a/src/Unittests/unittests_convert_meshes.cc +++ b/src/Unittests/unittests_convert_meshes.cc @@ -201,8 +201,12 @@ TEST_F(OpenMeshConvertPolyMeshToTriangle, VertexFaceCheck) { EXPECT_EQ(4u, p.n_vertices() ) << "Wrong number of vertices in TriMesh"; Mesh::VertexIter it = mesh_.vertices_begin(); + + //add face to original mesh - mesh_.add_face(vhand,(*it),(*++it)); + Mesh::VertexHandle vhand1 = *it; + Mesh::VertexHandle vhand2 = (*++it); + mesh_.add_face(vhand,vhand1,vhand2); EXPECT_EQ(2u, mesh_.n_faces() ) << "Wrong number of faces in PolyMesh"; EXPECT_EQ(2u, p.n_faces() ) << "Wrong number of faces in TriMesh";