From 4542a2a808bd14e036290b7c890af69d9c1a965e Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 29 Mar 2019 16:14:55 +0100 Subject: [PATCH 01/14] Be careful to not select a infinite face in the process. --- .../demo/Polyhedron/include/id_printing.h | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/include/id_printing.h b/Polyhedron/demo/Polyhedron/include/id_printing.h index 60b47de964e..c5b2e6436b8 100644 --- a/Polyhedron/demo/Polyhedron/include/id_printing.h +++ b/Polyhedron/demo/Polyhedron/include/id_printing.h @@ -550,12 +550,18 @@ int zoomToId(const Mesh& mesh, bool found = false; BOOST_FOREACH(vertex_descriptor vh, vertices(mesh)) { - if(get(vidmap, vh) == id) + std::size_t cur_id = get(vidmap, vh); + if( cur_id == id) { p = Point(get(ppmap, vh).x() + offset.x, get(ppmap, vh).y() + offset.y, get(ppmap, vh).z() + offset.z); - selected_fh = face(halfedge(vh, mesh), mesh); + typename boost::graph_traits::halfedge_descriptor hf = halfedge(vh, mesh); + if(CGAL::is_border_edge(hf, mesh)) + { + hf = opposite(hf, mesh); + } + selected_fh = face(hf, mesh); normal = CGAL::Polygon_mesh_processing::compute_vertex_normal(vh, mesh); found = true; break; @@ -573,17 +579,27 @@ int zoomToId(const Mesh& mesh, { if(get(eidmap, halfedge(e, mesh))/2 == id) { + typename boost::graph_traits::halfedge_descriptor hf = halfedge(e, mesh); const Point& p1 = get(ppmap, source(e, mesh)); const Point& p2 = get(ppmap, target(e, mesh)); p = Point((float)(p1.x() + p2.x()) / 2 + offset.x, (float)(p1.y() + p2.y()) / 2 + offset.y, (float)(p1.z() + p2.z()) / 2 + offset.z ); - typename Traits::Vector_3 normal1 = CGAL::Polygon_mesh_processing::compute_face_normal(face(halfedge(e, mesh),mesh), - mesh); - typename Traits::Vector_3 normal2 = CGAL::Polygon_mesh_processing::compute_face_normal(face(opposite(halfedge(e, mesh), mesh), mesh), - mesh); + typename Traits::Vector_3 normal1(0,0,0); + if(!is_border(hf, mesh)) + { + normal1= CGAL::Polygon_mesh_processing::compute_face_normal(face(hf,mesh), + mesh); + selected_fh = face(hf, mesh); + } + typename Traits::Vector_3 normal2(0,0,0); + if(!is_border(opposite(hf, mesh), mesh)) + { + normal2 = CGAL::Polygon_mesh_processing::compute_face_normal(face(opposite(hf, mesh), mesh), + mesh); + selected_fh = face(hf, mesh); + } normal = 0.5*normal1+0.5*normal2; - selected_fh = face(halfedge(e, mesh), mesh); found = true; break; } From 9c39f2260f3034a6573b3c67c5ff580539c57d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 2 Apr 2019 21:54:30 +0200 Subject: [PATCH 02/14] add calls to reserve before creating meshes --- BGL/include/CGAL/boost/graph/copy_face_graph.h | 1 + .../CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h | 1 + 2 files changed, 2 insertions(+) diff --git a/BGL/include/CGAL/boost/graph/copy_face_graph.h b/BGL/include/CGAL/boost/graph/copy_face_graph.h index 6be3d3ac865..a3aeaf48315 100644 --- a/BGL/include/CGAL/boost/graph/copy_face_graph.h +++ b/BGL/include/CGAL/boost/graph/copy_face_graph.h @@ -373,6 +373,7 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, V2V v2v, H2H h2h, F2F f2f, Src_vpm sm_vpm, Tgt_vpm tm_vpm ) { + reserve(tm, vertices(sm).size(), edges(sm).size(), faces(sm).size()); internal::copy_face_graph(sm, tm, CGAL::graph_has_property(), v2v, h2h, f2f, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index d3f70c87401..06ba56fdaac 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -72,6 +72,7 @@ public: void operator()(PM& pmesh, const bool insert_isolated_vertices = true) { + reserve(pmesh, _points.size(), 2*_polygons.size(), _polygons.size()); Vpmap vpmap = get(CGAL::vertex_point, pmesh); boost::dynamic_bitset<> not_isolated; From 49f1d2ba1bd1f4d802eaede15e652c90b9f08670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 5 Apr 2019 09:18:55 +0200 Subject: [PATCH 03/14] replace the edge map by a vector of flat_map it is very efficient since there should not be isolated vertices. On large data, the runtime of the function is divided by 3 to 4 --- .../orient_polygon_soup.h | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h index 67b22a81ac0..20330b97256 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h @@ -60,9 +60,11 @@ struct Polygon_soup_orienter /// Container types typedef PointRange Points; typedef PolygonRange Polygons; - typedef std::map > Edge_map; - typedef typename Edge_map::iterator Edge_map_iterator; + typedef std::set Marked_edges; + typedef boost::container::flat_map< V_ID, boost::container::flat_set > Internal_map_type; + typedef std::vector< Internal_map_type > Edge_map; + typedef typename Internal_map_type::iterator Edge_map_iterator; /// Data members Points& points; //< the set of input points @@ -108,8 +110,8 @@ struct Polygon_soup_orienter { typedef std::pair VID_and_PID; if ( is_edge_marked(src,tgt,marked_edges) ) return VID_and_PID(src,300612); - Edge_map_iterator em_it=edges.find(V_ID_pair(tgt, src)); - if ( em_it==edges.end() ) return VID_and_PID(src,300612);// the vertex is on the border + Edge_map_iterator em_it=edges[tgt].find(src); + if ( em_it==edges[tgt].end() ) return VID_and_PID(src,300612);// the vertex is on the border CGAL_assertion(em_it->second.size()==1); P_ID p_id = *(em_it->second.begin()); return VID_and_PID(get_neighbor_vertices(src, p_id, polygons)[2], p_id); @@ -120,8 +122,8 @@ struct Polygon_soup_orienter { typedef std::pair VID_and_PID; if ( is_edge_marked(src,tgt,marked_edges) ) return VID_and_PID(tgt,300612); - Edge_map_iterator em_it=edges.find(V_ID_pair(tgt, src)); - if ( em_it==edges.end() ) return VID_and_PID(tgt,300612);// the vertex is on the border + Edge_map_iterator em_it=edges[tgt].find(src); + if ( em_it==edges[tgt].end() ) return VID_and_PID(tgt,300612);// the vertex is on the border CGAL_assertion(em_it->second.size()==1); P_ID p_id = *(em_it->second.begin()); return VID_and_PID(get_neighbor_vertices(tgt, p_id, polygons)[0], p_id); @@ -155,7 +157,7 @@ struct Polygon_soup_orienter } Polygon_soup_orienter(Points& points, Polygons& polygons) - : points(points), polygons(polygons) + : points(points), polygons(polygons), edges(points.size()) {} //filling containers @@ -168,7 +170,7 @@ struct Polygon_soup_orienter for (P_ID j = 0; j < size; ++j) { V_ID i0 = polygons[i][j]; V_ID i1 = polygons[i][(j + 1) % size]; - edges[V_ID_pair(i0, i1)].insert(i); + edges[i0][i1].insert(i); } } @@ -182,10 +184,10 @@ struct Polygon_soup_orienter V_ID i1 = polygons[i][(j + 1) % size]; std::size_t nb_edges = 0; - Edge_map_iterator em_it = edges.find(V_ID_pair(i0, i1)); - if (em_it != edges.end()) nb_edges += em_it->second.size(); - em_it = edges.find(V_ID_pair(i1, i0)); - if (em_it != edges.end()) nb_edges += em_it->second.size(); + Edge_map_iterator em_it = edges[i0].find(i1); + if (em_it != edges[i0].end()) nb_edges += em_it->second.size(); + em_it = edges[i1].find(i0); + if (em_it != edges[i1].end()) nb_edges += em_it->second.size(); if (nb_edges > 2) set_edge_marked(i0, i1, marked_edges); } @@ -249,17 +251,17 @@ struct Polygon_soup_orienter if( is_edge_marked(i1,i2,marked_edges) ) continue; // edge (i1,i2) - Edge_map_iterator it_same_orient = edges.find(V_ID_pair(i1, i2)); + Edge_map_iterator it_same_orient = edges[i1].find(i2); // edges (i2,i1) - Edge_map_iterator it_other_orient = edges.find(V_ID_pair(i2, i1)); + Edge_map_iterator it_other_orient = edges[i2].find(i1); - CGAL_assertion(it_same_orient != edges.end()); - CGAL_assertion(it_other_orient == edges.end() || + CGAL_assertion(it_same_orient != edges[i1].end()); + CGAL_assertion(it_other_orient == edges[i2].end() || it_other_orient->second.size()==1); if (it_same_orient->second.size() > 1) { - CGAL_assertion(it_other_orient == edges.end()); + CGAL_assertion(it_other_orient == edges[i2].end()); // one neighbor but with the same orientation P_ID index = *(it_same_orient->second.begin()); if(index == to_be_oriented_index) @@ -276,25 +278,25 @@ struct Polygon_soup_orienter for(P_ID j = 0; j < size; ++j) { V_ID i0 = polygons[index][j]; V_ID i1 = polygons[index][(j+1)%size]; - Edge_map_iterator em_it = edges.find(V_ID_pair(i0, i1)); + Edge_map_iterator em_it = edges[i0].find(i1); CGAL_assertion_code(const bool r = ) em_it->second.erase(index) CGAL_assertion_code(!= 0); CGAL_assertion(r); - if ( em_it->second.empty() ) edges.erase(em_it); + if ( em_it->second.empty() ) edges[i0].erase(em_it); } inverse_orientation(index); for(P_ID j = 0; j < size; ++j) { V_ID i0 = polygons[index][j]; V_ID i1 = polygons[index][(j+1)%size]; - edges[V_ID_pair(i0, i1)].insert(index); + edges[i0][i1].insert(index); } // "inverse the orientation of polygon #index oriented[index] = true; stack.push(index); } else{ - if( it_other_orient != edges.end() ){ + if( it_other_orient != edges[i2].end() ){ CGAL_assertion(it_same_orient->second.size() == 1); CGAL_assertion(it_other_orient->second.size() == 1); // one polygon, same orientation @@ -377,6 +379,7 @@ struct Polygon_soup_orienter /// now duplicate the vertices typedef std::pair > V_ID_and_Polygon_ids; + edges.resize(edges.size()+vertices_to_duplicate.size()); BOOST_FOREACH(const V_ID_and_Polygon_ids& vid_and_pids, vertices_to_duplicate) { V_ID new_index = static_cast(points.size()); From f972d0a228e8209b62abefb78b30db0404ed9007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 5 Apr 2019 11:40:47 +0200 Subject: [PATCH 04/14] init edge map for is_polygon_mesh_a_polygon_soup --- .../CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index d3f70c87401..3be3f9332ca 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -180,7 +180,7 @@ public: //check manifoldness typedef std::vector PointRange; typedef internal::Polygon_soup_orienter Orienter; - typename Orienter::Edge_map edges; + typename Orienter::Edge_map edges(max_id+1); typename Orienter::Marked_edges marked_edges; Orienter::fill_edge_map(edges, marked_edges, polygons); //returns false if duplication is necessary From 07d1601ec9363e766006339ad093d785434b7510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 5 Apr 2019 12:17:17 +0200 Subject: [PATCH 05/14] remove useless (and harmful for the new method) call to clear --- .../include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h index 20330b97256..ab789adee74 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h @@ -163,7 +163,6 @@ struct Polygon_soup_orienter //filling containers static void fill_edge_map(Edge_map& edges, Marked_edges& marked_edges, const Polygons& polygons) { // Fill edges - edges.clear(); for (P_ID i = 0; i < polygons.size(); ++i) { const P_ID size = polygons[i].size(); From 028fcd7b346bd6770e229b3513af35ea41097e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 10 Apr 2019 11:06:26 +0200 Subject: [PATCH 06/14] add missing include directive --- .../include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h index ab789adee74..8a0b79d5002 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orient_polygon_soup.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include From bd955e57d391c87598347ba04991a7865cc11bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 10 Apr 2019 14:28:35 +0200 Subject: [PATCH 07/14] fix conversion warnings --- BGL/doc/BGL/Concepts/MutableFaceGraph.h | 2 +- BGL/include/CGAL/boost/graph/copy_face_graph.h | 5 ++++- .../Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/BGL/doc/BGL/Concepts/MutableFaceGraph.h b/BGL/doc/BGL/Concepts/MutableFaceGraph.h index eb7c5c915b2..7df4f7b4b5b 100644 --- a/BGL/doc/BGL/Concepts/MutableFaceGraph.h +++ b/BGL/doc/BGL/Concepts/MutableFaceGraph.h @@ -47,4 +47,4 @@ Indicates the expected size of vertices (`nv`), edges (`ed`) and faces (`nf`). */ template void -reserve(MutableFaceGraph& g, boost::graph_traits::vertices_size_type nv, boost::graph_traits::vertices_size_type ne, boost::graph_traits::vertices_size_type nf); +reserve(MutableFaceGraph& g, boost::graph_traits::vertices_size_type nv, boost::graph_traits::edges_size_type ne, boost::graph_traits::faces_size_type nf); diff --git a/BGL/include/CGAL/boost/graph/copy_face_graph.h b/BGL/include/CGAL/boost/graph/copy_face_graph.h index a3aeaf48315..3a869f2838c 100644 --- a/BGL/include/CGAL/boost/graph/copy_face_graph.h +++ b/BGL/include/CGAL/boost/graph/copy_face_graph.h @@ -71,6 +71,10 @@ void copy_face_graph_impl(const SourceMesh& sm, TargetMesh& tm, tm_face_descriptor tm_null_face = boost::graph_traits::null_face(); + reserve(tm, static_cast::vertices_size_type>(vertices(sm).size()), + static_cast::edges_size_type>(edges(sm).size()), + static_cast::faces_size_type>(faces(sm).size()) ); + //insert halfedges and create each vertex when encountering its halfedge BOOST_FOREACH(sm_edge_descriptor sm_e, edges(sm)) { @@ -373,7 +377,6 @@ void copy_face_graph(const SourceMesh& sm, TargetMesh& tm, V2V v2v, H2H h2h, F2F f2f, Src_vpm sm_vpm, Tgt_vpm tm_vpm ) { - reserve(tm, vertices(sm).size(), edges(sm).size(), faces(sm).size()); internal::copy_face_graph(sm, tm, CGAL::graph_has_property(), v2v, h2h, f2f, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index 06ba56fdaac..ccccdc22843 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -72,7 +72,10 @@ public: void operator()(PM& pmesh, const bool insert_isolated_vertices = true) { - reserve(pmesh, _points.size(), 2*_polygons.size(), _polygons.size()); + reserve(pmesh, static_cast::vertices_size_type>(_points.size()), + static_cast::edges_size_type>(2*_polygons.size()), + static_cast::faces_size_type>(_polygons.size()) ); + Vpmap vpmap = get(CGAL::vertex_point, pmesh); boost::dynamic_bitset<> not_isolated; From 9a4b4a7969187e08011c711a73e659a7dbbfaa86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 12 Apr 2019 14:33:28 +0200 Subject: [PATCH 08/14] add missing reserve overload for HDS --- .../boost/graph/graph_traits_HalfedgeDS_default.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS_default.h b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS_default.h index 05346c0aac7..1f84f085c02 100644 --- a/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS_default.h +++ b/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS_default.h @@ -470,7 +470,16 @@ struct HDS_property_map typename T::Point_3, const typename T::Point_3&> const_type; }; }; - + +template +void reserve(HalfedgeDS_default& p, + typename boost::graph_traits< HalfedgeDS_default const>::vertices_size_type nv, + typename boost::graph_traits< HalfedgeDS_default const>::edges_size_type ne, + typename boost::graph_traits< HalfedgeDS_default const>::faces_size_type nf) +{ + p.reserve(nv, 2*ne, nf); +} + }// namespace CGAL namespace boost { From 03ec0dfbe1f3e276d1a87715c599a014792c02bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 12 Apr 2019 19:09:25 +0200 Subject: [PATCH 09/14] update demo plugin --- Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp index 0ef8e67a5f3..317a9c1c90c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Orient_soup_plugin.cpp @@ -300,10 +300,10 @@ void Polyhedron_demo_orient_soup_plugin::getNMPoints( Scene_polygon_soup_item* item) { typedef std::pair V_ID_pair; - typedef std::map > Edge_map; - typedef std::set Marked_edges; typedef CGAL::Polygon_mesh_processing::internal::Polygon_soup_orienter PSO; + typedef PSO::Edge_map Edge_map; + typedef std::set Marked_edges; Edge_map edges; Marked_edges m_edges; From 7945ffeea23b3b1b815fa46673a857b03371695b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 12 Apr 2019 19:11:04 +0200 Subject: [PATCH 10/14] update surf plugin --- .../demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h b/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h index 9c4c9041b0d..121608f1906 100644 --- a/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h +++ b/Polyhedron/demo/Polyhedron/include/CGAL/IO/read_surf_trianglemesh.h @@ -286,7 +286,7 @@ bool read_surf(std::istream& input, std::vector& output, Mesh& mesh = output[i]; - PMP::internal::Polygon_soup_to_polygon_mesh + PMP::internal::Polygon_soup_to_polygon_mesh, std::vector> converter(points, polygons); converter(mesh, false/*insert_isolated_vertices*/); From e54c24f0a47e0b13cd7b2edd2390d2edfe4a5be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 15 Apr 2019 16:58:22 +0200 Subject: [PATCH 11/14] correct forwarding of projection traits --- .../include/CGAL/Extreme_points_traits_adapter_3.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h b/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h index 8991774adc3..8c84e567ca7 100644 --- a/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h +++ b/Convex_hull_3/include/CGAL/Extreme_points_traits_adapter_3.h @@ -221,16 +221,17 @@ public: Orientation_2 orientation_2_object ()const{return Orientation_2(vpm_,static_cast(this)->orientation_2_object() );} }; - typedef Proj_traits_3 Traits_xy_3; - typedef Proj_traits_3 Traits_yz_3; - typedef Proj_traits_3 Traits_xz_3; + typedef internal::Convex_hull_3::Projection_traits Base_PTraits; + typedef Proj_traits_3 Traits_xy_3; + typedef Proj_traits_3 Traits_yz_3; + typedef Proj_traits_3 Traits_xz_3; Traits_xy_3 construct_traits_xy_3_object()const - {return Traits_xy_3(vpm_, static_cast(this)->construct_traits_xy_3_object());} + {return Traits_xy_3(vpm_, Base_PTraits(static_cast(*this)).construct_traits_xy_3_object());} Traits_yz_3 construct_traits_yz_3_object()const - {return Traits_yz_3(vpm_, static_cast(this)->construct_traits_yz_3_object());} + {return Traits_yz_3(vpm_, Base_PTraits(static_cast(*this)).construct_traits_yz_3_object());} Traits_xz_3 construct_traits_xz_3_object()const - {return Traits_xz_3(vpm_, static_cast(this)->construct_traits_xz_3_object());} + {return Traits_xz_3(vpm_, Base_PTraits(static_cast(*this)).construct_traits_xz_3_object());} typename boost::property_traits::reference get_point(const typename boost::property_traits::key_type& k) const From d3128e75e544272f6d3c79299108cb311a86c155 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 17 Apr 2019 22:03:28 +0200 Subject: [PATCH 12/14] We need two versions of the insert_constraint() function, - one for the old API where constraints were just a 2d segment - and one for polylines --- .../CGAL/Constrained_triangulation_plus_2.h | 2 +- .../CGAL/Polyline_constraint_hierarchy_2.h | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 248159481ed..255abb52a11 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -271,7 +271,7 @@ public: return Constraint_id(NULL); } // protects against inserting twice the same constraint - Constraint_id cid = hierarchy.insert_constraint(va, vb); + Constraint_id cid = hierarchy.insert_constraint_old_API(va, vb); if (va != vb && (cid != Constraint_id(NULL)) ) insert_subconstraint(va,vb); return cid; diff --git a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h index 2c1654cece4..a1c9c73ea42 100644 --- a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h @@ -247,7 +247,8 @@ public: // insert/remove void add_Steiner(T va, T vb, T vx); - Vertex_list* insert_constraint(T va, T vb); + Vertex_list* insert_constraint_old_API(T va, T vb); + Vertex_list* insert_constraint(T va, T vb); void append_constraint(Constraint_id cid, T va, T vb); void swap(Constraint_id first, Constraint_id second); void remove_constraint(Constraint_id cid); @@ -868,6 +869,34 @@ typename Polyline_constraint_hierarchy_2::Vertex_list* Polyline_constraint_hierarchy_2:: insert_constraint(T va, T vb){ Edge he = make_edge(va, vb); + Vertex_list* children = new Vertex_list; + Context_list* fathers; + + typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he); + if(scit == sc_to_c_map.end()){ + fathers = new Context_list; + sc_to_c_map.insert(std::make_pair(he,fathers)); + } else { + fathers = scit->second; + } + + children->push_front(Node(va, true)); // was he.first + children->push_back(Node(vb, true)); // was he.second + constraint_set.insert(children); + Context ctxt; + ctxt.enclosing = children; + ctxt.pos = children->skip_begin(); + fathers->push_front(ctxt); + + return children; +} + + +template +typename Polyline_constraint_hierarchy_2::Vertex_list* +Polyline_constraint_hierarchy_2:: +insert_constraint_old_API(T va, T vb){ + Edge he = make_edge(va, vb); // First, check if the constraint was already inserted. // If it was not, then the iterator to the lower bound will serve as From f1c6990a57a35582e71fc64696b75264a369f731 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 18 Apr 2019 13:36:41 +0200 Subject: [PATCH 13/14] Add a test for a reported issue --- .../test/Triangulation_2/issue_3447.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Triangulation_2/test/Triangulation_2/issue_3447.cpp diff --git a/Triangulation_2/test/Triangulation_2/issue_3447.cpp b/Triangulation_2/test/Triangulation_2/issue_3447.cpp new file mode 100644 index 00000000000..de0a47601d0 --- /dev/null +++ b/Triangulation_2/test/Triangulation_2/issue_3447.cpp @@ -0,0 +1,34 @@ +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Constrained_triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_data_structure_2 TDS; +typedef CGAL::Exact_predicates_tag Itag; +typedef CGAL::Constrained_Delaunay_triangulation_2 Triangulation; +typedef CGAL::Constrained_triangulation_plus_2 Delaunay; + +typedef K::Point_2 Point_2; + +int main() +{ + Delaunay dt; + + dt.insert(Point_2(0,0)); + dt.insert(Point_2(10,0)); + dt.insert(Point_2(0,10)); + dt.insert(Point_2(10,10)); + + std::vector vec_constraint; + + vec_constraint.push_back(Point_2(1, 2)); + vec_constraint.push_back(Point_2(2, 2)); + vec_constraint.push_back(Point_2(3, 2)); + + dt.insert_constraint(vec_constraint.begin(), vec_constraint.end()); + + dt.insert_constraint(vec_constraint.begin(), vec_constraint.end()); + + return 0; +} From 14ebc2fabc56bae94d6b6c2e81b03611c2a23695 Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Thu, 18 Apr 2019 13:54:46 +0200 Subject: [PATCH 14/14] Update Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h Co-Authored-By: afabri --- Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h index a1c9c73ea42..1f3071db44e 100644 --- a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h @@ -248,7 +248,7 @@ public: // insert/remove void add_Steiner(T va, T vb, T vx); Vertex_list* insert_constraint_old_API(T va, T vb); - Vertex_list* insert_constraint(T va, T vb); + Vertex_list* insert_constraint(T va, T vb); void append_constraint(Constraint_id cid, T va, T vb); void swap(Constraint_id first, Constraint_id second); void remove_constraint(Constraint_id cid);