2 #include <gtest/gtest.h> 3 #include <Unittests/unittests_common.hh> 6 #include <OpenMesh/Tools/Subdivider/Uniform/MidpointT.hh> 13 virtual void SetUp() {
18 virtual void TearDown() {
26 class OpenMeshSubdividerUniform_Triangle :
public OpenMeshBase {
29 virtual void SetUp() {
34 virtual void TearDown() {
48 TEST_F(OpenMeshSubdividerUniform_Triangle, Subdivider_Sqrt3) {
65 std::vector<Mesh::VertexHandle> face_vhandles;
67 face_vhandles.push_back(vhandle[0]);
68 face_vhandles.push_back(vhandle[4]);
69 face_vhandles.push_back(vhandle[3]);
71 mesh_.add_face(face_vhandles);
72 face_vhandles.clear();
74 face_vhandles.push_back(vhandle[0]);
75 face_vhandles.push_back(vhandle[1]);
76 face_vhandles.push_back(vhandle[4]);
78 mesh_.add_face(face_vhandles);
79 face_vhandles.clear();
81 face_vhandles.push_back(vhandle[1]);
82 face_vhandles.push_back(vhandle[2]);
83 face_vhandles.push_back(vhandle[4]);
85 mesh_.add_face(face_vhandles);
86 face_vhandles.clear();
88 face_vhandles.push_back(vhandle[2]);
89 face_vhandles.push_back(vhandle[5]);
90 face_vhandles.push_back(vhandle[4]);
92 mesh_.add_face(face_vhandles);
93 face_vhandles.clear();
95 face_vhandles.push_back(vhandle[3]);
96 face_vhandles.push_back(vhandle[7]);
97 face_vhandles.push_back(vhandle[6]);
99 mesh_.add_face(face_vhandles);
100 face_vhandles.clear();
102 face_vhandles.push_back(vhandle[3]);
103 face_vhandles.push_back(vhandle[4]);
104 face_vhandles.push_back(vhandle[7]);
106 mesh_.add_face(face_vhandles);
107 face_vhandles.clear();
109 face_vhandles.push_back(vhandle[4]);
110 face_vhandles.push_back(vhandle[8]);
111 face_vhandles.push_back(vhandle[7]);
113 mesh_.add_face(face_vhandles);
114 face_vhandles.clear();
116 face_vhandles.push_back(vhandle[4]);
117 face_vhandles.push_back(vhandle[5]);
118 face_vhandles.push_back(vhandle[8]);
120 mesh_.add_face(face_vhandles);
137 EXPECT_EQ(9u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
138 EXPECT_EQ(8u, mesh_.n_faces() ) <<
"Wrong number of faces";
146 EXPECT_EQ(121u, mesh_.n_vertices() ) <<
"Wrong number of vertices after subdivision with sqrt3";
147 EXPECT_EQ(216u, mesh_.n_faces() ) <<
"Wrong number of faces after subdivision with sqrt3";
158 TEST_F(OpenMeshSubdividerUniform_Poly, Subdivider_CatmullClark) {
175 std::vector<Mesh::VertexHandle> face_vhandles;
177 face_vhandles.push_back(vhandle[0]);
178 face_vhandles.push_back(vhandle[1]);
179 face_vhandles.push_back(vhandle[4]);
180 face_vhandles.push_back(vhandle[3]);
182 mesh_.add_face(face_vhandles);
183 face_vhandles.clear();
185 face_vhandles.push_back(vhandle[1]);
186 face_vhandles.push_back(vhandle[2]);
187 face_vhandles.push_back(vhandle[5]);
188 face_vhandles.push_back(vhandle[4]);
190 mesh_.add_face(face_vhandles);
191 face_vhandles.clear();
193 face_vhandles.push_back(vhandle[4]);
194 face_vhandles.push_back(vhandle[5]);
195 face_vhandles.push_back(vhandle[8]);
196 face_vhandles.push_back(vhandle[7]);
198 mesh_.add_face(face_vhandles);
199 face_vhandles.clear();
201 face_vhandles.push_back(vhandle[3]);
202 face_vhandles.push_back(vhandle[4]);
203 face_vhandles.push_back(vhandle[7]);
204 face_vhandles.push_back(vhandle[6]);
206 mesh_.add_face(face_vhandles);
223 EXPECT_EQ(9u, mesh_.n_vertices() ) <<
"Wrong number of vertices";
224 EXPECT_EQ(4u, mesh_.n_faces() ) <<
"Wrong number of faces";
231 EXPECT_EQ(289u, mesh_.n_vertices() ) <<
"Wrong number of vertices after subdivision with catmull clark";
232 EXPECT_EQ(256u, mesh_.n_faces() ) <<
"Wrong number of faces after subdivision with catmull clark";
237 TEST_F(OpenMeshSubdividerUniform_Poly, Midpoint) {
252 std::vector<Mesh::VertexHandle> face_vhandles;
254 face_vhandles.clear();
255 face_vhandles.push_back(vhandle[0]);
256 face_vhandles.push_back(vhandle[1]);
257 face_vhandles.push_back(vhandle[2]);
258 face_vhandles.push_back(vhandle[3]);
259 mesh_.add_face(face_vhandles);
261 face_vhandles.clear();
262 face_vhandles.push_back(vhandle[7]);
263 face_vhandles.push_back(vhandle[6]);
264 face_vhandles.push_back(vhandle[5]);
265 face_vhandles.push_back(vhandle[4]);
266 mesh_.add_face(face_vhandles);
268 face_vhandles.clear();
269 face_vhandles.push_back(vhandle[1]);
270 face_vhandles.push_back(vhandle[0]);
271 face_vhandles.push_back(vhandle[4]);
272 face_vhandles.push_back(vhandle[5]);
273 mesh_.add_face(face_vhandles);
275 face_vhandles.clear();
276 face_vhandles.push_back(vhandle[2]);
277 face_vhandles.push_back(vhandle[1]);
278 face_vhandles.push_back(vhandle[5]);
279 face_vhandles.push_back(vhandle[6]);
280 mesh_.add_face(face_vhandles);
282 face_vhandles.clear();
283 face_vhandles.push_back(vhandle[3]);
284 face_vhandles.push_back(vhandle[2]);
285 face_vhandles.push_back(vhandle[6]);
286 face_vhandles.push_back(vhandle[7]);
287 mesh_.add_face(face_vhandles);
289 face_vhandles.clear();
290 face_vhandles.push_back(vhandle[0]);
291 face_vhandles.push_back(vhandle[3]);
292 face_vhandles.push_back(vhandle[7]);
293 face_vhandles.push_back(vhandle[4]);
294 mesh_.add_face(face_vhandles);
312 EXPECT_EQ(12u, mesh_.n_edges()) <<
"Wrong number of Edges";
313 EXPECT_EQ(24u, mesh_.n_halfedges()) <<
"Wrong number of HalfEdges";
314 EXPECT_EQ(8u, mesh_.n_vertices()) <<
"Wrong number of vertices";
315 EXPECT_EQ(6u, mesh_.n_faces()) <<
"Wrong number of faces";
326 EXPECT_EQ(48u, mesh_.n_edges()) <<
"Wrong number of Edges";
327 EXPECT_EQ(96u, mesh_.n_halfedges()) <<
"Wrong number of HalfEdges";
328 EXPECT_EQ(24u, mesh_.n_vertices()) <<
"Wrong number of vertices";
329 EXPECT_EQ(26u, mesh_.n_faces()) <<
"Wrong number of faces";
Kernel::Point Point
Coordinate type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
bool attach(MeshType &_m)