OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unittests_trimesh_circulator_face_vertex.hh
1 #pragma once
2 #include <gtest/gtest.h>
3 #include <Unittests/unittests_common.hh>
4 
5 #include <iostream>
6 
8 
9  protected:
10 
11  // This function is called before each test is run
12  virtual void SetUp() {
13  }
14 
15  // This function is called after all tests are through
16  virtual void TearDown() {
17 
18  // Do some final stuff with the member data here...
19  }
20 
21 
22  // Member already defined in OpenMeshBase
23  //Mesh mesh_;
24 };
25 
26 /*
27  * ====================================================================
28  * Define tests below
29  * ====================================================================
30  */
31 
32 
33 
34 /*
35  * Small FaceVertexIterator Test
36  */
37 TEST_F(OpenMeshTrimeshCirculatorFaceVertex, FaceVertexIterWithoutIncrement) {
38 
39  mesh_.clear();
40 
41  // Add some vertices
42  Mesh::VertexHandle vhandle[5];
43 
44  vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
45  vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
46  vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
47  vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
48  vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
49 
50  // Add two faces
51  std::vector<Mesh::VertexHandle> face_vhandles;
52 
53  face_vhandles.push_back(vhandle[0]);
54  face_vhandles.push_back(vhandle[1]);
55  face_vhandles.push_back(vhandle[2]);
56  Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
57 
58  face_vhandles.clear();
59 
60  face_vhandles.push_back(vhandle[1]);
61  face_vhandles.push_back(vhandle[3]);
62  face_vhandles.push_back(vhandle[4]);
63  mesh_.add_face(face_vhandles);
64 
65  face_vhandles.clear();
66 
67  face_vhandles.push_back(vhandle[0]);
68  face_vhandles.push_back(vhandle[3]);
69  face_vhandles.push_back(vhandle[1]);
70  mesh_.add_face(face_vhandles);
71 
72  face_vhandles.clear();
73 
74  face_vhandles.push_back(vhandle[2]);
75  face_vhandles.push_back(vhandle[1]);
76  face_vhandles.push_back(vhandle[4]);
77  mesh_.add_face(face_vhandles);
78 
79  /* Test setup:
80  0 ==== 2
81  |\ 0 /|
82  | \ / |
83  |2 1 3|
84  | / \ |
85  |/ 1 \|
86  3 ==== 4 */
87 
88 
89  // Check face handle index
90  EXPECT_EQ(0, fh0.idx() ) << "Index wrong in FaceVertexIter at initialization";
91 
92  // Iterate around vertex 1 at the middle (with holes in between)
93  Mesh::FaceVertexIter fv_it = mesh_.fv_begin(fh0);
94  Mesh::FaceVertexIter fv_end = mesh_.fv_end(fh0);
95  EXPECT_EQ(0, fv_it.handle().idx() ) << "Index wrong in FaceVertexIter at initialization";
96  EXPECT_TRUE(fv_it) << "Iterator invalid in FaceVertexIter at initialization";
97  ++fv_it ;
98  EXPECT_EQ(1, fv_it.handle().idx() ) << "Index wrong in FaceVertexIter at step 1";
99  EXPECT_TRUE(fv_it) << "Iterator invalid in FaceVertexIter at step 1";
100  ++fv_it ;
101  EXPECT_EQ(2, fv_it.handle().idx() ) << "Index wrong in FaceVertexIter at step 2";
102  EXPECT_TRUE(fv_it) << "Iterator invalid in FaceVertexIter at step 2";
103  ++fv_it ;
104  EXPECT_EQ(0, fv_it.handle().idx() ) << "Index wrong in FaceVertexIter at step 3";
105  EXPECT_FALSE(fv_it) << "Iterator invalid in FaceVertexIter at step 3";
106  EXPECT_TRUE( fv_it == fv_end ) << "End iterator for FaceVertexIter not matching";
107 
108  // Iterate around vertex 1 at the middle (with holes in between) with const iterator
109  Mesh::ConstFaceVertexIter cfv_it = mesh_.cfv_begin(fh0);
110  Mesh::ConstFaceVertexIter cfv_end = mesh_.cfv_end(fh0);
111  EXPECT_EQ(0, cfv_it.handle().idx() ) << "Index wrong in ConstFaceVertexIter at initialization";
112  EXPECT_TRUE(cfv_it) << "Iterator invalid in ConstFaceVertexIter at initialization";
113  ++cfv_it ;
114  EXPECT_EQ(1, cfv_it.handle().idx() ) << "Index wrong in ConstFaceVertexIter at step 1";
115  EXPECT_TRUE(cfv_it) << "Iterator invalid in ConstFaceVertexIter at step 1";
116  ++cfv_it ;
117  EXPECT_EQ(2, cfv_it.handle().idx() ) << "Index wrong in ConstFaceVertexIter at step 2";
118  EXPECT_TRUE(cfv_it) << "Iterator invalid in ConstFaceVertexIter at step 2";
119  ++cfv_it ;
120  EXPECT_EQ(0, cfv_it.handle().idx() ) << "Index wrong in ConstFaceVertexIter at step 3";
121  EXPECT_FALSE(cfv_it) << "Iterator invalid in ConstFaceVertexIter at step 3";
122  EXPECT_TRUE( cfv_it == cfv_end ) << "End iterator for ConstFaceVertexIter not matching";
123 
124 }

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .