1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 13 virtual void SetUp() {
17 virtual void TearDown() {
31 virtual void SetUp() {
37 virtual void TearDown() {
57 TEST_F(OpenMeshNormals, NormalCalculationSingleFaceTriMesh) {
68 std::vector<Mesh::VertexHandle> face_vhandles;
69 face_vhandles.push_back(vhandle[0]);
70 face_vhandles.push_back(vhandle[1]);
71 face_vhandles.push_back(vhandle[2]);
73 Mesh::FaceHandle fh = mesh_.add_face(face_vhandles);
76 mesh_.request_vertex_normals();
77 mesh_.request_halfedge_normals();
78 mesh_.request_face_normals();
82 EXPECT_EQ( mesh_.normal(fh)[0] ,0.0f );
83 EXPECT_EQ( mesh_.normal(fh)[1] ,0.0f );
84 EXPECT_EQ( mesh_.normal(fh)[2] ,1.0f );
91 TEST_F(OpenMeshNormalsPolyMesh, NormalCalculationSingleFacePolyMesh) {
96 PolyMesh::VertexHandle vhandle[4];
102 std::vector<Mesh::VertexHandle> face_vhandles;
103 face_vhandles.push_back(vhandle[0]);
104 face_vhandles.push_back(vhandle[1]);
105 face_vhandles.push_back(vhandle[2]);
107 PolyMesh::FaceHandle fh = mesh_.add_face(face_vhandles);
110 mesh_.request_vertex_normals();
111 mesh_.request_halfedge_normals();
112 mesh_.request_face_normals();
116 EXPECT_EQ( mesh_.normal(fh)[0] ,0.0f );
117 EXPECT_EQ( mesh_.normal(fh)[1] ,0.0f );
118 EXPECT_EQ( mesh_.normal(fh)[2] ,1.0f );
125 TEST_F(OpenMeshNormals, NormalCalculations) {
138 std::vector<Mesh::VertexHandle> face_vhandles;
140 face_vhandles.push_back(vhandle[0]);
141 face_vhandles.push_back(vhandle[1]);
142 face_vhandles.push_back(vhandle[2]);
143 mesh_.add_face(face_vhandles);
145 face_vhandles.clear();
147 face_vhandles.push_back(vhandle[0]);
148 face_vhandles.push_back(vhandle[2]);
149 face_vhandles.push_back(vhandle[3]);
150 mesh_.add_face(face_vhandles);
152 face_vhandles.clear();
154 face_vhandles.push_back(vhandle[2]);
155 face_vhandles.push_back(vhandle[1]);
156 face_vhandles.push_back(vhandle[3]);
157 mesh_.add_face(face_vhandles);
159 face_vhandles.clear();
161 face_vhandles.push_back(vhandle[3]);
162 face_vhandles.push_back(vhandle[1]);
163 face_vhandles.push_back(vhandle[0]);
164 mesh_.add_face(face_vhandles);
175 mesh_.request_vertex_normals();
176 mesh_.request_halfedge_normals();
182 mesh_.request_face_normals();
199 TEST_F(OpenMeshNormals, NormalCalculations_calc_vertex_normal_fast) {
212 std::vector<Mesh::VertexHandle> face_vhandles;
214 face_vhandles.push_back(vhandle[0]);
215 face_vhandles.push_back(vhandle[1]);
216 face_vhandles.push_back(vhandle[2]);
217 mesh_.add_face(face_vhandles);
219 face_vhandles.clear();
221 face_vhandles.push_back(vhandle[0]);
222 face_vhandles.push_back(vhandle[2]);
223 face_vhandles.push_back(vhandle[3]);
224 mesh_.add_face(face_vhandles);
226 face_vhandles.clear();
228 face_vhandles.push_back(vhandle[2]);
229 face_vhandles.push_back(vhandle[1]);
230 face_vhandles.push_back(vhandle[3]);
231 mesh_.add_face(face_vhandles);
233 face_vhandles.clear();
235 face_vhandles.push_back(vhandle[3]);
236 face_vhandles.push_back(vhandle[1]);
237 face_vhandles.push_back(vhandle[0]);
238 mesh_.add_face(face_vhandles);
245 mesh_.request_vertex_normals();
246 mesh_.request_halfedge_normals();
247 mesh_.request_face_normals();
256 TEST_F(OpenMeshNormals, NormalCalculations_calc_vertex_normal_correct) {
269 std::vector<Mesh::VertexHandle> face_vhandles;
271 face_vhandles.push_back(vhandle[0]);
272 face_vhandles.push_back(vhandle[1]);
273 face_vhandles.push_back(vhandle[2]);
274 mesh_.add_face(face_vhandles);
276 face_vhandles.clear();
278 face_vhandles.push_back(vhandle[0]);
279 face_vhandles.push_back(vhandle[2]);
280 face_vhandles.push_back(vhandle[3]);
281 mesh_.add_face(face_vhandles);
283 face_vhandles.clear();
285 face_vhandles.push_back(vhandle[2]);
286 face_vhandles.push_back(vhandle[1]);
287 face_vhandles.push_back(vhandle[3]);
288 mesh_.add_face(face_vhandles);
290 face_vhandles.clear();
292 face_vhandles.push_back(vhandle[3]);
293 face_vhandles.push_back(vhandle[1]);
294 face_vhandles.push_back(vhandle[0]);
295 mesh_.add_face(face_vhandles);
303 mesh_.request_vertex_normals();
304 mesh_.request_halfedge_normals();
305 mesh_.request_face_normals();
314 TEST_F(OpenMeshNormals, NormalCalculations_calc_vertex_normal_loop) {
327 std::vector<Mesh::VertexHandle> face_vhandles;
329 face_vhandles.push_back(vhandle[0]);
330 face_vhandles.push_back(vhandle[1]);
331 face_vhandles.push_back(vhandle[2]);
332 mesh_.add_face(face_vhandles);
334 face_vhandles.clear();
336 face_vhandles.push_back(vhandle[0]);
337 face_vhandles.push_back(vhandle[2]);
338 face_vhandles.push_back(vhandle[3]);
339 mesh_.add_face(face_vhandles);
341 face_vhandles.clear();
343 face_vhandles.push_back(vhandle[2]);
344 face_vhandles.push_back(vhandle[1]);
345 face_vhandles.push_back(vhandle[3]);
346 mesh_.add_face(face_vhandles);
348 face_vhandles.clear();
350 face_vhandles.push_back(vhandle[3]);
351 face_vhandles.push_back(vhandle[1]);
352 face_vhandles.push_back(vhandle[0]);
353 mesh_.add_face(face_vhandles);
360 mesh_.request_vertex_normals();
361 mesh_.request_halfedge_normals();
362 mesh_.request_face_normals();
void update_normals()
Compute normals for all primitives.
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
void calc_vertex_normal_loop(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
void update_face_normals()
Update normal vectors for all faces.
void calc_vertex_normal_fast(VertexHandle _vh, Normal &_n) const
Kernel::Point Point
Coordinate type.
void update_vertex_normals()
Update normal vectors for all vertices.
void calc_vertex_normal_correct(VertexHandle _vh, Normal &_n) const
Compute normals for all primitives.