From c2e849935ee5a16ca56d2a51ca84920a673b8dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 12 Mar 2018 11:38:38 +0100 Subject: [PATCH] handle isolated vertices --- .../Polygon_mesh_processing/orientation.h | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 5228ded538a..15d3299f895 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -73,6 +73,8 @@ namespace internal{ using boost::choose_param; using boost::get_param; + CGAL_assertion(halfedge(v_max, pmesh)!=boost::graph_traits::null_halfedge()); + //VertexPointMap typedef typename GetVertexPointMap::const_type VPMap; VPMap vpmap = choose_param(get_param(np, vertex_point), @@ -193,13 +195,22 @@ bool is_outward_oriented(const PolygonMesh& pmesh, GT gt = choose_param(get_param(np, internal_np::geom_traits), GT()); //find the vertex with maximal z coordinate - typename boost::graph_traits::vertex_iterator vbegin, vend; - cpp11::tie(vbegin, vend) = vertices(pmesh); - internal::Compare_vertex_points_z_3 less_z(vpmap, gt); - typename boost::graph_traits::vertex_iterator v_max_it - = std::max_element(vbegin, vend, less_z); - typename boost::graph_traits::vertex_descriptor v_max = *v_max_it; + typename boost::graph_traits::vertex_descriptor v_max = *(vertices(pmesh).first); + for (typename boost::graph_traits::vertex_iterator + vit=cpp11::next(vertices(pmesh).first), vit_end = vertices(pmesh).second; + vit!=vit_end; ++vit) + { + // skip isolated vertices + if (halfedge(*vit, pmesh)==boost::graph_traits::null_halfedge()) + continue; + if( less_z(v_max, *vit) ) + v_max=*vit; + } + + // only isolated vertices + if (halfedge(v_max, pmesh)==boost::graph_traits::null_halfedge()) + return true; return internal::is_outward_oriented(v_max, pmesh, np); }