1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 12 virtual void SetUp() {
18 virtual void TearDown() {
32 virtual void SetUp() {
38 virtual void TearDown() {
55 TEST_F(OpenMeshAddFaceTriangleMesh, AddTrianglesToTrimesh) {
68 std::vector<Mesh::VertexHandle> face_vhandles;
70 face_vhandles.push_back(vhandle[2]);
71 face_vhandles.push_back(vhandle[1]);
72 face_vhandles.push_back(vhandle[0]);
74 mesh_.add_face(face_vhandles);
76 face_vhandles.clear();
78 face_vhandles.push_back(vhandle[2]);
79 face_vhandles.push_back(vhandle[0]);
80 face_vhandles.push_back(vhandle[3]);
81 mesh_.add_face(face_vhandles);
91 EXPECT_EQ(4u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
92 EXPECT_EQ(2u, mesh_.n_faces() ) <<
"Wrong number of faces";
98 TEST_F(OpenMeshAddFaceTriangleMesh, AddQuadToTrimesh) {
111 std::vector<Mesh::VertexHandle> face_vhandles;
113 face_vhandles.push_back(vhandle[0]);
114 face_vhandles.push_back(vhandle[1]);
115 face_vhandles.push_back(vhandle[2]);
116 face_vhandles.push_back(vhandle[3]);
118 mesh_.add_face(face_vhandles);
128 EXPECT_EQ(4u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
129 EXPECT_EQ(2u, mesh_.n_faces() ) <<
"Wrong number of faces";
135 TEST_F(OpenMeshAddFaceTriangleMesh, CreateTriangleMeshCube) {
151 std::vector<Mesh::VertexHandle> face_vhandles;
153 face_vhandles.clear();
154 face_vhandles.push_back(vhandle[0]);
155 face_vhandles.push_back(vhandle[1]);
156 face_vhandles.push_back(vhandle[3]);
157 mesh_.add_face(face_vhandles);
159 face_vhandles.clear();
160 face_vhandles.push_back(vhandle[1]);
161 face_vhandles.push_back(vhandle[2]);
162 face_vhandles.push_back(vhandle[3]);
163 mesh_.add_face(face_vhandles);
167 face_vhandles.clear();
168 face_vhandles.push_back(vhandle[7]);
169 face_vhandles.push_back(vhandle[6]);
170 face_vhandles.push_back(vhandle[5]);
171 mesh_.add_face(face_vhandles);
173 face_vhandles.clear();
174 face_vhandles.push_back(vhandle[7]);
175 face_vhandles.push_back(vhandle[5]);
176 face_vhandles.push_back(vhandle[4]);
177 mesh_.add_face(face_vhandles);
181 face_vhandles.clear();
182 face_vhandles.push_back(vhandle[1]);
183 face_vhandles.push_back(vhandle[0]);
184 face_vhandles.push_back(vhandle[4]);
185 mesh_.add_face(face_vhandles);
187 face_vhandles.clear();
188 face_vhandles.push_back(vhandle[1]);
189 face_vhandles.push_back(vhandle[4]);
190 face_vhandles.push_back(vhandle[5]);
191 mesh_.add_face(face_vhandles);
195 face_vhandles.clear();
196 face_vhandles.push_back(vhandle[2]);
197 face_vhandles.push_back(vhandle[1]);
198 face_vhandles.push_back(vhandle[5]);
199 mesh_.add_face(face_vhandles);
201 face_vhandles.clear();
202 face_vhandles.push_back(vhandle[2]);
203 face_vhandles.push_back(vhandle[5]);
204 face_vhandles.push_back(vhandle[6]);
205 mesh_.add_face(face_vhandles);
210 face_vhandles.clear();
211 face_vhandles.push_back(vhandle[3]);
212 face_vhandles.push_back(vhandle[2]);
213 face_vhandles.push_back(vhandle[6]);
214 mesh_.add_face(face_vhandles);
216 face_vhandles.clear();
217 face_vhandles.push_back(vhandle[3]);
218 face_vhandles.push_back(vhandle[6]);
219 face_vhandles.push_back(vhandle[7]);
220 mesh_.add_face(face_vhandles);
224 face_vhandles.clear();
225 face_vhandles.push_back(vhandle[0]);
226 face_vhandles.push_back(vhandle[3]);
227 face_vhandles.push_back(vhandle[7]);
228 mesh_.add_face(face_vhandles);
230 face_vhandles.clear();
231 face_vhandles.push_back(vhandle[0]);
232 face_vhandles.push_back(vhandle[7]);
233 face_vhandles.push_back(vhandle[4]);
234 mesh_.add_face(face_vhandles);
252 EXPECT_EQ(18u, mesh_.n_edges() ) <<
"Wrong number of Edges";
253 EXPECT_EQ(36u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges";
254 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
255 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong number of faces";
262 TEST_F(OpenMeshAddFaceTriangleMesh, CreateStrangeConfig) {
294 mesh_.add_face( vh[0], vh[1], vh[2] );
295 mesh_.add_face( vh[0], vh[3], vh[4] );
296 mesh_.add_face( vh[0], vh[5], vh[6] );
299 Mesh::FaceHandle invalidFH = mesh_.add_face( vh[3], vh[0], vh[4] );
302 EXPECT_EQ(7u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
303 EXPECT_EQ(3u, mesh_.n_faces() ) <<
"Wrong number of faces";
304 EXPECT_EQ(invalidFH, Mesh::InvalidFaceHandle ) <<
"non manifold face is valid";
311 TEST_F(OpenMeshAddFacePolyMesh, AddQuadToPolymesh) {
324 std::vector<Mesh::VertexHandle> face_vhandles;
326 face_vhandles.push_back(vhandle[0]);
327 face_vhandles.push_back(vhandle[1]);
328 face_vhandles.push_back(vhandle[2]);
329 face_vhandles.push_back(vhandle[3]);
331 mesh_.add_face(face_vhandles);
341 EXPECT_EQ(4u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
342 EXPECT_EQ(1u, mesh_.n_faces() ) <<
"Wrong number of faces";
348 TEST_F(OpenMeshAddFacePolyMesh, CreatePolyMeshCube) {
364 std::vector<Mesh::VertexHandle> face_vhandles;
366 face_vhandles.clear();
367 face_vhandles.push_back(vhandle[0]);
368 face_vhandles.push_back(vhandle[1]);
369 face_vhandles.push_back(vhandle[2]);
370 face_vhandles.push_back(vhandle[3]);
371 mesh_.add_face(face_vhandles);
373 face_vhandles.clear();
374 face_vhandles.push_back(vhandle[7]);
375 face_vhandles.push_back(vhandle[6]);
376 face_vhandles.push_back(vhandle[5]);
377 face_vhandles.push_back(vhandle[4]);
378 mesh_.add_face(face_vhandles);
380 face_vhandles.clear();
381 face_vhandles.push_back(vhandle[1]);
382 face_vhandles.push_back(vhandle[0]);
383 face_vhandles.push_back(vhandle[4]);
384 face_vhandles.push_back(vhandle[5]);
385 mesh_.add_face(face_vhandles);
387 face_vhandles.clear();
388 face_vhandles.push_back(vhandle[2]);
389 face_vhandles.push_back(vhandle[1]);
390 face_vhandles.push_back(vhandle[5]);
391 face_vhandles.push_back(vhandle[6]);
392 mesh_.add_face(face_vhandles);
394 face_vhandles.clear();
395 face_vhandles.push_back(vhandle[3]);
396 face_vhandles.push_back(vhandle[2]);
397 face_vhandles.push_back(vhandle[6]);
398 face_vhandles.push_back(vhandle[7]);
399 mesh_.add_face(face_vhandles);
401 face_vhandles.clear();
402 face_vhandles.push_back(vhandle[0]);
403 face_vhandles.push_back(vhandle[3]);
404 face_vhandles.push_back(vhandle[7]);
405 face_vhandles.push_back(vhandle[4]);
406 mesh_.add_face(face_vhandles);
424 EXPECT_EQ(12u, mesh_.n_edges() ) <<
"Wrong number of Edges";
425 EXPECT_EQ(24u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges";
426 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
427 EXPECT_EQ(6u, mesh_.n_faces() ) <<
"Wrong number of faces";
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::Point Point
Coordinate type.