Commit ebff217e authored by Jan Möbius's avatar Jan Möbius

Added unittest, to check if halfedges were marked as deleted, if the edges are deleted

Fixed delete_face function, not marking halfedges as deleted, if the edge gets deleted.
(Thanks to Maxime Quiblier for the bug report)



git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@622 fdac6126-5c0c-442c-9429-916003d36597
parent 6a3fb965
...@@ -507,6 +507,7 @@ void PolyConnectivity::delete_face(FaceHandle _fh, bool _delete_isolated_vertice ...@@ -507,6 +507,7 @@ void PolyConnectivity::delete_face(FaceHandle _fh, bool _delete_isolated_vertice
// delete all collected (half)edges // delete all collected (half)edges
// these edges were all boundary
// delete isolated vertices (if _delete_isolated_vertices is true) // delete isolated vertices (if _delete_isolated_vertices is true)
if (!deleted_edges.empty()) if (!deleted_edges.empty())
{ {
...@@ -534,6 +535,15 @@ void PolyConnectivity::delete_face(FaceHandle _fh, bool _delete_isolated_vertice ...@@ -534,6 +535,15 @@ void PolyConnectivity::delete_face(FaceHandle _fh, bool _delete_isolated_vertice
// mark edge deleted // mark edge deleted
status(*del_it).set_deleted(true); status(*del_it).set_deleted(true);
// mark corresponding halfedges as deleted
// As the deleted edge is boundary,
// all corresponding halfedges will also e deleted.
if ( has_halfedge_status() ) {
status(h0).set_deleted(true);
status(h1).set_deleted(true);
}
// update v0 // update v0
if (halfedge_handle(v0) == h1) if (halfedge_handle(v0) == h1)
{ {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <Unittests/unittests_common.hh> #include <Unittests/unittests_common.hh>
#include <iostream>
class OpenMeshProperties : public OpenMeshBase { class OpenMeshProperties : public OpenMeshBase {
protected: protected:
...@@ -67,8 +67,8 @@ TEST_F(OpenMeshProperties, VertexPropertyCheckDouble) { ...@@ -67,8 +67,8 @@ TEST_F(OpenMeshProperties, VertexPropertyCheckDouble) {
// 0 === 3 // 0 === 3
// Check setup // Check setup
EXPECT_EQ(4, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(4u, mesh_.n_vertices() ) << "Wrong number of vertices";
EXPECT_EQ(2, mesh_.n_faces() ) << "Wrong number of faces"; EXPECT_EQ(2u, mesh_.n_faces() ) << "Wrong number of faces";
// Add a double vertex property // Add a double vertex property
OpenMesh::VPropHandleT<double> doubleHandle; OpenMesh::VPropHandleT<double> doubleHandle;
...@@ -158,8 +158,8 @@ TEST_F(OpenMeshProperties, VertexPropertyCheckBool) { ...@@ -158,8 +158,8 @@ TEST_F(OpenMeshProperties, VertexPropertyCheckBool) {
// 0 === 3 // 0 === 3
// Check setup // Check setup
EXPECT_EQ(4, mesh_.n_vertices() ) << "Wrong number of vertices"; EXPECT_EQ(4u, mesh_.n_vertices() ) << "Wrong number of vertices";
EXPECT_EQ(2, mesh_.n_faces() ) << "Wrong number of faces"; EXPECT_EQ(2u, mesh_.n_faces() ) << "Wrong number of faces";
// Add a double vertex property // Add a double vertex property
OpenMesh::VPropHandleT<bool> boolHandle; OpenMesh::VPropHandleT<bool> boolHandle;
...@@ -211,4 +211,51 @@ TEST_F(OpenMeshProperties, VertexPropertyCheckBool) { ...@@ -211,4 +211,51 @@ TEST_F(OpenMeshProperties, VertexPropertyCheckBool) {
} }
/*
* Checking for deleted flags of halfedge and edge handles
*
* Checks if after deleting a face, all halfedges and edges are arked as deleted as well
*/
TEST_F(OpenMeshProperties, CheckStatusPropertiesHalfedgeEdgeAllDeleted) {
mesh_.clear();
mesh_.request_vertex_status();
mesh_.request_face_status();
mesh_.request_halfedge_status();
mesh_.request_edge_status();
// Define positions
Mesh::Point p1 = Mesh::Point(0, 0, 0);
Mesh::Point p2 = Mesh::Point(0, 1, 0);
Mesh::Point p3 = Mesh::Point(1, 1, 0);
Mesh::Point p4 = Mesh::Point(0, 0, 1);
// Add some vertices
Mesh::VertexHandle vh1 = mesh_.add_vertex(p1);
Mesh::VertexHandle vh2 = mesh_.add_vertex(p2);
Mesh::VertexHandle vh3 = mesh_.add_vertex(p3);
Mesh::VertexHandle vh4 = mesh_.add_vertex(p4);
// Add some faces
Mesh::FaceHandle f1 = mesh_.add_face(vh1,vh3,vh2);
Mesh::FaceHandle f2 = mesh_.add_face(vh1,vh2,vh4);
Mesh::FaceHandle f3 = mesh_.add_face(vh2,vh3,vh4);
Mesh::FaceHandle f4 = mesh_.add_face(vh3,vh1,vh4);
// delete all faces
mesh_.delete_face(f1);
mesh_.delete_face(f2);
mesh_.delete_face(f3);
mesh_.delete_face(f4);
for(typename Mesh::ConstHalfedgeIter he_it = mesh_.halfedges_begin(); he_it != mesh_.halfedges_end(); ++he_it)
{
EXPECT_TRUE( mesh_.status(mesh_.edge_handle(he_it.handle())).deleted() ) << "Edge not deleted";
EXPECT_TRUE( mesh_.status(he_it.handle()).deleted() ) << "Halfedge not deleted";
}
}
#endif // INCLUDE GUARD #endif // INCLUDE GUARD
...@@ -67,9 +67,8 @@ TEST_F(OpenMeshIterators, VertexIter) { ...@@ -67,9 +67,8 @@ TEST_F(OpenMeshIterators, VertexIter) {
// | / | // | / |
// 0 === 3 // 0 === 3
Mesh::VertexIter v_it=mesh_.vertices_begin(); Mesh::VertexIter v_it = mesh_.vertices_begin();
Mesh::VertexIter v_end=mesh_.vertices_end(); Mesh::VertexIter v_end = mesh_.vertices_end();
EXPECT_EQ(0, v_it.handle().idx()) << "Index wrong for vertex iterator vertices_begin()"; EXPECT_EQ(0, v_it.handle().idx()) << "Index wrong for vertex iterator vertices_begin()";
++v_it; ++v_it;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment