2 #include <gtest/gtest.h>
3 #include <Unittests/unittests_common.hh>
8 class OpenMeshDeleteFaceTriangleMesh :
public OpenMeshBase {
13 virtual void SetUp() {
19 virtual void TearDown() {
33 virtual void SetUp() {
39 virtual void TearDown() {
57 TEST_F(OpenMeshDeleteFaceTriangleMesh, DeleteHalfTriangleMeshCubeNoEdgeStatus) {
73 std::vector<Mesh::VertexHandle> face_vhandles;
75 face_vhandles.clear();
76 face_vhandles.push_back(vhandle[0]);
77 face_vhandles.push_back(vhandle[1]);
78 face_vhandles.push_back(vhandle[3]);
79 mesh_.add_face(face_vhandles);
81 face_vhandles.clear();
82 face_vhandles.push_back(vhandle[1]);
83 face_vhandles.push_back(vhandle[2]);
84 face_vhandles.push_back(vhandle[3]);
85 mesh_.add_face(face_vhandles);
89 face_vhandles.clear();
90 face_vhandles.push_back(vhandle[7]);
91 face_vhandles.push_back(vhandle[6]);
92 face_vhandles.push_back(vhandle[5]);
93 mesh_.add_face(face_vhandles);
95 face_vhandles.clear();
96 face_vhandles.push_back(vhandle[7]);
97 face_vhandles.push_back(vhandle[5]);
98 face_vhandles.push_back(vhandle[4]);
99 mesh_.add_face(face_vhandles);
103 face_vhandles.clear();
104 face_vhandles.push_back(vhandle[1]);
105 face_vhandles.push_back(vhandle[0]);
106 face_vhandles.push_back(vhandle[4]);
107 mesh_.add_face(face_vhandles);
109 face_vhandles.clear();
110 face_vhandles.push_back(vhandle[1]);
111 face_vhandles.push_back(vhandle[4]);
112 face_vhandles.push_back(vhandle[5]);
113 mesh_.add_face(face_vhandles);
117 face_vhandles.clear();
118 face_vhandles.push_back(vhandle[2]);
119 face_vhandles.push_back(vhandle[1]);
120 face_vhandles.push_back(vhandle[5]);
121 mesh_.add_face(face_vhandles);
123 face_vhandles.clear();
124 face_vhandles.push_back(vhandle[2]);
125 face_vhandles.push_back(vhandle[5]);
126 face_vhandles.push_back(vhandle[6]);
127 mesh_.add_face(face_vhandles);
132 face_vhandles.clear();
133 face_vhandles.push_back(vhandle[3]);
134 face_vhandles.push_back(vhandle[2]);
135 face_vhandles.push_back(vhandle[6]);
136 mesh_.add_face(face_vhandles);
138 face_vhandles.clear();
139 face_vhandles.push_back(vhandle[3]);
140 face_vhandles.push_back(vhandle[6]);
141 face_vhandles.push_back(vhandle[7]);
142 mesh_.add_face(face_vhandles);
146 face_vhandles.clear();
147 face_vhandles.push_back(vhandle[0]);
148 face_vhandles.push_back(vhandle[3]);
149 face_vhandles.push_back(vhandle[7]);
150 mesh_.add_face(face_vhandles);
152 face_vhandles.clear();
153 face_vhandles.push_back(vhandle[0]);
154 face_vhandles.push_back(vhandle[7]);
155 face_vhandles.push_back(vhandle[4]);
156 mesh_.add_face(face_vhandles);
174 EXPECT_EQ(18u, mesh_.n_edges() ) <<
"Wrong number of Edges";
175 EXPECT_EQ(36u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges";
176 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
177 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong number of faces";
182 mesh_.request_face_status();
183 mesh_.request_vertex_status();
184 mesh_.request_halfedge_status();
185 const size_t n_face_to_delete = mesh_.n_faces()/2;
188 EXPECT_EQ(6u, n_face_to_delete ) <<
"Wrong number of faces to delete";
190 for(
size_t i = 0; i < n_face_to_delete; i++)
191 mesh_.delete_face(mesh_.face_handle(
int(i)));
197 EXPECT_EQ(18u, mesh_.n_edges() ) <<
"Wrong number of Edges after marking as deleted";
198 EXPECT_EQ(36u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges after marking as deleted";
199 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after marking as deleted";
200 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong number of faces after marking as deleted";
206 mesh_.garbage_collection();
208 EXPECT_EQ(18u, mesh_.n_edges() ) <<
"Wrong number of Edges after garbage collection";
209 EXPECT_EQ(36u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges after garbage collection";
210 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after garbage collection";
211 EXPECT_EQ(6u, mesh_.n_faces() ) <<
"Wrong number of faces after garbage collection";
217 TEST_F(OpenMeshDeleteFaceTriangleMesh, DeleteHalfTriangleMeshCubeWithEdgeStatus) {
233 std::vector<Mesh::VertexHandle> face_vhandles;
235 face_vhandles.clear();
236 face_vhandles.push_back(vhandle[0]);
237 face_vhandles.push_back(vhandle[1]);
238 face_vhandles.push_back(vhandle[3]);
239 mesh_.add_face(face_vhandles);
241 face_vhandles.clear();
242 face_vhandles.push_back(vhandle[1]);
243 face_vhandles.push_back(vhandle[2]);
244 face_vhandles.push_back(vhandle[3]);
245 mesh_.add_face(face_vhandles);
249 face_vhandles.clear();
250 face_vhandles.push_back(vhandle[7]);
251 face_vhandles.push_back(vhandle[6]);
252 face_vhandles.push_back(vhandle[5]);
253 mesh_.add_face(face_vhandles);
255 face_vhandles.clear();
256 face_vhandles.push_back(vhandle[7]);
257 face_vhandles.push_back(vhandle[5]);
258 face_vhandles.push_back(vhandle[4]);
259 mesh_.add_face(face_vhandles);
263 face_vhandles.clear();
264 face_vhandles.push_back(vhandle[1]);
265 face_vhandles.push_back(vhandle[0]);
266 face_vhandles.push_back(vhandle[4]);
267 mesh_.add_face(face_vhandles);
269 face_vhandles.clear();
270 face_vhandles.push_back(vhandle[1]);
271 face_vhandles.push_back(vhandle[4]);
272 face_vhandles.push_back(vhandle[5]);
273 mesh_.add_face(face_vhandles);
277 face_vhandles.clear();
278 face_vhandles.push_back(vhandle[2]);
279 face_vhandles.push_back(vhandle[1]);
280 face_vhandles.push_back(vhandle[5]);
281 mesh_.add_face(face_vhandles);
283 face_vhandles.clear();
284 face_vhandles.push_back(vhandle[2]);
285 face_vhandles.push_back(vhandle[5]);
286 face_vhandles.push_back(vhandle[6]);
287 mesh_.add_face(face_vhandles);
292 face_vhandles.clear();
293 face_vhandles.push_back(vhandle[3]);
294 face_vhandles.push_back(vhandle[2]);
295 face_vhandles.push_back(vhandle[6]);
296 mesh_.add_face(face_vhandles);
298 face_vhandles.clear();
299 face_vhandles.push_back(vhandle[3]);
300 face_vhandles.push_back(vhandle[6]);
301 face_vhandles.push_back(vhandle[7]);
302 mesh_.add_face(face_vhandles);
306 face_vhandles.clear();
307 face_vhandles.push_back(vhandle[0]);
308 face_vhandles.push_back(vhandle[3]);
309 face_vhandles.push_back(vhandle[7]);
310 mesh_.add_face(face_vhandles);
312 face_vhandles.clear();
313 face_vhandles.push_back(vhandle[0]);
314 face_vhandles.push_back(vhandle[7]);
315 face_vhandles.push_back(vhandle[4]);
316 mesh_.add_face(face_vhandles);
334 EXPECT_EQ(18u, mesh_.n_edges() ) <<
"Wrong number of Edges";
335 EXPECT_EQ(36u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges";
336 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
337 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong number of faces";
342 mesh_.request_face_status();
343 mesh_.request_vertex_status();
344 mesh_.request_edge_status();
345 mesh_.request_halfedge_status();
346 const size_t n_face_to_delete = mesh_.n_faces()/2;
349 EXPECT_EQ(6u, n_face_to_delete ) <<
"Wrong number of faces to delete";
351 for(
size_t i = 0; i < n_face_to_delete; i++)
352 mesh_.delete_face(mesh_.face_handle(
int(i)));
358 EXPECT_EQ(18u, mesh_.n_edges() ) <<
"Wrong number of Edges after marking as deleted";
359 EXPECT_EQ(36u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges after marking as deleted";
360 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after marking as deleted";
361 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong number of faces after marking as deleted";
367 mesh_.garbage_collection();
369 EXPECT_EQ(13u, mesh_.n_edges() ) <<
"Wrong number of Edges after garbage collection";
370 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after garbage collection";
371 EXPECT_EQ(6u, mesh_.n_faces() ) <<
"Wrong number of faces after garbage collection";
380 TEST_F(OpenMeshDeleteFacePolyMesh, DeleteteHalfPolyMeshCubeWithoutEdgeStatus) {
396 std::vector<Mesh::VertexHandle> face_vhandles;
398 face_vhandles.clear();
399 face_vhandles.push_back(vhandle[0]);
400 face_vhandles.push_back(vhandle[1]);
401 face_vhandles.push_back(vhandle[2]);
402 face_vhandles.push_back(vhandle[3]);
403 mesh_.add_face(face_vhandles);
405 face_vhandles.clear();
406 face_vhandles.push_back(vhandle[7]);
407 face_vhandles.push_back(vhandle[6]);
408 face_vhandles.push_back(vhandle[5]);
409 face_vhandles.push_back(vhandle[4]);
410 mesh_.add_face(face_vhandles);
412 face_vhandles.clear();
413 face_vhandles.push_back(vhandle[1]);
414 face_vhandles.push_back(vhandle[0]);
415 face_vhandles.push_back(vhandle[4]);
416 face_vhandles.push_back(vhandle[5]);
417 mesh_.add_face(face_vhandles);
419 face_vhandles.clear();
420 face_vhandles.push_back(vhandle[2]);
421 face_vhandles.push_back(vhandle[1]);
422 face_vhandles.push_back(vhandle[5]);
423 face_vhandles.push_back(vhandle[6]);
424 mesh_.add_face(face_vhandles);
426 face_vhandles.clear();
427 face_vhandles.push_back(vhandle[3]);
428 face_vhandles.push_back(vhandle[2]);
429 face_vhandles.push_back(vhandle[6]);
430 face_vhandles.push_back(vhandle[7]);
431 mesh_.add_face(face_vhandles);
433 face_vhandles.clear();
434 face_vhandles.push_back(vhandle[0]);
435 face_vhandles.push_back(vhandle[3]);
436 face_vhandles.push_back(vhandle[7]);
437 face_vhandles.push_back(vhandle[4]);
438 mesh_.add_face(face_vhandles);
456 EXPECT_EQ(12u, mesh_.n_edges() ) <<
"Wrong number of Edges";
457 EXPECT_EQ(24u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges";
458 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
459 EXPECT_EQ(6u, mesh_.n_faces() ) <<
"Wrong number of faces";
464 mesh_.request_face_status();
465 mesh_.request_vertex_status();
466 mesh_.request_halfedge_status();
467 const size_t n_face_to_delete = mesh_.n_faces()/2;
470 EXPECT_EQ(3u, n_face_to_delete ) <<
"Wrong number of faces to delete";
472 for(
size_t i = 0; i < n_face_to_delete; i++)
473 mesh_.delete_face(mesh_.face_handle(
int(i)));
479 EXPECT_EQ(12u, mesh_.n_edges() ) <<
"Wrong number of Edges after marking as deleted";
480 EXPECT_EQ(24u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges after marking as deleted";
481 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after marking as deleted";
482 EXPECT_EQ(6u, mesh_.n_faces() ) <<
"Wrong number of faces after marking as deleted";
487 mesh_.garbage_collection();
489 EXPECT_EQ(12u, mesh_.n_edges() ) <<
"Wrong number of Edges after garbage collection";
490 EXPECT_EQ(24u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges after garbage collection";
491 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after garbage collection";
492 EXPECT_EQ(3u, mesh_.n_faces() ) <<
"Wrong number of faces after garbage collection";
499 TEST_F(OpenMeshDeleteFacePolyMesh, DeleteteHalfPolyMeshCubeWithEdgeStatus) {
515 std::vector<Mesh::VertexHandle> face_vhandles;
517 face_vhandles.clear();
518 face_vhandles.push_back(vhandle[0]);
519 face_vhandles.push_back(vhandle[1]);
520 face_vhandles.push_back(vhandle[2]);
521 face_vhandles.push_back(vhandle[3]);
522 mesh_.add_face(face_vhandles);
524 face_vhandles.clear();
525 face_vhandles.push_back(vhandle[7]);
526 face_vhandles.push_back(vhandle[6]);
527 face_vhandles.push_back(vhandle[5]);
528 face_vhandles.push_back(vhandle[4]);
529 mesh_.add_face(face_vhandles);
531 face_vhandles.clear();
532 face_vhandles.push_back(vhandle[1]);
533 face_vhandles.push_back(vhandle[0]);
534 face_vhandles.push_back(vhandle[4]);
535 face_vhandles.push_back(vhandle[5]);
536 mesh_.add_face(face_vhandles);
538 face_vhandles.clear();
539 face_vhandles.push_back(vhandle[2]);
540 face_vhandles.push_back(vhandle[1]);
541 face_vhandles.push_back(vhandle[5]);
542 face_vhandles.push_back(vhandle[6]);
543 mesh_.add_face(face_vhandles);
545 face_vhandles.clear();
546 face_vhandles.push_back(vhandle[3]);
547 face_vhandles.push_back(vhandle[2]);
548 face_vhandles.push_back(vhandle[6]);
549 face_vhandles.push_back(vhandle[7]);
550 mesh_.add_face(face_vhandles);
552 face_vhandles.clear();
553 face_vhandles.push_back(vhandle[0]);
554 face_vhandles.push_back(vhandle[3]);
555 face_vhandles.push_back(vhandle[7]);
556 face_vhandles.push_back(vhandle[4]);
557 mesh_.add_face(face_vhandles);
575 EXPECT_EQ(12u, mesh_.n_edges() ) <<
"Wrong number of Edges";
576 EXPECT_EQ(24u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges";
577 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
578 EXPECT_EQ(6u, mesh_.n_faces() ) <<
"Wrong number of faces";
583 mesh_.request_face_status();
584 mesh_.request_vertex_status();
585 mesh_.request_edge_status();
586 mesh_.request_halfedge_status();
587 const size_t n_face_to_delete = mesh_.n_faces()/2;
590 EXPECT_EQ(3u, n_face_to_delete ) <<
"Wrong number of faces to delete";
592 for(
size_t i = 0; i < n_face_to_delete; i++)
593 mesh_.delete_face(mesh_.face_handle(
int(i)));
599 EXPECT_EQ(12u, mesh_.n_edges() ) <<
"Wrong number of Edges after marking as deleted";
600 EXPECT_EQ(24u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges after marking as deleted";
601 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after marking as deleted";
602 EXPECT_EQ(6u, mesh_.n_faces() ) <<
"Wrong number of faces after marking as deleted";
607 mesh_.garbage_collection();
609 EXPECT_EQ(10u, mesh_.n_edges() ) <<
"Wrong number of Edges after garbage collection";
610 EXPECT_EQ(20u, mesh_.n_halfedges() ) <<
"Wrong number of HalfEdges after garbage collection";
611 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after garbage collection";
612 EXPECT_EQ(3u, mesh_.n_faces() ) <<
"Wrong number of faces after garbage collection";
Kernel::Point Point
Coordinate type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.