1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 8 class OpenMeshTriMeshGarbageCollection :
public OpenMeshBase {
13 virtual void SetUp() {
17 virtual void TearDown() {
34 TEST_F(OpenMeshTriMeshGarbageCollection, StandardGarbageCollection) {
38 mesh_.request_vertex_status();
39 mesh_.request_edge_status();
40 mesh_.request_halfedge_status();
41 mesh_.request_face_status();
55 std::vector<Mesh::VertexHandle> face_vhandles;
57 face_vhandles.clear();
58 face_vhandles.push_back(vhandle[0]);
59 face_vhandles.push_back(vhandle[1]);
60 face_vhandles.push_back(vhandle[3]);
61 mesh_.add_face(face_vhandles);
63 face_vhandles.clear();
64 face_vhandles.push_back(vhandle[1]);
65 face_vhandles.push_back(vhandle[2]);
66 face_vhandles.push_back(vhandle[3]);
67 mesh_.add_face(face_vhandles);
71 face_vhandles.clear();
72 face_vhandles.push_back(vhandle[7]);
73 face_vhandles.push_back(vhandle[6]);
74 face_vhandles.push_back(vhandle[5]);
75 mesh_.add_face(face_vhandles);
77 face_vhandles.clear();
78 face_vhandles.push_back(vhandle[7]);
79 face_vhandles.push_back(vhandle[5]);
80 face_vhandles.push_back(vhandle[4]);
81 mesh_.add_face(face_vhandles);
85 face_vhandles.clear();
86 face_vhandles.push_back(vhandle[1]);
87 face_vhandles.push_back(vhandle[0]);
88 face_vhandles.push_back(vhandle[4]);
89 mesh_.add_face(face_vhandles);
91 face_vhandles.clear();
92 face_vhandles.push_back(vhandle[1]);
93 face_vhandles.push_back(vhandle[4]);
94 face_vhandles.push_back(vhandle[5]);
95 mesh_.add_face(face_vhandles);
99 face_vhandles.clear();
100 face_vhandles.push_back(vhandle[2]);
101 face_vhandles.push_back(vhandle[1]);
102 face_vhandles.push_back(vhandle[5]);
103 mesh_.add_face(face_vhandles);
105 face_vhandles.clear();
106 face_vhandles.push_back(vhandle[2]);
107 face_vhandles.push_back(vhandle[5]);
108 face_vhandles.push_back(vhandle[6]);
109 mesh_.add_face(face_vhandles);
114 face_vhandles.clear();
115 face_vhandles.push_back(vhandle[3]);
116 face_vhandles.push_back(vhandle[2]);
117 face_vhandles.push_back(vhandle[6]);
118 mesh_.add_face(face_vhandles);
120 face_vhandles.clear();
121 face_vhandles.push_back(vhandle[3]);
122 face_vhandles.push_back(vhandle[6]);
123 face_vhandles.push_back(vhandle[7]);
124 mesh_.add_face(face_vhandles);
128 face_vhandles.clear();
129 face_vhandles.push_back(vhandle[0]);
130 face_vhandles.push_back(vhandle[3]);
131 face_vhandles.push_back(vhandle[7]);
132 mesh_.add_face(face_vhandles);
134 face_vhandles.clear();
135 face_vhandles.push_back(vhandle[0]);
136 face_vhandles.push_back(vhandle[7]);
137 face_vhandles.push_back(vhandle[4]);
138 mesh_.add_face(face_vhandles);
156 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong initial number of vertices";
157 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong initial number of faces";
159 mesh_.delete_vertex(vhandle[0]);
162 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after deletion";
163 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong number of faces after deletion";
165 mesh_.garbage_collection();
168 EXPECT_EQ(7u, mesh_.n_vertices() ) <<
"Wrong number of vertices after garbage collection";
169 EXPECT_EQ(8u, mesh_.n_faces() ) <<
"Wrong number of faces after garbage collection";
176 TEST_F(OpenMeshTriMeshGarbageCollection, TrackedGarbageCollection) {
180 mesh_.request_vertex_status();
181 mesh_.request_edge_status();
182 mesh_.request_halfedge_status();
183 mesh_.request_face_status();
197 std::vector<Mesh::VertexHandle> face_vhandles;
200 face_vhandles.clear();
201 face_vhandles.push_back(vhandle[0]);
202 face_vhandles.push_back(vhandle[1]);
203 face_vhandles.push_back(vhandle[3]);
204 mesh_.add_face(face_vhandles);
207 face_vhandles.clear();
208 face_vhandles.push_back(vhandle[1]);
209 face_vhandles.push_back(vhandle[2]);
210 face_vhandles.push_back(vhandle[3]);
211 mesh_.add_face(face_vhandles);
216 face_vhandles.clear();
217 face_vhandles.push_back(vhandle[7]);
218 face_vhandles.push_back(vhandle[6]);
219 face_vhandles.push_back(vhandle[5]);
220 mesh_.add_face(face_vhandles);
223 face_vhandles.clear();
224 face_vhandles.push_back(vhandle[7]);
225 face_vhandles.push_back(vhandle[5]);
226 face_vhandles.push_back(vhandle[4]);
227 mesh_.add_face(face_vhandles);
232 face_vhandles.clear();
233 face_vhandles.push_back(vhandle[1]);
234 face_vhandles.push_back(vhandle[0]);
235 face_vhandles.push_back(vhandle[4]);
236 mesh_.add_face(face_vhandles);
239 face_vhandles.clear();
240 face_vhandles.push_back(vhandle[1]);
241 face_vhandles.push_back(vhandle[4]);
242 face_vhandles.push_back(vhandle[5]);
243 mesh_.add_face(face_vhandles);
248 face_vhandles.clear();
249 face_vhandles.push_back(vhandle[2]);
250 face_vhandles.push_back(vhandle[1]);
251 face_vhandles.push_back(vhandle[5]);
252 mesh_.add_face(face_vhandles);
255 face_vhandles.clear();
256 face_vhandles.push_back(vhandle[2]);
257 face_vhandles.push_back(vhandle[5]);
258 face_vhandles.push_back(vhandle[6]);
259 mesh_.add_face(face_vhandles);
265 face_vhandles.clear();
266 face_vhandles.push_back(vhandle[3]);
267 face_vhandles.push_back(vhandle[2]);
268 face_vhandles.push_back(vhandle[6]);
269 mesh_.add_face(face_vhandles);
272 face_vhandles.clear();
273 face_vhandles.push_back(vhandle[3]);
274 face_vhandles.push_back(vhandle[6]);
275 face_vhandles.push_back(vhandle[7]);
276 mesh_.add_face(face_vhandles);
281 face_vhandles.clear();
282 face_vhandles.push_back(vhandle[0]);
283 face_vhandles.push_back(vhandle[3]);
284 face_vhandles.push_back(vhandle[7]);
285 mesh_.add_face(face_vhandles);
288 face_vhandles.clear();
289 face_vhandles.push_back(vhandle[0]);
290 face_vhandles.push_back(vhandle[7]);
291 face_vhandles.push_back(vhandle[4]);
292 mesh_.add_face(face_vhandles);
310 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong initial number of vertices";
311 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong initial number of faces";
316 std::vector<Mesh::VertexHandle> vertexHandles;
317 for ( Mesh::VertexIter v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
318 vertexHandles.push_back(*v_it);
320 std::vector<Mesh::HalfedgeHandle> halfedgeHandles;
321 for ( Mesh::HalfedgeIter he_it = mesh_.halfedges_begin(); he_it != mesh_.halfedges_end(); ++he_it)
322 halfedgeHandles.push_back(*he_it);
324 std::vector<Mesh::FaceHandle> faceHandles;
325 for ( Mesh::FaceIter f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it)
326 faceHandles.push_back(*f_it);
331 std::vector<Mesh::VertexHandle*> vertexHandlesP;
332 for (
unsigned int i = 0 ; i < vertexHandles.size() ; ++i)
333 vertexHandlesP.push_back(&(vertexHandles[i]));
335 std::vector<Mesh::HalfedgeHandle*> halfedgeHandlesP;
336 for (
unsigned int i = 0 ; i < halfedgeHandles.size() ; ++i) {
337 halfedgeHandlesP.push_back(&(halfedgeHandles[i]));
340 std::vector<Mesh::FaceHandle*> faceHandlesP;
341 for (
unsigned int i = 0 ; i < faceHandles.size() ; ++i)
342 faceHandlesP.push_back(&(faceHandles[i]));
383 mesh_.delete_vertex(vhandle[0]);
387 EXPECT_EQ(8u, mesh_.n_vertices() ) <<
"Wrong number of vertices after deletion";
388 EXPECT_EQ(12u, mesh_.n_faces() ) <<
"Wrong number of faces after deletion";
390 mesh_.garbage_collection(vertexHandlesP,halfedgeHandlesP,faceHandlesP,
true,
true,
true);
393 EXPECT_EQ(7u, mesh_.n_vertices() ) <<
"Wrong number of vertices after garbage collection";
394 EXPECT_EQ(8u, mesh_.n_faces() ) <<
"Wrong number of faces after garbage collection";
424 EXPECT_EQ(-1, vertexHandles[0].idx() ) <<
"Wrong vertex handle after update";
425 EXPECT_EQ(1 , vertexHandles[1].idx() ) <<
"Wrong vertex handle after update";
426 EXPECT_EQ(2 , vertexHandles[2].idx() ) <<
"Wrong vertex handle after update";
427 EXPECT_EQ(3 , vertexHandles[3].idx() ) <<
"Wrong vertex handle after update";
428 EXPECT_EQ(4 , vertexHandles[4].idx() ) <<
"Wrong vertex handle after update";
429 EXPECT_EQ(5 , vertexHandles[5].idx() ) <<
"Wrong vertex handle after update";
430 EXPECT_EQ(6 , vertexHandles[6].idx() ) <<
"Wrong vertex handle after update";
431 EXPECT_EQ(0 , vertexHandles[7].idx() ) <<
"Wrong vertex handle after update";
434 EXPECT_EQ(-1, halfedgeHandles[0 ].idx() ) <<
"Wrong halfedge handle after update";
435 EXPECT_EQ(-1, halfedgeHandles[1 ].idx() ) <<
"Wrong halfedge handle after update";
436 EXPECT_EQ( 2, halfedgeHandles[2 ].idx() ) <<
"Wrong halfedge handle after update";
437 EXPECT_EQ( 3, halfedgeHandles[3 ].idx() ) <<
"Wrong halfedge handle after update";
438 EXPECT_EQ(-1, halfedgeHandles[4 ].idx() ) <<
"Wrong halfedge handle after update";
439 EXPECT_EQ(-1, halfedgeHandles[5 ].idx() ) <<
"Wrong halfedge handle after update";
440 EXPECT_EQ( 6, halfedgeHandles[6 ].idx() ) <<
"Wrong halfedge handle after update";
441 EXPECT_EQ( 7, halfedgeHandles[7 ].idx() ) <<
"Wrong halfedge handle after update";
442 EXPECT_EQ( 8, halfedgeHandles[8 ].idx() ) <<
"Wrong halfedge handle after update";
443 EXPECT_EQ( 9, halfedgeHandles[9 ].idx() ) <<
"Wrong halfedge handle after update";
444 EXPECT_EQ(10, halfedgeHandles[10].idx() ) <<
"Wrong halfedge handle after update";
445 EXPECT_EQ(11, halfedgeHandles[11].idx() ) <<
"Wrong halfedge handle after update";
446 EXPECT_EQ(12, halfedgeHandles[12].idx() ) <<
"Wrong halfedge handle after update";
447 EXPECT_EQ(13, halfedgeHandles[13].idx() ) <<
"Wrong halfedge handle after update";
448 EXPECT_EQ(14, halfedgeHandles[14].idx() ) <<
"Wrong halfedge handle after update";
449 EXPECT_EQ(15, halfedgeHandles[15].idx() ) <<
"Wrong halfedge handle after update";
450 EXPECT_EQ(16, halfedgeHandles[16].idx() ) <<
"Wrong halfedge handle after update";
451 EXPECT_EQ(17, halfedgeHandles[17].idx() ) <<
"Wrong halfedge handle after update";
452 EXPECT_EQ(18, halfedgeHandles[18].idx() ) <<
"Wrong halfedge handle after update";
453 EXPECT_EQ(19, halfedgeHandles[19].idx() ) <<
"Wrong halfedge handle after update";
454 EXPECT_EQ(-1, halfedgeHandles[20].idx() ) <<
"Wrong halfedge handle after update";
455 EXPECT_EQ(-1, halfedgeHandles[21].idx() ) <<
"Wrong halfedge handle after update";
456 EXPECT_EQ(22, halfedgeHandles[22].idx() ) <<
"Wrong halfedge handle after update";
457 EXPECT_EQ(23, halfedgeHandles[23].idx() ) <<
"Wrong halfedge handle after update";
458 EXPECT_EQ(24, halfedgeHandles[24].idx() ) <<
"Wrong halfedge handle after update";
459 EXPECT_EQ(25, halfedgeHandles[25].idx() ) <<
"Wrong halfedge handle after update";
460 EXPECT_EQ(26, halfedgeHandles[26].idx() ) <<
"Wrong halfedge handle after update";
461 EXPECT_EQ(27, halfedgeHandles[27].idx() ) <<
"Wrong halfedge handle after update";
462 EXPECT_EQ(20, halfedgeHandles[28].idx() ) <<
"Wrong halfedge handle after update";
463 EXPECT_EQ(21, halfedgeHandles[29].idx() ) <<
"Wrong halfedge handle after update";
464 EXPECT_EQ( 4, halfedgeHandles[30].idx() ) <<
"Wrong halfedge handle after update";
465 EXPECT_EQ( 5, halfedgeHandles[31].idx() ) <<
"Wrong halfedge handle after update";
466 EXPECT_EQ( 0, halfedgeHandles[32].idx() ) <<
"Wrong halfedge handle after update";
467 EXPECT_EQ( 1, halfedgeHandles[33].idx() ) <<
"Wrong halfedge handle after update";
468 EXPECT_EQ(-1, halfedgeHandles[34].idx() ) <<
"Wrong halfedge handle after update";
469 EXPECT_EQ(-1, halfedgeHandles[35].idx() ) <<
"Wrong halfedge handle after update";
472 EXPECT_EQ(-1 , faceHandles[0 ].idx() ) <<
"Wrong face handle after update";
473 EXPECT_EQ(1 , faceHandles[1 ].idx() ) <<
"Wrong face handle after update";
474 EXPECT_EQ(2 , faceHandles[2 ].idx() ) <<
"Wrong face handle after update";
475 EXPECT_EQ(3 , faceHandles[3 ].idx() ) <<
"Wrong face handle after update";
476 EXPECT_EQ(-1 , faceHandles[4 ].idx() ) <<
"Wrong face handle after update";
477 EXPECT_EQ(5 , faceHandles[5 ].idx() ) <<
"Wrong face handle after update";
478 EXPECT_EQ(6 , faceHandles[6 ].idx() ) <<
"Wrong face handle after update";
479 EXPECT_EQ(7 , faceHandles[7 ].idx() ) <<
"Wrong face handle after update";
480 EXPECT_EQ(4 , faceHandles[8 ].idx() ) <<
"Wrong face handle after update";
481 EXPECT_EQ(0 , faceHandles[9 ].idx() ) <<
"Wrong face handle after update";
482 EXPECT_EQ(-1 , faceHandles[10].idx() ) <<
"Wrong face handle after update";
483 EXPECT_EQ(-1 , faceHandles[11].idx() ) <<
"Wrong face handle after update";
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.