Merge remote-tracking branch 'lrineau/Triangulation_3-fix_simplex_traverser-GF' into Triangulation_3-CDT_3-lrineau

This commit is contained in:
Laurent Rineau 2023-05-04 15:12:39 +02:00
commit f7b949834c
9 changed files with 79 additions and 20 deletions

View File

@ -26,22 +26,25 @@ if( NOT GMP_in_cache )
NAMES gmp.h NAMES gmp.h
HINTS ENV GMP_INC_DIR HINTS ENV GMP_INC_DIR
ENV GMP_DIR ENV GMP_DIR
$ENV{GMP_DIR}/include
${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include
PATH_SUFFIXES include PATH_SUFFIXES include
DOC "The directory containing the GMP header files" 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 HINTS ENV GMP_LIB_DIR
ENV GMP_DIR ENV GMP_DIR
$ENV{GMP_DIR}/lib
${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib
PATH_SUFFIXES lib PATH_SUFFIXES lib
DOC "Path to the Release GMP library" 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 HINTS ENV GMP_LIB_DIR
ENV GMP_DIR ENV GMP_DIR
$ENV{GMP_DIR}/include
${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib
PATH_SUFFIXES lib PATH_SUFFIXES lib
DOC "Path to the Debug GMP library" DOC "Path to the Debug GMP library"

View File

@ -25,6 +25,7 @@ if (NOT MPFR_in_cache)
NAMES mpfr.h NAMES mpfr.h
HINTS ENV MPFR_INC_DIR HINTS ENV MPFR_INC_DIR
ENV MPFR_DIR ENV MPFR_DIR
$ENV{MPFR_DIR}/include
${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/include
PATH_SUFFIXES include PATH_SUFFIXES include
DOC "The directory containing the MPFR header files" 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 find_library(MPFR_LIBRARIES NAMES mpfr libmpfr-4 libmpfr-1
HINTS ENV MPFR_LIB_DIR HINTS ENV MPFR_LIB_DIR
ENV MPFR_DIR ENV MPFR_DIR
$ENV{MPFR_DIR}/lib
${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib ${CGAL_INSTALLATION_PACKAGE_DIR}/auxiliary/gmp/lib
PATH_SUFFIXES lib PATH_SUFFIXES lib
DOC "Path to the MPFR library" DOC "Path to the MPFR library"

View File

@ -8,10 +8,8 @@ int main() {
#define GMP_SONAME "libgmp-10" #define GMP_SONAME "libgmp-10"
#define MPFR_SONAME "libmpfr-4" #define MPFR_SONAME "libmpfr-4"
#define GMP_SONAME_BACKUP "gmp" #define GMP_SONAME_BACKUP "gmp"
#define GMP_SONAME_BACKUP_2 "gmp-10"
#define MPFR_SONAME_BACKUP "mpfr-6" #define MPFR_SONAME_BACKUP "mpfr-6"
#define GMP_MAJOR 5
#define MPFR_MAJOR 3
#include <iostream> #include <iostream>
#include <cassert> #include <cassert>
@ -35,12 +33,21 @@ bool get_version_info(const LPCTSTR name,
std::cerr << name << " is not loaded!\n"; std::cerr << name << " is not loaded!\n";
return false; return false;
} }
else
std::cerr << name << " is loaded.\n";
char fileName[_MAX_PATH]; char fileName[_MAX_PATH];
DWORD size = GetModuleFileName(g_dllHandle, fileName, _MAX_PATH); DWORD size = GetModuleFileName(g_dllHandle, fileName, _MAX_PATH);
fileName[size] = NULL; fileName[size] = NULL;
std::cerr << "Query FileVersion of \"" << fileName << "\"\n"; std::cerr << "Query FileVersion of \"" << fileName << "\"\n";
DWORD handle = 0; DWORD handle = 0;
size = GetFileVersionInfoSize(fileName, &handle); size = GetFileVersionInfoSize(fileName, &handle);
DWORD err = GetLastError();
if (size == 0) {
std::cerr << "GetFileVersionInfoSize failed with error " << err << std::endl;
}
BYTE* versionInfo = new BYTE[size]; BYTE* versionInfo = new BYTE[size];
if (!GetFileVersionInfo(fileName, handle, size, versionInfo)) if (!GetFileVersionInfo(fileName, handle, size, versionInfo))
{ {
@ -66,9 +73,11 @@ int main() {
int major, minor, patch, build; int major, minor, patch, build;
if(!get_version_info(GMP_SONAME, 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)) { if(!get_version_info(GMP_SONAME_BACKUP, major, minor, patch, build)) {
if (!get_version_info(GMP_SONAME_BACKUP_2, major, minor, patch, build)) {
return 1; return 1;
} }
} }
}
std::cout << "GMP version " std::cout << "GMP version "
<< major << "." << major << "."

View File

@ -23,18 +23,32 @@ int main(int argc, char* argv[])
Surface_mesh mesh; Surface_mesh mesh;
if(!PMP::IO::read_polygon_mesh(filename, mesh)) if(!PMP::IO::read_polygon_mesh(filename, mesh))
{ {
std::cerr << "Invalid input." << std::endl; std::cerr << "Error: Invalid input." << std::endl;
return 1; 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); PMP::triangulate_faces(mesh);
// Confirm that all faces are triangles. // Confirm that all faces are triangles.
for(boost::graph_traits<Surface_mesh>::face_descriptor f : faces(mesh)) for(boost::graph_traits<Surface_mesh>::face_descriptor f : faces(mesh))
{
if(!CGAL::is_triangle(halfedge(f, mesh), mesh)) if(!CGAL::is_triangle(halfedge(f, mesh), mesh))
std::cerr << "Error: non-triangular face left in mesh." << std::endl; std::cerr << "Error: non-triangular face left in mesh." << std::endl;
}
CGAL::IO::write_polygon_mesh(outfilename, mesh, CGAL::parameters::stream_precision(17)); CGAL::IO::write_polygon_mesh(outfilename, mesh, CGAL::parameters::stream_precision(17));
return 0; return EXIT_SUCCESS;
} }

View File

@ -105,7 +105,7 @@ bool read_polygon_mesh(const std::string& fname,
std::vector<Point> points; std::vector<Point> points;
std::vector<std::vector<std::size_t> > faces; std::vector<std::vector<std::size_t> > 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) if(verbose)
std::cerr << "Warning: cannot read polygon soup" << std::endl; std::cerr << "Warning: cannot read polygon soup" << std::endl;

View File

@ -24,6 +24,7 @@
#include <boost/range/value_type.hpp> #include <boost/range/value_type.hpp>
#include <CGAL/Named_function_parameters.h> #include <CGAL/Named_function_parameters.h>
#include <algorithm>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -67,12 +68,30 @@ bool read_OBJ(std::istream& is,
bool tex_found(false), norm_found(false); bool tex_found(false), norm_found(false);
while(getline(is, line)) while(getline(is, line))
{ {
if(line.empty()) // get last non-whitespace, non-null character
continue; 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); std::istringstream iss(line);
if(!(iss >> s)) if(!(iss >> s))
continue; // can't read anything on the line, whitespace only? continue;
if(s == "v") if(s == "v")
{ {
@ -122,8 +141,12 @@ bool read_OBJ(std::istream& is,
} }
if(iss.bad()) if(iss.bad())
{
if(verbose)
std::cerr << "error while reading OBJ face." << std::endl;
return false; return false;
} }
}
else if(s.front() == '#') else if(s.front() == '#')
{ {
// this is a commented line, ignored // this is a commented line, ignored
@ -148,15 +171,15 @@ bool read_OBJ(std::istream& is,
else else
{ {
if(verbose) if(verbose)
std::cerr << "error: unrecognized line: " << s << std::endl; std::cerr << "Error: unrecognized line: " << s << std::endl;
return false; return false;
} }
} }
if(norm_found && verbose) if(norm_found && verbose)
std::cout<<"NOTE: normals were found in this file, but were discarded."<<std::endl; std::cout << "NOTE: normals were found in this file, but were discarded." << std::endl;
if(tex_found && verbose) if(tex_found && verbose)
std::cout<<"NOTE: textures were found in this file, but were discarded."<<std::endl; std::cout << "NOTE: textures were found in this file, but were discarded." << std::endl;
if(points.empty() || polygons.empty()) if(points.empty() || polygons.empty())
{ {

View File

@ -180,7 +180,7 @@ operator==(Triangulation_simplex_3<TriangulationDataStructure_3> s0,
} }
return false; return false;
case (3): case (3):
return (&(*s0.ch) == &(*s1.ch)); return s0.ch.operator->() == s1.ch.operator->();
} }
CGAL_error(); CGAL_error();
return false; return false;

View File

@ -241,6 +241,7 @@ walk_to_next() {
// The target is inside the cell. // The target is inside the cell.
_prev = Simplex( cell(), Tr::VERTEX, ti, -1 ); _prev = Simplex( cell(), Tr::VERTEX, ti, -1 );
cell() = Cell_handle(); cell() = Cell_handle();
lt() = Locate_type::VERTEX;
return; return;
} }

View File

@ -228,6 +228,8 @@ public:
*/ */
const Point& target() const { return _target; } const Point& target() const { return _target; }
Vertex_handle target_vertex() const { return _t_vertex; }
// gives a handle to the current cell. // gives a handle to the current cell.
/* By invariance, this cell is intersected by the segment /* By invariance, this cell is intersected by the segment
* between `source()` and `target()`. * between `source()` and `target()`.
@ -809,7 +811,7 @@ public:
else else
ch = _cell_iterator.previous(); 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 //_cell_iterator is one step forward _curr_simplex
CGAL_assertion(ch != chnext); CGAL_assertion(ch != chnext);
@ -834,9 +836,14 @@ public:
{ {
if (prev == ch && ltprev == Locate_type::VERTEX) if (prev == ch && ltprev == Locate_type::VERTEX)
{ {
CGAL_assertion(prev->vertex(liprev) == get_vertex()); 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; _curr_simplex = ch;
} }
}
else else
{ {
if(ltprev == Locate_type::FACET) if(ltprev == Locate_type::FACET)