Commit 1b6bc573 authored by Jan Möbius's avatar Jan Möbius

unittest for FaceFaceIterators

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@416 fdac6126-5c0c-442c-9429-916003d36597
parent 8cc50f96
......@@ -35,9 +35,6 @@ class OpenMeshIterators : public OpenMeshBase {
*/
TEST_F(OpenMeshIterators, VertexIter) {
unsigned int i = 0;
mesh_.clear();
// Add some vertices
......@@ -126,8 +123,6 @@ TEST_F(OpenMeshIterators, EdgeIter) {
// | / |
// 0 === 3
unsigned int i = 0;
Mesh::EdgeIter e_it = mesh_.edges_begin();
Mesh::EdgeIter e_end = mesh_.edges_end();
......@@ -218,9 +213,6 @@ TEST_F(OpenMeshIterators, VertexFaceIterWithHoles) {
/ \
3 ==== 4 */
unsigned int i = 0;
// Iterate around vertex 1 at the middle (with holes in between)
Mesh::VertexFaceIter vf_it = mesh_.vf_begin(vhandle[1]);
Mesh::VertexFaceIter vf_end = mesh_.vf_end(vhandle[1]);
......@@ -303,8 +295,6 @@ TEST_F(OpenMeshIterators, VertexFaceIterWithoutHoles) {
|/ 1 \|
3 ==== 4 */
unsigned int i = 0;
Mesh::VertexFaceIter vfa_it = mesh_.vf_begin(vhandle[1]);
// Iterate around vertex 1 at the middle (with holes in between)
......@@ -322,6 +312,7 @@ TEST_F(OpenMeshIterators, VertexFaceIterWithoutHoles) {
EXPECT_EQ(0, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 3";
EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at step 3";
++vf_it ;
EXPECT_EQ(3, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at end";
EXPECT_FALSE(vf_it) << "Iterator not invalid in VertexFaceIter at end";
EXPECT_TRUE( vf_it == vf_end ) << "End iterator for VertexFaceIter not matching";
......@@ -340,13 +331,183 @@ TEST_F(OpenMeshIterators, VertexFaceIterWithoutHoles) {
EXPECT_EQ(0, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at step 3";
EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at step 3";
++cvf_it ;
EXPECT_EQ(3, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at end";
EXPECT_FALSE(cvf_it) << "Iterator not invalid in VertexFaceIter at end";
EXPECT_TRUE( cvf_it == cvf_end ) << "End iterator for ConstVertexFaceIter not matching";
}
/*
* Small FaceFaceIterator Test with holes in it
*/
TEST_F(OpenMeshIterators, FaceFaceIterWithHoles) {
mesh_.clear();
// Add some vertices
Mesh::VertexHandle vhandle[5];
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(3, 0, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(4, 1, 0));
// Add three faces
std::vector<Mesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
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[3]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
/* Test setup:
*
* 0 ------ 2 ------ 4
* \ / \ /
* \ 0 / \ 2 /
* \ / 1 \ /
* 1 ------- 3
*/
Mesh::FaceFaceIter ff_it = mesh_.ff_begin(mesh_.face_handle(1));
Mesh::FaceFaceIter ff_end = mesh_.ff_end(mesh_.face_handle(1));
EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at initialization";
EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at initialization";
++ff_it;
EXPECT_EQ(0, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at step 1";
EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at step 1";
++ff_it;
EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at end";
EXPECT_FALSE(ff_it) << "Iterator invalid in FaceFaceIter at end";
EXPECT_TRUE( ff_it == ff_end ) << "End iterator for FaceFaceIter not matching";
Mesh::ConstFaceFaceIter cff_it = mesh_.cff_begin(mesh_.face_handle(1));
Mesh::ConstFaceFaceIter cff_end = mesh_.cff_end(mesh_.face_handle(1));
EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at initialization";
EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at initialization";
++cff_it;
EXPECT_EQ(0, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at step 1";
EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at step 1";
++cff_it;
EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at end";
EXPECT_FALSE(cff_it) << "Iterator invalid in ConstFaceFaceIter at end";
EXPECT_TRUE( cff_it == cff_end ) << "End iterator for ConstFaceFaceIter not matching";
}
/*
* Small FaceFaceIterator Test with holes in it
*/
TEST_F(OpenMeshIterators, FaceFaceIterWithoutHoles) {
mesh_.clear();
// Add some vertices
Mesh::VertexHandle vhandle[5];
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(3, 0, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(4, 1, 0));
vhandle[5] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
// Add three faces
std::vector<Mesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
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[3]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[5]);
face_vhandles.push_back(vhandle[3]);
mesh_.add_face(face_vhandles);
/* Test setup:
*
* 0 ------ 2 ------ 4
* \ / \ /
* \ 0 / \ 2 /
* \ / 1 \ /
* 1 ------- 3
* \ /
* \ 3 /
* \ /
* \ /
* 5
*/
Mesh::FaceFaceIter ff_it = mesh_.ff_begin(mesh_.face_handle(1));
Mesh::FaceFaceIter ff_end = mesh_.ff_end(mesh_.face_handle(1));
EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at initialization";
EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at initialization";
++ff_it;
EXPECT_EQ(0, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at step 1";
EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at step 1";
++ff_it;
EXPECT_EQ(3, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at step 2";
EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at step 2";
++ff_it;
EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at end";
EXPECT_FALSE(ff_it) << "Iterator invalid in FaceFaceIter at end";
EXPECT_TRUE( ff_it == ff_end ) << "End iterator for FaceFaceIter not matching";
Mesh::ConstFaceFaceIter cff_it = mesh_.cff_begin(mesh_.face_handle(1));
Mesh::ConstFaceFaceIter cff_end = mesh_.cff_end(mesh_.face_handle(1));
EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at initialization";
EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at initialization";
++cff_it;
EXPECT_EQ(0, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at step 1";
EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at step 1";
++cff_it;
EXPECT_EQ(3, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at step 2";
EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at step 2";
++cff_it;
EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at end";
EXPECT_FALSE(cff_it) << "Iterator invalid in ConstFaceFaceIter at end";
EXPECT_TRUE( cff_it == cff_end ) << "End iterator for ConstFaceFaceIter not matching";
}
......
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