From 8fe0633fb5895d1fdc1fdd7bc99f3b7ed8439d2c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 15:44:21 +0200 Subject: [PATCH 01/11] add new possible gmp name for MSVC gmp-10 was compiled with vcpkg and installed on Christo --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index 3f407098996..fbc511c3889 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -8,6 +8,7 @@ int main() { #define GMP_SONAME "libgmp-10" #define MPFR_SONAME "libmpfr-4" #define GMP_SONAME_BACKUP "gmp" +#define GMP_SONAME_BACKUP_2 "gmp-10" #define MPFR_SONAME_BACKUP "mpfr-6" #define GMP_MAJOR 5 #define MPFR_MAJOR 3 @@ -66,7 +67,9 @@ int main() { int major, minor, patch, build; if(!get_version_info(GMP_SONAME, major, minor, patch, build)) { if(!get_version_info(GMP_SONAME_BACKUP, major, minor, patch, build)) { - return 1; + if (!get_version_info(GMP_SONAME_BACKUP_2, major, minor, patch, build)) { + return 1; + } } } From 3c6a4c16c4b4e92e77884485ffb6e8986e1e5d6a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 15:58:49 +0200 Subject: [PATCH 02/11] add debug info for the testsuite --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index fbc511c3889..67ed1e76ee4 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -42,6 +42,12 @@ bool get_version_info(const LPCTSTR name, std::cerr << "Query FileVersion of \"" << fileName << "\"\n"; DWORD handle = 0; size = GetFileVersionInfoSize(fileName, &handle); + + DWORD err = GetLastError(); + if (size == 0) { + std::cerr << "GetFileVersionInfoSize failed with error " << err << std::endl; + } + BYTE* versionInfo = new BYTE[size]; if (!GetFileVersionInfo(fileName, handle, size, versionInfo)) { From 37c0b5eaa60558e5b4516608851ef0970fa4e176 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 16:14:19 +0200 Subject: [PATCH 03/11] add gmp-10 as a hint for findGMP and add GMP_DIR and MPFR_DIR as hints to find all includes and libs --- Installation/cmake/modules/FindGMP.cmake | 7 +++++-- Installation/cmake/modules/FindMPFR.cmake | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Installation/cmake/modules/FindGMP.cmake b/Installation/cmake/modules/FindGMP.cmake index 3a1d355d41f..f452c0287f7 100644 --- a/Installation/cmake/modules/FindGMP.cmake +++ b/Installation/cmake/modules/FindGMP.cmake @@ -26,22 +26,25 @@ if( NOT GMP_in_cache ) NAMES gmp.h HINTS ENV GMP_INC_DIR ENV GMP_DIR + $ENV{GMP_DIR}/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include PATH_SUFFIXES include DOC "The directory containing the GMP header files" ) - find_library(GMP_LIBRARY_RELEASE NAMES gmp libgmp-10 mpir + find_library(GMP_LIBRARY_RELEASE NAMES gmp libgmp-10 gmp-10 mpir HINTS ENV GMP_LIB_DIR ENV GMP_DIR + $ENV{GMP_DIR}/lib ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib PATH_SUFFIXES lib DOC "Path to the Release GMP library" ) - find_library(GMP_LIBRARY_DEBUG NAMES gmpd gmp libgmp-10 mpir + find_library(GMP_LIBRARY_DEBUG NAMES gmpd gmp libgmp-10 gmp-10 mpir HINTS ENV GMP_LIB_DIR ENV GMP_DIR + $ENV{GMP_DIR}/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib PATH_SUFFIXES lib DOC "Path to the Debug GMP library" diff --git a/Installation/cmake/modules/FindMPFR.cmake b/Installation/cmake/modules/FindMPFR.cmake index b21fb1f678e..4d1bc43553d 100644 --- a/Installation/cmake/modules/FindMPFR.cmake +++ b/Installation/cmake/modules/FindMPFR.cmake @@ -25,6 +25,7 @@ if (NOT MPFR_in_cache) NAMES mpfr.h HINTS ENV MPFR_INC_DIR ENV MPFR_DIR + $ENV{MPFR_DIR}/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include PATH_SUFFIXES include DOC "The directory containing the MPFR header files" @@ -33,6 +34,7 @@ if (NOT MPFR_in_cache) find_library(MPFR_LIBRARIES NAMES mpfr libmpfr-4 libmpfr-1 HINTS ENV MPFR_LIB_DIR ENV MPFR_DIR + $ENV{MPFR_DIR}/lib ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib PATH_SUFFIXES lib DOC "Path to the MPFR library" From 3077d8b6572bd1d540b9519aae3842c450f16127 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 16:33:20 +0200 Subject: [PATCH 04/11] remove useless definitions --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index 67ed1e76ee4..e7ccd4307d2 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -10,9 +10,6 @@ int main() { #define GMP_SONAME_BACKUP "gmp" #define GMP_SONAME_BACKUP_2 "gmp-10" #define MPFR_SONAME_BACKUP "mpfr-6" -#define GMP_MAJOR 5 -#define MPFR_MAJOR 3 - #include #include From d4b5fec0a673a6c717a7d1d428f9beadc9539bfe Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 13 Apr 2023 16:40:15 +0200 Subject: [PATCH 05/11] be verbose when loading succeeded --- Installation/test/Installation/test_gmp_mpfr_dll.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index e7ccd4307d2..17ec0939d6a 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -33,6 +33,9 @@ bool get_version_info(const LPCTSTR name, std::cerr << name << " is not loaded!\n"; return false; } + else + std::cerr << name << " is loaded.\n"; + char fileName[_MAX_PATH]; DWORD size = GetModuleFileName(g_dllHandle, fileName, _MAX_PATH); fileName[size] = NULL; From 451223a2e8611ff40dff8de074de3ad4690bd262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Apr 2023 11:20:04 +0200 Subject: [PATCH 06/11] Fix not forwarding verbose NP to inner functions --- .../include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h index 4fe8a9deaf0..fe136bd4545 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h @@ -101,7 +101,7 @@ bool read_polygon_mesh(const std::string& fname, std::vector points; std::vector > faces; - if(!CGAL::IO::read_polygon_soup(fname, points, faces)) + if(!CGAL::IO::read_polygon_soup(fname, points, faces, CGAL::parameters::verbose(verbose))) { if(verbose) std::cerr << "Warning: cannot read polygon soup" << std::endl; From b7ca320000b92d378e9e97f28d0e41e064eee09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Apr 2023 11:20:49 +0200 Subject: [PATCH 07/11] Fix null char reading and backslash separated multi lines --- Stream_support/include/CGAL/IO/OBJ.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 9cdc507e3cc..da8b51f9af6 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -72,12 +73,30 @@ bool read_OBJ(std::istream& is, bool tex_found(false), norm_found(false); while(getline(is, line)) { - if(line.empty()) - continue; + // get last non-whitespace, non-null character + auto last = std::find_if(line.rbegin(), line.rend(), [](char c) { return c != '\0' && !std::isspace(c); }); + if(last == line.rend()) + continue; // line is empty or only whitespace + + // keep reading lines as long as the last non-whitespace, non-null character is a backslash + while(last != line.rend() && *last == '\\') + { + // remove everything from the backslash (included) + line = line.substr(0, line.size() - (last - line.rbegin()) - 1); + + std::string next_line; + if(!getline(is, next_line)) + break; + + line += next_line; + last = std::find_if(line.rbegin(), line.rend(), [](char c) { return c != '\0' && !std::isspace(c); }); + } + + CGAL_assertion(!line.empty()); std::istringstream iss(line); if(!(iss >> s)) - continue; // can't read anything on the line, whitespace only? + continue; if(s == "v") { From d33fc1ad075c123adaa68d583c1a79b70e147f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 18 Apr 2023 11:21:54 +0200 Subject: [PATCH 08/11] Add missing error message --- Stream_support/include/CGAL/IO/OBJ.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index da8b51f9af6..5d9a14e94b0 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -146,7 +146,11 @@ bool read_OBJ(std::istream& is, } if(iss.bad()) + { + if(verbose) + std::cerr << "error while reading OBJ face." << std::endl; return false; + } } else if(s.front() == '#') { @@ -172,15 +176,15 @@ bool read_OBJ(std::istream& is, else { if(verbose) - std::cerr << "error: unrecognized line: " << s << std::endl; + std::cerr << "Error: unrecognized line: " << s << std::endl; return false; } } if(norm_found && verbose) - std::cout<<"NOTE: normals were found in this file, but were discarded."< Date: Tue, 18 Apr 2023 12:08:39 +0200 Subject: [PATCH 09/11] Minor example improvements --- .../triangulate_faces_example.cpp | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp index ce098ae6d4b..52982dbb923 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp @@ -23,18 +23,32 @@ int main(int argc, char* argv[]) Surface_mesh mesh; if(!PMP::IO::read_polygon_mesh(filename, mesh)) { - std::cerr << "Invalid input." << std::endl; - return 1; + std::cerr << "Error: Invalid input." << std::endl; + return EXIT_FAILURE; } + if(is_empty(mesh)) + { + std::cerr << "Warning: empty file?" << std::endl; + return EXIT_SUCCESS; + } + + if(!CGAL::is_triangle_mesh(mesh)) + std::cout << "Input mesh is not triangulated." << std::endl; + else + std::cout << "Input mesh is triangulated." << std::endl; + PMP::triangulate_faces(mesh); // Confirm that all faces are triangles. for(boost::graph_traits::face_descriptor f : faces(mesh)) + { if(!CGAL::is_triangle(halfedge(f, mesh), mesh)) std::cerr << "Error: non-triangular face left in mesh." << std::endl; + } + CGAL::IO::write_polygon_mesh(outfilename, mesh, CGAL::parameters::stream_precision(17)); - return 0; + return EXIT_SUCCESS; } From 2434b2437be01a6fe675edefee855e3765da1cef Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 4 May 2023 09:54:40 +0200 Subject: [PATCH 10/11] fix an UBSAN report when `ch` is null --- TDS_3/include/CGAL/Triangulation_simplex_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TDS_3/include/CGAL/Triangulation_simplex_3.h b/TDS_3/include/CGAL/Triangulation_simplex_3.h index aa2109b89ce..8bb4188f442 100644 --- a/TDS_3/include/CGAL/Triangulation_simplex_3.h +++ b/TDS_3/include/CGAL/Triangulation_simplex_3.h @@ -180,7 +180,7 @@ operator==(Triangulation_simplex_3 s0, } return false; case (3): - return (&(*s0.ch) == &(*s1.ch)); + return s0.ch.operator->() == s1.ch.operator->(); } CGAL_error(); return false; From dd738bf0297ceff9bd71186360661ff0a0891094 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 4 May 2023 09:55:10 +0200 Subject: [PATCH 11/11] bug fix for the simplex traverser --- .../Triangulation_segment_traverser_3_impl.h | 1 + .../CGAL/Triangulation_segment_traverser_3.h | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Triangulation_3/include/CGAL/Triangulation_3/internal/Triangulation_segment_traverser_3_impl.h b/Triangulation_3/include/CGAL/Triangulation_3/internal/Triangulation_segment_traverser_3_impl.h index 663032162a4..f7411f652e8 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3/internal/Triangulation_segment_traverser_3_impl.h +++ b/Triangulation_3/include/CGAL/Triangulation_3/internal/Triangulation_segment_traverser_3_impl.h @@ -241,6 +241,7 @@ walk_to_next() { // The target is inside the cell. _prev = Simplex( cell(), Tr::VERTEX, ti, -1 ); cell() = Cell_handle(); + lt() = Locate_type::VERTEX; return; } diff --git a/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h b/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h index 76b0f7572e3..49ba25ccd3e 100644 --- a/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h @@ -228,6 +228,8 @@ public: */ const Point& target() const { return _target; } + Vertex_handle target_vertex() const { return _t_vertex; } + // gives a handle to the current cell. /* By invariance, this cell is intersected by the segment * between `source()` and `target()`. @@ -809,7 +811,7 @@ public: else ch = _cell_iterator.previous(); - Cell_handle chnext = Cell_handle(_cell_iterator); + const Cell_handle chnext = Cell_handle(_cell_iterator); //_cell_iterator is one step forward _curr_simplex CGAL_assertion(ch != chnext); @@ -834,8 +836,13 @@ public: { if (prev == ch && ltprev == Locate_type::VERTEX) { - CGAL_assertion(prev->vertex(liprev) == get_vertex()); - _curr_simplex = ch; + const auto current_vertex = get_vertex(); + if(current_vertex == _cell_iterator.target_vertex()) { + _curr_simplex = Simplex_3(); + } else { + CGAL_assertion(prev->vertex(liprev) == _cell_iterator.target_vertex()); + _curr_simplex = ch; + } } else {