From 9a5805839e389c85043401e98b1a968999a72f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 19 Jul 2021 15:54:46 +0200 Subject: [PATCH 01/20] Do not set irrelevant neighbors with garbage (dim -1) In dim -1, there is only one vertex and one face, no neighbor in position '0' to set. --- .../CGAL/Triangulation_data_structure_2.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index a9d7a057439..a50bfdd9262 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -1984,13 +1984,16 @@ copy_tds(const TDS_src& tds_src, CGAL_triangulation_precondition( tds_src.is_vertex(vert)); clear(); - size_type n = tds_src.number_of_vertices(); set_dimension(tds_src.dimension()); - // Number of pointers to cell/vertex to copy per cell. - int dim = (std::max)(1, dimension() + 1); + if(tds_src.number_of_vertices() == 0) + return Vertex_handle(); - if(n == 0) {return Vertex_handle();} + // Number of pointers to face/vertex to copy per face. + const int dim = (std::max)(1, dimension() + 1); + + // Number of neighbors to set in each face (dim -1 has a single face) + const int nn = (std::max)(0, dimension() + 1); //initializes maps Unique_hash_map vmap; @@ -2012,7 +2015,7 @@ copy_tds(const TDS_src& tds_src, convert_face(*fit1, *fh); } - //link vertices to a cell + //link vertices to a face vit1 = tds_src.vertices_begin(); for ( ; vit1 != tds_src.vertices_end(); vit1++) { vmap[vit1]->set_face(fmap[vit1->face()]); @@ -2021,10 +2024,10 @@ copy_tds(const TDS_src& tds_src, //update vertices and neighbor pointers fit1 = tds_src.faces().begin(); for ( ; fit1 != tds_src.faces_end(); ++fit1) { - for (int j = 0; j < dim ; ++j) { + for (int j = 0; j < dim ; ++j) fmap[fit1]->set_vertex(j, vmap[fit1->vertex(j)] ); + for (int j = 0; j < nn ; ++j) fmap[fit1]->set_neighbor(j, fmap[fit1->neighbor(j)]); - } } // remove the post condition because it is false when copying the From 1fc3050e0b0fb1890ea6449ae7fa217fead3ced6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 19 Jul 2021 15:55:47 +0200 Subject: [PATCH 02/20] Avoid UB with default constructed handle See also f9c9cfa40bdad5c5f250e4d600c43aa2f0d50021 --- TDS_2/include/CGAL/Triangulation_ds_face_base_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h b/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h index cbe8b8e1d49..2a7d1e3a850 100644 --- a/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h +++ b/TDS_2/include/CGAL/Triangulation_ds_face_base_2.h @@ -235,7 +235,7 @@ Triangulation_ds_face_base_2 :: set_neighbor(int i, Face_handle n) { CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); - CGAL_triangulation_precondition( this != &*n ); + CGAL_triangulation_precondition( this != n.operator->() ); N[i] = n; } From 8727fd17af7683624e20c25ca7c0a3c2ead81911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 19 Jul 2021 15:57:24 +0200 Subject: [PATCH 03/20] Avoid needless containers in TDS3::copy_tds() --- .../CGAL/Triangulation_data_structure_3.h | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 7c01149ab44..946c028f9a8 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -4039,32 +4039,24 @@ copy_tds(const TDS_src& tds, || tds.is_vertex(vert) ); clear(); - - size_type n = tds.number_of_vertices(); set_dimension(tds.dimension()); - if (n == 0) return Vertex_handle(); + if(tds.number_of_vertices() == 0) + return Vertex_handle(); // Number of pointers to cell/vertex to copy per cell. - int dim = (std::max)(1, dimension() + 1); - - // Create the vertices. - std::vector TV(n); - size_type i = 0; - - for (typename TDS_src::Vertex_iterator vit = tds.vertices_begin(); - vit != tds.vertices_end(); ++vit) - TV[i++] = vit; - - CGAL_triangulation_assertion( i == n ); + const int dim = (std::max)(1, dimension() + 1); + // Initializes maps Unique_hash_map< typename TDS_src::Vertex_handle,Vertex_handle > V; Unique_hash_map< typename TDS_src::Cell_handle,Cell_handle > F; - for (i=0; i <= n-1; ++i){ - Vertex_handle vh=create_vertex( convert_vertex(*TV[i]) ); - V[ TV[i] ] = vh; - convert_vertex(*TV[i],*vh); + // Create the vertices. + for (typename TDS_src::Vertex_iterator vit = tds.vertices_begin(); + vit != tds.vertices_end(); ++vit) { + Vertex_handle vh = create_vertex( convert_vertex(*vit) ); + V[vit] = vh; + convert_vertex(*vit,*vh); } // Create the cells. From 3fcae5244dcb65d7b0e11fa7dda60ea7588296e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 19 Jul 2021 15:58:10 +0200 Subject: [PATCH 04/20] Add a few more tests --- .../include/CGAL/_test_cls_triangulation_2.h | 17 +++++++++++++++-- .../include/CGAL/_test_cls_triangulation_3.h | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h index 348428439f7..e9fcc57d555 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.h @@ -132,9 +132,14 @@ _test_cls_triangulation_2( const Triangul & ) assert( T1.number_of_vertices() == 0 ); Triangul T3(T1); - Triangul T4 = T1; - T3.swap(T1); + assert(T3.tds().vertices().size() == T1.tds().vertices().size()); + assert(T3.tds().faces().size() == T1.tds().faces().size()); + Triangul T4 = T1; + assert(T4.tds().vertices().size() == T1.tds().vertices().size()); + assert(T4.tds().faces().size() == T1.tds().faces().size()); + + T3.swap(T1); /**************************/ /******* INSERTIONS *******/ @@ -162,6 +167,10 @@ _test_cls_triangulation_2( const Triangul & ) assert( T0_1.number_of_faces() == 0); assert( T0_1.is_valid() ); + Triangul T0_1b(T0_1); + assert(T0_1b.tds().vertices().size() == T0_1.tds().vertices().size()); + assert(T0_1b.tds().faces().size() == T0_1.tds().faces().size()); + // test insert_first() Triangul T0_2; Vertex_handle v0_2_0 = T0_2.insert_first(p0); @@ -184,6 +193,10 @@ _test_cls_triangulation_2( const Triangul & ) assert( T1_2.number_of_faces() == 0 ); assert( T1_2.is_valid() ); + Triangul T1_2b(T1_2); + assert(T1_2b.tds().vertices().size() == T1_2.tds().vertices().size()); + assert(T1_2b.tds().faces().size() == T1_2.tds().faces().size()); + // p1,p3,p2 [endpoints first] Triangul T1_3_0; Vertex_handle v1_3_0_1 = T1_3_0.insert(p1); assert( v1_3_0_1 != NULL ); diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h index a2afe749131..5bca6985c83 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h @@ -190,7 +190,21 @@ _test_cls_triangulation_3(const Triangulation &) //######################################################################## - /**************CONSTRUCTORS (1)*********************/ + /************** CONSTRUCTORS (1)********************/ + + Cls Tm1; + assert( Tm1.dimension() == -1 ); + assert( Tm1.number_of_vertices() == 0 ); + + Cls Tm3(Tm1); + assert(Tm3 == Tm1); + + Cls Tm4 = Tm1; + assert(Tm4 == Tm1); + + Tm3.swap(Tm1); + + /************** INSERTIONS *************************/ /************** and I/O ****************************/ std::cout << " Constructor " << std::endl; From cc790a8a6c158590103880471fd3775fd2073029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 19 Jul 2021 22:01:21 +0200 Subject: [PATCH 05/20] Do not set irrelevant neighbors with garbage (T3) --- TDS_3/include/CGAL/Triangulation_data_structure_3.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 946c028f9a8..a65d211d549 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -4047,6 +4047,9 @@ copy_tds(const TDS_src& tds, // Number of pointers to cell/vertex to copy per cell. const int dim = (std::max)(1, dimension() + 1); + // Number of neighbors to set + const int nn = (std::max)(0, dimension() + 1); + // Initializes maps Unique_hash_map< typename TDS_src::Vertex_handle,Vertex_handle > V; Unique_hash_map< typename TDS_src::Cell_handle,Cell_handle > F; @@ -4077,7 +4080,7 @@ copy_tds(const TDS_src& tds, // Hook neighbor pointers of the cells. for (typename TDS_src::Cell_iterator cit2 = tds.cells().begin(); cit2 != tds.cells_end(); ++cit2) { - for (int j = 0; j < dim; j++) + for (int j = 0; j < nn; j++) F[cit2]->set_neighbor(j, F[cit2->neighbor(j)] ); } From b14fbe18753579745bfc07744fe4d0f0b107b042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 19 Jul 2021 22:01:45 +0200 Subject: [PATCH 06/20] Add more tests --- .../include/CGAL/_test_cls_triangulation_3.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h index 5bca6985c83..275ec2a2ae4 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_triangulation_3.h @@ -228,6 +228,9 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.number_of_vertices() == 1); assert(T0.is_valid()); + Cls T0d0(T0); + assert(T0 == T0d0); + if (! del) // to avoid doing the following tests for both Delaunay // and non Delaunay triangulations { @@ -242,6 +245,9 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.number_of_vertices() == 2); assert(T0.is_valid()); + Cls T0d1(T0); + assert(T0 == T0d1); + if (! del) // to avoid doing the following tests for both Delaunay // and non Delaunay triangulations { @@ -256,6 +262,9 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.number_of_vertices() == 3); assert(T0.is_valid()); + Cls T0d2(T0); + assert(T0 == T0d2); + if (! del) // to avoid doing the following tests for both Delaunay // and non Delaunay triangulations { @@ -270,6 +279,9 @@ _test_cls_triangulation_3(const Triangulation &) assert(T0.number_of_vertices() == 4); assert(T0.is_valid()); + Cls T0d3(T0); + assert(T0 == T0d3); + if (! del) // to avoid doing the following tests for both Delaunay // and non Delaunay triangulations { From 7f6c39e89888a37138e4e0cfb8bf64b437c64126 Mon Sep 17 00:00:00 2001 From: Simon Lopez Date: Fri, 23 Jul 2021 18:16:40 +0200 Subject: [PATCH 07/20] Skip shared edges which are border edges --- .../include/CGAL/Polygon_mesh_processing/clip.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h index dd9672e4a35..886b2fed92a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -316,6 +316,7 @@ void split_along_edges(TriangleMesh& tm, std::set extra_border_hedges; for(std::size_t k=0; k Date: Thu, 29 Jul 2021 13:21:16 +0200 Subject: [PATCH 08/20] add split case with a plane containing border edges --- .../Polygon_mesh_processing/test_pmp_clip.cpp | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp index b1e123f3472..cad344d72cf 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp @@ -502,7 +502,7 @@ void test() template void test_split_plane() { - // test with a clipper mesh +//test with a splitter mesh Mesh tm1; std::ifstream input("data-coref/elephant.off"); input >> tm1; @@ -529,7 +529,45 @@ void test_split_plane() CGAL::clear(tm1); meshes.clear(); - //test with SI +//test with a non-closed splitter mesh (border edges in the plane) + input.open("data-coref/open_large_cube.off"); + input >> tm1; + + if(!input) + { + std::cerr<<"File not found. Aborting."<> tm1; + + if(!input) + { + std::cerr<<"File not found. Aborting."<> tm1; if(num_vertices(tm1) == 0) { From 10ed1a058e2b407282bcc05f4c6b4f2db2bc66dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 29 Jul 2021 17:22:37 +0200 Subject: [PATCH 09/20] add more tests --- .../Polygon_mesh_processing/test_pmp_clip.cpp | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp index cad344d72cf..5d188bdf3f1 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp @@ -497,6 +497,64 @@ void test() PMP::clip(tm1, K::Plane_3(0,-1,0,0)); assert(vertices(tm1).size() == 7); } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + PMP::clip(tm1, K::Plane_3(0,0,1,-1), CGAL::parameters::use_compact_clipper(false)); + assert(vertices(tm1).size()==753); + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + std::size_t nbv = vertices(tm1).size(); + PMP::clip(tm1, K::Plane_3(0,0,1,-1), CGAL::parameters::use_compact_clipper(true)); + assert(vertices(tm1).size()==nbv+2); // because of the plane diagonal + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + PMP::clip(tm1, K::Plane_3(0,0,1,-1), CGAL::parameters::use_compact_clipper(false).allow_self_intersections(true)); + assert(vertices(tm1).size()==753); + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + std::size_t nbv = vertices(tm1).size(); + PMP::clip(tm1, K::Plane_3(0,0,1,-1), CGAL::parameters::use_compact_clipper(true).allow_self_intersections(true)); + assert(vertices(tm1).size()==nbv+2); // because of the plane diagonal + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + PMP::clip(tm1, K::Plane_3(0,0,-1,1), CGAL::parameters::use_compact_clipper(false)); + assert(vertices(tm1).size()==0); + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + PMP::clip(tm1, K::Plane_3(0,0,-1,1), CGAL::parameters::use_compact_clipper(true)); + assert(vertices(tm1).size()==176); + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + PMP::clip(tm1, K::Plane_3(0,0,-1,1), CGAL::parameters::use_compact_clipper(false).allow_self_intersections(true)); + assert(vertices(tm1).size()==0); + } + + { + TriangleMesh tm1; + std::ifstream("data-coref/open_large_cube.off") >> tm1; + PMP::clip(tm1, K::Plane_3(0,0,-1,1), CGAL::parameters::use_compact_clipper(true).allow_self_intersections(true)); + assert(vertices(tm1).size()==176); + } } template From aee767b2e3dba2755cac68f3bdcb9307ec23926d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 30 Jul 2021 10:07:33 +0200 Subject: [PATCH 10/20] update to valid format --- BGL/test/BGL/data/colored_tetra.ply | 4 ++-- BGL/test/BGL/data/invalid_cut.ply | 4 ++-- BGL/test/BGL/data/invalid_nv.ply | 4 ++-- Stream_support/test/Stream_support/data/colored_tetra.ply | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/BGL/test/BGL/data/colored_tetra.ply b/BGL/test/BGL/data/colored_tetra.ply index 7ec622125d1..0512db6f502 100644 --- a/BGL/test/BGL/data/colored_tetra.ply +++ b/BGL/test/BGL/data/colored_tetra.ply @@ -18,8 +18,8 @@ property uchar green property uchar blue property int label element edge 6 -property int v0 -property int v1 +property int vertex1 +property int vertex2 property float confidence end_header 0 0 0 -0.5 -0.5 -0.5 255 255 0 0 diff --git a/BGL/test/BGL/data/invalid_cut.ply b/BGL/test/BGL/data/invalid_cut.ply index a158f142b37..c50bb6c56ad 100644 --- a/BGL/test/BGL/data/invalid_cut.ply +++ b/BGL/test/BGL/data/invalid_cut.ply @@ -18,8 +18,8 @@ property uchar green property uchar blue property int label element edge 6 -property int v0 -property int v1 +property int vertex1 +property int vertex2 property float confidence end_header 0 0 0 -0.5 -0.5 -0.5 255 255 0 0 diff --git a/BGL/test/BGL/data/invalid_nv.ply b/BGL/test/BGL/data/invalid_nv.ply index e6a3ca46bb2..18903f10b96 100644 --- a/BGL/test/BGL/data/invalid_nv.ply +++ b/BGL/test/BGL/data/invalid_nv.ply @@ -18,8 +18,8 @@ property uchar green property uchar blue property int label element edge 6 -property int v0 -property int v1 +property int vertex1 +property int vertex2 property float confidence end_header 0 0 0 -0.5 -0.5 -0.5 0 diff --git a/Stream_support/test/Stream_support/data/colored_tetra.ply b/Stream_support/test/Stream_support/data/colored_tetra.ply index 7ec622125d1..0512db6f502 100644 --- a/Stream_support/test/Stream_support/data/colored_tetra.ply +++ b/Stream_support/test/Stream_support/data/colored_tetra.ply @@ -18,8 +18,8 @@ property uchar green property uchar blue property int label element edge 6 -property int v0 -property int v1 +property int vertex1 +property int vertex2 property float confidence end_header 0 0 0 -0.5 -0.5 -0.5 255 255 0 0 From 149b5af81f05af9c337b586aed2dda37ba165524 Mon Sep 17 00:00:00 2001 From: Dan Bumbarger Date: Thu, 29 Jul 2021 16:02:14 -0700 Subject: [PATCH 11/20] Update PLY.h Aligned Edge property to PLY standard --- Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index 9a9d242b7b7..a6660baa2f9 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -162,7 +162,7 @@ public: bool has_simplex_specific_property (internal::PLY::PLY_read_number* property, Edge_index) { const std::string& name = property->name(); - if (name == "v0" || name == "v1") + if(name == "vertex1" || name == "vertex2") return true; return false; } @@ -368,8 +368,8 @@ public: void process_line (PLY_element& element, Edge_index& ei) { IntType v0, v1; - element.assign (v0, "v0"); - element.assign (v1, "v1"); + element.assign(v0, "vertex1"); + element.assign(v1, "vertex2"); Halfedge_index hi = m_mesh.halfedge(m_map_v2v[std::size_t(v0)], m_map_v2v[std::size_t(v1)]); From 65f3803bab18faddc3a47a1b55b2c7ff204e76f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 30 Jul 2021 10:13:26 +0200 Subject: [PATCH 12/20] compatibility for files written with the old code --- Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index a6660baa2f9..bde524f6242 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -164,6 +164,10 @@ public: const std::string& name = property->name(); if(name == "vertex1" || name == "vertex2") return true; +#ifndef CGAL_NO_DEPRECATED_CODE + if(name == "v0" || name == "v1") + return true; +#endif return false; } From 49e720068ff57f5cea69aecaf0d33f8180657c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 30 Jul 2021 10:03:10 +0200 Subject: [PATCH 13/20] update to valid format --- Surface_mesh/test/Surface_mesh/colored_tetra.ply | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Surface_mesh/test/Surface_mesh/colored_tetra.ply b/Surface_mesh/test/Surface_mesh/colored_tetra.ply index 7ec622125d1..0512db6f502 100644 --- a/Surface_mesh/test/Surface_mesh/colored_tetra.ply +++ b/Surface_mesh/test/Surface_mesh/colored_tetra.ply @@ -18,8 +18,8 @@ property uchar green property uchar blue property int label element edge 6 -property int v0 -property int v1 +property int vertex1 +property int vertex2 property float confidence end_header 0 0 0 -0.5 -0.5 -0.5 255 255 0 0 From 8123a841f2a5bef73720eb38e11b92b050b7161e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 30 Jul 2021 10:16:58 +0200 Subject: [PATCH 14/20] update to valid format --- Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h index b6196d5908c..599ab894517 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/PLY.h @@ -961,8 +961,8 @@ bool write_PLY(std::ostream& os, if(!eprinters.empty()) { os << "element edge " << sm.number_of_edges() << std::endl; - os << "property int v0" << std::endl; - os << "property int v1" << std::endl; + os << "property int vertex1" << std::endl; + os << "property int vertex2" << std::endl; os << oss.str(); } } From 32b2354ac1a8910faebb82e0d3b33163f35e46b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 30 Jul 2021 10:35:10 +0200 Subject: [PATCH 15/20] Fix may-be-used-uninitialized warning --- BGL/test/BGL/test_split.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BGL/test/BGL/test_split.cpp b/BGL/test/BGL/test_split.cpp index f9b6fff3ced..9c13a2d0307 100644 --- a/BGL/test/BGL/test_split.cpp +++ b/BGL/test/BGL/test_split.cpp @@ -24,7 +24,8 @@ typedef std::vector Polyline_2; // inserts a polyline into a graph void insert(const std::vector& poly, Graph& graph, Point_vertex_map& pvmap) { - vertex_descriptor u, v; + vertex_descriptor u = boost::graph_traits::null_vertex(); + vertex_descriptor v; for (std::size_t i = 0; i < poly.size(); i++) { // check if the point is not yet in the graph if (pvmap.find(poly[i]) == pvmap.end()) { From 9dc3f84d730cd3ddc208a31698dea11d2df62222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 3 Aug 2021 14:16:29 +0200 Subject: [PATCH 16/20] try to workaround non-determinism --- .../Polygon_mesh_processing/test_pmp_clip.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp index 5d188bdf3f1..8fe4562d8b7 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp @@ -831,12 +831,15 @@ void test_isocuboid() .allow_self_intersections(true)); PMP::split_connected_components(tm, meshes, params::all_default()); assert(meshes.size() == 4); - //if the order is not deterministc, put the num_vertices in a list and check - //if the list does contain all those numbers. - assert(vertices(meshes[0]).size() == 22); - assert(vertices(meshes[1]).size() == 23); - assert(vertices(meshes[2]).size() == 7); - assert(vertices(meshes[3]).size() == 4); + + std::set sizes; + for (int i=0; i<4; ++i) + sizes.insert(vertices(meshes[i]).size()); + + assert(sizes.count(22)==1); + assert(sizes.count(23)==1); + assert(sizes.count(7)==1); + assert(sizes.count(4)==1); CGAL::clear(tm); meshes.clear(); From 0361a83cd31d3744dc788bc65d42824160cc239d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 4 Aug 2021 15:22:14 +0200 Subject: [PATCH 17/20] fix degree of an isolated vertex --- Polyhedron/include/CGAL/Polyhedron_3.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polyhedron/include/CGAL/Polyhedron_3.h b/Polyhedron/include/CGAL/Polyhedron_3.h index 278d3b9b8a2..922c5110e69 100644 --- a/Polyhedron/include/CGAL/Polyhedron_3.h +++ b/Polyhedron/include/CGAL/Polyhedron_3.h @@ -111,7 +111,8 @@ public: // the degree of the vertex, i.e., edges emanating from this vertex std::size_t vertex_degree() const { - return this->halfedge()->vertex_degree(); + return this->halfedge()!=Halfedge_const_handle() + ? this->halfedge()->vertex_degree() : 0; } size_type degree() const { return vertex_degree(); } //backwards compatible From 84fac01b0683fe9e3f72aaa334d97d6f856c2748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 4 Aug 2021 15:29:22 +0200 Subject: [PATCH 18/20] fix doc: constants -> functions since e3e0efb --- Stream_support/doc/Stream_support/IOstream.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Stream_support/doc/Stream_support/IOstream.txt b/Stream_support/doc/Stream_support/IOstream.txt index 6f0f73ba7a2..4d262edeaf2 100644 --- a/Stream_support/doc/Stream_support/IOstream.txt +++ b/Stream_support/doc/Stream_support/IOstream.txt @@ -224,10 +224,10 @@ for drawing operations in many \cgal output streams. Each color is defined by a triple of integers `(r,g,b)` with 0 \f$ \le \f$ r,g,b \f$ \le \f$ 255, the so-called rgb-value of the color. -There are a 11 predefined `Color` constants available: -`BLACK`, `WHITE`, `GRAY`, `RED`, `GREEN`, -`DEEPBLUE`, `BLUE`, `PURPLE`, `VIOLET`, `ORANGE`, -and `YELLOW`. +There are a 11 predefined `Color` functions available: +`black()`, `white()`, `gray()`, `red()`, `green()`, +`deep_blue()`, `blue()`, `purple()`, `violet()`, `orange()`, +and `yellow()`. From c9780d93e49116bfe721037cf7cf5fc6902557c8 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 10 Aug 2021 13:11:42 +0200 Subject: [PATCH 19/20] For the moment, documentation_parser.py is a python2 script --- Documentation/doc/scripts/compare_testsuites.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/doc/scripts/compare_testsuites.sh b/Documentation/doc/scripts/compare_testsuites.sh index 1c5a594ce1b..140dd9a94db 100644 --- a/Documentation/doc/scripts/compare_testsuites.sh +++ b/Documentation/doc/scripts/compare_testsuites.sh @@ -28,7 +28,7 @@ FAILURES=() for dir in $PATH_TO_DOC/* do OUTPUT=$(basename $dir) - python ../documentation_parser.py $dir/xml > ./"$OUTPUT.txt" + python2 ../documentation_parser.py $dir/xml > ./"$OUTPUT.txt" if [ $? -eq 0 ]; then echo "$dir OK" else From 97fb041ad5ee39ad4041f3dbb564e398bb93bbaf Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 10 Aug 2021 13:34:40 +0200 Subject: [PATCH 20/20] Port documentation_parser.py to Python3 My attempt with python2 on Ubuntu 20.04 failed. Let's move to Python3, at least for this script. --- .../doc/scripts/compare_testsuites.sh | 2 +- .../doc/scripts/documentation_parser.py | 38 ++++++++++--------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Documentation/doc/scripts/compare_testsuites.sh b/Documentation/doc/scripts/compare_testsuites.sh index 140dd9a94db..0181e8166cc 100644 --- a/Documentation/doc/scripts/compare_testsuites.sh +++ b/Documentation/doc/scripts/compare_testsuites.sh @@ -28,7 +28,7 @@ FAILURES=() for dir in $PATH_TO_DOC/* do OUTPUT=$(basename $dir) - python2 ../documentation_parser.py $dir/xml > ./"$OUTPUT.txt" + python3 ../documentation_parser.py $dir/xml > ./"$OUTPUT.txt" if [ $? -eq 0 ]; then echo "$dir OK" else diff --git a/Documentation/doc/scripts/documentation_parser.py b/Documentation/doc/scripts/documentation_parser.py index 187b175bf4f..462291efae6 100644 --- a/Documentation/doc/scripts/documentation_parser.py +++ b/Documentation/doc/scripts/documentation_parser.py @@ -1,3 +1,5 @@ +#/usr/bin/env python3 + from pyquery import PyQuery as pq from collections import defaultdict from sys import argv @@ -12,17 +14,17 @@ def check_type(_in, args): root_path=argv[1] d = pq(filename=op.join(op.sep, root_path,'index.xml'), parser="xml") -compounds=[p.text() for p in d('compound').items()] -types=[p.attr('kind') for p in d('compound').items()] +compounds=[p.text() for p in list(d('compound').items())] +types=[p.attr('kind') for p in list(d('compound').items())] type_map = defaultdict(list) #map dict_map = defaultdict(dict)#map > #FOREACH compounds : fill maps -for i in xrange(0,len(compounds)): +for i in range(0,len(compounds)): if check_type(types[i], "typedef"): types[i]="type" name=d('compound').children("name").eq(i).text() - members=[p.text() for p in d('compound').eq(i).children("member").items()] - m_types=[p.attr('kind') for p in d('compound').eq(i).children("member").items()] + members=[p.text() for p in list(d('compound').eq(i).children("member").items())] + m_types=[p.attr('kind') for p in list(d('compound').eq(i).children("member").items())] if (not check_type(types[i], ['example', 'file', 'dir', 'page', 'group']) and not (types[i] == "namespace" and len(members) == 0) and not (types[i] == "enum" and len(members) == 0) ): @@ -32,7 +34,7 @@ for i in xrange(0,len(compounds)): total_path=op.join(op.sep, root_path,filepath) if(op.isfile(total_path)): e = pq(filename=total_path, parser="xml") - compoundnames=[p.text() for p in e('includes').items()] + compoundnames=[p.text() for p in list(e('includes').items())] if(len(compoundnames) > 1 and compoundnames[0].find("Concept") != -1): types[i] = 'Concept '+types[i].lower() @@ -41,7 +43,7 @@ for i in xrange(0,len(compounds)): mtype_map = defaultdict(list)# map #FOREACH member : - for j in xrange(0,len(members)): + for j in range(0,len(members)): if(check_type(types[i], ['class', 'Concept class']) and m_types[j] == "function"): m_types[j]="method" @@ -62,7 +64,7 @@ for btype in type_map: out=btype if btype.endswith('s'): out+='e' - print out.title()+'s' + print(out.title()+'s') indent+=" " #FOREACH name for name in type_map[btype]: @@ -74,7 +76,7 @@ for btype in type_map: templates=[] if op.isfile(op.join(op.sep, root_path,filepath)): f=pq(filename=op.join(op.sep, root_path,filepath), parser="xml") - templateparams=f("compounddef").children("templateparamlist").eq(0).children("param").items() + templateparams=list(f("compounddef").children("templateparamlist").eq(0).children("param").items()) for param in templateparams: template_type="" template_name="" @@ -91,7 +93,7 @@ for btype in type_map: complete_template+=' = '+template_defval templates.append(complete_template) if templates==[]:#if no child was found, just take param.text() - templates=[t.text() for t in param.items()] + templates=[t.text() for t in list(param.items())] suffix="<" #as template got type, defname and declname, name is twice in template. keep only one of them. to_remove=[""] @@ -101,7 +103,7 @@ for btype in type_map: suffix="" if suffix.endswith(', '): suffix = suffix[:-2]+'>' - print indent+name+suffix + print(indent+name+suffix) indent+=" " #FOREACH mtype @@ -109,7 +111,7 @@ for btype in type_map: out=mtype if mtype.endswith('s'): out+='e' - print indent+out.title()+'s' + print(indent+out.title()+'s') indent+=" " #FOREACH member overload_map = defaultdict(int) #contains the number of times a member has appeared (to manage the overloads) @@ -123,16 +125,16 @@ for btype in type_map: if op.isfile(op.join(op.sep, root_path,filepath)): f=pq(filename=op.join(op.sep, root_path,filepath), parser="xml") index=0 - memberdefs=[m.text() for m in f("memberdef").items()] - for i in xrange(0,len(memberdefs)): - member_names=[member_name.text() for member_name in f('memberdef').eq(i).children("name").items()] + memberdefs=[m.text() for m in list(f("memberdef").items())] + for i in range(0,len(memberdefs)): + member_names=[member_name.text() for member_name in list(f('memberdef').eq(i).children("name").items())] if f('memberdef').eq(i).children("name").text() == member: if (index < overload_map[member]): index+=1 elif (index == overload_map[member]): if check_type(mtype, ['function', 'method']): args=[f('memberdef').eq(i).children("argsstring").text()] - templateparams=f('memberdef').eq(i).children("templateparamlist").children("param").items() + templateparams=list(f('memberdef').eq(i).children("templateparamlist").children("param").items()) if check_type(mtype, ['function', 'method', 'type', 'variable']): return_type=[f('memberdef').eq(i).children("type").text()] break; @@ -158,7 +160,7 @@ for btype in type_map: complete_template+=' = '+template_defval templates.append(complete_template) if templates==[]:#if no child was found, just take param.text() - templates=[t.text() for t in param.items()] + templates=[t.text() for t in list(param.items())] prefix="template <" for template in templates: @@ -171,7 +173,7 @@ for btype in type_map: prefix+=definition if(prefix != ""): prefix+=" " - print indent+prefix+member+arguments + print(indent+prefix+member+arguments) overload_map[member]+=1 #END foreach member indent=indent[:-2]