diff --git a/BGL/include/CGAL/boost/graph/Euler_operations.h b/BGL/include/CGAL/boost/graph/Euler_operations.h index ece862d5dc7..74bf7bd3f2f 100644 --- a/BGL/include/CGAL/boost/graph/Euler_operations.h +++ b/BGL/include/CGAL/boost/graph/Euler_operations.h @@ -585,8 +585,11 @@ add_edge(typename boost::graph_traits::vertex_descriptor s, * checks whether a new face defined by a range of vertices (identified by their descriptors, * `boost::graph_traits::%vertex_descriptor`) can be added. */ -template -bool can_add_face(const VertexRange& vrange, const PMesh& sm) +template +bool can_add_face(const VertexRange& vrange, + const PMesh& sm, + const bool verbose = false) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -603,10 +606,16 @@ bool can_add_face(const VertexRange& vrange, const PMesh& sm) typename std::vector::iterator it = std::unique(f2.begin(),f2.end()); if((N > 0) && (it != f2.end())){ + if (verbose){ + std::cerr << "Cannot add face: face contains duplicate vertices." << std::endl; + } return false; } if(N < 3){ + if (verbose){ + std::cerr << "Cannot add face: face must contain at least 3 vertices." << std::endl; + } return false; } @@ -617,6 +626,9 @@ bool can_add_face(const VertexRange& vrange, const PMesh& sm) bool found; std::tie(hd,found) = halfedge(face[i],face[i+1],sm); if(found && (! is_border(hd,sm))){ + if (verbose){ + std::cerr << "Cannot add face: face contains an edge that is not a border halfedge." << std::endl; + } return false; } } @@ -627,6 +639,9 @@ bool can_add_face(const VertexRange& vrange, const PMesh& sm) } if(! is_border(face[i],sm)){ + if (verbose){ + std::cerr << "Cannot add face: face contains a vertex that is not a border vertex." << std::endl; + } return false; } } @@ -648,8 +663,9 @@ bool can_add_face(const VertexRange& vrange, const PMesh& sm) if ( halfedge_around_vertex == boost::graph_traits::null_halfedge() || halfedge(previous_vertex,sm) == boost::graph_traits::null_halfedge()|| - halfedge(next_vertex,sm) == boost::graph_traits::null_halfedge() - ) continue; + halfedge(next_vertex,sm) == boost::graph_traits::null_halfedge() ) { + continue; + } halfedge_descriptor start=halfedge_around_vertex; //halfedges pointing to/running out from vertex indices[i] @@ -694,7 +710,12 @@ bool can_add_face(const VertexRange& vrange, const PMesh& sm) if ( is_border(opposite(halfedge_around_vertex,sm),sm) ) break; } while (halfedge_around_vertex != prev_hd); - if (halfedge_around_vertex == prev_hd) return false; + if (halfedge_around_vertex == prev_hd) { + if (verbose){ + std::cerr << "Cannot add face: halfedge_around_vertex == prev_hd" << std::endl; + } + return false; + } start = halfedge_around_vertex; } } @@ -703,7 +724,6 @@ bool can_add_face(const VertexRange& vrange, const PMesh& sm) } - /** * adds a new face defined by a range of vertices (identified by their descriptors, * `boost::graph_traits::%vertex_descriptor`).