From 15a546084c144b134eab6895a09bb50172be6934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 10 Oct 2019 17:22:19 +0200 Subject: [PATCH] be more robust to degenerate and almost degenerate faces --- .../internal/Surface_mesh_segmentation/SDF_calculation.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h index b4d79c41816..7196f539672 100644 --- a/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h +++ b/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/SDF_calculation.h @@ -126,6 +126,7 @@ private: typename GeomTraits::Construct_normal_3 normal_functor; typename GeomTraits::Construct_translated_point_3 translated_point_functor; typename GeomTraits::Construct_centroid_3 centroid_functor; + typename GeomTraits::Collinear_3 collinear_functor; Tree tree; @@ -153,11 +154,11 @@ public: normal_functor(traits.construct_normal_3_object()), translated_point_functor(traits.construct_translated_point_3_object()), centroid_functor(traits.construct_centroid_3_object()), + collinear_functor(traits.collinear_3_object()), tree(create_traits(mesh, vertex_point_map)), use_diagonal(use_diagonal) { typedef typename boost::property_traits::reference Point_ref; - typename GeomTraits::Collinear_3 collinear = traits.collinear_3_object(); face_iterator it, end; for(it = faces(mesh).begin(), end = faces(mesh).end(); it!=end; it++) { @@ -167,7 +168,7 @@ public: Point_ref b(get(vertex_point_map,target(h, mesh))); h = next(h, mesh); Point_ref c(get(vertex_point_map, target(h, mesh))); - bool test = collinear(a,b,c); + bool test = collinear_functor(a,b,c); if(!test) tree.insert(Primitive(it, mesh, vertex_point_map)); } @@ -388,10 +389,11 @@ private: const Point p2 = get(vertex_point_map,target(next(halfedge(facet,mesh),mesh),mesh)); const Point p3 = get(vertex_point_map,target(prev(halfedge(facet,mesh),mesh),mesh)); const Point center = centroid_functor(p1, p2, p3); + if (collinear_functor(p1, p2, p3)) return boost::none; Vector normal = normal_functor(p2, p1, p3); normal=scale_functor(normal, FT(1.0/std::sqrt(to_double(normal.squared_length())))); - + if (normal!=normal) return boost::none; CGAL::internal::SkipPrimitiveFunctor skip(facet); CGAL::internal::FirstIntersectionVisitor