2 #include <gtest/gtest.h> 3 #include <Unittests/unittests_common.hh> 14 virtual void SetUp() {
20 virtual void TearDown() {
29 class OpenMeshSubdividerAdaptive_Triangle :
public OpenMeshBase {
34 virtual void SetUp() {
40 virtual void TearDown() {
66 typedef MyMesh::FaceHandle FHandle;
68 TEST_F(OpenMeshSubdividerAdaptive_Triangle, AdaptiveCompositeRefineVertex) {
71 mesh.request_vertex_status();
72 mesh.request_edge_status();
73 mesh.request_face_status();
74 mesh.request_vertex_normals();
75 mesh.request_face_normals();
91 std::vector<VHandle> face_vhandles;
93 face_vhandles.push_back(vhandle[0]);
94 face_vhandles.push_back(vhandle[4]);
95 face_vhandles.push_back(vhandle[3]);
97 mesh.add_face(face_vhandles);
98 face_vhandles.clear();
100 face_vhandles.push_back(vhandle[0]);
101 face_vhandles.push_back(vhandle[1]);
102 face_vhandles.push_back(vhandle[4]);
104 mesh.add_face(face_vhandles);
105 face_vhandles.clear();
107 face_vhandles.push_back(vhandle[1]);
108 face_vhandles.push_back(vhandle[2]);
109 face_vhandles.push_back(vhandle[4]);
111 mesh.add_face(face_vhandles);
112 face_vhandles.clear();
114 face_vhandles.push_back(vhandle[2]);
115 face_vhandles.push_back(vhandle[5]);
116 face_vhandles.push_back(vhandle[4]);
118 mesh.add_face(face_vhandles);
119 face_vhandles.clear();
121 face_vhandles.push_back(vhandle[3]);
122 face_vhandles.push_back(vhandle[7]);
123 face_vhandles.push_back(vhandle[6]);
125 mesh.add_face(face_vhandles);
126 face_vhandles.clear();
128 face_vhandles.push_back(vhandle[3]);
129 face_vhandles.push_back(vhandle[4]);
130 face_vhandles.push_back(vhandle[7]);
132 mesh.add_face(face_vhandles);
133 face_vhandles.clear();
135 face_vhandles.push_back(vhandle[4]);
136 face_vhandles.push_back(vhandle[8]);
137 face_vhandles.push_back(vhandle[7]);
139 mesh.add_face(face_vhandles);
140 face_vhandles.clear();
142 face_vhandles.push_back(vhandle[4]);
143 face_vhandles.push_back(vhandle[5]);
144 face_vhandles.push_back(vhandle[8]);
146 mesh.add_face(face_vhandles);
167 subdivider.initialize();
170 EXPECT_EQ(9u, mesh.n_vertices() ) <<
"Wrong number of vertices";
171 EXPECT_EQ(8u, mesh.n_faces() ) <<
"Wrong number of faces";
174 subdivider.refine(vhandle[4]);
178 EXPECT_EQ(17u, mesh.n_vertices() ) <<
"Wrong number of vertices after subdivision with sqrt3";
179 EXPECT_EQ(24u, mesh.n_faces() ) <<
"Wrong number of faces after subdivision with sqrt3";
183 TEST_F(OpenMeshSubdividerAdaptive_Triangle, AdaptiveCompositeRefineFace) {
186 mesh.request_vertex_status();
187 mesh.request_edge_status();
188 mesh.request_face_status();
189 mesh.request_vertex_normals();
190 mesh.request_face_normals();
206 std::vector<VHandle> face_vhandles;
207 std::vector<FHandle> face_handles;
209 face_vhandles.push_back(vhandle[0]);
210 face_vhandles.push_back(vhandle[4]);
211 face_vhandles.push_back(vhandle[3]);
213 face_handles.push_back(mesh.add_face(face_vhandles));
214 face_vhandles.clear();
216 face_vhandles.push_back(vhandle[0]);
217 face_vhandles.push_back(vhandle[1]);
218 face_vhandles.push_back(vhandle[4]);
220 face_handles.push_back(mesh.add_face(face_vhandles));
221 face_vhandles.clear();
223 face_vhandles.push_back(vhandle[1]);
224 face_vhandles.push_back(vhandle[2]);
225 face_vhandles.push_back(vhandle[4]);
227 face_handles.push_back(mesh.add_face(face_vhandles));
228 face_vhandles.clear();
230 face_vhandles.push_back(vhandle[2]);
231 face_vhandles.push_back(vhandle[5]);
232 face_vhandles.push_back(vhandle[4]);
234 face_handles.push_back(mesh.add_face(face_vhandles));
235 face_vhandles.clear();
237 face_vhandles.push_back(vhandle[3]);
238 face_vhandles.push_back(vhandle[7]);
239 face_vhandles.push_back(vhandle[6]);
241 face_handles.push_back(mesh.add_face(face_vhandles));
242 face_vhandles.clear();
244 face_vhandles.push_back(vhandle[3]);
245 face_vhandles.push_back(vhandle[4]);
246 face_vhandles.push_back(vhandle[7]);
248 face_handles.push_back(mesh.add_face(face_vhandles));
249 face_vhandles.clear();
251 face_vhandles.push_back(vhandle[4]);
252 face_vhandles.push_back(vhandle[8]);
253 face_vhandles.push_back(vhandle[7]);
255 face_handles.push_back(mesh.add_face(face_vhandles));
256 face_vhandles.clear();
258 face_vhandles.push_back(vhandle[4]);
259 face_vhandles.push_back(vhandle[5]);
260 face_vhandles.push_back(vhandle[8]);
262 face_handles.push_back(mesh.add_face(face_vhandles));
283 subdivider.initialize();
286 EXPECT_EQ(9u, mesh.n_vertices() ) <<
"Wrong number of vertices";
287 EXPECT_EQ(8u, mesh.n_faces() ) <<
"Wrong number of faces";
290 std::vector<FHandle>::iterator it, end;
291 it = face_handles.begin();
292 end = face_handles.end();
293 for (; it != end; ++it)
294 subdivider.refine(*it);
298 EXPECT_EQ(245u, mesh.n_vertices() ) <<
"Wrong number of vertices after subdivision with sqrt3";
299 EXPECT_EQ(458u, mesh.n_faces() ) <<
"Wrong number of faces after subdivision with sqrt3";
Add normals to mesh item (vertices/faces)
#define VertexAttributes(_i)
Macro for defining the vertex attributes. See Specifying your MyMesh.
Add status to mesh item (all items)
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
#define FaceAttributes(_i)
Macro for defining the face attributes. See Specifying your MyMesh.
Kernel::Point Point
Coordinate type.
#define EdgeAttributes(_i)
Macro for defining the edge attributes. See Specifying your MyMesh.