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_edge.hh
1 #pragma once
2
3 #include <gtest/gtest.h>
4 #include <Unittests/unittests_common.hh>
5
6 #include <iostream>
7
8 class OpenMeshTrimeshCirculatorFaceEdge : 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 /*
37 * Small FaceEdgeIterator Test
38 */
39 TEST_F(OpenMeshTrimeshCirculatorFaceEdge, FaceEdgeIterWithoutHolesIncrement) {
40
41 mesh_.clear();
42
43 // Add some vertices
44 Mesh::VertexHandle vhandle[6];
45
46 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
47 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
48 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
49 vhandle[3] = mesh_.add_vertex(Mesh::Point(3, 0, 0));
50 vhandle[4] = mesh_.add_vertex(Mesh::Point(4, 1, 0));
51 vhandle[5] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
52
53 // Add three faces
54 std::vector<Mesh::VertexHandle> face_vhandles;
55
56 face_vhandles.push_back(vhandle[0]);
57 face_vhandles.push_back(vhandle[1]);
58 face_vhandles.push_back(vhandle[2]);
59 mesh_.add_face(face_vhandles);
60
61 face_vhandles.clear();
62
63 face_vhandles.push_back(vhandle[2]);
64 face_vhandles.push_back(vhandle[1]);
65 face_vhandles.push_back(vhandle[3]);
66 mesh_.add_face(face_vhandles);
67
68 face_vhandles.clear();
69
70 face_vhandles.push_back(vhandle[2]);
71 face_vhandles.push_back(vhandle[3]);
72 face_vhandles.push_back(vhandle[4]);
73 mesh_.add_face(face_vhandles);
74
75 face_vhandles.clear();
76
77 face_vhandles.push_back(vhandle[1]);
78 face_vhandles.push_back(vhandle[5]);
79 face_vhandles.push_back(vhandle[3]);
80 mesh_.add_face(face_vhandles);
81
82 /* Test setup:
83 *
84 * 0 ------ 2 ------ 4
85 * \ / \ /
86 * \ 0 / \ 2 /
87 * \ / 1 \ /
88 * 1 ------- 3
89 * \ /
90 * \ 3 /
91 * \ /
92 * \ /
93 * 5
94 */
95
96
97 Mesh::FaceEdgeIter fe_it = mesh_.fe_begin(mesh_.face_handle(1));
98 Mesh::FaceEdgeIter fe_end = mesh_.fe_end(mesh_.face_handle(1));
99
100 EXPECT_EQ(4, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at initialization";
101 EXPECT_TRUE(fe_it) << "Iterator invalid in FaceEdgeIter at initialization";
102 ++fe_it;
103 EXPECT_EQ(1, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at step 1";
104 EXPECT_TRUE(fe_it) << "Iterator invalid in FaceEdgeIter at step 1";
105 ++fe_it;
106 EXPECT_EQ(3, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at step 2";
107 EXPECT_TRUE(fe_it) << "Iterator invalid in FaceEdgeIter at step 2";
108 ++fe_it;
109 EXPECT_EQ(4, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at end";
110 EXPECT_FALSE(fe_it) << "Iterator invalid in FaceEdgeIter at end";
111 EXPECT_TRUE( fe_it == fe_end ) << "End iterator for FaceEdgeIter not matching";
112
113 Mesh::ConstFaceEdgeIter cfe_it = mesh_.cfe_begin(mesh_.face_handle(1));
114 Mesh::ConstFaceEdgeIter cfe_end = mesh_.cfe_end(mesh_.face_handle(1));
115
116 EXPECT_EQ(4, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at initialization";
117 EXPECT_TRUE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at initialization";
118 ++cfe_it;
119 EXPECT_EQ(1, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at step 1";
120 EXPECT_TRUE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at step 1";
121 ++cfe_it;
122 EXPECT_EQ(3, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at step 2";
123 EXPECT_TRUE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at step 2";
124 ++cfe_it;
125 EXPECT_EQ(4, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at end";
126 EXPECT_FALSE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at end";
127 EXPECT_TRUE( cfe_it == cfe_end ) << "End iterator for ConstFaceEdgeIter not matching";
128
129 }
130
131
132 /*
133 * Small FaceEdgeIterator Test
134 */
135 /*
136 TEST_F(OpenMeshTrimeshCirculatorFaceEdge, FaceEdgeIterWithoutHolesDecrement) {
137
138 mesh_.clear();
139
140 // Add some vertices
141 Mesh::VertexHandle vhandle[6];
142
143 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
144 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
145 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
146 vhandle[3] = mesh_.add_vertex(Mesh::Point(3, 0, 0));
147 vhandle[4] = mesh_.add_vertex(Mesh::Point(4, 1, 0));
148 vhandle[5] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
149
150 // Add three faces
151 std::vector<Mesh::VertexHandle> face_vhandles;
152
153 face_vhandles.push_back(vhandle[0]);
154 face_vhandles.push_back(vhandle[1]);
155 face_vhandles.push_back(vhandle[2]);
156 mesh_.add_face(face_vhandles);
157
158 face_vhandles.clear();
159
160 face_vhandles.push_back(vhandle[2]);
161 face_vhandles.push_back(vhandle[1]);
162 face_vhandles.push_back(vhandle[3]);
163 mesh_.add_face(face_vhandles);
164
165 face_vhandles.clear();
166
167 face_vhandles.push_back(vhandle[2]);
168 face_vhandles.push_back(vhandle[3]);
169 face_vhandles.push_back(vhandle[4]);
170 mesh_.add_face(face_vhandles);
171
172 face_vhandles.clear();
173
174 face_vhandles.push_back(vhandle[1]);
175 face_vhandles.push_back(vhandle[5]);
176 face_vhandles.push_back(vhandle[3]);
177 mesh_.add_face(face_vhandles);
178 */
179 /* Test setup:
180 *
181 * 0 ------ 2 ------ 4
182 * \ / \ /
183 * \ 0 / \ 2 /
184 * \ / 1 \ /
185 * 1 ------- 3
186 * \ /
187 * \ 3 /
188 * \ /
189 * \ /
190 * 5
191 */
192
193 /*
194 Mesh::FaceEdgeIter fe_it = mesh_.fe_begin(mesh_.face_handle(1));
195 Mesh::FaceEdgeIter fe_end = mesh_.fe_end(mesh_.face_handle(1));
196
197 EXPECT_EQ(4, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at initialization";
198 EXPECT_TRUE(fe_it) << "Iterator invalid in FaceEdgeIter at initialization";
199 --fe_it;
200 EXPECT_EQ(1, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at step 1";
201 EXPECT_TRUE(fe_it) << "Iterator invalid in FaceEdgeIter at step 1";
202 --fe_it;
203 EXPECT_EQ(3, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at step 2";
204 EXPECT_TRUE(fe_it) << "Iterator invalid in FaceEdgeIter at step 2";
205 --fe_it;
206 EXPECT_EQ(4, fe_it.handle().idx() ) << "Index wrong in FaceEdgeIter at end";
207 EXPECT_FALSE(fe_it) << "Iterator invalid in FaceEdgeIter at end";
208 EXPECT_TRUE( fe_it == fe_end ) << "End iterator for FaceEdgeIter not matching";
209
210 Mesh::ConstFaceEdgeIter cfe_it = mesh_.cfe_begin(mesh_.face_handle(1));
211 Mesh::ConstFaceEdgeIter cfe_end = mesh_.cfe_end(mesh_.face_handle(1));
212
213 EXPECT_EQ(4, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at initialization";
214 EXPECT_TRUE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at initialization";
215 --cfe_it;
216 EXPECT_EQ(1, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at step 1";
217 EXPECT_TRUE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at step 1";
218 --cfe_it;
219 EXPECT_EQ(3, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at step 2";
220 EXPECT_TRUE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at step 2";
221 --cfe_it;
222 EXPECT_EQ(4, cfe_it.handle().idx() ) << "Index wrong in ConstFaceEdgeIter at end";
223 EXPECT_FALSE(cfe_it) << "Iterator invalid in ConstFaceEdgeIter at end";
224 EXPECT_TRUE( cfe_it == cfe_end ) << "End iterator for ConstFaceEdgeIter not matching";
225
226 }
227
228 */