OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unittests_trimesh_circulator_face_halfedge.hh
1 #pragma once
2
3 #include <gtest/gtest.h>
4 #include <Unittests/unittests_common.hh>
5
6 #include <iostream>
7
8 class OpenMeshTrimeshCirculatorFaceHalfEdge : public OpenMeshBase {
9
10 protected:
11
12 // This function is called before each test is run
13 virtual void SetUp() {
14 }
15
16 // This function is called after all tests are through
17 virtual void TearDown() {
18
19 // Do some final stuff with the member data here...
20 }
21
22
23 // Member already defined in OpenMeshBase
24 //Mesh mesh_;
25 };
26
27 /*
28 * ====================================================================
29 * Define tests below
30 * ====================================================================
31 */
32
33
34
35 /*
36 * Small FaceHalfedgeIterator Test
37 */
38 TEST_F(OpenMeshTrimeshCirculatorFaceHalfEdge, FaceHalfedgeIterWithoutHolesIncrement) {
39
40 mesh_.clear();
41
42 // Add some vertices
43 Mesh::VertexHandle vhandle[6];
44
45 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
46 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
47 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
48 vhandle[3] = mesh_.add_vertex(Mesh::Point(3, 0, 0));
49 vhandle[4] = mesh_.add_vertex(Mesh::Point(4, 1, 0));
50 vhandle[5] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
51
52 // Add three faces
53 std::vector<Mesh::VertexHandle> face_vhandles;
54
55 face_vhandles.push_back(vhandle[0]);
56 face_vhandles.push_back(vhandle[1]);
57 face_vhandles.push_back(vhandle[2]);
58 mesh_.add_face(face_vhandles);
59
60 face_vhandles.clear();
61
62 face_vhandles.push_back(vhandle[2]);
63 face_vhandles.push_back(vhandle[1]);
64 face_vhandles.push_back(vhandle[3]);
65 mesh_.add_face(face_vhandles);
66
67 face_vhandles.clear();
68
69 face_vhandles.push_back(vhandle[2]);
70 face_vhandles.push_back(vhandle[3]);
71 face_vhandles.push_back(vhandle[4]);
72 mesh_.add_face(face_vhandles);
73
74 face_vhandles.clear();
75
76 face_vhandles.push_back(vhandle[1]);
77 face_vhandles.push_back(vhandle[5]);
78 face_vhandles.push_back(vhandle[3]);
79 mesh_.add_face(face_vhandles);
80
81 /* Test setup:
82 *
83 * 0 ------ 2 ------ 4
84 * \ / \ /
85 * \ 0 / \ 2 /
86 * \ / 1 \ /
87 * 1 ------- 3
88 * \ /
89 * \ 3 /
90 * \ /
91 * \ /
92 * 5
93 */
94
95
96 Mesh::FaceHalfedgeIter fh_it = mesh_.fh_begin(mesh_.face_handle(1));
97 Mesh::FaceHalfedgeIter fh_end = mesh_.fh_end(mesh_.face_handle(1));
98
99 EXPECT_EQ(8, fh_it.handle().idx() ) << "Index wrong in FaceHalfedgeIter at initialization";
100 EXPECT_TRUE(fh_it) << "Iterator invalid in FaceHalfedgeIter at initialization";
101 ++fh_it;
102 EXPECT_EQ(3, fh_it.handle().idx() ) << "Index wrong in FaceHalfedgeIter at step 1";
103 EXPECT_TRUE(fh_it) << "Iterator invalid in FaceHalfedgeIter at step 1";
104 ++fh_it;
105 EXPECT_EQ(6, fh_it.handle().idx() ) << "Index wrong in FaceHalfedgeIter at step 2";
106 EXPECT_TRUE(fh_it) << "Iterator invalid in FaceHalfedgeIter at step 2";
107 ++fh_it;
108 EXPECT_EQ(8, fh_it.handle().idx() ) << "Index wrong in FaceHalfedgeIter at end";
109 EXPECT_FALSE(fh_it) << "Iterator invalid in FaceHalfedgeIter at end";
110 EXPECT_TRUE( fh_it == fh_end ) << "End iterator for FaceHalfedgeIter not matching";
111
112 Mesh::ConstFaceHalfedgeIter cfh_it = mesh_.cfh_begin(mesh_.face_handle(1));
113 Mesh::ConstFaceHalfedgeIter cfh_end = mesh_.cfh_end(mesh_.face_handle(1));
114
115 EXPECT_EQ(8, cfh_it.handle().idx() ) << "Index wrong in ConstFaceHalfedgeIter at initialization";
116 EXPECT_TRUE(cfh_it) << "Iterator invalid in ConstFaceHalfedgeIter at initialization";
117 ++cfh_it;
118 EXPECT_EQ(3, cfh_it.handle().idx() ) << "Index wrong in ConstFaceHalfedgeIter at step 1";
119 EXPECT_TRUE(cfh_it) << "Iterator invalid in ConstFaceHalfedgeIter at step 1";
120 ++cfh_it;
121 EXPECT_EQ(6, cfh_it.handle().idx() ) << "Index wrong in ConstFaceHalfedgeIter at step 2";
122 EXPECT_TRUE(cfh_it) << "Iterator invalid in ConstFaceHalfedgeIter at step 2";
123 ++cfh_it;
124 EXPECT_EQ(8, cfh_it.handle().idx() ) << "Index wrong in ConstFaceHalfedgeIter at end";
125 EXPECT_FALSE(cfh_it) << "Iterator invalid in ConstFaceHalfedgeIter at end";
126 EXPECT_TRUE( cfh_it == cfh_end ) << "End iterator for ConstFaceHalfedgeIter not matching";
127
128 }
129