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" diff --git a/Installation/test/Installation/test_gmp_mpfr_dll.cpp b/Installation/test/Installation/test_gmp_mpfr_dll.cpp index 3f407098996..17ec0939d6a 100644 --- a/Installation/test/Installation/test_gmp_mpfr_dll.cpp +++ b/Installation/test/Installation/test_gmp_mpfr_dll.cpp @@ -8,10 +8,8 @@ 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 - #include #include @@ -35,12 +33,21 @@ 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; 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)) { @@ -66,7 +73,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; + } } } 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 431c71ba980..7587d012363 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; } 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 923030c6d86..f2d93e83f01 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 @@ -105,7 +105,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; diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 32f783eeeee..01237138e4c 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -67,12 +68,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") { @@ -122,7 +141,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() == '#') { @@ -148,15 +171,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."< s0, } return false; case (3): - return (&(*s0.ch) == &(*s1.ch)); + return s0.ch.operator->() == s1.ch.operator->(); } CGAL_error(); return false; 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 7caccf31e72..d1fd010db3a 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 904421786ba..521273ae30f 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 {