Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
unittests_boundary.cc
1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
3 #include <iostream>
4 
5 namespace {
6 
7 class OpenMeshBoundaryTriangleMesh : public OpenMeshBase {
8 
9  protected:
10 
11  // This function is called before each test is run
12  virtual void SetUp() {
13 
14  // Do some initial stuff with the member data here...
15  }
16 
17  // This function is called after all tests are through
18  virtual void TearDown() {
19 
20  // Do some final stuff with the member data here...
21  }
22 
23  // Member already defined in OpenMeshBase
24  //Mesh mesh_;
25 };
26 
27 /*
28  * ====================================================================
29  * Define tests below
30  * ====================================================================
31  */
32 
33 /* Checks vertices, if they are boundary vertices
34  */
35 TEST_F(OpenMeshBoundaryTriangleMesh, TestBoundaryVertex) {
36 
37  mesh_.clear();
38 
39  // Add some vertices
40  Mesh::VertexHandle vhandle[7];
41 
42  vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
43  vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
44  vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
45  vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
46  vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
47  vhandle[5] = mesh_.add_vertex(Mesh::Point(3, 0, 0));
48 
49  // Single point
50  vhandle[6] = mesh_.add_vertex(Mesh::Point(0,-2, 0));
51 
52  // Add two faces
53  std::vector<Mesh::VertexHandle> face_vhandles;
54 
55  face_vhandles.push_back(vhandle[0]);
56  face_vhandles.push_back(vhandle[1]);
57  face_vhandles.push_back(vhandle[2]);
58  mesh_.add_face(face_vhandles);
59 
60  face_vhandles.clear();
61 
62  face_vhandles.push_back(vhandle[1]);
63  face_vhandles.push_back(vhandle[3]);
64  face_vhandles.push_back(vhandle[4]);
65  mesh_.add_face(face_vhandles);
66 
67  face_vhandles.clear();
68 
69  face_vhandles.push_back(vhandle[0]);
70  face_vhandles.push_back(vhandle[3]);
71  face_vhandles.push_back(vhandle[1]);
72  mesh_.add_face(face_vhandles);
73 
74  face_vhandles.clear();
75 
76  face_vhandles.push_back(vhandle[2]);
77  face_vhandles.push_back(vhandle[1]);
78  face_vhandles.push_back(vhandle[4]);
79  mesh_.add_face(face_vhandles);
80 
81  face_vhandles.clear();
82 
83  face_vhandles.push_back(vhandle[5]);
84  face_vhandles.push_back(vhandle[2]);
85  face_vhandles.push_back(vhandle[4]);
86  mesh_.add_face(face_vhandles);
87 
88  /* Test setup:
89  0 ==== 2
90  |\ 0 /|\
91  | \ / | \
92  |2 1 3|4 5
93  | / \ | /
94  |/ 1 \|/
95  3 ==== 4
96 
97  Vertex 6 single
98  */
99 
100 
101  // Check for boundary vertices
102  EXPECT_TRUE ( mesh_.is_boundary( vhandle[0] ) ) << "Vertex 0 is not boundary!";
103  EXPECT_FALSE( mesh_.is_boundary( vhandle[1] ) ) << "Vertex 1 is boundary!";
104  EXPECT_TRUE ( mesh_.is_boundary( vhandle[2] ) ) << "Vertex 2 is not boundary!";
105  EXPECT_TRUE ( mesh_.is_boundary( vhandle[3] ) ) << "Vertex 3 is not boundary!";
106  EXPECT_TRUE ( mesh_.is_boundary( vhandle[4] ) ) << "Vertex 4 is not boundary!";
107  EXPECT_TRUE ( mesh_.is_boundary( vhandle[5] ) ) << "Vertex 5 is not boundary!";
108 
109  EXPECT_TRUE ( mesh_.is_boundary( vhandle[6] ) ) << "Singular Vertex 6 is not boundary!";
110 
111 
112 }
113 
114 /* Checks faces, if they are boundary faces
115  */
116 TEST_F(OpenMeshBoundaryTriangleMesh, TestBoundaryFace) {
117 
118  mesh_.clear();
119 
120  // Add some vertices
121  Mesh::VertexHandle vhandle[7];
122 
123  vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
124  vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
125  vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
126  vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
127  vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
128  vhandle[5] = mesh_.add_vertex(Mesh::Point(3, 0, 0));
129 
130  // Single point
131  vhandle[6] = mesh_.add_vertex(Mesh::Point(0,-2, 0));
132 
133  // Add two faces
134  std::vector<Mesh::VertexHandle> face_vhandles;
135  std::vector<Mesh::FaceHandle> face_handles;
136 
137  face_vhandles.push_back(vhandle[0]);
138  face_vhandles.push_back(vhandle[1]);
139  face_vhandles.push_back(vhandle[2]);
140  face_handles.push_back(mesh_.add_face(face_vhandles));
141 
142  face_vhandles.clear();
143 
144  face_vhandles.push_back(vhandle[1]);
145  face_vhandles.push_back(vhandle[3]);
146  face_vhandles.push_back(vhandle[4]);
147  face_handles.push_back(mesh_.add_face(face_vhandles));
148 
149  face_vhandles.clear();
150 
151  face_vhandles.push_back(vhandle[0]);
152  face_vhandles.push_back(vhandle[3]);
153  face_vhandles.push_back(vhandle[1]);
154  face_handles.push_back(mesh_.add_face(face_vhandles));
155 
156  face_vhandles.clear();
157 
158  face_vhandles.push_back(vhandle[2]);
159  face_vhandles.push_back(vhandle[1]);
160  face_vhandles.push_back(vhandle[4]);
161  face_handles.push_back(mesh_.add_face(face_vhandles));
162 
163  face_vhandles.clear();
164 
165  face_vhandles.push_back(vhandle[5]);
166  face_vhandles.push_back(vhandle[2]);
167  face_vhandles.push_back(vhandle[4]);
168  face_handles.push_back(mesh_.add_face(face_vhandles));
169 
170  /* Test setup:
171  0 ==== 2
172  |\ 0 /|\
173  | \ / | \
174  |2 1 3|4 5
175  | / \ | /
176  |/ 1 \|/
177  3 ==== 4
178 
179  Vertex 6 single
180  */
181 
182 
183  // Check the boundary faces
184  EXPECT_TRUE ( mesh_.is_boundary( face_handles[0] ) ) << "Face 0 is not boundary!";
185  EXPECT_TRUE ( mesh_.is_boundary( face_handles[1] ) ) << "Face 1 is not boundary!";
186  EXPECT_TRUE ( mesh_.is_boundary( face_handles[2] ) ) << "Face 2 is not boundary!";
187  EXPECT_FALSE( mesh_.is_boundary( face_handles[3] ) ) << "Face 3 is boundary!";
188  EXPECT_TRUE ( mesh_.is_boundary( face_handles[4] ) ) << "Face 4 is not boundary!";
189 
190 }
191 }
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Definition: PolyMeshT.hh:236
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139