OpenMesh
|
00001 #ifndef INCLUDE_UNITTESTS_TRIMESH_CIRCULATORS_HH 00002 #define INCLUDE_UNITTESTS_TRIMESH_CIRCULATORS_HH 00003 00004 #include <gtest/gtest.h> 00005 #include <Unittests/unittests_common.hh> 00006 00007 #include <iostream> 00008 00009 class OpenMeshCirculators : public OpenMeshBase { 00010 00011 protected: 00012 00013 // This function is called before each test is run 00014 virtual void SetUp() { 00015 } 00016 00017 // This function is called after all tests are through 00018 virtual void TearDown() { 00019 00020 // Do some final stuff with the member data here... 00021 } 00022 00023 // Member already defined in OpenMeshBase 00024 //Mesh mesh_; 00025 }; 00026 00027 /* 00028 * ==================================================================== 00029 * Define tests below 00030 * ==================================================================== 00031 */ 00032 00033 00034 /* 00035 * Small VertexFaceIterator Test with holes in it 00036 * 00037 * WARNING!!! Basically this is an illegal configuration! 00038 * But this way we can still detect if it breaks! 00039 */ 00040 TEST_F(OpenMeshCirculators, VertexFaceIterWithHoles) { 00041 00042 mesh_.clear(); 00043 00044 // Add some vertices 00045 Mesh::VertexHandle vhandle[5]; 00046 00047 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); 00048 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); 00049 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); 00050 vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); 00051 vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); 00052 00053 // Add two faces 00054 std::vector<Mesh::VertexHandle> face_vhandles; 00055 00056 face_vhandles.push_back(vhandle[0]); 00057 face_vhandles.push_back(vhandle[1]); 00058 face_vhandles.push_back(vhandle[2]); 00059 mesh_.add_face(face_vhandles); 00060 00061 face_vhandles.clear(); 00062 00063 face_vhandles.push_back(vhandle[1]); 00064 face_vhandles.push_back(vhandle[3]); 00065 face_vhandles.push_back(vhandle[4]); 00066 mesh_.add_face(face_vhandles); 00067 00068 /* Test setup: 00069 0 ==== 2 00070 \ / 00071 \ / 00072 1 00073 / \ 00074 / \ 00075 3 ==== 4 */ 00076 00077 // Iterate around vertex 1 at the middle (with holes in between) 00078 Mesh::VertexFaceIter vf_it = mesh_.vf_begin(vhandle[1]); 00079 Mesh::VertexFaceIter vf_end = mesh_.vf_end(vhandle[1]); 00080 EXPECT_EQ(0, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at initialization"; 00081 EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at initialization"; 00082 ++vf_it ; 00083 EXPECT_EQ(1, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 1"; 00084 EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at step 1"; 00085 ++vf_it ; 00086 EXPECT_EQ(-1, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at end"; 00087 EXPECT_FALSE(vf_it) << "Iterator not invalid in VertexFaceIter at end"; 00088 EXPECT_TRUE( vf_it == vf_end ) << "End iterator for VertexFaceIter not matching"; 00089 00090 // Iterate around vertex 1 at the middle (with holes in between) with const iterator 00091 Mesh::ConstVertexFaceIter cvf_it = mesh_.cvf_begin(vhandle[1]); 00092 Mesh::ConstVertexFaceIter cvf_end = mesh_.cvf_end(vhandle[1]); 00093 EXPECT_EQ(0, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at initialization"; 00094 EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at initialization"; 00095 ++cvf_it ; 00096 EXPECT_EQ(1, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at step one"; 00097 EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at step one"; 00098 ++cvf_it ; 00099 EXPECT_EQ(-1, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at end"; 00100 EXPECT_FALSE(cvf_it) << "Iterator not invalid in ConstVertexFaceIter at end"; 00101 EXPECT_TRUE( cvf_it == cvf_end ) << "End iterator for ConstVertexFaceIter not matching"; 00102 00103 } 00104 00105 /* 00106 * Small VertexFaceIterator Test without holes in it 00107 */ 00108 TEST_F(OpenMeshCirculators, VertexFaceIterWithoutHoles) { 00109 00110 mesh_.clear(); 00111 00112 // Add some vertices 00113 Mesh::VertexHandle vhandle[5]; 00114 00115 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); 00116 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); 00117 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); 00118 vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); 00119 vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); 00120 00121 // Add two faces 00122 std::vector<Mesh::VertexHandle> face_vhandles; 00123 00124 face_vhandles.push_back(vhandle[0]); 00125 face_vhandles.push_back(vhandle[1]); 00126 face_vhandles.push_back(vhandle[2]); 00127 mesh_.add_face(face_vhandles); 00128 00129 face_vhandles.clear(); 00130 00131 face_vhandles.push_back(vhandle[1]); 00132 face_vhandles.push_back(vhandle[3]); 00133 face_vhandles.push_back(vhandle[4]); 00134 mesh_.add_face(face_vhandles); 00135 00136 face_vhandles.clear(); 00137 00138 face_vhandles.push_back(vhandle[0]); 00139 face_vhandles.push_back(vhandle[3]); 00140 face_vhandles.push_back(vhandle[1]); 00141 mesh_.add_face(face_vhandles); 00142 00143 face_vhandles.clear(); 00144 00145 face_vhandles.push_back(vhandle[2]); 00146 face_vhandles.push_back(vhandle[1]); 00147 face_vhandles.push_back(vhandle[4]); 00148 mesh_.add_face(face_vhandles); 00149 00150 /* Test setup: 00151 0 ==== 2 00152 |\ 0 /| 00153 | \ / | 00154 |2 1 3| 00155 | / \ | 00156 |/ 1 \| 00157 3 ==== 4 */ 00158 00159 Mesh::VertexFaceIter vfa_it = mesh_.vf_begin(vhandle[1]); 00160 00161 // Iterate around vertex 1 at the middle (with holes in between) 00162 Mesh::VertexFaceIter vf_it = mesh_.vf_begin(vhandle[1]); 00163 Mesh::VertexFaceIter vf_end = mesh_.vf_end(vhandle[1]); 00164 EXPECT_EQ(3, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at initialization"; 00165 EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at initialization"; 00166 ++vf_it ; 00167 EXPECT_EQ(1, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 1"; 00168 EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at step 1"; 00169 ++vf_it ; 00170 EXPECT_EQ(2, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 2"; 00171 EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at step 2"; 00172 ++vf_it ; 00173 EXPECT_EQ(0, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 3"; 00174 EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at step 3"; 00175 ++vf_it ; 00176 EXPECT_EQ(3, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at end"; 00177 EXPECT_FALSE(vf_it) << "Iterator not invalid in VertexFaceIter at end"; 00178 EXPECT_TRUE( vf_it == vf_end ) << "End iterator for VertexFaceIter not matching"; 00179 00180 // Iterate around vertex 1 at the middle (with holes in between) with const iterator 00181 Mesh::ConstVertexFaceIter cvf_it = mesh_.cvf_begin(vhandle[1]); 00182 Mesh::ConstVertexFaceIter cvf_end = mesh_.cvf_end(vhandle[1]); 00183 EXPECT_EQ(3, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at initialization"; 00184 EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at initialization"; 00185 ++cvf_it ; 00186 EXPECT_EQ(1, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at step 1"; 00187 EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at step 1"; 00188 ++cvf_it ; 00189 EXPECT_EQ(2, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at step 2"; 00190 EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at step 2"; 00191 ++cvf_it ; 00192 EXPECT_EQ(0, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at step 3"; 00193 EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at step 3"; 00194 ++cvf_it ; 00195 EXPECT_EQ(3, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at end"; 00196 EXPECT_FALSE(cvf_it) << "Iterator not invalid in VertexFaceIter at end"; 00197 EXPECT_TRUE( cvf_it == cvf_end ) << "End iterator for ConstVertexFaceIter not matching"; 00198 00199 00200 } 00201 00202 /* 00203 * Small VertexFaceIterator Test without holes in it 00204 */ 00205 TEST_F(OpenMeshCirculators, VertexOutgoingHalfedgeWithoutHoles) { 00206 00207 mesh_.clear(); 00208 00209 // Add some vertices 00210 Mesh::VertexHandle vhandle[5]; 00211 00212 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); 00213 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); 00214 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); 00215 vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); 00216 vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); 00217 00218 // Add two faces 00219 std::vector<Mesh::VertexHandle> face_vhandles; 00220 00221 face_vhandles.push_back(vhandle[0]); 00222 face_vhandles.push_back(vhandle[1]); 00223 face_vhandles.push_back(vhandle[2]); 00224 mesh_.add_face(face_vhandles); 00225 00226 face_vhandles.clear(); 00227 00228 face_vhandles.push_back(vhandle[1]); 00229 face_vhandles.push_back(vhandle[3]); 00230 face_vhandles.push_back(vhandle[4]); 00231 mesh_.add_face(face_vhandles); 00232 00233 face_vhandles.clear(); 00234 00235 face_vhandles.push_back(vhandle[0]); 00236 face_vhandles.push_back(vhandle[3]); 00237 face_vhandles.push_back(vhandle[1]); 00238 mesh_.add_face(face_vhandles); 00239 00240 face_vhandles.clear(); 00241 00242 face_vhandles.push_back(vhandle[2]); 00243 face_vhandles.push_back(vhandle[1]); 00244 face_vhandles.push_back(vhandle[4]); 00245 mesh_.add_face(face_vhandles); 00246 00247 /* Test setup: 00248 0 ==== 2 00249 |\ 0 /| 00250 | \ / | 00251 |2 1 3| 00252 | / \ | 00253 |/ 1 \| 00254 3 ==== 4 */ 00255 00256 00257 // Iterate around vertex 1 at the middle (with holes in between) 00258 Mesh::VertexOHalfedgeIter voh_it = mesh_.voh_begin(vhandle[1]); 00259 Mesh::VertexOHalfedgeIter voh_end = mesh_.voh_end(vhandle[1]); 00260 00261 EXPECT_EQ(11, voh_it.handle().idx() ) << "Index wrong in VertexOHalfedgeIter begin at initialization"; 00262 EXPECT_EQ(11, voh_end.handle().idx() ) << "Index wrong in VertexOHalfedgeIter end at initialization"; 00263 EXPECT_EQ(3, mesh_.face_handle(voh_it.handle()).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter begin at initialization"; 00264 EXPECT_TRUE(voh_it) << "Iterator invalid in VertexOHalfedgeIter at initialization"; 00265 00266 ++voh_it ; 00267 00268 EXPECT_EQ(6, voh_it.handle().idx() ) << "Index wrong in VertexOHalfedgeIter step 1"; 00269 EXPECT_EQ(1, mesh_.face_handle(voh_it.handle()).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 1"; 00270 EXPECT_TRUE(voh_it) << "Iterator invalid in VertexOHalfedgeIter at step 1"; 00271 00272 ++voh_it ; 00273 00274 EXPECT_EQ(1, voh_it.handle().idx() ) << "Index wrong in VertexOHalfedgeIter step 2"; 00275 EXPECT_EQ(2, mesh_.face_handle(voh_it.handle()).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 2"; 00276 EXPECT_TRUE(voh_it) << "Iterator invalid in VertexOHalfedgeIter at step 2"; 00277 00278 ++voh_it ; 00279 00280 EXPECT_EQ(2, voh_it.handle().idx() ) << "Index wrong in VertexOHalfedgeIter step 3"; 00281 EXPECT_EQ(0, mesh_.face_handle(voh_it.handle()).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 3"; 00282 EXPECT_TRUE(voh_it) << "Iterator invalid in VertexOHalfedgeIter at step 3"; 00283 00284 ++voh_it ; 00285 00286 EXPECT_EQ(11, voh_it.handle().idx() ) << "Index wrong in VertexOHalfedgeIter step 4"; 00287 EXPECT_EQ(3, mesh_.face_handle(voh_it.handle()).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 4"; 00288 EXPECT_FALSE(voh_it) << "Iterator still valid in VertexOHalfedgeIter at step 4"; 00289 EXPECT_TRUE( voh_it == voh_end ) << "Miss matched end iterator"; 00290 00291 ++voh_it ; 00292 00293 EXPECT_EQ(6, voh_it.handle().idx() ) << "Index wrong in VertexOHalfedgeIter step 5"; 00294 EXPECT_EQ(1, mesh_.face_handle(voh_it.handle()).idx() ) << "Corresponding face Index wrong in VertexOHalfedgeIter step 5"; 00295 //EXPECT_FALSE(voh_it) << "Iterator still valid in VertexOHalfedgeIter at step 5"; 00296 00297 00298 00299 // Iterate around vertex 1 at the middle (with holes in between) 00300 Mesh::ConstVertexOHalfedgeIter cvoh_it = mesh_.cvoh_begin(vhandle[1]); 00301 Mesh::ConstVertexOHalfedgeIter cvoh_end = mesh_.cvoh_end(vhandle[1]); 00302 00303 EXPECT_EQ(11, cvoh_it.handle().idx() ) << "Index wrong in ConstVertexOHalfedgeIter begin at initialization"; 00304 EXPECT_EQ(11, cvoh_end.handle().idx() ) << "Index wrong in ConstVertexOHalfedgeIter end at initialization"; 00305 EXPECT_EQ(3, mesh_.face_handle(cvoh_it.handle()).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter begin at initialization"; 00306 EXPECT_TRUE(cvoh_it) << "Iterator invalid in ConstVertexOHalfedgeIter at initialization"; 00307 00308 ++cvoh_it ; 00309 00310 EXPECT_EQ(6, cvoh_it.handle().idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 1"; 00311 EXPECT_EQ(1, mesh_.face_handle(cvoh_it.handle()).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 1"; 00312 EXPECT_TRUE(cvoh_it) << "Iterator invalid in ConstVertexOHalfedgeIter at step 1"; 00313 00314 ++cvoh_it ; 00315 00316 EXPECT_EQ(1, cvoh_it.handle().idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 2"; 00317 EXPECT_EQ(2, mesh_.face_handle(cvoh_it.handle()).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 2"; 00318 EXPECT_TRUE(cvoh_it) << "Iterator invalid in ConstVertexOHalfedgeIter at step 2"; 00319 00320 ++cvoh_it ; 00321 00322 EXPECT_EQ(2, cvoh_it.handle().idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 3"; 00323 EXPECT_EQ(0, mesh_.face_handle(cvoh_it.handle()).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 3"; 00324 EXPECT_TRUE(cvoh_it) << "Iterator invalid in ConstVertexOHalfedgeIter at step 3"; 00325 00326 ++cvoh_it ; 00327 00328 EXPECT_EQ(11, cvoh_it.handle().idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 4"; 00329 EXPECT_EQ(3, mesh_.face_handle(cvoh_it.handle()).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 4"; 00330 EXPECT_FALSE(cvoh_it) << "Iterator still valid in ConstVertexOHalfedgeIter at step 4"; 00331 EXPECT_TRUE( cvoh_it == cvoh_end ) << "Miss matched end iterator"; 00332 00333 ++cvoh_it ; 00334 00335 EXPECT_EQ(6, cvoh_it.handle().idx() ) << "Index wrong in ConstVertexOHalfedgeIter step 5"; 00336 EXPECT_EQ(1, mesh_.face_handle(cvoh_it.handle()).idx() ) << "Corresponding face Index wrong in ConstVertexOHalfedgeIter step 5"; 00337 //EXPECT_FALSE(cvoh_it) << "Iterator still valid in ConstVertexOHalfedgeIter at step 5"; 00338 00339 00340 } 00341 00342 /* 00343 * Small FaceFaceIterator Test with holes in it 00344 */ 00345 TEST_F(OpenMeshCirculators, FaceFaceIterWithHoles) { 00346 00347 mesh_.clear(); 00348 00349 // Add some vertices 00350 Mesh::VertexHandle vhandle[5]; 00351 00352 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); 00353 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); 00354 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); 00355 vhandle[3] = mesh_.add_vertex(Mesh::Point(3, 0, 0)); 00356 vhandle[4] = mesh_.add_vertex(Mesh::Point(4, 1, 0)); 00357 00358 // Add three faces 00359 std::vector<Mesh::VertexHandle> face_vhandles; 00360 00361 face_vhandles.push_back(vhandle[0]); 00362 face_vhandles.push_back(vhandle[1]); 00363 face_vhandles.push_back(vhandle[2]); 00364 mesh_.add_face(face_vhandles); 00365 00366 face_vhandles.clear(); 00367 00368 face_vhandles.push_back(vhandle[2]); 00369 face_vhandles.push_back(vhandle[1]); 00370 face_vhandles.push_back(vhandle[3]); 00371 mesh_.add_face(face_vhandles); 00372 00373 face_vhandles.clear(); 00374 00375 face_vhandles.push_back(vhandle[2]); 00376 face_vhandles.push_back(vhandle[3]); 00377 face_vhandles.push_back(vhandle[4]); 00378 mesh_.add_face(face_vhandles); 00379 00380 /* Test setup: 00381 * 00382 * 0 ------ 2 ------ 4 00383 * \ / \ / 00384 * \ 0 / \ 2 / 00385 * \ / 1 \ / 00386 * 1 ------- 3 00387 */ 00388 00389 00390 Mesh::FaceFaceIter ff_it = mesh_.ff_begin(mesh_.face_handle(1)); 00391 Mesh::FaceFaceIter ff_end = mesh_.ff_end(mesh_.face_handle(1)); 00392 00393 EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at initialization"; 00394 EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at initialization"; 00395 ++ff_it; 00396 EXPECT_EQ(0, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at step 1"; 00397 EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at step 1"; 00398 ++ff_it; 00399 EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at end"; 00400 EXPECT_FALSE(ff_it) << "Iterator invalid in FaceFaceIter at end"; 00401 EXPECT_TRUE( ff_it == ff_end ) << "End iterator for FaceFaceIter not matching"; 00402 00403 Mesh::ConstFaceFaceIter cff_it = mesh_.cff_begin(mesh_.face_handle(1)); 00404 Mesh::ConstFaceFaceIter cff_end = mesh_.cff_end(mesh_.face_handle(1)); 00405 00406 EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at initialization"; 00407 EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at initialization"; 00408 ++cff_it; 00409 EXPECT_EQ(0, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at step 1"; 00410 EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at step 1"; 00411 ++cff_it; 00412 EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at end"; 00413 EXPECT_FALSE(cff_it) << "Iterator invalid in ConstFaceFaceIter at end"; 00414 EXPECT_TRUE( cff_it == cff_end ) << "End iterator for ConstFaceFaceIter not matching"; 00415 00416 } 00417 00418 /* 00419 * Small FaceFaceIterator Test with holes in it 00420 */ 00421 TEST_F(OpenMeshCirculators, FaceFaceIterWithoutHoles) { 00422 00423 mesh_.clear(); 00424 00425 // Add some vertices 00426 Mesh::VertexHandle vhandle[6]; 00427 00428 vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); 00429 vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); 00430 vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); 00431 vhandle[3] = mesh_.add_vertex(Mesh::Point(3, 0, 0)); 00432 vhandle[4] = mesh_.add_vertex(Mesh::Point(4, 1, 0)); 00433 vhandle[5] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); 00434 00435 // Add three faces 00436 std::vector<Mesh::VertexHandle> face_vhandles; 00437 00438 face_vhandles.push_back(vhandle[0]); 00439 face_vhandles.push_back(vhandle[1]); 00440 face_vhandles.push_back(vhandle[2]); 00441 mesh_.add_face(face_vhandles); 00442 00443 face_vhandles.clear(); 00444 00445 face_vhandles.push_back(vhandle[2]); 00446 face_vhandles.push_back(vhandle[1]); 00447 face_vhandles.push_back(vhandle[3]); 00448 mesh_.add_face(face_vhandles); 00449 00450 face_vhandles.clear(); 00451 00452 face_vhandles.push_back(vhandle[2]); 00453 face_vhandles.push_back(vhandle[3]); 00454 face_vhandles.push_back(vhandle[4]); 00455 mesh_.add_face(face_vhandles); 00456 00457 face_vhandles.clear(); 00458 00459 face_vhandles.push_back(vhandle[1]); 00460 face_vhandles.push_back(vhandle[5]); 00461 face_vhandles.push_back(vhandle[3]); 00462 mesh_.add_face(face_vhandles); 00463 00464 /* Test setup: 00465 * 00466 * 0 ------ 2 ------ 4 00467 * \ / \ / 00468 * \ 0 / \ 2 / 00469 * \ / 1 \ / 00470 * 1 ------- 3 00471 * \ / 00472 * \ 3 / 00473 * \ / 00474 * \ / 00475 * 5 00476 */ 00477 00478 00479 Mesh::FaceFaceIter ff_it = mesh_.ff_begin(mesh_.face_handle(1)); 00480 Mesh::FaceFaceIter ff_end = mesh_.ff_end(mesh_.face_handle(1)); 00481 00482 EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at initialization"; 00483 EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at initialization"; 00484 ++ff_it; 00485 EXPECT_EQ(0, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at step 1"; 00486 EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at step 1"; 00487 ++ff_it; 00488 EXPECT_EQ(3, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at step 2"; 00489 EXPECT_TRUE(ff_it) << "Iterator invalid in FaceFaceIter at step 2"; 00490 ++ff_it; 00491 EXPECT_EQ(2, ff_it.handle().idx() ) << "Index wrong in FaceFaceIter at end"; 00492 EXPECT_FALSE(ff_it) << "Iterator invalid in FaceFaceIter at end"; 00493 EXPECT_TRUE( ff_it == ff_end ) << "End iterator for FaceFaceIter not matching"; 00494 00495 Mesh::ConstFaceFaceIter cff_it = mesh_.cff_begin(mesh_.face_handle(1)); 00496 Mesh::ConstFaceFaceIter cff_end = mesh_.cff_end(mesh_.face_handle(1)); 00497 00498 EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at initialization"; 00499 EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at initialization"; 00500 ++cff_it; 00501 EXPECT_EQ(0, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at step 1"; 00502 EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at step 1"; 00503 ++cff_it; 00504 EXPECT_EQ(3, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at step 2"; 00505 EXPECT_TRUE(cff_it) << "Iterator invalid in ConstFaceFaceIter at step 2"; 00506 ++cff_it; 00507 EXPECT_EQ(2, cff_it.handle().idx() ) << "Index wrong in ConstFaceFaceIter at end"; 00508 EXPECT_FALSE(cff_it) << "Iterator invalid in ConstFaceFaceIter at end"; 00509 EXPECT_TRUE( cff_it == cff_end ) << "End iterator for ConstFaceFaceIter not matching"; 00510 00511 } 00512 00513 00514 00515 00516 00517 #endif // INCLUDE GUARD