From c668b903799ed76b33bd52e75d560e509c8ee97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 1 Mar 2018 16:09:55 +0100 Subject: [PATCH 1/5] add assertion and fix comment --- .../internal/Corefinement/Output_builder_for_autorefinement.h | 2 +- .../Polygon_mesh_processing/internal/Corefinement/Visitor.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 b5b221b838b..6bd505327d0 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,9 @@ 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)).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, From 29eeac3e3d4f9933c5f065ce313d3168159e2234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 1 Mar 2018 16:10:14 +0100 Subject: [PATCH 2/5] make autorefinement working with exact constructions --- .../Corefinement/intersection_nodes.h | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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, 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 3/5] 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 ) From 8817f067d1f4ff8b9b66d4c0e8d70d4bbfa6b265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 2 Mar 2018 09:52:32 +0100 Subject: [PATCH 4/5] mark vertices as terminal if incident to edge where the surface is pinched --- .../internal/Corefinement/intersection_impl.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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 7c4e96b8956..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 @@ -195,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, @@ -1051,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); @@ -1187,6 +1195,7 @@ class Intersection_of_triangle_meshes ++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; From 7ab6120a0ccdb3428b4db2f08cb8f9e8cf9c15d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 5 Mar 2018 17:09:23 +0100 Subject: [PATCH 5/5] workaround warning --- .../Polygon_mesh_processing/internal/Corefinement/Visitor.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 6bd505327d0..0d1a5779aad 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 @@ -340,7 +340,8 @@ public: TriangleMesh& tm) { CGAL_assertion_code(bool insert_ok = ) - mesh_to_vertex_to_node_id[&tm].insert(std::make_pair(target(h,tm),node_id)).second; + 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); }