From 2bfdc8398f4cd17f5fefc90455e1c00e4f970e70 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 8 Jan 2020 16:37:39 +0100 Subject: [PATCH 01/40] Move the file_input.h file to Triangulation_3 and write some doc. Unify with the API of copy_tds() and adapt the c3t3_io plugin. --- .../Plugins/Mesh_3/C3t3_io_plugin.cpp | 47 ++++++++++++++----- .../Concepts/TriangulationDataStructure_3.h | 4 +- .../CGAL/IO/Triangulation_file_input.h | 37 +++++++++++++++ .../CGAL/IO}/Triangulation_file_input.h | 41 ++++++++-------- 4 files changed, 95 insertions(+), 34 deletions(-) create mode 100644 Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h rename {Polyhedron/demo/Polyhedron/include/CGAL => Triangulation_3/include/CGAL/IO}/Triangulation_file_input.h (73%) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 4a7c004be2b..3f36d847090 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -400,7 +400,12 @@ struct Update_vertex typedef typename Tr1::Vertex V1; typedef typename Tr2::Vertex V2; typedef typename Tr2::Point Point; - + + V2 operator()(const V1&) + { + return V2(); + } + bool operator()(const V1& v1, V2& v2) { v2.set_point(Point(v1.point())); @@ -413,7 +418,7 @@ struct Update_vertex const Sp_index sp_index = boost::get(index); v2.set_index((std::max)(sp_index.first, sp_index.second)); } - break; + break; default:// -1, 0, 1, 3 v2.set_index(boost::get(v1.index())); } @@ -421,9 +426,18 @@ struct Update_vertex } }; // end struct Update_vertex +template struct Update_cell { + typedef Fake_mesh_domain::Surface_patch_index Sp_index; - template + typedef typename Tr2::Cell C2; + + template + C2 operator()(const C1&) { + return C2(); + } + + template bool operator()(const C1& c1, C2& c2) { c2.set_subdomain_index(c1.subdomain_index()); for(int i = 0; i < 4; ++i) { @@ -437,7 +451,7 @@ struct Update_cell { } }; // end struct Update_cell -#include +#include template struct Update_vertex_from_CDT_3 { @@ -447,24 +461,35 @@ struct Update_vertex_from_CDT_3 { typedef typename Tr2::Vertex V2; typedef typename Tr2::Point Point; - bool operator()(const V1& v1, V2& v2) + V2 operator()(const V1&) + { + return V2(); + } + void operator()(const V1& v1, V2& v2) { v2.set_point(Point(v1.point())); v2.set_dimension(2); v2.set_special(false); - return true; } }; // end struct Update_vertex +template struct Update_cell_from_CDT_3 { + typedef Fake_mesh_domain::Surface_patch_index Sp_index; - template - bool operator()(const C1& c1, C2& c2) { + typedef typename Tr2::Cell C2; + + template + C2 operator()(const C1&) { + return C2(); + } + + template + void operator()(const C1& c1, C2& c2) { c2.set_subdomain_index(1); for(int i = 0; i < 4; ++i) { c2.set_surface_patch_index(i, c1.constrained_facet[i]); } - return true; } }; // end struct Update_cell @@ -499,7 +524,7 @@ try_load_a_cdt_3(std::istream& is, C3t3& c3t3) Fake_CDT_3, C3t3::Triangulation, Update_vertex_from_CDT_3, - Update_cell_from_CDT_3>(is, c3t3.triangulation())) + Update_cell_from_CDT_3 >(is, c3t3.triangulation())) { c3t3.rescan_after_load_of_triangulation(); std::cerr << "Try load a CDT_3... DONE"; @@ -543,7 +568,7 @@ try_load_other_binary_format(std::istream& is, C3t3& c3t3) Fake_c3t3::Triangulation, C3t3::Triangulation, Update_vertex, - Update_cell>(is, c3t3.triangulation()); + Update_cell >(is, c3t3.triangulation()); c3t3.rescan_after_load_of_triangulation(); return f_is.good(); diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h index 175a64c4e20..e97594ba277 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h @@ -251,10 +251,10 @@ otherwise `Vertex_handle()` is returned. - A model of `ConvertVertex` must provide two operator()'s that are responsible for converting the source vertex `v_src` into the target vertex: - `Vertex operator()(const TDS_src::Vertex& v_src) const;` This operator is used to create the vertex from `v_src`. - - `void operator()(const TDS_src::Vertex& v_src, Vertex& v_tgt) const;` This operator is meant to be used in case heavy data should transferred to `v_tgt`. + - `void operator()(const TDS_src::Vertex& v_src, Vertex& v_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `v_tgt`. - A model of ConvertCell must provide two operator()'s that are responsible for converting the source cell `c_src` into the target cell: - `Cell operator()(const TDS_src::Cell& c_src) const;` This operator is used to create the cell from `c_src`. - - `void operator()(const TDS_src::Cell& c_src, Cell& c_tgt) const;` This operator is meant to be used in case heavy data should transferred to `c_tgt`. + - `void operator()(const TDS_src::Cell& c_src, Cell& c_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `c_tgt`. \pre The optional argument `v` is a vertex of `tds_src` or is `Vertex_handle()`. */ diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h new file mode 100644 index 00000000000..6b9f8645638 --- /dev/null +++ b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h @@ -0,0 +1,37 @@ +namespace CGAL { + +/*! +The triangulation streamed in `is` is written into `tr`. As the vertex and cell + types might be different +and incompatible, the creation of new cells and vertices is made thanks to the +functors `convert_vertex` and `convert_cell`, that convert vertex and cell types. +For each vertex `v_src` in `in`, the corresponding vertex `v_tgt` in `tr` is a +copy of the vertex returned by `convert_vertex(v_src)`. The same operations are +done for cells with the functor convert_cell. If `v != Tr_src::Vertex_handle()`, +a handle to the vertex created in `tr` that is the copy of `v` is returned, +otherwise `Tr_tgt::Vertex_handle()` is returned. + + - A model of `ConvertVertex` must provide two operator()'s that are responsible + for converting the source vertex `v_src` into the target vertex: + - `Tr_tgt::Vertex operator()(const Tr_src::Vertex& v_src) const;` This operator is +used to create the vertex from `v_src`. + - `void operator()(const Tr_src::Vertex& v_src, Tr_tgt::Vertex& v_tgt) const;` This + operator is meant to be used in case heavy data should be transferred to `v_tgt`. + - A model of ConvertCell must provide two operator()'s that are responsible for +converting the source cell `c_src` into the target cell: + - `Tr_tgt::Cell operator()(const Tr_src::Cell& c_src) const;` This operator is used to + create the cell from `c_src`. + - `void operator()(const Tr_src::Cell& c_src, Tr_tgt::Cell& c_tgt) const;` This operator + is meant to be used in case heavy data should be transferred to `c_tgt`. + +\pre The optional argument `v` is a vertex of `tr_src` or is `Vertex_handle()`. +*/ +template +std::istream& file_input(std::istream& is, Tr_tgt &tr, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()); + +} diff --git a/Polyhedron/demo/Polyhedron/include/CGAL/Triangulation_file_input.h b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h similarity index 73% rename from Polyhedron/demo/Polyhedron/include/CGAL/Triangulation_file_input.h rename to Triangulation_3/include/CGAL/IO/Triangulation_file_input.h index 6c2906c7ccb..4cbb63a7c3b 100644 --- a/Polyhedron/demo/Polyhedron/include/CGAL/Triangulation_file_input.h +++ b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h @@ -15,7 +15,7 @@ // $URL$ // $Id$ // -// Author(s) : Laurent Rineau +// Author(s) : Laurent Rineau, Maxime Gimeno // // Adapted from operator>>(std::istream&, Triangulation_3&) from @@ -28,13 +28,13 @@ namespace CGAL { -template -std::istream& file_input(std::istream& is, Tr2 &tr, - Update_vertex update_vertex = Update_vertex(), - Update_cell update_cell = Update_cell()) +template +std::istream& file_input(std::istream& is, Tr_tgt &tr, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()) // reads // the dimension // the number of finite vertices @@ -45,12 +45,12 @@ std::istream& file_input(std::istream& is, Tr2 &tr, // the neighbors of each cell by their index in the preceding list of cells // when dimension < 3 : the same with faces of maximal dimension { - typedef Tr2 Triangulation; + typedef Tr_tgt Triangulation; typedef typename Triangulation::Vertex_handle Vertex_handle; typedef typename Triangulation::Cell_handle Cell_handle; - typedef typename Tr1::Vertex Vertex1; - typedef typename Tr1::Cell Cell1; + typedef typename Tr_src::Vertex Vertex1; + typedef typename Tr_src::Cell Cell1; tr.clear(); tr.tds().cells().clear(); @@ -71,13 +71,12 @@ std::istream& file_input(std::istream& is, Tr2 &tr, // the infinite vertex is numbered 0 for (std::size_t i=1; i <= n; i++) { - V[i] = tr.tds().create_vertex(); + //V[i] = tr.tds().create_vertex(); Vertex1 v; if(!(is >> v)) return is; - if(!update_vertex(v, *V[i])) { - is.setstate(std::ios_base::failbit); - return is; - } + Vertex_handle vh=tr.tds().create_vertex( convert_vertex(v) ); + V[i] = vh; + convert_vertex(v, *V[i]); } std::vector< Cell_handle > C; @@ -88,10 +87,9 @@ std::istream& file_input(std::istream& is, Tr2 &tr, for (std::size_t j=0 ; j < m; j++) { Cell1 c; if(!(is >> c)) return is; - if(!update_cell(c, *(C[j]))) { - is.setstate(std::ios_base::failbit); - return is; - } + Cell_handle ch=tr.tds().create_cell(convert_cell(c)); + C[j] = ch; + convert_cell(c, *ch); } CGAL_triangulation_assertion( tr.is_valid(false) ); @@ -100,4 +98,5 @@ std::istream& file_input(std::istream& is, Tr2 &tr, } // end namespace CGAL -#endif // CGAL_TRIANGULATION_FILE_INPUT_3_H + +#endif // TRIANGULATION_FILE_INPUT_H From 82bcfb7087899e11b3751770e509e39444da40f8 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 9 Jan 2020 09:58:40 +0100 Subject: [PATCH 02/40] Add license and remove need for operator(const C&), which cannot be called. --- .../Plugins/Mesh_3/C3t3_io_plugin.cpp | 24 ++++--------------- .../CGAL/IO/Triangulation_file_input.h | 22 ++++++++--------- .../CGAL/IO/Triangulation_file_input.h | 8 ++++--- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 3f36d847090..3faf168ac37 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -426,18 +426,11 @@ struct Update_vertex } }; // end struct Update_vertex -template struct Update_cell { typedef Fake_mesh_domain::Surface_patch_index Sp_index; - typedef typename Tr2::Cell C2; - - template - C2 operator()(const C1&) { - return C2(); - } - - template + + template bool operator()(const C1& c1, C2& c2) { c2.set_subdomain_index(c1.subdomain_index()); for(int i = 0; i < 4; ++i) { @@ -473,18 +466,11 @@ struct Update_vertex_from_CDT_3 { } }; // end struct Update_vertex -template struct Update_cell_from_CDT_3 { typedef Fake_mesh_domain::Surface_patch_index Sp_index; - typedef typename Tr2::Cell C2; - template - C2 operator()(const C1&) { - return C2(); - } - - template + template void operator()(const C1& c1, C2& c2) { c2.set_subdomain_index(1); for(int i = 0; i < 4; ++i) { @@ -524,7 +510,7 @@ try_load_a_cdt_3(std::istream& is, C3t3& c3t3) Fake_CDT_3, C3t3::Triangulation, Update_vertex_from_CDT_3, - Update_cell_from_CDT_3 >(is, c3t3.triangulation())) + Update_cell_from_CDT_3>(is, c3t3.triangulation())) { c3t3.rescan_after_load_of_triangulation(); std::cerr << "Try load a CDT_3... DONE"; @@ -568,7 +554,7 @@ try_load_other_binary_format(std::istream& is, C3t3& c3t3) Fake_c3t3::Triangulation, C3t3::Triangulation, Update_vertex, - Update_cell >(is, c3t3.triangulation()); + Update_cell>(is, c3t3.triangulation()); c3t3.rescan_after_load_of_triangulation(); return f_is.good(); diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h index 6b9f8645638..225ac7d014e 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h @@ -2,14 +2,16 @@ namespace CGAL { /*! The triangulation streamed in `is` is written into `tr`. As the vertex and cell - types might be different -and incompatible, the creation of new cells and vertices is made thanks to the -functors `convert_vertex` and `convert_cell`, that convert vertex and cell types. -For each vertex `v_src` in `in`, the corresponding vertex `v_tgt` in `tr` is a -copy of the vertex returned by `convert_vertex(v_src)`. The same operations are -done for cells with the functor convert_cell. If `v != Tr_src::Vertex_handle()`, -a handle to the vertex created in `tr` that is the copy of `v` is returned, -otherwise `Tr_tgt::Vertex_handle()` is returned. + types might be different and incompatible, the creation of new cells and vertices +is made thanks to the functors `convert_vertex` and `convert_cell`, that convert +vertex and cell types. For each vertex `v_src` in `in`, the corresponding +vertex `v_tgt` in `tr` is a copy of the vertex returned by `convert_vertex(v_src)`. +The same operations are done for cells with the functor convert_cell, except cells +int tr are created using the default constructor, and then filled with the data +contained in the stream. + +If `v != Tr_src::Vertex_handle()`, a handle to the vertex created in `tr` +that is the copy of `v` is returned, otherwise `Tr_tgt::Vertex_handle()` is returned. - A model of `ConvertVertex` must provide two operator()'s that are responsible for converting the source vertex `v_src` into the target vertex: @@ -17,10 +19,8 @@ otherwise `Tr_tgt::Vertex_handle()` is returned. used to create the vertex from `v_src`. - `void operator()(const Tr_src::Vertex& v_src, Tr_tgt::Vertex& v_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `v_tgt`. - - A model of ConvertCell must provide two operator()'s that are responsible for + - A model of ConvertCell must provide an operator()'s that are responsible for converting the source cell `c_src` into the target cell: - - `Tr_tgt::Cell operator()(const Tr_src::Cell& c_src) const;` This operator is used to - create the cell from `c_src`. - `void operator()(const Tr_src::Cell& c_src, Tr_tgt::Cell& c_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `c_tgt`. diff --git a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h index 4cbb63a7c3b..11f0daa02e7 100644 --- a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h +++ b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h @@ -14,6 +14,7 @@ // // $URL$ // $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Laurent Rineau, Maxime Gimeno // @@ -24,6 +25,9 @@ #ifndef CGAL_TRIANGULATION_FILE_INPUT_3_H #define CGAL_TRIANGULATION_FILE_INPUT_3_H +#include + + #include namespace CGAL { @@ -87,9 +91,7 @@ std::istream& file_input(std::istream& is, Tr_tgt &tr, for (std::size_t j=0 ; j < m; j++) { Cell1 c; if(!(is >> c)) return is; - Cell_handle ch=tr.tds().create_cell(convert_cell(c)); - C[j] = ch; - convert_cell(c, *ch); + convert_cell(c, *C[j]); } CGAL_triangulation_assertion( tr.is_valid(false) ); From 9fe491adfb87cedafd05ad982218fb44509fa41a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 10 Jan 2020 11:54:48 +0100 Subject: [PATCH 03/40] Update license header --- .../include/CGAL/IO/Triangulation_file_input.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h index 11f0daa02e7..f887d6be435 100644 --- a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h +++ b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h @@ -1,27 +1,20 @@ // Copyright (c) 1997-2010 INRIA Sophia-Antipolis (France). -// Copyright (c) 2011 GeometryFactory Sarl (France) +// Copyright (c) 2011, 2020 GeometryFactory Sarl (France) // All rights reserved. // -// This file is part of CGAL (www.cgal.org); you may redistribute it under -// the terms of the Q Public License version 1.0. -// See the file LICENSE.QPL distributed with CGAL. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// This file is part of CGAL (www.cgal.org). // // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Laurent Rineau, Maxime Gimeno // +// Author(s) : Laurent Rineau, Maxime Gimeno // Adapted from operator>>(std::istream&, Triangulation_3&) from // + #ifndef CGAL_TRIANGULATION_FILE_INPUT_3_H #define CGAL_TRIANGULATION_FILE_INPUT_3_H From 065a7ac0c65c167fa3dd21c45a3129dd17a79baf Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 10 Jan 2020 13:14:31 +0100 Subject: [PATCH 04/40] Add a test for file_input() --- .../include/CGAL/Triangulation_3.h | 13 ++++ .../test/Triangulation_3/CMakeLists.txt | 1 + .../test_io_triangulation_3.cpp | 66 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 6941c6c8acf..6f05f4e52e9 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -60,6 +60,7 @@ #include #include #include +#include #ifndef CGAL_TRIANGULATION_3_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO #include @@ -2193,8 +2194,20 @@ public: bool is_valid(bool verbose = false, int level = 0) const; bool is_valid(Cell_handle c, bool verbose = false, int level = 0) const; bool is_valid_finite(Cell_handle c, bool verbose = false, int level=0) const; + + //IO + template + std::istream& file_input(std::istream& is, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()) + { + return CGAL::file_input(is, *this, convert_vertex, convert_cell); + } }; + template < class GT, class Tds, class Lds > std::istream& operator>> (std::istream& is, Triangulation_3& tr) { diff --git a/Triangulation_3/test/Triangulation_3/CMakeLists.txt b/Triangulation_3/test/Triangulation_3/CMakeLists.txt index 0fdbcfc1d4e..bd63ebce0be 100644 --- a/Triangulation_3/test/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/test/Triangulation_3/CMakeLists.txt @@ -28,6 +28,7 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "test_simplex_3.cpp" ) create_single_source_cgal_program( "test_static_filters.cpp" ) create_single_source_cgal_program( "test_triangulation_3.cpp" ) + create_single_source_cgal_program( "test_io_triangulation_3.cpp" ) if(TBB_FOUND) foreach(target diff --git a/Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp b/Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp new file mode 100644 index 00000000000..51e0d9a9355 --- /dev/null +++ b/Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp @@ -0,0 +1,66 @@ + + +#include +#include +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian K1; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K2; +typedef CGAL::Triangulation_3 Tr1; +typedef CGAL::Triangulation_3 Tr2; + + +template +struct Update_vertex +{ + typedef typename T1::Vertex V1; + typedef typename T2::Vertex V2; + typedef typename T2::Point Point; + + V2 operator()(const V1&) + { + return V2(); + } + + void operator()(const V1& v1, V2& v2) + { + CGAL::Cartesian_converter c; + v2.set_point(Point(c(v1.point()))); + } +}; // end struct Update_vertex + +struct Update_cell { + template + void operator()(const C1&, C2&) {} +}; // end struct Update_cell +int main() +{ + // construction from a list of points : + std::list L; + L.push_back(Tr1::Point(0,0,0)); + L.push_back(Tr1::Point(1,0,0)); + L.push_back(Tr1::Point(0,1,0)); + L.push_back(Tr1::Point(0,0,1)); + Tr1 T1(L.begin(), L.end()); + std::ofstream out("tr"); + out << T1; + out.close(); + + Tr2 T2; + std::ifstream in("tr"); + T2.file_input, Update_cell>(in); + in.close(); + assert(T2.is_valid()); + Tr2::Point_iterator pit = T2.points_begin(); + assert(*(pit)++ == Tr2::Point(0,0,0)); + assert(*(pit)++ == Tr2::Point(1,0,0)); + assert(*(pit)++ == Tr2::Point(0,1,0)); + assert(*(pit)++ == Tr2::Point(0,0,1)); + + + std::cout << "done" << std::endl; + return 0; +} From 283c4e67a5fbc47232e6a353dd1d6b984a44987a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 13 Jan 2020 14:44:35 +0100 Subject: [PATCH 05/40] Add CHANGES.md --- Installation/CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 012dbdf1a9b..3d397b8d427 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -27,6 +27,12 @@ Release date: June 2020 does not allow any intersection, except for the configuration of two constraints having a single common endpoints, for convience. +### 3D Triangulations +- The free function `CGAL::file_input()` and the member function `CGAL::Triangulation_3::file_input()` + have been added. The first allows to load a `Triangulation_3` from an input stream, using functors to create vertices and cells. + The second is simply the member function version of the first one. + + ### dD Spatial Searching - Improved the performance of the kd-tree in some cases: From 796402859032673b31f5b6eb8bb8abf142c7826b Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 13 Jan 2020 15:48:38 +0100 Subject: [PATCH 06/40] More doc --- .../CGAL/IO/Triangulation_file_input.h | 13 ++++--- .../Triangulation_3/CGAL/Triangulation_3.h | 36 ++++++++++++++++++- .../Triangulation_3/PackageDescription.txt | 6 ++++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h index 225ac7d014e..026df60935b 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h @@ -1,30 +1,33 @@ namespace CGAL { /*! -The triangulation streamed in `is` is written into `tr`. As the vertex and cell +\ingroup PkgIOTriangulation3 + +The triangulation streamed in `is`, of original type `Tr_src`, is written into `tr`, of type `Tr_tgt`. As the vertex and cell types might be different and incompatible, the creation of new cells and vertices is made thanks to the functors `convert_vertex` and `convert_cell`, that convert vertex and cell types. For each vertex `v_src` in `in`, the corresponding vertex `v_tgt` in `tr` is a copy of the vertex returned by `convert_vertex(v_src)`. The same operations are done for cells with the functor convert_cell, except cells -int tr are created using the default constructor, and then filled with the data +in `tr` are created using the default constructor, and then filled with the data contained in the stream. If `v != Tr_src::Vertex_handle()`, a handle to the vertex created in `tr` that is the copy of `v` is returned, otherwise `Tr_tgt::Vertex_handle()` is returned. - - A model of `ConvertVertex` must provide two operator()'s that are responsible + - A model of `ConvertVertex` must provide two `operator()`s that are responsible for converting the source vertex `v_src` into the target vertex: - `Tr_tgt::Vertex operator()(const Tr_src::Vertex& v_src) const;` This operator is used to create the vertex from `v_src`. - `void operator()(const Tr_src::Vertex& v_src, Tr_tgt::Vertex& v_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `v_tgt`. - - A model of ConvertCell must provide an operator()'s that are responsible for + - A model of ConvertCell must provide an `operator()` that is responsible for converting the source cell `c_src` into the target cell: - `void operator()(const Tr_src::Cell& c_src, Tr_tgt::Cell& c_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `c_tgt`. -\pre The optional argument `v` is a vertex of `tr_src` or is `Vertex_handle()`. +\note It is required to know the type `Tr_src`, or one that is compatible with it, to call this function. +\note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. */ template > (istream& is, Triangulation_3 &t); Writes the triangulation `t` into `os`. */ ostream& operator<< (ostream& os, const Triangulation_3 &t); - /// @} +/// +/*! +\ingroup PkgIOTriangulation3 +The triangulation streamed in `is`, of original type `Tr_src`, is written into the triangulation. As the vertex and cell + types might be different and incompatible, the creation of new cells and vertices +is made thanks to the functors `convert_vertex` and `convert_cell`, that convert +vertex and cell types. For each vertex `v_src` in `in`, the corresponding +vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. +The same operations are done for cells with the functor convert_cell, except cells +in the triangulation are created using the default constructor, and then filled with the data +contained in the stream. + +If `v != Tr_src::Vertex_handle()`, a handle to the vertex created in `tr` +that is the copy of `v` is returned, otherwise `Vertex_handle()` is returned. + + - A model of `ConvertVertex` must provide two `operator()`s that are responsible + for converting the source vertex `v_src` into the target vertex: + - `Vertex operator()(const Tr_src::Vertex& v_src) const;` This operator is +used to create the vertex from `v_src`. + - `void operator()(const Tr_src::Vertex& v_src, Vertex& v_tgt) const;` This + operator is meant to be used in case heavy data should be transferred to `v_tgt`. + - A model of ConvertCell must provide an operator() that is responsible for +converting the source cell `c_src` into the target cell: + - `void operator()(const Tr_src::Cell& c_src, Cell& c_tgt) const;` This operator + is meant to be used in case heavy data should be transferred to `c_tgt`. + +\note It is required to know the type `Tr_src`, or one that is compatible with it, to call this function. +\note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. +*/ +template +std::istream& file_input(std::istream& is, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()); /// \name Concurrency /// @{ diff --git a/Triangulation_3/doc/Triangulation_3/PackageDescription.txt b/Triangulation_3/doc/Triangulation_3/PackageDescription.txt index 1804cdccaf7..a912dd4eec4 100644 --- a/Triangulation_3/doc/Triangulation_3/PackageDescription.txt +++ b/Triangulation_3/doc/Triangulation_3/PackageDescription.txt @@ -21,6 +21,9 @@ /// \defgroup PkgDrawTriangulation3 Draw a Triangulation 3 /// \ingroup PkgTriangulation3Ref +/// \defgroup PkgIOTriangulation3 Input for a Triangulation 3 +/// \ingroup PkgTriangulation3Ref + /*! \addtogroup PkgTriangulation3Ref \cgalPkgDescriptionBegin{3D Triangulations,PkgTriangulation3} @@ -121,5 +124,8 @@ is opposite to the vertex with the same index. See - \link PkgDrawTriangulation3 CGAL::draw() \endlink +\cgalCRPSection{I/O} + - \link PkgIOTriangulation3 CGAL:Triangulation_3::file_input()\endlink + - \link PkgIOTriangulation3 CGAL::file_input()\endlink */ From 66cd3401f9e0c73b637d85486869489cc7ae8012 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 26 Feb 2020 10:57:55 +0100 Subject: [PATCH 07/40] Add a generic function in TDS_3 that takes a boolean argument to decide how to take care of the infinite_vertex, and use it in the T3 functions. --- TDS_3/include/CGAL/IO/TDS_3_file_input.h | 38 +++++++ .../CGAL/internal/Tr_or_tds_file_input.h | 106 ++++++++++++++++++ .../CGAL/IO/Triangulation_file_input.h | 60 +--------- 3 files changed, 146 insertions(+), 58 deletions(-) create mode 100644 TDS_3/include/CGAL/IO/TDS_3_file_input.h create mode 100644 TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h diff --git a/TDS_3/include/CGAL/IO/TDS_3_file_input.h b/TDS_3/include/CGAL/IO/TDS_3_file_input.h new file mode 100644 index 00000000000..50b698ecdf6 --- /dev/null +++ b/TDS_3/include/CGAL/IO/TDS_3_file_input.h @@ -0,0 +1,38 @@ +#ifndef TDS_3_FILE_INPUT_H +#define TDS_3_FILE_INPUT_H +// Copyright (c) 1997-2010 INRIA Sophia-Antipolis (France). +// Copyright (c) 2011, 2020 GeometryFactory Sarl (France) +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Laurent Rineau, Maxime Gimeno + +// Adapted from operator>>(std::istream&, Triangulation_3&) from +// + +#include + + +#include + +namespace CGAL { + +template +std::istream& file_input(std::istream& is, Tr_tgt &tr, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()) +{ + return internal::file_input(is, tr, true, convert_vertex, convert_cell); +} + +} //end CGAL +#endif // TDS_3_FILE_INPUT_H diff --git a/TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h b/TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h new file mode 100644 index 00000000000..516bbb60d25 --- /dev/null +++ b/TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h @@ -0,0 +1,106 @@ +// Copyright (c) 1997-2010 INRIA Sophia-Antipolis (France). +// Copyright (c) 2011, 2020 GeometryFactory Sarl (France) +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Laurent Rineau, Maxime Gimeno + +// Adapted from operator>>(std::istream&, Triangulation_3&) from +// + + +#ifndef CGAL_TR_OR_TDS_FILE_INPUT_H +#define CGAL_TR_OR_TDS_FILE_INPUT_H + +#include + +#include + + +#include + +namespace CGAL { +namespace internal{ + +template +std::istream& file_input(std::istream& is, Tr_tgt &tr, bool is_tds, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()) + // reads + // the dimension + // the number of finite vertices + // the non combinatorial information on vertices (point, etc) + // the number of cells + // the cells by the indices of their vertices in the preceding list + // of vertices, plus the non combinatorial information on each cell + // the neighbors of each cell by their index in the preceding list of cells + // when dimension < 3 : the same with faces of maximal dimension + + // If this is used for a TDS, the vertices are processed from 0 to n. + // Else, we make V[0] the infinite vertex and work from 1 to n+1. +{ + typedef Tr_tgt Triangulation; + typedef typename Triangulation::Vertex_handle Vertex_handle; + typedef typename Triangulation::Cell_handle Cell_handle; + + typedef typename Tr_src::Vertex Vertex1; + typedef typename Tr_src::Cell Cell1; + + tr.clear(); + tr.tds().cells().clear(); + + std::size_t n; + int d; + if(is_ascii(is)) + is >> d >> n; + else { + read(is, d); + read(is, n); + } + if(!is) return is; + tr.tds().set_dimension(d); + + std::size_t V_size = is_tds ? n : n+1; + std::vector< Vertex_handle > V(V_size); + + // the infinite vertex is numbered 0 + if(!is_tds) + V[0] = tr.infinite_vertex(); + + for (std::size_t i=is_tds ? 0 : 1; i < V_size; ++i) { + Vertex1 v; + if(!(is >> v)) return is; + Vertex_handle vh=tr.tds().create_vertex( convert_vertex(v) ); + V[i] = vh; + convert_vertex(v, *V[i]); + } + + std::vector< Cell_handle > C; + + std::size_t m; + tr.tds().read_cells(is, V, m, C); + + for (std::size_t j=0 ; j < m; j++) { + Cell1 c; + if(!(is >> c)) return is; + convert_cell(c, *C[j]); + } + + CGAL_triangulation_assertion( tr.is_valid(false) ); + return is; +} + +} //end internal +} // end namespace CGAL + + +#endif // CGAL_TR_OR_TDS_FILE_INPUT_H diff --git a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h index f887d6be435..0d6159489d7 100644 --- a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h +++ b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h @@ -20,8 +20,7 @@ #include - -#include +#include namespace CGAL { @@ -32,63 +31,8 @@ template > d >> n; - else { - read(is, d); - read(is, n); - } - if(!is) return is; - tr.tds().set_dimension(d); - - std::vector< Vertex_handle > V(n+1); - V[0] = tr.infinite_vertex(); - // the infinite vertex is numbered 0 - - for (std::size_t i=1; i <= n; i++) { - //V[i] = tr.tds().create_vertex(); - Vertex1 v; - if(!(is >> v)) return is; - Vertex_handle vh=tr.tds().create_vertex( convert_vertex(v) ); - V[i] = vh; - convert_vertex(v, *V[i]); - } - - std::vector< Cell_handle > C; - - std::size_t m; - tr.tds().read_cells(is, V, m, C); - - for (std::size_t j=0 ; j < m; j++) { - Cell1 c; - if(!(is >> c)) return is; - convert_cell(c, *C[j]); - } - - CGAL_triangulation_assertion( tr.is_valid(false) ); - return is; + return internal::file_input(is, tr, false, convert_vertex, convert_cell); } } // end namespace CGAL From 808606ebe34ed5fac7f60214826fb72e4ccc387a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 26 Feb 2020 11:36:34 +0100 Subject: [PATCH 08/40] Add a test in tds3 --- .../CGAL/Triangulation_data_structure_3.h | 14 +++++ TDS_3/test/TDS_3/CMakeLists.txt | 1 + TDS_3/test/TDS_3/test_io_tds3.cpp | 58 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 TDS_3/test/TDS_3/test_io_tds3.cpp diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index e971ee6a7db..9ddc129e82f 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -51,6 +51,8 @@ #include #include +#include + #ifdef CGAL_LINKED_WITH_TBB # include #endif @@ -189,6 +191,7 @@ public: return hf ^ 419 * hs; } + }; static const int maximal_nb_of_facets_of_small_hole = 128; @@ -1550,6 +1553,17 @@ private: // counts but does not check bool count_cells(size_type &i, bool verbose = false, int level = 0) const; // counts AND checks the validity + + //IO + template + std::istream& file_input(std::istream& is, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()) + { + return CGAL::file_input(is, *this, convert_vertex, convert_cell); + } }; #ifdef CGAL_TDS_USE_RECURSIVE_CREATE_STAR_3 diff --git a/TDS_3/test/TDS_3/CMakeLists.txt b/TDS_3/test/TDS_3/CMakeLists.txt index 0253c40548c..b21488fe951 100644 --- a/TDS_3/test/TDS_3/CMakeLists.txt +++ b/TDS_3/test/TDS_3/CMakeLists.txt @@ -10,6 +10,7 @@ if ( CGAL_FOUND ) find_package( TBB QUIET ) create_single_source_cgal_program( "test_triangulation_tds_3.cpp" ) + create_single_source_cgal_program( "test_io_tds3.cpp" ) if(TBB_FOUND) CGAL_target_use_TBB(test_triangulation_tds_3) endif() diff --git a/TDS_3/test/TDS_3/test_io_tds3.cpp b/TDS_3/test/TDS_3/test_io_tds3.cpp new file mode 100644 index 00000000000..fb1dc31092f --- /dev/null +++ b/TDS_3/test/TDS_3/test_io_tds3.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef CGAL::Triangulation_data_structure_3<> Tds; +typedef Tds::size_type size_type; +typedef Tds::Cell_handle Cell_handle; +typedef Tds::Vertex_handle Vertex_handle; + +template +struct Update_vertex +{ + typedef typename T1::Vertex V1; + typedef typename T2::Vertex V2; + + V2 operator()(const V1&) + { + return V2(); + } + + void operator()(const V1&, V2&) + { + + } +}; // end struct Update_vertex + + +int main() +{ + Tds T; + std::vector PV(7); + PV[0] = T.insert_increase_dimension(); + // each of the following insertions of vertices increases the dimension + for ( int i=1; i<5; i++ ) { + PV[i] = T.insert_increase_dimension(PV[0]); + } + // we now have a simplex in dimension 4 + // cell incident to PV[0] + Cell_handle c = PV[0]->cell(); + int ind; + // PV[0] is the vertex of index ind in c + // insertion of a new vertex in the facet opposite to PV[0] + PV[5] = T.insert_in_facet(c, ind); + // insertion of a new vertex in c + PV[6] = T.insert_in_cell(c); + std::ofstream out("tr"); + out << T; + out.close(); + Tds T2; + std::ifstream in("tr"); + //T2.file_input, Update_cell>(in); + in.close(); + return 0; +} From 14669c213c5748bb2542bd179b899fc64d266caa Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 26 Feb 2020 12:32:05 +0100 Subject: [PATCH 09/40] Doc --- Installation/CHANGES.md | 6 +++- .../Concepts/TriangulationDataStructure_3.h | 34 +++++++++++++++++++ .../Triangulation_3/CGAL/Triangulation_3.h | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 3d397b8d427..4f70bccd713 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -30,8 +30,12 @@ Release date: June 2020 ### 3D Triangulations - The free function `CGAL::file_input()` and the member function `CGAL::Triangulation_3::file_input()` have been added. The first allows to load a `Triangulation_3` from an input stream, using functors to create vertices and cells. - The second is simply the member function version of the first one. + The second is simply the member function version of the first one. +### 3D Triangulation Data Structure +- The free function `CGAL::file_input()` and the member function `CGAL::TDS_3::file_input()` + have been added. The first allows to load a `TDS_3` from an input stream, using functors to create vertices and cells. + The second is simply the member function version of the first one. ### dD Spatial Searching diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h index e97594ba277..7364fa36292 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h @@ -269,6 +269,40 @@ that. */ void swap(TriangulationDataStructure_3 & tds1); +/*! +The tds streamed in `is`, of original type `TDS_src`, is written into the triangulation. As the vertex and cell + types might be different and incompatible, the creation of new cells and vertices +is made thanks to the functors `convert_vertex` and `convert_cell`, that convert +vertex and cell types. For each vertex `v_src` in `in`, the corresponding +vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. +The same operations are done for cells with the functor convert_cell, except cells +in the triangulation are created using the default constructor, and then filled with the data +contained in the stream. + +If `v != TDS_src::Vertex_handle()`, a handle to the vertex created in this tds +that is the copy of `v` is returned, otherwise `Vertex_handle()` is returned. + + - A model of `ConvertVertex` must provide two `operator()`s that are responsible + for converting the source vertex `v_src` into the target vertex: + - `Vertex operator()(const TDS_src::Vertex& v_src) const;` This operator is +used to create the vertex from `v_src`. + - `void operator()(const TDS_src::Vertex& v_src, Vertex& v_tgt) const;` This + operator is meant to be used in case heavy data should be transferred to `v_tgt`. + - A model of ConvertCell must provide an operator() that is responsible for +converting the source cell `c_src` into the target cell: + - `void operator()(const TDS_src::Cell& c_src, Cell& c_tgt) const;` This operator + is meant to be used in case heavy data should be transferred to `c_tgt`. + +\note It is required to know the type `Tr_src`, or one that is compatible with it, to call this function. +\note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. +*/ +template +std::istream& file_input(std::istream& is, + ConvertVertex convert_vertex, + ConvertCell convert_cell); + /*! Deletes all cells and vertices. `tds` is reset as a triangulation data structure constructed by the default constructor. diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index e699abe913d..c4ed56bb003 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -1566,7 +1566,7 @@ The same operations are done for cells with the functor convert_cell, except cel in the triangulation are created using the default constructor, and then filled with the data contained in the stream. -If `v != Tr_src::Vertex_handle()`, a handle to the vertex created in `tr` +If `v != Tr_src::Vertex_handle()`, a handle to the vertex created in this triangulation that is the copy of `v` is returned, otherwise `Vertex_handle()` is returned. - A model of `ConvertVertex` must provide two `operator()`s that are responsible From ddc784db228b4d7c07395194a1a30bc4c7e8dfe2 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 26 Feb 2020 16:16:19 +0100 Subject: [PATCH 10/40] Fix doc --- TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h | 6 +++--- TDS_3/doc/TDS_3/PackageDescription.txt | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h index 7364fa36292..443ac28fd53 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h @@ -269,7 +269,7 @@ that. */ void swap(TriangulationDataStructure_3 & tds1); -/*! +/*! \ingroup PkgIOTDS3 The tds streamed in `is`, of original type `TDS_src`, is written into the triangulation. As the vertex and cell types might be different and incompatible, the creation of new cells and vertices is made thanks to the functors `convert_vertex` and `convert_cell`, that convert @@ -293,8 +293,8 @@ converting the source cell `c_src` into the target cell: - `void operator()(const TDS_src::Cell& c_src, Cell& c_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `c_tgt`. -\note It is required to know the type `Tr_src`, or one that is compatible with it, to call this function. -\note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. +\note It is required to know the type `TDS_src`, or one that is compatible with it, to call this function. +\note The triangulation contained in `is` can be obtained with the `operator>>` of a `TriangulationDataStructure_3`. */ template Date: Thu, 27 Feb 2020 11:43:31 +0100 Subject: [PATCH 11/40] Fixes in the doc --- .../Concepts/TriangulationDataStructure_3.h | 70 +++++++++---------- TDS_3/doc/TDS_3/PackageDescription.txt | 2 +- .../CGAL/IO/Triangulation_file_input.h | 8 +-- .../Triangulation_3/CGAL/Triangulation_3.h | 15 ++-- .../Triangulation_3/PackageDescription.txt | 2 +- 5 files changed, 47 insertions(+), 50 deletions(-) diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h index 443ac28fd53..aaca735e647 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h @@ -269,40 +269,6 @@ that. */ void swap(TriangulationDataStructure_3 & tds1); -/*! \ingroup PkgIOTDS3 -The tds streamed in `is`, of original type `TDS_src`, is written into the triangulation. As the vertex and cell - types might be different and incompatible, the creation of new cells and vertices -is made thanks to the functors `convert_vertex` and `convert_cell`, that convert -vertex and cell types. For each vertex `v_src` in `in`, the corresponding -vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. -The same operations are done for cells with the functor convert_cell, except cells -in the triangulation are created using the default constructor, and then filled with the data -contained in the stream. - -If `v != TDS_src::Vertex_handle()`, a handle to the vertex created in this tds -that is the copy of `v` is returned, otherwise `Vertex_handle()` is returned. - - - A model of `ConvertVertex` must provide two `operator()`s that are responsible - for converting the source vertex `v_src` into the target vertex: - - `Vertex operator()(const TDS_src::Vertex& v_src) const;` This operator is -used to create the vertex from `v_src`. - - `void operator()(const TDS_src::Vertex& v_src, Vertex& v_tgt) const;` This - operator is meant to be used in case heavy data should be transferred to `v_tgt`. - - A model of ConvertCell must provide an operator() that is responsible for -converting the source cell `c_src` into the target cell: - - `void operator()(const TDS_src::Cell& c_src, Cell& c_tgt) const;` This operator - is meant to be used in case heavy data should be transferred to `c_tgt`. - -\note It is required to know the type `TDS_src`, or one that is compatible with it, to call this function. -\note The triangulation contained in `is` can be obtained with the `operator>>` of a `TriangulationDataStructure_3`. -*/ -template -std::istream& file_input(std::istream& is, - ConvertVertex convert_vertex, - ConvertCell convert_cell); - /*! Deletes all cells and vertices. `tds` is reset as a triangulation data structure constructed by the default constructor. @@ -1055,17 +1021,51 @@ a precise indication on the kind of invalidity encountered. \cgalDebugEnd */ bool is_valid(Cell_handle c, bool verbose = false) const; +/// @} +/// \name I/O +/// @{ /*! + \ingroup PkgIOTDS3 Reads a combinatorial triangulation from `is` and assigns it to `tds` */ istream& operator>> (istream& is, TriangulationDataStructure_3 & tds); -/*! +/*! \ingroup PkgIOTDS3 Writes `tds` into the stream `os` */ ostream& operator<< (ostream& os, const TriangulationDataStructure_3 & tds); +/*! \ingroup PkgIOTDS3 +The tds streamed in `is`, of original type `TDS_src`, is written into the triangulation. As the vertex and cell + types might be different and incompatible, the creation of new cells and vertices +is made thanks to the functors `convert_vertex` and `convert_cell`, that convert +vertex and cell types. For each vertex `v_src` in `is`, the corresponding +vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. +The same operations are done for cells with the functor convert_cell, except cells +in the triangulation are created using the default constructor, and then filled with the data +contained in the stream. + + - A model of `ConvertVertex` must provide two `operator()`s that are responsible + for converting the source vertex `v_src` into the target vertex: + - `Vertex operator()(const TDS_src::Vertex& v_src) const;` This operator is +used to create the vertex from `v_src`. + - `void operator()(const TDS_src::Vertex& v_src, Vertex& v_tgt) const;` This + operator is meant to be used in case heavy data should be transferred to `v_tgt`. + - A model of ConvertCell must provide an operator() that is responsible for +converting the source cell `c_src` into the target cell: + - `void operator()(const TDS_src::Cell& c_src, Cell& c_tgt) const;` This operator + is meant to be used in case heavy data should be transferred to `c_tgt`. + +\note The triangulation contained in `is` can be obtained with the `operator>>` of a `TriangulationDataStructure_3`. +*/ +template +std::istream& file_input(std::istream& is, + ConvertVertex convert_vertex, + ConvertCell convert_cell); + /// @} }; /* end TriangulationDataStructure_3 */ diff --git a/TDS_3/doc/TDS_3/PackageDescription.txt b/TDS_3/doc/TDS_3/PackageDescription.txt index 6596a4d795e..9d680e94b3c 100644 --- a/TDS_3/doc/TDS_3/PackageDescription.txt +++ b/TDS_3/doc/TDS_3/PackageDescription.txt @@ -6,7 +6,7 @@ /// \defgroup PkgTDS3Classes Classes /// \ingroup PkgTDS3Ref -/// \defgroup PkgIOTDS3 Input for a Triangulation_data_structure_3 +/// \defgroup PkgIOTDS3 I/O for a Triangulation_data_structure_3 /// \ingroup PkgTDS3Ref /*! \addtogroup PkgTDS3Ref diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h index 026df60935b..f315ecc6116 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h @@ -1,5 +1,6 @@ namespace CGAL { +///@{ /*! \ingroup PkgIOTriangulation3 @@ -12,8 +13,6 @@ The same operations are done for cells with the functor convert_cell, except cel in `tr` are created using the default constructor, and then filled with the data contained in the stream. -If `v != Tr_src::Vertex_handle()`, a handle to the vertex created in `tr` -that is the copy of `v` is returned, otherwise `Tr_tgt::Vertex_handle()` is returned. - A model of `ConvertVertex` must provide two `operator()`s that are responsible for converting the source vertex `v_src` into the target vertex: @@ -24,9 +23,8 @@ used to create the vertex from `v_src`. - A model of ConvertCell must provide an `operator()` that is responsible for converting the source cell `c_src` into the target cell: - `void operator()(const Tr_src::Cell& c_src, Tr_tgt::Cell& c_tgt) const;` This operator - is meant to be used in case heavy data should be transferred to `c_tgt`. + is meant to be used in case data should be transferred to `c_tgt`. -\note It is required to know the type `Tr_src`, or one that is compatible with it, to call this function. \note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. */ template > (istream& is, Triangulation_3 &t); /*! + \ingroup PkgIOTriangulation3 Writes the triangulation `t` into `os`. */ ostream& operator<< (ostream& os, const Triangulation_3 &t); -/// @} -/// + /*! \ingroup PkgIOTriangulation3 The triangulation streamed in `is`, of original type `Tr_src`, is written into the triangulation. As the vertex and cell types might be different and incompatible, the creation of new cells and vertices is made thanks to the functors `convert_vertex` and `convert_cell`, that convert -vertex and cell types. For each vertex `v_src` in `in`, the corresponding +vertex and cell types. For each vertex `v_src` in `is`, the corresponding vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. The same operations are done for cells with the functor convert_cell, except cells in the triangulation are created using the default constructor, and then filled with the data contained in the stream. -If `v != Tr_src::Vertex_handle()`, a handle to the vertex created in this triangulation -that is the copy of `v` is returned, otherwise `Vertex_handle()` is returned. - - A model of `ConvertVertex` must provide two `operator()`s that are responsible for converting the source vertex `v_src` into the target vertex: - `Vertex operator()(const Tr_src::Vertex& v_src) const;` This operator is @@ -1578,9 +1576,8 @@ used to create the vertex from `v_src`. - A model of ConvertCell must provide an operator() that is responsible for converting the source cell `c_src` into the target cell: - `void operator()(const Tr_src::Cell& c_src, Cell& c_tgt) const;` This operator - is meant to be used in case heavy data should be transferred to `c_tgt`. + is meant to be used in case data should be transferred to `c_tgt`. -\note It is required to know the type `Tr_src`, or one that is compatible with it, to call this function. \note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. */ template Date: Fri, 28 Feb 2020 09:09:55 +0100 Subject: [PATCH 12/40] more doc fixes --- TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h | 8 ++++---- .../Triangulation_3/CGAL/IO/Triangulation_file_input.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h index aaca735e647..40a9247d38e 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h @@ -1037,13 +1037,13 @@ Writes `tds` into the stream `os` ostream& operator<< (ostream& os, const TriangulationDataStructure_3 & tds); /*! \ingroup PkgIOTDS3 -The tds streamed in `is`, of original type `TDS_src`, is written into the triangulation. As the vertex and cell +The tds streamed in `is`, of original type `TDS_src`, is written into the triangulation data structure. As the vertex and cell types might be different and incompatible, the creation of new cells and vertices is made thanks to the functors `convert_vertex` and `convert_cell`, that convert vertex and cell types. For each vertex `v_src` in `is`, the corresponding -vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. +vertex `v_tgt` in the triangulation data structure is a copy of the vertex returned by `convert_vertex(v_src)`. The same operations are done for cells with the functor convert_cell, except cells -in the triangulation are created using the default constructor, and then filled with the data +in the triangulation data structure are created using the default constructor, and then filled with the data contained in the stream. - A model of `ConvertVertex` must provide two `operator()`s that are responsible @@ -1057,7 +1057,7 @@ converting the source cell `c_src` into the target cell: - `void operator()(const TDS_src::Cell& c_src, Cell& c_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `c_tgt`. -\note The triangulation contained in `is` can be obtained with the `operator>>` of a `TriangulationDataStructure_3`. +\note The triangulation data structure contained in `is` can be obtained with the `operator>>` of a `TriangulationDataStructure_3`. */ template Date: Fri, 28 Feb 2020 15:33:03 +0100 Subject: [PATCH 13/40] Remove free function and fix TDS3 test --- .../CGAL/Triangulation_data_structure_3.h | 50 +++++---- .../TDS_3/CGAL/Triangulation_ds_cell_base_3.h | 3 +- .../CGAL/Triangulation_ds_vertex_base_3.h | 3 +- TDS_3/include/CGAL/IO/TDS_3_file_input.h | 38 ------- .../CGAL/Triangulation_data_structure_3.h | 79 +++++++++++-- .../CGAL/internal/Tr_or_tds_file_input.h | 106 ------------------ TDS_3/test/TDS_3/test_io_tds3.cpp | 22 +++- .../CGAL/IO/Triangulation_file_input.h | 38 ------- .../CGAL/IO/Triangulation_file_input.h | 41 ------- .../include/CGAL/Triangulation_3.h | 63 ++++++++++- 10 files changed, 182 insertions(+), 261 deletions(-) delete mode 100644 TDS_3/include/CGAL/IO/TDS_3_file_input.h delete mode 100644 TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h delete mode 100644 Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h delete mode 100644 Triangulation_3/include/CGAL/IO/Triangulation_file_input.h diff --git a/TDS_3/doc/TDS_3/CGAL/Triangulation_data_structure_3.h b/TDS_3/doc/TDS_3/CGAL/Triangulation_data_structure_3.h index 742ea25c03c..22fc2c4d296 100644 --- a/TDS_3/doc/TDS_3/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/doc/TDS_3/CGAL/Triangulation_data_structure_3.h @@ -15,21 +15,16 @@ see below). The class may offer some flexibility for the choice of container in the future, in the form of additional template parameters. -\cgalHeading{Parameters} +\tparam VertexBase must be a model of `TriangulationDSVertexBase_3`. The default is `Triangulation_ds_vertex_base_3`. -It is parameterized by base classes for vertices and cells which have to match -the requirements for the concepts `TriangulationDSCellBase_3` and -`TriangulationDSVertexBase_3` respectively. +\tparam CellBase must be a model of `TriangulationDSCellBase_3`. The default is `Triangulation_ds_cell_base_3`. -They have the default values `Triangulation_ds_vertex_base_3` and -`Triangulation_ds_cell_base_3` respectively. - -The `Concurrency_tag` parameter allows to enable the use of a concurrent +\tparam ConcurrencyTag enables the use of a concurrent container to store vertices and cells. It can be `Sequential_tag` (use of a -`Compact_container` to store vertices and cells) or `Parallel_tag` +`Compact_container` to store vertices and cells) or `Parallel_tag` (use of a `Concurrent_compact_container`). If it is `Parallel_tag`, the following functions can be called concurrently: -`create_vertex`, `create_cell`, `delete_vertex`, `delete_cell`. +`create_vertex()`, `create_cell()`, `delete_vertex()`, and `delete_cell()`. `Sequential_tag` is the default value. \cgalModels `TriangulationDataStructure_3` @@ -37,37 +32,50 @@ container to store vertices and cells. It can be `Sequential_tag` (use of a The base class `Triangulation_utils_3` defines basic computations on indices of vertices and neighbors of cells. -\attention All members listed here are additional to the interface -specified by the concept. - \sa `CGAL::Triangulation_ds_vertex_base_3` \sa `CGAL::Triangulation_ds_cell_base_3` -\sa `CGAL::Triangulation_vertex_base_with_info_3` -\sa `CGAL::Triangulation_cell_base_with_info_3` */ -template< typename TriangulationDSVertexBase_3, - typename TriangulationDSCellBase_3, - typename Concurrency_tag > -class Triangulation_data_structure_3 : public CGAL::Triangulation_utils_3 { +template< typename VertexBase, + typename CellBase, + typename ConcurrencyTag > +class Triangulation_data_structure_3 + : public CGAL::Triangulation_utils_3 +{ public: /// \name Types /// @{ +typedef Triangulation_data_structure_2 Tds; + +/// The vertex type. +/// +/// \sa Section \ref tds3cyclic +typedef typename VertexBase::template Rebind_TDS::Other Vertex; + +/// The face type. +/// +/// \sa Section \ref tds3cyclic +typedef typename CellBase::template Rebind_TDS::Other Cell; + /*! -Vertex container type. If Concurrency_tag is Parallel_tag, a +Vertex container type. If `ConcurrencyTag` is `Parallel_tag`, a `Concurrent_compact_container` is used instead of a `Compact_container`. */ typedef Compact_container Vertex_range; /*! -Cell container type. If Concurrency_tag is Parallel_tag, a +Cell container type. If `ConcurrencyTag` is `Parallel_tag`, a `Concurrent_compact_container` is used instead of a `Compact_container`. */ typedef Compact_container Cell_range; /// @} /// \name Operations +/// +/// In addition to the interface documented in the concept, +/// the class offers the following functions. +/// /// @{ /*! diff --git a/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_cell_base_3.h b/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_cell_base_3.h index 51c3048d577..90f86670ea8 100644 --- a/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_cell_base_3.h +++ b/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_cell_base_3.h @@ -10,9 +10,10 @@ The class `Triangulation_ds_cell_base_3<>` is a model for the concept \cgalModels `TriangulationDSCellBase_3` +\tparam TDS should not be specified (see Section \ref tds3cyclic and examples) + \sa `CGAL::Triangulation_cell_base_3` \sa `CGAL::Triangulation_ds_vertex_base_3` -\sa `CGAL::Triangulation_cell_base_with_info_3` */ template< typename TDS = void > diff --git a/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_vertex_base_3.h b/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_vertex_base_3.h index 10a7a078f09..c54caf3952a 100644 --- a/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_vertex_base_3.h +++ b/TDS_3/doc/TDS_3/CGAL/Triangulation_ds_vertex_base_3.h @@ -20,9 +20,10 @@ example) tuned for a specific application. \cgalModels `TriangulationDSVertexBase_3` +\tparam TDS should not be specified (see Section \ref tds3cyclic and examples) + \sa `CGAL::Triangulation_vertex_base_3` \sa `CGAL::Triangulation_ds_cell_base_3` -\sa `CGAL::Triangulation_vertex_base_with_info_3` */ template< typename TDS = void > diff --git a/TDS_3/include/CGAL/IO/TDS_3_file_input.h b/TDS_3/include/CGAL/IO/TDS_3_file_input.h deleted file mode 100644 index 50b698ecdf6..00000000000 --- a/TDS_3/include/CGAL/IO/TDS_3_file_input.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef TDS_3_FILE_INPUT_H -#define TDS_3_FILE_INPUT_H -// Copyright (c) 1997-2010 INRIA Sophia-Antipolis (France). -// Copyright (c) 2011, 2020 GeometryFactory Sarl (France) -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// -// Author(s) : Laurent Rineau, Maxime Gimeno - -// Adapted from operator>>(std::istream&, Triangulation_3&) from -// - -#include - - -#include - -namespace CGAL { - -template -std::istream& file_input(std::istream& is, Tr_tgt &tr, - ConvertVertex convert_vertex = ConvertVertex(), - ConvertCell convert_cell = ConvertCell()) -{ - return internal::file_input(is, tr, true, convert_vertex, convert_cell); -} - -} //end CGAL -#endif // TDS_3_FILE_INPUT_H diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 9ddc129e82f..8ae2d277f7a 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -51,8 +51,6 @@ #include #include -#include - #ifdef CGAL_LINKED_WITH_TBB # include #endif @@ -1524,6 +1522,73 @@ public: return s <= maximal_nb_of_facets_of_small_hole; } + //IO + template + std::istream& file_input(std::istream& is, + ConvertVertex convert_vertex = ConvertVertex(), + ConvertCell convert_cell = ConvertCell()) + { + // reads + // the dimension + // the number of finite vertices + // the non combinatorial information on vertices (point, etc) + // the number of cells + // the cells by the indices of their vertices in the preceding list + // of vertices, plus the non combinatorial information on each cell + // the neighbors of each cell by their index in the preceding list of cells + // when dimension < 3 : the same with faces of maximal dimension + + // If this is used for a TDS, the vertices are processed from 0 to n. + // Else, we make V[0] the infinite vertex and work from 1 to n+1. + + typedef typename Tds::Vertex_handle Vertex_handle; + typedef typename Tds::Cell_handle Cell_handle; + + typedef typename TDS_src::Vertex Vertex1; + typedef typename TDS_src::Cell Cell1; + clear(); + cells().clear(); + + std::size_t n; + int d; + if(is_ascii(is)) + is >> d >> n; + else { + read(is, d); + read(is, n); + } + if(!is) return is; + set_dimension(d); + + std::size_t V_size = n; + std::vector< Vertex_handle > V(V_size); + + // the infinite vertex is numbered 0 + for (std::size_t i=0 ; i < V_size; ++i) { + Vertex1 v; + if(!(is >> v)) return is; + Vertex_handle vh=create_vertex( convert_vertex(v) ); + V[i] = vh; + convert_vertex(v, *V[i]); + } + + std::vector< Cell_handle > C; + + std::size_t m; + read_cells(is, V, m, C); + + for (std::size_t j=0 ; j < m; j++) { + Cell1 c; + if(!(is >> c)) return is; + convert_cell(c, *C[j]); + } + + CGAL_triangulation_assertion(is_valid(false)); + return is; + } + private: // Change the orientation of the cell by swapping indices 0 and 1. @@ -1554,16 +1619,6 @@ private: bool count_cells(size_type &i, bool verbose = false, int level = 0) const; // counts AND checks the validity - //IO - template - std::istream& file_input(std::istream& is, - ConvertVertex convert_vertex = ConvertVertex(), - ConvertCell convert_cell = ConvertCell()) - { - return CGAL::file_input(is, *this, convert_vertex, convert_cell); - } }; #ifdef CGAL_TDS_USE_RECURSIVE_CREATE_STAR_3 diff --git a/TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h b/TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h deleted file mode 100644 index 516bbb60d25..00000000000 --- a/TDS_3/include/CGAL/internal/Tr_or_tds_file_input.h +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 1997-2010 INRIA Sophia-Antipolis (France). -// Copyright (c) 2011, 2020 GeometryFactory Sarl (France) -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// -// Author(s) : Laurent Rineau, Maxime Gimeno - -// Adapted from operator>>(std::istream&, Triangulation_3&) from -// - - -#ifndef CGAL_TR_OR_TDS_FILE_INPUT_H -#define CGAL_TR_OR_TDS_FILE_INPUT_H - -#include - -#include - - -#include - -namespace CGAL { -namespace internal{ - -template -std::istream& file_input(std::istream& is, Tr_tgt &tr, bool is_tds, - ConvertVertex convert_vertex = ConvertVertex(), - ConvertCell convert_cell = ConvertCell()) - // reads - // the dimension - // the number of finite vertices - // the non combinatorial information on vertices (point, etc) - // the number of cells - // the cells by the indices of their vertices in the preceding list - // of vertices, plus the non combinatorial information on each cell - // the neighbors of each cell by their index in the preceding list of cells - // when dimension < 3 : the same with faces of maximal dimension - - // If this is used for a TDS, the vertices are processed from 0 to n. - // Else, we make V[0] the infinite vertex and work from 1 to n+1. -{ - typedef Tr_tgt Triangulation; - typedef typename Triangulation::Vertex_handle Vertex_handle; - typedef typename Triangulation::Cell_handle Cell_handle; - - typedef typename Tr_src::Vertex Vertex1; - typedef typename Tr_src::Cell Cell1; - - tr.clear(); - tr.tds().cells().clear(); - - std::size_t n; - int d; - if(is_ascii(is)) - is >> d >> n; - else { - read(is, d); - read(is, n); - } - if(!is) return is; - tr.tds().set_dimension(d); - - std::size_t V_size = is_tds ? n : n+1; - std::vector< Vertex_handle > V(V_size); - - // the infinite vertex is numbered 0 - if(!is_tds) - V[0] = tr.infinite_vertex(); - - for (std::size_t i=is_tds ? 0 : 1; i < V_size; ++i) { - Vertex1 v; - if(!(is >> v)) return is; - Vertex_handle vh=tr.tds().create_vertex( convert_vertex(v) ); - V[i] = vh; - convert_vertex(v, *V[i]); - } - - std::vector< Cell_handle > C; - - std::size_t m; - tr.tds().read_cells(is, V, m, C); - - for (std::size_t j=0 ; j < m; j++) { - Cell1 c; - if(!(is >> c)) return is; - convert_cell(c, *C[j]); - } - - CGAL_triangulation_assertion( tr.is_valid(false) ); - return is; -} - -} //end internal -} // end namespace CGAL - - -#endif // CGAL_TR_OR_TDS_FILE_INPUT_H diff --git a/TDS_3/test/TDS_3/test_io_tds3.cpp b/TDS_3/test/TDS_3/test_io_tds3.cpp index fb1dc31092f..98ed299540e 100644 --- a/TDS_3/test/TDS_3/test_io_tds3.cpp +++ b/TDS_3/test/TDS_3/test_io_tds3.cpp @@ -26,8 +26,28 @@ struct Update_vertex { } + + }; // end struct Update_vertex +template +struct Update_cell +{ + typedef typename T1::Cell C1; + typedef typename T2::Cell C2; + + C2 operator()(const C1&) + { + return C2(); + } + + void operator()(const C1&, C2&) + { + + } + + +}; // end struct Update_vertex int main() { @@ -52,7 +72,7 @@ int main() out.close(); Tds T2; std::ifstream in("tr"); - //T2.file_input, Update_cell>(in); + T2.file_input, Update_cell >(in); in.close(); return 0; } diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h deleted file mode 100644 index 128448543d9..00000000000 --- a/Triangulation_3/doc/Triangulation_3/CGAL/IO/Triangulation_file_input.h +++ /dev/null @@ -1,38 +0,0 @@ -namespace CGAL { - -///@{ -/*! -\ingroup PkgIOTriangulation3 - -The triangulation streamed in `is`, of original type `Tr_src`, is written into `tr`, of type `Tr_tgt`. As the vertex and cell - types might be different and incompatible, the creation of new cells and vertices -is made thanks to the functors `convert_vertex` and `convert_cell`, that convert -vertex and cell types. For each vertex `v_src` in `is`, the corresponding -vertex `v_tgt` in `tr` is a copy of the vertex returned by `convert_vertex(v_src)`. -The same operations are done for cells with the functor convert_cell, except cells -in `tr` are created using the default constructor, and then filled with the data -contained in the stream. - - - - A model of `ConvertVertex` must provide two `operator()`s that are responsible - for converting the source vertex `v_src` into the target vertex: - - `Tr_tgt::Vertex operator()(const Tr_src::Vertex& v_src) const;` This operator is -used to create the vertex from `v_src`. - - `void operator()(const Tr_src::Vertex& v_src, Tr_tgt::Vertex& v_tgt) const;` This - operator is meant to be used in case heavy data should be transferred to `v_tgt`. - - A model of ConvertCell must provide an `operator()` that is responsible for -converting the source cell `c_src` into the target cell: - - `void operator()(const Tr_src::Cell& c_src, Tr_tgt::Cell& c_tgt) const;` This operator - is meant to be used in case data should be transferred to `c_tgt`. - -\note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. -*/ -template -std::istream& file_input(std::istream& is, Tr_tgt &tr, - ConvertVertex convert_vertex = ConvertVertex(), - ConvertCell convert_cell = ConvertCell()); -///@} -} diff --git a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h b/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h deleted file mode 100644 index 0d6159489d7..00000000000 --- a/Triangulation_3/include/CGAL/IO/Triangulation_file_input.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 1997-2010 INRIA Sophia-Antipolis (France). -// Copyright (c) 2011, 2020 GeometryFactory Sarl (France) -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// -// Author(s) : Laurent Rineau, Maxime Gimeno - -// Adapted from operator>>(std::istream&, Triangulation_3&) from -// - - -#ifndef CGAL_TRIANGULATION_FILE_INPUT_3_H -#define CGAL_TRIANGULATION_FILE_INPUT_3_H - -#include - -#include - -namespace CGAL { - -template -std::istream& file_input(std::istream& is, Tr_tgt &tr, - ConvertVertex convert_vertex = ConvertVertex(), - ConvertCell convert_cell = ConvertCell()) -{ - return internal::file_input(is, tr, false, convert_vertex, convert_cell); -} - -} // end namespace CGAL - - -#endif // TRIANGULATION_FILE_INPUT_H diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 6f05f4e52e9..682a5b8837e 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -60,7 +60,6 @@ #include #include #include -#include #ifndef CGAL_TRIANGULATION_3_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO #include @@ -2203,7 +2202,67 @@ public: ConvertVertex convert_vertex = ConvertVertex(), ConvertCell convert_cell = ConvertCell()) { - return CGAL::file_input(is, *this, convert_vertex, convert_cell); + // reads + // the dimension + // the number of finite vertices + // the non combinatorial information on vertices (point, etc) + // the number of cells + // the cells by the indices of their vertices in the preceding list + // of vertices, plus the non combinatorial information on each cell + // the neighbors of each cell by their index in the preceding list of cells + // when dimension < 3 : the same with faces of maximal dimension + + // If this is used for a TDS, the vertices are processed from 0 to n. + // Else, we make V[0] the infinite vertex and work from 1 to n+1. + + typedef Self Triangulation; + typedef typename Triangulation::Vertex_handle Vertex_handle; + typedef typename Triangulation::Cell_handle Cell_handle; + + typedef typename Tr_src::Vertex Vertex1; + typedef typename Tr_src::Cell Cell1; + + clear(); + tds().cells().clear(); + + std::size_t n; + int d; + if(is_ascii(is)) + is >> d >> n; + else { + read(is, d); + read(is, n); + } + if(!is) return is; + tds().set_dimension(d); + + std::size_t V_size = n+1; + std::vector< Vertex_handle > V(V_size); + + // the infinite vertex is numbered 0 + V[0] = infinite_vertex(); + + for (std::size_t i = 1; i < V_size; ++i) { + Vertex1 v; + if(!(is >> v)) return is; + Vertex_handle vh=tds().create_vertex( convert_vertex(v) ); + V[i] = vh; + convert_vertex(v, *V[i]); + } + + std::vector< Cell_handle > C; + + std::size_t m; + tds().read_cells(is, V, m, C); + + for (std::size_t j=0 ; j < m; j++) { + Cell1 c; + if(!(is >> c)) return is; + convert_cell(c, *C[j]); + } + + CGAL_triangulation_assertion( is_valid(false) ); + return is; } }; From 2e0de573dda5264c9128cbea6cec0d1f5c4b8273 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 18 Mar 2020 15:45:05 +0100 Subject: [PATCH 14/40] Add custom property map example --- .../examples/Property_map/CMakeLists.txt | 6 + .../Property_map/custom_property_map.cpp | 117 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 Property_map/examples/Property_map/custom_property_map.cpp diff --git a/Property_map/examples/Property_map/CMakeLists.txt b/Property_map/examples/Property_map/CMakeLists.txt index 19f1e6fa5ed..b01994b8dba 100644 --- a/Property_map/examples/Property_map/CMakeLists.txt +++ b/Property_map/examples/Property_map/CMakeLists.txt @@ -32,4 +32,10 @@ endif() create_single_source_cgal_program( "dynamic_properties.cpp" ) +find_package(Eigen3 3.1.0) #(requires 3.1.0 or greater) +if (EIGEN3_FOUND) + create_single_source_cgal_program( "custom_property_map.cpp" ) + CGAL_target_use_Eigen(custom_property_map) +endif() + diff --git a/Property_map/examples/Property_map/custom_property_map.cpp b/Property_map/examples/Property_map/custom_property_map.cpp new file mode 100644 index 00000000000..fc0f8fbc779 --- /dev/null +++ b/Property_map/examples/Property_map/custom_property_map.cpp @@ -0,0 +1,117 @@ +#include +#include +#include +#include + +using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; +using Point_3 = Kernel::Point_3; +using Vector_3 = Kernel::Vector_3; +using Generator = CGAL::Random_points_on_sphere_3; + +// Example of readable property map to get CGAL::Point_3 objects from +// 3 coordinate arrays +struct Custom_point_map +{ + using key_type = std::size_t; // The iterator's value type is an index + using value_type = Point_3; // The object manipulated by the algorithm is a Point_3 + using reference = Point_3; // The object does not exist in memory, so there's no reference + using category = boost::readable_property_map_tag; // The property map is only used for reading + + double *x, *y, *z; + + Custom_point_map (double* x = nullptr, double* y = nullptr, double* z = nullptr) + : x(x), y(y), z(z) { } + + // The get() function returns the object expected by the algorithm (here, Point_3) + friend Point_3 get (const Custom_point_map& map, std::size_t idx) + { + return Point_3 (map.x[idx], map.y[idx], map.z[idx]); + } +}; + +// Example of read-write property map to get CGAL::Vector_3 objects from +// a buffer array and put CGAL::Vector_3 values in this buffer +struct Custom_normal_map +{ + using key_type = std::size_t; // The iterator's value type is an index + using value_type = Vector_3; // The object manipulated by the algorithm is a Vector_3 + using reference = Vector_3; // The object does not exist in memory, so there's no reference + using category = boost::read_write_property_map_tag; // The property map is used both + // for reading and writing data + double *buffer; + + Custom_normal_map (double* buffer = nullptr) + : buffer (buffer) { } + + // The get() function returns the object expected by the algorithm (here, Vector_3) + friend Vector_3 get (const Custom_normal_map& map, std::size_t idx) + { + return Vector_3 (map.buffer[idx * 3 ], + map.buffer[idx * 3 + 1], + map.buffer[idx * 3 + 2]); + } + + // The put() function updated the user's data structure from the + // object handled by the algorithm (here Vector_3) + friend void put (const Custom_normal_map& map, std::size_t idx, const Vector_3& vector_3) + { + map.buffer[idx * 3 ] = vector_3.x(); + map.buffer[idx * 3 + 1] = vector_3.y(); + map.buffer[idx * 3 + 2] = vector_3.z(); + } +}; + + +int main() +{ + std::size_t nb_points = 1000; + + // in this example, points are stored as separate coordinate arrays + double* x = new double[nb_points]; + double* y = new double[nb_points]; + double* z = new double[nb_points]; + + // generate random points + Generator generator; + for (std::size_t i = 0; i < nb_points; ++ i) + { + Point_3 p = *(generator ++ ); + x[i] = p.x(); + y[i] = p.y(); + z[i] = p.z(); + } + + // normals are stored as a contiguous double array + double* normals = new double[3 * nb_points]; + + // we use a vector of indices to access arrays + std::vector indices; + indices.reserve (nb_points); + for (std::size_t i = 0; i < nb_points; ++ i) + indices.push_back(i); + + // estimate and orient normals using directly user's data structure + // instead of creating deep copies using Point_3 and Vector_3 + CGAL::jet_estimate_normals + (indices, 12, + CGAL::parameters::point_map (Custom_point_map(x,y,z)). + normal_map (Custom_normal_map(normals))); + + CGAL::mst_orient_normals + (indices, 12, + CGAL::parameters::point_map (Custom_point_map(x,y,z)). + normal_map (Custom_normal_map(normals))); + + // Display first 10 points+normals + for (std::size_t i = 0; i < 10; ++ i) + std::cerr << "Point(" << i << ") = " << x[i] << " " << y[i] << " " << z[i] + << "\tNormal(" << i << ") = " + << normals[3*i] << " " << normals[3*i+1] << " " << normals[3*i+2] << std::endl; + + delete[] x; + delete[] y; + delete[] z; + delete[] normals; + + return EXIT_SUCCESS; +} From 012fed5e44ae5a88793cfbba6c99bd1075dd8ae6 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 18 Mar 2020 16:01:14 +0100 Subject: [PATCH 15/40] Update property maps manual --- Property_map/doc/Property_map/Doxyfile.in | 2 +- Property_map/doc/Property_map/Property_map.txt | 16 ++++++++++++++++ Property_map/doc/Property_map/examples.txt | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Property_map/doc/Property_map/Doxyfile.in b/Property_map/doc/Property_map/Doxyfile.in index 2167dbca4fe..a079ae055f4 100644 --- a/Property_map/doc/Property_map/Doxyfile.in +++ b/Property_map/doc/Property_map/Doxyfile.in @@ -3,4 +3,4 @@ PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - CGAL and Boost Property Maps" INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/property_map.h EXCLUDE += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Dynamic_property_map.h -EXAMPLE_PATH = ${CGAL_Point_set_processing_3_EXAMPLE_DIR} +EXAMPLE_PATH += ${CGAL_Point_set_processing_3_EXAMPLE_DIR} diff --git a/Property_map/doc/Property_map/Property_map.txt b/Property_map/doc/Property_map/Property_map.txt index e29a999cf10..06d78d76d2b 100644 --- a/Property_map/doc/Property_map/Property_map.txt +++ b/Property_map/doc/Property_map/Property_map.txt @@ -6,6 +6,8 @@ namespace CGAL { \anchor chapterProperty_map +\cgalAutoToc + \authors Andreas Fabri and Laurent Saboret \section Property_mapA A Short Introduction to the Boost Property Maps Library @@ -55,6 +57,20 @@ The following example reads a point set from an input file and writes it to a fi The following example reads a point set in the `xyz` format and computes the average spacing. %Index, position and color are stored in a tuple and accessed through property maps. \cgalExample{Point_set_processing_3/average_spacing_example.cpp} +\section Property_mapCustom Writing Custom Property Maps + +Property maps are especially useful when using predefined data +structures that are not part of the \cgal library: algorithms written +with property maps can be called on these data structures provided the +user writes the required property maps, without the need to create +deep copies of potentially large data into \cgal formats. + +The following example shows how to write a readable point map and a +read-write normal map to run \cgal normal estimation and orientation +algorithm on raw `double` arrays: +\cgalExample{Property_map/custom_property_map.cpp} + + */ } /* namespace CGAL */ diff --git a/Property_map/doc/Property_map/examples.txt b/Property_map/doc/Property_map/examples.txt index fe5b9e2f71c..30870650f01 100644 --- a/Property_map/doc/Property_map/examples.txt +++ b/Property_map/doc/Property_map/examples.txt @@ -2,4 +2,5 @@ \example Point_set_processing_3/remove_outliers_example.cpp \example Point_set_processing_3/read_write_xyz_point_set_example.cpp \example Point_set_processing_3/average_spacing_example.cpp +\example Property_map/custom_property_map.cpp */ From f7b72e6c0580049d5782a9ea66a8f10ac8a716a0 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Thu, 19 Mar 2020 14:00:19 +0100 Subject: [PATCH 16/40] Remove new/delete --- .../Property_map/custom_property_map.cpp | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Property_map/examples/Property_map/custom_property_map.cpp b/Property_map/examples/Property_map/custom_property_map.cpp index fc0f8fbc779..dedd0d6dd02 100644 --- a/Property_map/examples/Property_map/custom_property_map.cpp +++ b/Property_map/examples/Property_map/custom_property_map.cpp @@ -3,6 +3,8 @@ #include #include +#define NB_POINTS 1000 + using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; using Point_3 = Kernel::Point_3; using Vector_3 = Kernel::Vector_3; @@ -64,16 +66,14 @@ struct Custom_normal_map int main() { - std::size_t nb_points = 1000; - // in this example, points are stored as separate coordinate arrays - double* x = new double[nb_points]; - double* y = new double[nb_points]; - double* z = new double[nb_points]; + double x[NB_POINTS]; + double y[NB_POINTS]; + double z[NB_POINTS]; // generate random points Generator generator; - for (std::size_t i = 0; i < nb_points; ++ i) + for (std::size_t i = 0; i < NB_POINTS; ++ i) { Point_3 p = *(generator ++ ); x[i] = p.x(); @@ -82,12 +82,12 @@ int main() } // normals are stored as a contiguous double array - double* normals = new double[3 * nb_points]; + double normals[3 *NB_POINTS]; // we use a vector of indices to access arrays std::vector indices; - indices.reserve (nb_points); - for (std::size_t i = 0; i < nb_points; ++ i) + indices.reserve (NB_POINTS); + for (std::size_t i = 0; i < NB_POINTS; ++ i) indices.push_back(i); // estimate and orient normals using directly user's data structure @@ -108,10 +108,5 @@ int main() << "\tNormal(" << i << ") = " << normals[3*i] << " " << normals[3*i+1] << " " << normals[3*i+2] << std::endl; - delete[] x; - delete[] y; - delete[] z; - delete[] normals; - return EXIT_SUCCESS; } From de8abc55560604434c09a8e6702a2ef6a2d8a94b Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Thu, 19 Mar 2020 15:05:50 +0100 Subject: [PATCH 17/40] Do not use DEFINE --- .../Property_map/custom_property_map.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Property_map/examples/Property_map/custom_property_map.cpp b/Property_map/examples/Property_map/custom_property_map.cpp index dedd0d6dd02..22a923a200d 100644 --- a/Property_map/examples/Property_map/custom_property_map.cpp +++ b/Property_map/examples/Property_map/custom_property_map.cpp @@ -3,8 +3,6 @@ #include #include -#define NB_POINTS 1000 - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; using Point_3 = Kernel::Point_3; using Vector_3 = Kernel::Vector_3; @@ -66,14 +64,16 @@ struct Custom_normal_map int main() { + constexpr std::size_t nb_points = 1000; + // in this example, points are stored as separate coordinate arrays - double x[NB_POINTS]; - double y[NB_POINTS]; - double z[NB_POINTS]; + double x[nb_points]; + double y[nb_points]; + double z[nb_points]; // generate random points Generator generator; - for (std::size_t i = 0; i < NB_POINTS; ++ i) + for (std::size_t i = 0; i < nb_points; ++ i) { Point_3 p = *(generator ++ ); x[i] = p.x(); @@ -82,12 +82,12 @@ int main() } // normals are stored as a contiguous double array - double normals[3 *NB_POINTS]; + double normals[3 *nb_points]; // we use a vector of indices to access arrays std::vector indices; - indices.reserve (NB_POINTS); - for (std::size_t i = 0; i < NB_POINTS; ++ i) + indices.reserve (nb_points); + for (std::size_t i = 0; i < nb_points; ++ i) indices.push_back(i); // estimate and orient normals using directly user's data structure From bc956295da46db07b99674c31fbfdf63f643670f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 23 Mar 2020 13:19:16 +0100 Subject: [PATCH 18/40] Add face_patch_map as NP to split_connected_components() to allow giving an existing map to the function and avoid having to recompute it. --- .../connected_components.h | 44 +++++++++++++++---- .../Polygon_mesh_processing/test_pmp_clip.cpp | 8 +++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 361fd938645..203a3b36e66 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -931,21 +931,46 @@ struct No_mark template < class PolygonMesh, class PolygonMeshRange, class FIMap, class VIMap, - class HIMap, class Ecm > + class HIMap, class Ecm, class NamedParameters > void split_connected_components_impl(FIMap fim, HIMap him, VIMap vim, Ecm ecm, PolygonMeshRange& range, - const PolygonMesh& tm) + const PolygonMesh& tm, + const NamedParameters& np) { - typename boost::template property_map< + typedef typename internal_np::Lookup_named_param_def < + internal_np::face_patch_t, + NamedParameters, + typename boost::template property_map< PolygonMesh, CGAL::dynamic_face_property_t >::const_type - pidmap = get(CGAL::dynamic_face_property_t(), tm); + > ::type Fpm; - int nb_patches = CGAL::Polygon_mesh_processing::connected_components( - tm, pidmap, CGAL::parameters::face_index_map(fim) - .edge_is_constrained_map(ecm)); + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + + Fpm pidmap = choose_parameter(get_parameter(np, internal_np::face_patch), + get(CGAL::dynamic_face_property_t(), tm)); + + int nb_patches = 0; + if(is_default_parameter(get_parameter(np, internal_np::face_patch))) + { + nb_patches = CGAL::Polygon_mesh_processing::connected_components( + tm, pidmap, CGAL::parameters::face_index_map(fim) + .edge_is_constrained_map(ecm)); + } + else + { + for(const auto& f : faces(tm)) + { + std::size_t patch = get(pidmap, f); + if(patch > nb_patches) + nb_patches = patch; + } + nb_patches+=1; + } for(int i=0; i 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 aa63899f127..690b5c4eec8 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 @@ -528,9 +528,15 @@ void test_split() std::vector meshes; PMP::split(tm1, tm2); + //try with np + typename boost::template property_map< + TriangleMesh, CGAL::dynamic_face_property_t >::type + pidmap = get(CGAL::dynamic_face_property_t(), tm1); + CGAL::Polygon_mesh_processing::connected_components( + tm1, pidmap, CGAL::parameters::all_default()); PMP::split_connected_components(tm1, meshes, - params::all_default()); + params::face_patch_map(pidmap)); CGAL_assertion(meshes.size() == 5); //if the order is not deterministc, put the num_vertices in a list and check From c3bcf9cbfe69d6f665cb2e4b0152a95f6d13341a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 23 Mar 2020 16:06:18 +0100 Subject: [PATCH 19/40] Changes after review --- .../CGAL/Polygon_mesh_processing/connected_components.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 203a3b36e66..c39d6fd648e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -952,9 +952,9 @@ void split_connected_components_impl(FIMap fim, using parameters::is_default_parameter; Fpm pidmap = choose_parameter(get_parameter(np, internal_np::face_patch), - get(CGAL::dynamic_face_property_t(), tm)); + get(CGAL::dynamic_face_property_t(), tm)); - int nb_patches = 0; + std::size_t nb_patches = 0; if(is_default_parameter(get_parameter(np, internal_np::face_patch))) { nb_patches = CGAL::Polygon_mesh_processing::connected_components( @@ -972,7 +972,7 @@ void split_connected_components_impl(FIMap fim, nb_patches+=1; } - for(int i=0; i filter_graph(tm, i, pidmap, CGAL::parameters::face_index_map(fim) @@ -1013,6 +1013,8 @@ void split_connected_components_impl(FIMap fim, * \cgalNPEnd * \cgalParamBegin{face_patch_map} a property map with the patch id's associated to the faces of `pm`. Instance of a class model of `ReadPropertyMap`. + If not provided, an internal map will be filled with a call to + `connected_components()` with `edge_is_constrained_map()` (if provided). * \cgalParamEnd * \cgalNamedParamsEnd * From 5762211d394888b4e5dee6f8941e2c80e35c211a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 23 Mar 2020 16:14:33 +0100 Subject: [PATCH 20/40] add split iso_cuboid --- .../CGAL/Polygon_mesh_processing/clip.h | 116 +++++++++++++----- .../connected_components.h | 2 +- .../Polygon_mesh_processing/test_pmp_clip.cpp | 51 ++++++++ 3 files changed, 136 insertions(+), 33 deletions(-) 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 05ca9388ebb..d059c3eb33d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip.h @@ -547,6 +547,65 @@ bool clip(TriangleMesh& tm, return clip(tm, clipper, np, parameters::all_default()); } +/** + * \ingroup PMP_corefinement_grp + * clips `tm` by keeping the part that is inside `iso_cuboid`. + * If `tm` is closed, the clipped part can be closed too if the named parameter `clip_volume` is set to `true`. + * See Subsection \ref coref_clip for more details. + * + * \note In the current implementation it is not possible to set the vertex point map and the default will be used. `Iso_cuboid_3` must be + * from the same %Kernel as the point of the vertex point map. + * \pre \link CGAL::Polygon_mesh_processing::does_self_intersect() `!CGAL::Polygon_mesh_processing::does_self_intersect(tm)` \endlink + * + * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. + * An internal property map for `CGAL::vertex_point_t` must be available. + * + * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" + * + * @param tm input triangulated surface mesh + * @param iso_cuboid iso-cuboid used to clip `tm`. + * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamBegin{visitor} a class model of `PMPCorefinementVisitor` + * that is used to track the creation of new faces. + * \cgalParamEnd + * \cgalParamBegin{throw_on_self_intersection} if `true`, + * the set of triangles closed to the intersection of `tm` and `iso_cuboid` will be + * checked for self-intersections and `CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception` + * will be thrown if at least one is found. + * \cgalParamEnd + * \cgalParamBegin{clip_volume} if `true` and `tm` is closed, the clipping will be done on + * the volume \link coref_def_subsec bounded \endlink by `tm` rather than on its surface + * (i.e., `tm` will be kept closed). + * \cgalParamEnd + * \cgalParamBegin{use_compact_clipper} if `false` and `clip_volume` is `false` and `tm` is open, the parts of `tm` coplanar with `is_cuboid` + * will not be part of the output. + * \cgalNamedParamsEnd + * + * @return `true` if the output surface mesh is manifold. + * If `false` is returned `tm` is only refined by the intersection with `iso_cuboid`. + */ +template +bool clip(TriangleMesh& tm, +#ifdef DOXYGEN_RUNNING + const Iso_cuboid_3& iso_cuboid, +#else + const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid, +#endif + const NamedParameters& np) +{ + if(boost::begin(faces(tm))==boost::end(faces(tm))) return true; + TriangleMesh clipper; + + make_hexahedron(iso_cuboid[0], iso_cuboid[1], iso_cuboid[2], iso_cuboid[3], + iso_cuboid[4], iso_cuboid[5], iso_cuboid[6], iso_cuboid[7], + clipper); + triangulate_faces(clipper); + + return clip(tm, clipper, np, parameters::all_default()); +} /*! * \ingroup PMP_corefinement_grp @@ -635,9 +694,6 @@ void split(TriangleMesh& tm, * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin - * \cgalParamBegin{vertex_point_map} - * the property map with the points associated to the vertices of `tm`. - * \cgalParamEnd * \cgalParamBegin{visitor} a class model of `PMPCorefinementVisitor` * that is used to track the creation of new faces. * \cgalParamEnd @@ -680,23 +736,22 @@ void split(TriangleMesh& tm, //else nothing to do, no intersection. } + /** * \ingroup PMP_corefinement_grp - * clips `tm` by keeping the part that is inside `iso_cuboid`. - * If `tm` is closed, the clipped part can be closed too if the named parameter `clip_volume` is set to `true`. - * See Subsection \ref coref_clip for more details. + * adds intersection edges of `iso_cuboid` and `tm` in `tm` and duplicates those edges. * - * \note In the current implementation it is not possible to set the vertex point map and the default will be used. `Iso_cuboid_3` must be - * from the same %Kernel as the point of the vertex point map. + * \note In the current implementation it is not possible to set the vertex point map and the default will be used. + * \note `Iso_cuboid_3` must be from the same %Kernel as the point of the vertex point map. * \pre \link CGAL::Polygon_mesh_processing::does_self_intersect() `!CGAL::Polygon_mesh_processing::does_self_intersect(tm)` \endlink * - * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. + * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph` * An internal property map for `CGAL::vertex_point_t` must be available. * * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * * @param tm input triangulated surface mesh - * @param iso_cuboid iso-cuboid used to clip `tm`. + * @param iso_cuboid iso-cuboid used to split `tm`. * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -708,36 +763,26 @@ void split(TriangleMesh& tm, * checked for self-intersections and `CGAL::Polygon_mesh_processing::Corefinement::Self_intersection_exception` * will be thrown if at least one is found. * \cgalParamEnd - * \cgalParamBegin{clip_volume} if `true` and `tm` is closed, the clipping will be done on - * the volume \link coref_def_subsec bounded \endlink by `tm` rather than on its surface - * (i.e., `tm` will be kept closed). - * \cgalParamEnd - * \cgalParamBegin{use_compact_clipper} if `false` and `clip_volume` is `false` and `tm` is open, the parts of `tm` coplanar with `is_cuboid` - * will not be part of the output. * \cgalNamedParamsEnd - * - * @return `true` if the output surface mesh is manifold. - * If `false` is returned `tm` is only refined by the intersection with `iso_cuboid`. */ template -bool clip(TriangleMesh& tm, -#ifdef DOXYGEN_RUNNING - const Iso_cuboid_3& iso_cuboid, -#else - const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid, -#endif - const NamedParameters& np) +void split(TriangleMesh& tm, + #ifdef DOXYGEN_RUNNING + const Iso_cuboid_3& iso_cuboid, + #else + const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid, + #endif + const NamedParameters& np) { - if(boost::begin(faces(tm))==boost::end(faces(tm))) return true; - TriangleMesh clipper; + TriangleMesh splitter; make_hexahedron(iso_cuboid[0], iso_cuboid[1], iso_cuboid[2], iso_cuboid[3], - iso_cuboid[4], iso_cuboid[5], iso_cuboid[6], iso_cuboid[7], - clipper); - triangulate_faces(clipper); + iso_cuboid[4], iso_cuboid[5], iso_cuboid[6], iso_cuboid[7], + splitter); + triangulate_faces(splitter); - return clip(tm, clipper, np, parameters::all_default()); + split(tm, splitter, np, parameters::all_default()); } /// \cond SKIP_IN_MANUAL @@ -806,6 +851,13 @@ void split(TriangleMesh& tm, split(tm, plane, parameters::all_default()); } +template +void split(TriangleMesh& tm, + const typename GetGeomTraits::type::Iso_cuboid_3& iso_cuboid) +{ + split(tm, iso_cuboid, parameters::all_default()); +} + /// \endcond } } //end of namespace CGAL::Polygon_mesh_processing diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index c39d6fd648e..2dfaade293d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -952,7 +952,7 @@ void split_connected_components_impl(FIMap fim, using parameters::is_default_parameter; Fpm pidmap = choose_parameter(get_parameter(np, internal_np::face_patch), - get(CGAL::dynamic_face_property_t(), tm)); + get(CGAL::dynamic_face_property_t(), tm)); std::size_t nb_patches = 0; if(is_default_parameter(get_parameter(np, internal_np::face_patch))) 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 690b5c4eec8..591c99a0ba8 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 @@ -546,6 +546,7 @@ void test_split() CGAL_assertion(num_vertices(meshes[2]) == 142); CGAL_assertion(num_vertices(meshes[3]) == 83); CGAL_assertion(num_vertices(meshes[4]) == 104); + CGAL_assertion(tm1.is_valid()); CGAL::clear(tm1); CGAL::clear(tm2); @@ -586,14 +587,59 @@ void test_split() //if the list does contain all those numbers. CGAL_assertion(num_vertices(meshes[0]) == 588); CGAL_assertion(num_vertices(meshes[1]) == 50); + CGAL_assertion(tm1.is_valid()); CGAL::clear(tm1); CGAL::clear(tm2); meshes.clear(); } +template +void test_isocuboid() +{ + TriangleMesh tm; + //closed intersection curves + std::ifstream input("data-coref/elephant.off"); + input >> tm; + + if(!input) + { + std::cerr<<"File not found. Aborting."< meshes; + K::Iso_cuboid_3 splitter(K::Point_3(-0.3, -0.45, -0.25), + K::Point_3( 0.3, 0.45, 0.25)); + PMP::split(tm, splitter); + + PMP::split_connected_components(tm, + meshes); + + CGAL_assertion(meshes.size() == 10); + //if the order is not deterministc, put the num_vertices in a list and check + //if the list does contain all those numbers. + CGAL_assertion(num_vertices(meshes[0]) == 2657); + CGAL_assertion(num_vertices(meshes[1]) == 131 ); + CGAL_assertion(num_vertices(meshes[2]) == 32 ); + CGAL_assertion(num_vertices(meshes[3]) == 123 ); + CGAL_assertion(num_vertices(meshes[4]) == 220 ); + CGAL_assertion(num_vertices(meshes[5]) == 107 ); + CGAL_assertion(num_vertices(meshes[6]) == 121 ); + CGAL_assertion(num_vertices(meshes[7]) == 56 ); + CGAL_assertion(num_vertices(meshes[8]) == 49 ); + CGAL_assertion(num_vertices(meshes[9]) == 13 ); + CGAL_assertion(tm.is_valid()); + + CGAL::clear(tm); + meshes.clear(); +} int main() { + std::cout << "Surface Mesh" << std::endl; test(); @@ -603,6 +649,9 @@ int main() std::cout << "running test_split with Surface_mesh\n"; test_split(); + std::cout << "running test_iso_cuboid with Surface_mesh\n"; + test_isocuboid(); + std::cout << "running test_split_plane with Surface_mesh\n"; test_split_plane(); @@ -612,6 +661,8 @@ int main() std::cout << "running test_split_plane with Polyhedron\n"; test_split_plane(); + std::cout << "running test_iso_cuboid with Polyhedron\n"; + test_isocuboid(); std::cout << "Done!" << std::endl; return EXIT_SUCCESS; From 023085af4129c4c3cbb28da665cfef45d50dd9e3 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Wed, 25 Mar 2020 15:36:58 +0100 Subject: [PATCH 21/40] Fix misused iterator --- Spatial_searching/include/CGAL/Euclidean_distance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spatial_searching/include/CGAL/Euclidean_distance.h b/Spatial_searching/include/CGAL/Euclidean_distance.h index 161d5b2dd55..70b52f854ed 100644 --- a/Spatial_searching/include/CGAL/Euclidean_distance.h +++ b/Spatial_searching/include/CGAL/Euclidean_distance.h @@ -132,7 +132,7 @@ namespace CGAL { // Note: the concept SearchTraits specifies that Cartesian_const_iterator_d // must be a random-access iterator typename SearchTraits::Cartesian_const_iterator_d qe_minus_5 = qe; - std::advance(qe, -5); + std::advance(qe_minus_5, -5); for (;;) { FT diff = (*qit) - (*it_coord_begin); From 20d2770d3a36029d44ce5fbce814395d60789078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 26 Mar 2020 19:39:09 +0100 Subject: [PATCH 22/40] extra run of the script to remove tabs and trailing whitespaces --- Property_map/doc/Property_map/Property_map.txt | 10 +++++----- Property_map/examples/Property_map/CMakeLists.txt | 4 ++-- .../examples/Property_map/custom_property_map.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Property_map/doc/Property_map/Property_map.txt b/Property_map/doc/Property_map/Property_map.txt index 06d78d76d2b..d2ecf66d1df 100644 --- a/Property_map/doc/Property_map/Property_map.txt +++ b/Property_map/doc/Property_map/Property_map.txt @@ -1,7 +1,7 @@ namespace CGAL { /*! -\mainpage User Manual +\mainpage User Manual \anchor Chapter_CGAL_and_Boost_Property_Maps \anchor chapterProperty_map @@ -27,15 +27,15 @@ Property maps in the Boost manuals: , Vector_3 >`, or as a `boost::tuple<..,Point_3, ..., Vector_3 >`. -This component provides property maps to support these cases: +This component provides property maps to support these cases: - `Identity_property_map` - `First_of_pair_property_map` and `Second_of_pair_property_map` @@ -71,6 +71,6 @@ algorithm on raw `double` arrays: \cgalExample{Property_map/custom_property_map.cpp} -*/ +*/ } /* namespace CGAL */ diff --git a/Property_map/examples/Property_map/CMakeLists.txt b/Property_map/examples/Property_map/CMakeLists.txt index b01994b8dba..d5717d3f5d2 100644 --- a/Property_map/examples/Property_map/CMakeLists.txt +++ b/Property_map/examples/Property_map/CMakeLists.txt @@ -9,7 +9,7 @@ find_package( CGAL QUIET COMPONENTS ) if ( NOT CGAL_FOUND ) message(STATUS "This project requires the CGAL library, and will not be compiled.") - return() + return() endif() @@ -20,7 +20,7 @@ if ( NOT Boost_FOUND ) message(STATUS "This project requires the Boost library, and will not be compiled.") - return() + return() endif() diff --git a/Property_map/examples/Property_map/custom_property_map.cpp b/Property_map/examples/Property_map/custom_property_map.cpp index 22a923a200d..540bec3cd2d 100644 --- a/Property_map/examples/Property_map/custom_property_map.cpp +++ b/Property_map/examples/Property_map/custom_property_map.cpp @@ -16,7 +16,7 @@ struct Custom_point_map using value_type = Point_3; // The object manipulated by the algorithm is a Point_3 using reference = Point_3; // The object does not exist in memory, so there's no reference using category = boost::readable_property_map_tag; // The property map is only used for reading - + double *x, *y, *z; Custom_point_map (double* x = nullptr, double* y = nullptr, double* z = nullptr) @@ -65,7 +65,7 @@ struct Custom_normal_map int main() { constexpr std::size_t nb_points = 1000; - + // in this example, points are stored as separate coordinate arrays double x[nb_points]; double y[nb_points]; @@ -96,7 +96,7 @@ int main() (indices, 12, CGAL::parameters::point_map (Custom_point_map(x,y,z)). normal_map (Custom_normal_map(normals))); - + CGAL::mst_orient_normals (indices, 12, CGAL::parameters::point_map (Custom_point_map(x,y,z)). @@ -107,6 +107,6 @@ int main() std::cerr << "Point(" << i << ") = " << x[i] << " " << y[i] << " " << z[i] << "\tNormal(" << i << ") = " << normals[3*i] << " " << normals[3*i+1] << " " << normals[3*i+2] << std::endl; - + return EXIT_SUCCESS; } From e6e9e23fdd9665d31eac780d645962e0ddc76435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 26 Mar 2020 19:40:08 +0100 Subject: [PATCH 23/40] extra run of the script to remove tabs and trailing whitespaces --- .../CGAL/Polygon_mesh_processing/connected_components.h | 2 +- .../test/Polygon_mesh_processing/test_pmp_clip.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 2dfaade293d..0cef49a7acf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -215,7 +215,7 @@ connected_components(const PolygonMesh& pmesh, NamedParameters, internal::No_constraint//default > ::type EdgeConstraintMap; - + EdgeConstraintMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained)); 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 591c99a0ba8..8fa24510f64 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 @@ -645,19 +645,19 @@ int main() std::cout << "Polyhedron" << std::endl; test(); - + std::cout << "running test_split with Surface_mesh\n"; test_split(); - + std::cout << "running test_iso_cuboid with Surface_mesh\n"; test_isocuboid(); std::cout << "running test_split_plane with Surface_mesh\n"; test_split_plane(); - + std::cout << "running test_split with Polyhedron\n"; test_split(); - + std::cout << "running test_split_plane with Polyhedron\n"; test_split_plane(); From a774b367f3e252c3bea6d7ef32a7077d61c83f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 26 Mar 2020 19:41:07 +0100 Subject: [PATCH 24/40] extra run of the script to remove tabs and trailing whitespaces --- .../include/CGAL/Euclidean_distance.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Spatial_searching/include/CGAL/Euclidean_distance.h b/Spatial_searching/include/CGAL/Euclidean_distance.h index 70b52f854ed..60fde16c20b 100644 --- a/Spatial_searching/include/CGAL/Euclidean_distance.h +++ b/Spatial_searching/include/CGAL/Euclidean_distance.h @@ -6,7 +6,7 @@ // $URL$ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// +// // // Author(s) : Hans Tangelder () // Clement Jamin (clement.jamin.pro@gmail.com) @@ -29,7 +29,7 @@ namespace CGAL { template class Euclidean_distance; - + namespace internal{ template struct Spatial_searching_default_distance{ @@ -39,9 +39,9 @@ namespace CGAL { template class Euclidean_distance { - + SearchTraits traits; - + public: typedef typename SearchTraits::FT FT; @@ -49,7 +49,7 @@ namespace CGAL { typedef Point_d Query_item; typedef typename internal::Get_dimension_tag::Dimension D; - + // default constructor Euclidean_distance(const SearchTraits& traits_=SearchTraits()):traits(traits_) {} @@ -118,8 +118,8 @@ namespace CGAL { // During the computation, if the partially-computed distance `pcd` gets greater or equal // to `stop_if_geq_to_this`, the computation is stopped and `pcd` is returned template - inline FT interruptible_transformed_distance(const Query_item& q, - Coord_iterator it_coord_begin, Coord_iterator /*unused*/, + inline FT interruptible_transformed_distance(const Query_item& q, + Coord_iterator it_coord_begin, Coord_iterator /*unused*/, FT stop_if_geq_to_this) const { FT distance = FT(0); @@ -129,7 +129,7 @@ namespace CGAL { { // Every 4 coordinates, the current partially-computed distance // is compared to stop_if_geq_to_this - // Note: the concept SearchTraits specifies that Cartesian_const_iterator_d + // Note: the concept SearchTraits specifies that Cartesian_const_iterator_d // must be a random-access iterator typename SearchTraits::Cartesian_const_iterator_d qe_minus_5 = qe; std::advance(qe_minus_5, -5); From fbc731b909cce70ff9e8a1462bde89e6b313480f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 2 Apr 2020 09:31:24 +0200 Subject: [PATCH 25/40] Fix PidMap value type --- .../Polygon_mesh_processing/connected_components.h | 14 ++++++++------ .../test/Polygon_mesh_processing/test_pmp_clip.cpp | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 0cef49a7acf..68c7e47af71 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -299,7 +299,8 @@ template Face_property_tag; + typedef typename boost::graph_traits::faces_size_type faces_size_type; + typedef CGAL::dynamic_face_property_t Face_property_tag; typedef typename boost::property_map::const_type Patch_ids_map; Patch_ids_map patch_ids_map = get(Face_property_tag(), pmesh); @@ -940,21 +941,22 @@ void split_connected_components_impl(FIMap fim, const PolygonMesh& tm, const NamedParameters& np) { + typedef typename boost::graph_traits::faces_size_type faces_size_type; typedef typename internal_np::Lookup_named_param_def < internal_np::face_patch_t, NamedParameters, typename boost::template property_map< - PolygonMesh, CGAL::dynamic_face_property_t >::const_type - > ::type Fpm; + PolygonMesh, CGAL::dynamic_face_property_t >::const_type> ::type + Fpm; using parameters::choose_parameter; using parameters::get_parameter; using parameters::is_default_parameter; Fpm pidmap = choose_parameter(get_parameter(np, internal_np::face_patch), - get(CGAL::dynamic_face_property_t(), tm)); + get(CGAL::dynamic_face_property_t(), tm)); - std::size_t nb_patches = 0; + faces_size_type nb_patches = 0; if(is_default_parameter(get_parameter(np, internal_np::face_patch))) { nb_patches = CGAL::Polygon_mesh_processing::connected_components( @@ -965,7 +967,7 @@ void split_connected_components_impl(FIMap fim, { for(const auto& f : faces(tm)) { - std::size_t patch = get(pidmap, f); + faces_size_type patch = get(pidmap, f); if(patch > nb_patches) nb_patches = patch; } 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 8fa24510f64..857d236ce89 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 @@ -529,9 +529,10 @@ void test_split() PMP::split(tm1, tm2); //try with np + typedef typename boost::graph_traits::faces_size_type faces_size_type; typename boost::template property_map< - TriangleMesh, CGAL::dynamic_face_property_t >::type - pidmap = get(CGAL::dynamic_face_property_t(), tm1); + TriangleMesh, CGAL::dynamic_face_property_t >::type + pidmap = get(CGAL::dynamic_face_property_t(), tm1); CGAL::Polygon_mesh_processing::connected_components( tm1, pidmap, CGAL::parameters::all_default()); PMP::split_connected_components(tm1, From 507d6d17b542d492b79eb9eb245c304394acb2ea Mon Sep 17 00:00:00 2001 From: Mael Date: Thu, 2 Apr 2020 10:18:06 +0200 Subject: [PATCH 26/40] Fix type --- .../CGAL/Polygon_mesh_processing/connected_components.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h index 68c7e47af71..b98a70c63c5 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h @@ -967,14 +967,14 @@ void split_connected_components_impl(FIMap fim, { for(const auto& f : faces(tm)) { - faces_size_type patch = get(pidmap, f); - if(patch > nb_patches) - nb_patches = patch; + faces_size_type patch_id = get(pidmap, f); + if(patch_id > nb_patches) + nb_patches = patch_id; } nb_patches+=1; } - for(std::size_t i=0; i filter_graph(tm, i, pidmap, CGAL::parameters::face_index_map(fim) From 9d138a788d23b7ed7697125450878b41a95cf0c2 Mon Sep 17 00:00:00 2001 From: Mael Date: Thu, 2 Apr 2020 13:14:07 +0200 Subject: [PATCH 27/40] Fix compilation --- .../test/Polygon_mesh_processing/test_pmp_clip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 857d236ce89..a20745227b7 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 @@ -532,7 +532,7 @@ void test_split() typedef typename boost::graph_traits::faces_size_type faces_size_type; typename boost::template property_map< TriangleMesh, CGAL::dynamic_face_property_t >::type - pidmap = get(CGAL::dynamic_face_property_t(), tm1); + pidmap = get(CGAL::dynamic_face_property_t(), tm1); CGAL::Polygon_mesh_processing::connected_components( tm1, pidmap, CGAL::parameters::all_default()); PMP::split_connected_components(tm1, From 0c8c36fe90c87ebafaa9902fc3f075f9bf625db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 2 Apr 2020 14:48:57 +0200 Subject: [PATCH 28/40] patch at the wrong line --- .travis/generate_travis.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/generate_travis.sh b/.travis/generate_travis.sh index 77f6dd51362..c6102268d63 100755 --- a/.travis/generate_travis.sh +++ b/.travis/generate_travis.sh @@ -21,14 +21,14 @@ for f in * do if [ -d "$f/package_info/$f" ] then - PACKAGES[$INDEX]+="$f" + PACKAGES[$INDEX]+="$f " i=$[i+1] if [ $i = 3 ] then i=0 INDEX=$[INDEX+1] fi - echo "$f " >> ./.travis/packages.txt + echo "$f" >> ./.travis/packages.txt fi done if [ -f ".travis.yml" ] From b6a5f23e4ecc8ebc749ed024ab9350c56e65f687 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 2 Apr 2020 15:02:27 +0200 Subject: [PATCH 29/40] remove trailing whitespaces --- .../Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp | 12 ++++++------ .../TDS_3/Concepts/TriangulationDataStructure_3.h | 12 ++++++------ .../doc/Triangulation_3/CGAL/Triangulation_3.h | 14 +++++++------- Triangulation_3/include/CGAL/Triangulation_3.h | 4 ++-- .../Triangulation_3/test_io_triangulation_3.cpp | 14 +++++++------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 326d2702f05..5e21aba3749 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -405,12 +405,12 @@ struct Update_vertex typedef typename Tr1::Vertex V1; typedef typename Tr2::Vertex V2; typedef typename Tr2::Point Point; - + V2 operator()(const V1&) { return V2(); } - + bool operator()(const V1& v1, V2& v2) { v2.set_point(Point(v1.point())); @@ -432,9 +432,9 @@ struct Update_vertex }; // end struct Update_vertex struct Update_cell { - + typedef Fake_mesh_domain::Surface_patch_index Sp_index; - + template bool operator()(const C1& c1, C2& c2) { c2.set_subdomain_index(c1.subdomain_index()); @@ -472,9 +472,9 @@ struct Update_vertex_from_CDT_3 { }; // end struct Update_vertex struct Update_cell_from_CDT_3 { - + typedef Fake_mesh_domain::Surface_patch_index Sp_index; - + template void operator()(const C1& c1, C2& c2) { c2.set_subdomain_index(1); diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h index a13840f6f79..081f9f98513 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h @@ -1022,8 +1022,8 @@ It also calls the `is_valid` member function of the cell. When `verbose` is set to `true`, messages are printed to give a precise indication on the kind of invalidity encountered. \cgalDebugEnd -*/ -bool is_valid(Cell_handle c, bool verbose = false) const; +*/ +bool is_valid(Cell_handle c, bool verbose = false) const; /// @} @@ -1031,13 +1031,13 @@ bool is_valid(Cell_handle c, bool verbose = false) const; /// @{ /*! \ingroup PkgIOTDS3 -Reads a combinatorial triangulation from `is` and assigns it to `tds` -*/ -istream& operator>> (istream& is, TriangulationDataStructure_3 & tds); +Reads a combinatorial triangulation from `is` and assigns it to `tds` +*/ +istream& operator>> (istream& is, TriangulationDataStructure_3 & tds); /*! \ingroup PkgIOTDS3 Writes `tds` into the stream `os` -*/ +*/ ostream& operator<< (ostream& os, const TriangulationDataStructure_3 & tds); /*! \ingroup PkgIOTDS3 diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index a6e6bb4fe44..e86c542c60d 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -1559,28 +1559,28 @@ ostream& operator<< (ostream& os, const Triangulation_3 &t); /*! \ingroup PkgIOTriangulation3 The triangulation streamed in `is`, of original type `Tr_src`, is written into the triangulation. As the vertex and cell - types might be different and incompatible, the creation of new cells and vertices -is made thanks to the functors `convert_vertex` and `convert_cell`, that convert + types might be different and incompatible, the creation of new cells and vertices +is made thanks to the functors `convert_vertex` and `convert_cell`, that convert vertex and cell types. For each vertex `v_src` in `is`, the corresponding -vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. +vertex `v_tgt` in the triangulation is a copy of the vertex returned by `convert_vertex(v_src)`. The same operations are done for cells with the functor convert_cell, except cells in the triangulation are created using the default constructor, and then filled with the data contained in the stream. - A model of `ConvertVertex` must provide two `operator()`s that are responsible for converting the source vertex `v_src` into the target vertex: - - `Vertex operator()(const Tr_src::Vertex& v_src) const;` This operator is + - `Vertex operator()(const Tr_src::Vertex& v_src) const;` This operator is used to create the vertex from `v_src`. - `void operator()(const Tr_src::Vertex& v_src, Vertex& v_tgt) const;` This operator is meant to be used in case heavy data should be transferred to `v_tgt`. - - A model of ConvertCell must provide an operator() that is responsible for + - A model of ConvertCell must provide an operator() that is responsible for converting the source cell `c_src` into the target cell: - `void operator()(const Tr_src::Cell& c_src, Cell& c_tgt) const;` This operator is meant to be used in case data should be transferred to `c_tgt`. \note The triangulation contained in `is` can be obtained with the `operator>>` of a `Triangulation_3`. */ -template std::istream& file_input(std::istream& is, @@ -1589,7 +1589,7 @@ std::istream& file_input(std::istream& is, /// @} /// -/// \name Concurrency +/// \name Concurrency /// @{ /*! diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 18aafd68ed3..c3f6e310f44 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -2196,9 +2196,9 @@ public: bool is_valid(bool verbose = false, int level = 0) const; bool is_valid(Cell_handle c, bool verbose = false, int level = 0) const; bool is_valid_finite(Cell_handle c, bool verbose = false, int level=0) const; - + //IO - template std::istream& file_input(std::istream& is, diff --git a/Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp b/Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp index 51e0d9a9355..a6e4694e5e1 100644 --- a/Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp +++ b/Triangulation_3/test/Triangulation_3/test_io_triangulation_3.cpp @@ -19,12 +19,12 @@ struct Update_vertex typedef typename T1::Vertex V1; typedef typename T2::Vertex V2; typedef typename T2::Point Point; - + V2 operator()(const V1&) { return V2(); } - + void operator()(const V1& v1, V2& v2) { CGAL::Cartesian_converter c; @@ -32,7 +32,7 @@ struct Update_vertex } }; // end struct Update_vertex -struct Update_cell { +struct Update_cell { template void operator()(const C1&, C2&) {} }; // end struct Update_cell @@ -48,8 +48,8 @@ int main() std::ofstream out("tr"); out << T1; out.close(); - - Tr2 T2; + + Tr2 T2; std::ifstream in("tr"); T2.file_input, Update_cell>(in); in.close(); @@ -59,8 +59,8 @@ int main() assert(*(pit)++ == Tr2::Point(1,0,0)); assert(*(pit)++ == Tr2::Point(0,1,0)); assert(*(pit)++ == Tr2::Point(0,0,1)); - - + + std::cout << "done" << std::endl; return 0; } From c8af1fb3cc27beb1a11ce64868bb1a341ce41058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 2 Apr 2020 16:15:11 +0200 Subject: [PATCH 30/40] Do not initialize meshes in assertions Otherwise things break when DNDEBUG is used --- BGL/test/BGL/test_Prefix.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/BGL/test/BGL/test_Prefix.h b/BGL/test/BGL/test_Prefix.h index 2bc58be848b..a2328b46484 100644 --- a/BGL/test/BGL/test_Prefix.h +++ b/BGL/test/BGL/test_Prefix.h @@ -156,7 +156,8 @@ std::vector lcc_data() template struct Surface_fixture_1 { Surface_fixture_1() { - assert(read_a_mesh(m, "data/fixture1.off")); + const bool is_reading_successful = read_a_mesh(m, "data/fixture1.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); typename boost::property_map::const_type pm = get(CGAL::vertex_point, const_cast(m)); @@ -205,7 +206,8 @@ struct Surface_fixture_1 { template struct Surface_fixture_2 { Surface_fixture_2() { - assert(read_a_mesh(m, "data/fixture2.off")); + const bool is_reading_successful = read_a_mesh(m, "data/fixture2.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); typename boost::property_map::const_type @@ -266,7 +268,8 @@ struct Surface_fixture_2 { template struct Surface_fixture_3 { Surface_fixture_3() { - assert(read_a_mesh(m, "data/fixture3.off")); + const bool is_reading_successful = read_a_mesh(m, "data/fixture3.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); typename boost::property_map::const_type @@ -312,7 +315,8 @@ struct Surface_fixture_3 { template struct Surface_fixture_4 { Surface_fixture_4() { - assert(read_a_mesh(m, "data/fixture4.off")); + const bool is_reading_successful = read_a_mesh(m, "data/fixture4.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); typename boost::property_map::const_type @@ -347,7 +351,8 @@ struct Surface_fixture_4 { template struct Surface_fixture_5 { Surface_fixture_5() { - assert(read_a_mesh(m, "data/add_face_to_border.off")); + const bool is_reading_successful = read_a_mesh(m, "data/add_face_to_border.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); typename boost::property_map::const_type @@ -377,7 +382,8 @@ struct Surface_fixture_5 { template struct Surface_fixture_6 { Surface_fixture_6() { - assert(read_a_mesh(m, "data/quad.off")); + const bool is_reading_successful = read_a_mesh(m, "data/quad.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); typename boost::graph_traits::halfedge_descriptor h; @@ -396,7 +402,8 @@ struct Surface_fixture_6 { template struct Surface_fixture_7 { Surface_fixture_7() { - assert(read_a_mesh(m, "data/cube.off")); + const bool is_reading_successful = read_a_mesh(m, "data/cube.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); h = *(halfedges(m).first); @@ -409,7 +416,8 @@ struct Surface_fixture_7 { template struct Surface_fixture_8 { Surface_fixture_8() { - assert(read_a_mesh(m, "data/fixture5.off")); + const bool is_reading_successful = read_a_mesh(m, "data/fixture5.off"); + assert(is_reading_successful); assert(CGAL::is_valid_polygon_mesh(m)); typename boost::property_map::const_type From 733f71a6bca4553828611d1b38d6aac70d634c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 2 Apr 2020 16:16:06 +0200 Subject: [PATCH 31/40] Do not initialize variables / change the triangulation in assertions Otherwise things break when DNDEBUG is used --- .../CGAL/_test_cls_constrained_triangulation_2.h | 5 +++-- .../CGAL/_test_cls_delaunay_triangulation_2.h | 6 ++++-- .../include/CGAL/_test_cls_triangulation_2.h | 15 ++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h index 5f6b7556ee2..219a54c726b 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h @@ -217,7 +217,8 @@ _test_cls_constrained_triangulation(const Triang &) vha = fh->vertex(li); fh = T1_2.locate(Point(3,2),lt,li); assert( lt == Triang::VERTEX ); vhb = fh->vertex(li); - assert(T1_2.is_edge(vha,vhb, fh, ih)); + bool check = T1_2.is_edge(vha,vhb, fh, ih); + assert(check); assert(fh->is_constrained(ih)); T1_2.remove_constrained_edge(fh,ih); assert(T1_2.is_valid()); @@ -250,7 +251,7 @@ _test_cls_constrained_triangulation(const Triang &) vha = fh->vertex(li); fh = T2_2.locate(lpt[m+1],lt,li); assert( lt == Triang::VERTEX ); vhb = fh->vertex(li); - bool check = T2_2.is_edge(vha,vhb, fh, ih); + check = T2_2.is_edge(vha,vhb, fh, ih); assert(check); assert(fh->is_constrained(ih)); T2_2.remove_constrained_edge(fh,ih); diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h index 7c5907160d0..d5088cb094d 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_delaunay_triangulation_2.h @@ -293,7 +293,8 @@ _test_cls_delaunay_triangulation_2( const Del & ) assert(TM_0.tds().is_valid()); assert(TM_0.is_valid()); assert(TM_0.dimension() == 2); - assert(TM_0.move_if_no_collision(tmv1, Point(3, 0)) != tmv1); + Vertex_handle mtmv1 = TM_0.move_if_no_collision(tmv1, Point(3, 0)); + assert(mtmv1 != tmv1); TM_0.move_if_no_collision(tmv1, Point(0, 1)); assert(TM_0.tds().is_valid()); @@ -340,7 +341,8 @@ _test_cls_delaunay_triangulation_2( const Del & ) // A simple test to see if move return the good vertex // when there is a collision - assert(TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()) == vTM_1); + Vertex_handle mvTM_1 = TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()); + assert(mvTM_1 == vTM_1); } 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 8beb8650271..336897fb0fb 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 @@ -270,11 +270,13 @@ _test_cls_triangulation_2( const Triangul & ) assert( T2_3.is_valid() ); // make sure inserting on a previous point does not insert it again - assert( T2_3.insert(p10) == v2_3_10 ); + Vertex_handle vp10 = T2_3.insert(p10); + assert( vp10 == v2_3_10 ); assert( T2_3.number_of_vertices() == 11 ); // make sure push_back exists and does the same thing as insert - assert( T2_3.push_back(p10) == v2_3_10 ); + Vertex_handle vp10 = T2_3.push_back(p10); + assert( vp10 == v2_3_10 ); assert( T2_3.number_of_vertices() == 11 ); // test generic iterator insert @@ -288,14 +290,16 @@ _test_cls_triangulation_2( const Triangul & ) // test list iterator insert Triangul T2_5; - assert( T2_5.insert(l.begin(), l.end()) == 10 ); + std::ptrdiff_t T2_5_nv = T2_5.insert(l.begin(), l.end()); + assert( T2_5_nv == 10 ); assert( T2_5.dimension() == 2 ); assert( T2_5.number_of_vertices() == 10 ); assert( T2_5.is_valid() ); // test list iterator insert Triangul T2_6; - assert( T2_6.insert(v.begin(), v.end()) == 10 ); + std::ptrdiff_t T2_6_nv = T2_6.insert(v.begin(), v.end()); + assert( T2_6_nv == 10 ); assert( T2_6.dimension() == 2 ); assert( T2_6.number_of_vertices() == 10 ); assert( T2_6.is_valid() ); @@ -451,7 +455,8 @@ _test_cls_triangulation_2( const Triangul & ) // A simple test to see if move returns the good vertex // when there is a collision - assert(TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()) == vTM_1); + Vertex_handle mvTM_1 = TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()) + assert(mvTM_1 == vTM_1); /****************************/ /***** CONSTRUCTORS (2) *****/ From 1cb3736f1a672eebd789995e888656d7815478d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 3 Apr 2020 09:03:56 +0200 Subject: [PATCH 32/40] Fix compilation errors --- .../Triangulation_2/include/CGAL/_test_cls_triangulation_2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 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 336897fb0fb..096b6bc5d7a 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 @@ -275,7 +275,7 @@ _test_cls_triangulation_2( const Triangul & ) assert( T2_3.number_of_vertices() == 11 ); // make sure push_back exists and does the same thing as insert - Vertex_handle vp10 = T2_3.push_back(p10); + vp10 = T2_3.push_back(p10); assert( vp10 == v2_3_10 ); assert( T2_3.number_of_vertices() == 11 ); @@ -455,7 +455,7 @@ _test_cls_triangulation_2( const Triangul & ) // A simple test to see if move returns the good vertex // when there is a collision - Vertex_handle mvTM_1 = TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()) + Vertex_handle mvTM_1 = TM_1.move(TM_1.finite_vertices_begin(), vTM_1->point()); assert(mvTM_1 == vTM_1); /****************************/ From 952d5721fd39c23be1736fd09b006a8c2e1aeb13 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 3 Apr 2020 12:31:59 +0200 Subject: [PATCH 33/40] fix c3t3_io plugin --- .../demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 5e21aba3749..d2232c11dd4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -449,7 +449,6 @@ struct Update_cell { } }; // end struct Update_cell -#include template struct Update_vertex_from_CDT_3 { @@ -511,11 +510,10 @@ try_load_a_cdt_3(std::istream& is, C3t3& c3t3) } } if(binary) CGAL::set_binary_mode(is); - if(CGAL::file_input< + if(c3t3.triangulation().file_input< Fake_CDT_3, - C3t3::Triangulation, Update_vertex_from_CDT_3, - Update_cell_from_CDT_3>(is, c3t3.triangulation())) + Update_cell_from_CDT_3>(is)) { c3t3.rescan_after_load_of_triangulation(); std::cerr << "Try load a CDT_3... DONE"; @@ -555,11 +553,10 @@ try_load_other_binary_format(std::istream& is, C3t3& c3t3) } if(binary) CGAL::set_binary_mode(is); else CGAL::set_ascii_mode(is); - std::istream& f_is = CGAL::file_input< + std::istream& f_is = c3t3.triangulation().file_input< Fake_c3t3::Triangulation, - C3t3::Triangulation, Update_vertex, - Update_cell>(is, c3t3.triangulation()); + Update_cell>(is); c3t3.rescan_after_load_of_triangulation(); return f_is.good(); From 25c7c570ebc9eb1c15772e13bb66896447549d4c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 6 Apr 2020 09:05:29 +0200 Subject: [PATCH 34/40] Update CHANGES.md --- Installation/CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index b7da527361a..aeb612f7cc6 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -8,6 +8,12 @@ Release History the signed distance of two points to a line, or the line passing through two given points. Corresponding functors in the model (`Compare_signed_distance_to_line_2`) are also added. +### 2D Triangulations + - Add function `split_subconstraint_graph_into_constraints()` to + `Constrained_triangulation_plus_2` to initialize the constraints + from a soup of disconnected segments that should first be split + into polylines. + Release 5.0 ----------- From a6d800ae5e697b58ff8fa56e2299bbecb02e7ac6 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 6 Apr 2020 13:40:13 +0200 Subject: [PATCH 35/40] Fix jet smoothing --- .../include/CGAL/jet_smooth_point_set.h | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h index 474c6754ac9..b36714258cf 100644 --- a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h @@ -192,26 +192,42 @@ jet_smooth_point_set( Point_set_processing_3::internal::Callback_wrapper callback_wrapper (callback, nb_points); + std::vector smoothed (points.size()); + + typedef boost::zip_iterator + ::iterator> > Zip_iterator; + CGAL::for_each - (points, - [&](value_type vt) + (CGAL::make_range (boost::make_zip_iterator (boost::make_tuple (points.begin(), smoothed.begin())), + boost::make_zip_iterator (boost::make_tuple (points.end(), smoothed.end()))), + [&](const typename Zip_iterator::reference& t) { if (callback_wrapper.interrupted()) return false; - put (point_map, vt, - CGAL::internal::jet_smooth_point - (get (point_map, vt), neighbor_query, - k, - neighbor_radius, - degree_fitting, - degree_monge)); + get<1>(t) = CGAL::internal::jet_smooth_point + (get (point_map, get<0>(t)), neighbor_query, + k, + neighbor_radius, + degree_fitting, + degree_monge); ++ callback_wrapper.advancement(); return true; }); callback_wrapper.join(); + + // Finally, update points + CGAL::for_each + (CGAL::make_range (boost::make_zip_iterator (boost::make_tuple (points.begin(), smoothed.begin())), + boost::make_zip_iterator (boost::make_tuple (points.end(), smoothed.end()))), + [&](const typename Zip_iterator::reference& t) + { + put (point_map, get<0>(t), get<1>(t)); + return true; + }); } From ee052cd6228359abe2ffa29d539e9c0c6a08a1e2 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 6 Apr 2020 14:09:33 +0200 Subject: [PATCH 36/40] fix test_io_tds_3 --- TDS_3/test/TDS_3/test_io_tds3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TDS_3/test/TDS_3/test_io_tds3.cpp b/TDS_3/test/TDS_3/test_io_tds3.cpp index 98ed299540e..10bfcedc030 100644 --- a/TDS_3/test/TDS_3/test_io_tds3.cpp +++ b/TDS_3/test/TDS_3/test_io_tds3.cpp @@ -61,7 +61,7 @@ int main() // we now have a simplex in dimension 4 // cell incident to PV[0] Cell_handle c = PV[0]->cell(); - int ind; + int ind=0; // PV[0] is the vertex of index ind in c // insertion of a new vertex in the facet opposite to PV[0] PV[5] = T.insert_in_facet(c, ind); From cecc0debe38f624d68b5844b5429bb1c83a71ec9 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 7 Apr 2020 09:11:25 +0200 Subject: [PATCH 37/40] Fix missing include --- Point_set_processing_3/include/CGAL/jet_smooth_point_set.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h index b36714258cf..0f26897ce79 100644 --- a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h @@ -28,6 +28,8 @@ #include #include +#include + #include #include From 5828c759f955a740700c18344fad224a6b64793c Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 7 Apr 2020 09:12:17 +0200 Subject: [PATCH 38/40] Remove unused typedef --- Point_set_processing_3/include/CGAL/jet_smooth_point_set.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h index 0f26897ce79..e787b48d18c 100644 --- a/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h +++ b/Point_set_processing_3/include/CGAL/jet_smooth_point_set.h @@ -155,7 +155,6 @@ jet_smooth_point_set( // basic geometric types typedef typename PointRange::iterator iterator; - typedef typename iterator::value_type value_type; typedef typename CGAL::GetPointMap::type PointMap; typedef typename Point_set_processing_3::GetK::Kernel Kernel; typedef typename GetSvdTraits::type SvdTraits; From 75f0b18224b3a42ef0c515d841fc00a772b88ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 7 Apr 2020 14:31:36 +0200 Subject: [PATCH 39/40] remove deprecated config options --- .../doc/resources/1.8.14/BaseDoxyfile.in | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/Documentation/doc/resources/1.8.14/BaseDoxyfile.in b/Documentation/doc/resources/1.8.14/BaseDoxyfile.in index 872b616f346..4f97a0477d8 100644 --- a/Documentation/doc/resources/1.8.14/BaseDoxyfile.in +++ b/Documentation/doc/resources/1.8.14/BaseDoxyfile.in @@ -299,12 +299,6 @@ ALIASES = "sc{1}=\1\cite \1" \ "cgalPackageSection{2}=\htmlonly[block]
\endhtmlonly \section \1 \2 ^^ \htmlonly[block]
\endhtmlonly" -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all @@ -2185,12 +2179,6 @@ EXTERNAL_GROUPS = NO EXTERNAL_PAGES = NO -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -2204,15 +2192,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = NO -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. From a60b15c90e3fbd508b832969269c0b44ffe6fb6e Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 6 Apr 2020 13:45:56 +0200 Subject: [PATCH 40/40] Fix picking with wireframe and points --- Polyhedron/demo/Polyhedron/Scene.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index a1d107a15de..bf2041c8593 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -598,6 +598,10 @@ void Scene::renderWireScene(const QList &items, || item.renderingMode() == PointsPlusNormals || item.renderingMode() == GouraudPlusEdges) { + if(with_names) { + viewer->glClearDepthf(1.0); + viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } viewer->setGlPointSize(2.f); item.drawEdges(viewer); } @@ -656,6 +660,10 @@ void Scene::renderPointScene(const QList &items, (item.renderingMode() == PointsPlusNormals) || (item.renderingMode() == ShadedPoints)) { + if(with_names) { + viewer->glClearDepthf(1.0); + viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } viewer->setGlPointSize(3.0f); item.drawPoints(viewer); }