OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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