From 33766800b6da78d53bd65b0f963ad9afcde15fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 3 Feb 2020 18:10:41 +0100 Subject: [PATCH] Fix some corner cases with the new compute normals and degenerate faces --- .../Polygon_mesh_processing/compute_normal.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index a149ef1155f..0c254332e78 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -311,18 +311,18 @@ typename GT::Vector_3 compute_normals_bisector(const typename GT::Vector_3& ni, Vector_3 nb = cv_3(CGAL::NULL_VECTOR); - if(almost_equal(ni, nj, traits)) + if(almost_equal(ni, nj, traits) || nk == CGAL::NULL_VECTOR) { if(almost_equal(nj, nk, traits)) nb = ni; else // ni == nj, but nij != nk nb = compute_normals_bisector(nj, nk, traits); } - else if(almost_equal(ni, nk, traits)) // ni != nj + else if(almost_equal(ni, nk, traits) || nj == CGAL::NULL_VECTOR) // ni != nj { nb = compute_normals_bisector(nj, nk, traits); } - else if(almost_equal(nj, nk, traits)) // ni != nj, ni != nk + else if(almost_equal(nj, nk, traits) || ni == CGAL::NULL_VECTOR) // ni != nj, ni != nk { nb = compute_normals_bisector(ni, nk, traits); } @@ -345,7 +345,7 @@ typename GT::Vector_3 compute_normals_bisector(const typename GT::Vector_3& ni, return csv_3(csv_3(cslv_3(ni, third), cslv_3(nj, third)), cslv_3(nk, third)); } - nb = cv_3(CGAL::ORIGIN, c); // note that this isn't normalized + nb = cv_3(CGAL::ORIGIN, c); // not normalized } return nb; @@ -432,6 +432,10 @@ compute_most_visible_normal_3_points(const std::vector 2); + // The vertex has only two incident faces with opposite normals (fold)... + // @todo devise something based on the directions of the 2/3/4 incident edges? + if(incident_faces.size() == 2 && res == CGAL::NULL_VECTOR) + return res; + + CGAL_assertion(incident_faces.size() >= 2); return compute_most_visible_normal_3_points(incident_faces, face_normals, traits); }