From 26dec7527aed7fc988e113c40cbc9cb7ea65d00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 1 Mar 2018 16:19:23 +0100 Subject: [PATCH] prevent duplicated nodes at existing vertex between faces intersecting --- .../internal/Corefinement/intersection_impl.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h index 332f9196084..7c4e96b8956 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_impl.h @@ -163,6 +163,7 @@ class Intersection_of_triangle_meshes typedef typename graph_traits::face_descriptor face_descriptor; typedef typename graph_traits::edge_descriptor edge_descriptor; typedef typename graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename graph_traits::vertex_descriptor vertex_descriptor; typedef typename CGAL::Box_intersection_d::Box_with_info_d Box; @@ -1163,6 +1164,7 @@ class Intersection_of_triangle_meshes { const TriangleMesh& tm = nodes.tm1; CGAL_assertion(doing_autorefinement); + std::map vertex_to_node_id; for (typename Faces_to_nodes_map::iterator it=f_to_node.begin(); it!=f_to_node.end(); ++it) { @@ -1177,9 +1179,17 @@ class Intersection_of_triangle_meshes { if ( target(h1, tm)==target(h2,tm) ) { - Node_id node_id=++current_node; - nodes.add_new_node(get(nodes.vpm1, target(h1,tm))); - visitor.new_node_added(node_id,ON_VERTEX,h1,h2,tm,tm,true,false); + Node_id node_id = current_node+1; + std::pair< typename std::map::iterator, bool> + insert_res = vertex_to_node_id.insert(std::make_pair(target(h1,tm), node_id)); + if (insert_res.second) + { + ++current_node; + nodes.add_new_node(get(nodes.vpm1, target(h1,tm))); + visitor.new_node_added(node_id,ON_VERTEX,h1,h2,tm,tm,true,false); + } + else + node_id = insert_res.first->second; it->second.insert(node_id); break; } @@ -1320,11 +1330,12 @@ public: /// TODO AUTOREF_TAG does this happen in coplanar cases only? + shall we do it have new edge splitting? remove_duplicated_intersecting_edges(); - detect_intersections_in_the_graph(tm, vpm, current_node); // If a pair of faces defines an isolated node, check if they share a common // vertex and create a new node in that case. add_common_vertices_for_pairs_of_faces_with_isolated_node(current_node); + + detect_intersections_in_the_graph(tm, vpm, current_node); #if 0 //collect connectivity infos and create polylines if ( Node_visitor::do_need_vertex_graph )