diff --git a/src/Unittests/unittests_smarttagger.cc b/src/Unittests/unittests_smarttagger.cc index fcbc9287..112fbf74 100644 --- a/src/Unittests/unittests_smarttagger.cc +++ b/src/Unittests/unittests_smarttagger.cc @@ -31,7 +31,7 @@ class OpenMeshSmartTagger : public OpenMeshBase { * ==================================================================== */ -/* Checks vertices, if they are boundary vertices +/* Checks SmartTagger on vertices */ TEST_F(OpenMeshSmartTagger, SmartTaggerVertices) { @@ -140,4 +140,113 @@ TEST_F(OpenMeshSmartTagger, SmartTaggerVertices) { } +/* Checks SmartTagger on vertices + */ +TEST_F(OpenMeshSmartTagger, SmartTaggerFaces) { + + mesh_.clear(); + + // Add some vertices + Mesh::VertexHandle vhandle[7]; + + vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); + vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); + vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); + vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); + vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); + vhandle[5] = mesh_.add_vertex(Mesh::Point(3, 0, 0)); + + + // Add two faces + std::vector face_vhandles; + + face_vhandles.push_back(vhandle[0]); + face_vhandles.push_back(vhandle[1]); + face_vhandles.push_back(vhandle[2]); + Mesh::FaceHandle fh1 = mesh_.add_face(face_vhandles); + + face_vhandles.clear(); + + face_vhandles.push_back(vhandle[1]); + face_vhandles.push_back(vhandle[3]); + face_vhandles.push_back(vhandle[4]); + Mesh::FaceHandle fh2 = mesh_.add_face(face_vhandles); + + face_vhandles.clear(); + + face_vhandles.push_back(vhandle[0]); + face_vhandles.push_back(vhandle[3]); + face_vhandles.push_back(vhandle[1]); + Mesh::FaceHandle fh3 = mesh_.add_face(face_vhandles); + + face_vhandles.clear(); + + face_vhandles.push_back(vhandle[2]); + face_vhandles.push_back(vhandle[1]); + face_vhandles.push_back(vhandle[4]); + Mesh::FaceHandle fh4 = mesh_.add_face(face_vhandles); + + face_vhandles.clear(); + + face_vhandles.push_back(vhandle[5]); + face_vhandles.push_back(vhandle[2]); + face_vhandles.push_back(vhandle[4]); + Mesh::FaceHandle fh5 = mesh_.add_face(face_vhandles); + + /* Test setup: + 0 ==== 2 + |\ /|\ + | \ / | \ + | 1 | 5 + | / \ | / + |/ \|/ + 3 ==== 4 + + */ + + + OpenMesh::SmartTaggerFT< Mesh > tagger(mesh_); + + + EXPECT_FALSE( tagger.is_tagged( fh1 ) ) << "Face should be untagged after init!"; + EXPECT_FALSE( tagger.is_tagged( fh2 ) ) << "Face should be untagged after init!"; + EXPECT_FALSE( tagger.is_tagged( fh3 ) ) << "Face should be untagged after init!"; + EXPECT_FALSE( tagger.is_tagged( fh4 ) ) << "Face should be untagged after init!"; + EXPECT_FALSE( tagger.is_tagged( fh5 ) ) << "Face should be untagged after init!"; + + + // Reset tagged flag on all vertices + tagger.untag_all(); + + EXPECT_FALSE( tagger.is_tagged( fh1 ) ) << "Face should be untagged after first untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh2 ) ) << "Face should be untagged after first untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh3 ) ) << "Face should be untagged after first untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh4 ) ) << "Face should be untagged after first untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh5 ) ) << "Face should be untagged after first untag_all!"; + + + + // Set tagged: + tagger.set_tag(fh3); + tagger.set_tag(fh5); + + + EXPECT_FALSE( tagger.is_tagged(fh1 ) ) << "Face should be untagged!"; + EXPECT_FALSE( tagger.is_tagged(fh2 ) ) << "Face should be untagged!"; + EXPECT_TRUE( tagger.is_tagged(fh3 ) ) << "Face should be tagged!"; + EXPECT_FALSE( tagger.is_tagged(fh4 ) ) << "Face should be tagged!"; + EXPECT_TRUE( tagger.is_tagged(fh5 ) ) << "Face should be tagged!"; + + + // Reset tagged flag on all vertices + tagger.untag_all(); + + EXPECT_FALSE( tagger.is_tagged( fh1 ) ) << "Face should be untagged after second untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh2 ) ) << "Face should be untagged after second untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh3 ) ) << "Face should be untagged after second untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh4 ) ) << "Face should be untagged after second untag_all!"; + EXPECT_FALSE( tagger.is_tagged( fh5 ) ) << "Face should be untagged after second untag_all!"; + +} + }