Merge branch 'Degenerate_assertion' into 'master'

Throw assertion in debug when adding topologically degenerate faces

Closes #66

See merge request OpenMesh/OpenMesh!296
This commit is contained in:
Jan Möbius
2021-01-29 11:08:42 +00:00
2 changed files with 18 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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";