diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h index eddef61a954..c7876d0d4cb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Output_builder_for_autorefinement.h @@ -801,7 +801,7 @@ public: // parts of a mesh (ex: a square in crossing the interior // of a larger). In practice, we could say this is not an // issue if anyway the whole patch would be dropped. - // Note that this remark is value for all cases where + // Note that this remark is valid for all cases where // all_fixed is set to false. if (patch_id_p1==patch_id_p2 || patch_id_q1==patch_id_q2) { diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h index 926ea76c2dd..f6f4ebd128c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h @@ -339,7 +339,10 @@ public: Node_id node_id, TriangleMesh& tm) { - mesh_to_vertex_to_node_id[&tm].insert(std::make_pair(target(h,tm),node_id)); + CGAL_assertion_code(bool insert_ok = ) + mesh_to_vertex_to_node_id[&tm].insert(std::make_pair(target(h,tm),node_id)) + CGAL_assertion_code(.second); + CGAL_assertion(insert_ok || mesh_to_vertex_to_node_id[&tm][target(h,tm)]==node_id); } void new_node_added_triple_face(std::size_t node_id, 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..741ffc2ae00 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; @@ -194,6 +195,7 @@ class Intersection_of_triangle_meshes Node_vector nodes; Node_visitor visitor; Faces_to_nodes_map f_to_node; //Associate a pair of triangles to their intersection points + std::vector extra_terminal_nodes; //used only for autorefinement CGAL_assertion_code(bool doing_autorefinement;) // member functions void filter_intersections(const TriangleMesh& tm_f, @@ -1050,6 +1052,13 @@ class Intersection_of_triangle_meshes } } + CGAL_assertion(extra_terminal_nodes.empty() || doing_autorefinement); + // these nodes are created by pinchements along an edge of the surface. + // the node ids being the same for the two edges, the degree of the node + // in the graph is two while it should be 3 + BOOST_FOREACH(Node_id id, extra_terminal_nodes) + graph[id].make_terminal(); + //visitor call visitor.annotate_graph(graph); @@ -1163,6 +1172,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 +1187,18 @@ 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); + extra_terminal_nodes.push_back(node_id); + } + else + node_id = insert_res.first->second; it->second.insert(node_id); break; } @@ -1320,11 +1339,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 ) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h index 26832b6b3e2..85285e265b9 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_nodes.h @@ -320,6 +320,7 @@ class Intersection_nodes::type inter_res = intersection(p1, p2, p3); + + CGAL_assertion(inter_res != boost::none); + const Point_3* pt = + boost::get(&(*inter_res)); + CGAL_assertion(pt!=NULL); + add_new_node(*pt); + } + //add a new node in the final graph. //it is the intersection of the triangle with the segment void add_new_node(halfedge_descriptor h_a,