prevent duplicated nodes at existing vertex between faces intersecting

This commit is contained in:
Sébastien Loriot 2018-03-01 16:19:23 +01:00
parent 29eeac3e3d
commit 26dec7527a
1 changed files with 15 additions and 4 deletions

View File

@ -163,6 +163,7 @@ class Intersection_of_triangle_meshes
typedef typename graph_traits::face_descriptor face_descriptor; typedef typename graph_traits::face_descriptor face_descriptor;
typedef typename graph_traits::edge_descriptor edge_descriptor; typedef typename graph_traits::edge_descriptor edge_descriptor;
typedef typename graph_traits::halfedge_descriptor halfedge_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<double, 3, halfedge_descriptor> Box; typedef typename CGAL::Box_intersection_d::Box_with_info_d<double, 3, halfedge_descriptor> Box;
@ -1163,6 +1164,7 @@ class Intersection_of_triangle_meshes
{ {
const TriangleMesh& tm = nodes.tm1; const TriangleMesh& tm = nodes.tm1;
CGAL_assertion(doing_autorefinement); CGAL_assertion(doing_autorefinement);
std::map<vertex_descriptor, Node_id> vertex_to_node_id;
for (typename Faces_to_nodes_map::iterator it=f_to_node.begin(); for (typename Faces_to_nodes_map::iterator it=f_to_node.begin();
it!=f_to_node.end(); ++it) it!=f_to_node.end(); ++it)
{ {
@ -1177,9 +1179,17 @@ class Intersection_of_triangle_meshes
{ {
if ( target(h1, tm)==target(h2,tm) ) if ( target(h1, tm)==target(h2,tm) )
{ {
Node_id node_id=++current_node; Node_id node_id = current_node+1;
nodes.add_new_node(get(nodes.vpm1, target(h1,tm))); std::pair< typename std::map<vertex_descriptor, Node_id>::iterator, bool>
visitor.new_node_added(node_id,ON_VERTEX,h1,h2,tm,tm,true,false); 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); it->second.insert(node_id);
break; break;
} }
@ -1320,11 +1330,12 @@ public:
/// TODO AUTOREF_TAG does this happen in coplanar cases only? + shall we do it have new edge splitting? /// TODO AUTOREF_TAG does this happen in coplanar cases only? + shall we do it have new edge splitting?
remove_duplicated_intersecting_edges(); 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 // If a pair of faces defines an isolated node, check if they share a common
// vertex and create a new node in that case. // vertex and create a new node in that case.
add_common_vertices_for_pairs_of_faces_with_isolated_node(current_node); add_common_vertices_for_pairs_of_faces_with_isolated_node(current_node);
detect_intersections_in_the_graph(tm, vpm, current_node);
#if 0 #if 0
//collect connectivity infos and create polylines //collect connectivity infos and create polylines
if ( Node_visitor::do_need_vertex_graph ) if ( Node_visitor::do_need_vertex_graph )