From bfe4bcff3bb7b157cb57cfe41346d06494b24aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 13 Oct 2020 18:09:56 +0200 Subject: [PATCH] Fix assuming orient_PS returns `false` on failure (and not duplication) --- .../Polygon_mesh_processing/IO/polygon_mesh_io.h | 13 +++++++++---- .../demo/Polyhedron/Scene_surface_mesh_item.cpp | 5 ++--- 2 files changed, 11 insertions(+), 7 deletions(-) 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 cfd2b5da6bd..d932c5b7583 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 @@ -104,7 +104,7 @@ bool read_polygon_mesh(const std::string& fname, if(!CGAL::read_polygon_soup(fname, points, faces)) { if(verbose) - std::cerr << "W: cannot read polygon soup\n"; + std::cerr << "Warning: cannot read polygon soup" << std::endl; return false; } @@ -112,11 +112,16 @@ bool read_polygon_mesh(const std::string& fname, if(do_repair) PMP::repair_polygon_soup(points, faces, np); - if(!PMP::orient_polygon_soup(points, faces) || - !PMP::is_polygon_soup_a_polygon_mesh(faces)) + if(!PMP::orient_polygon_soup(points, faces)) { if(verbose) - std::cerr << "W: File does not describe a polygon mesh" << std::endl; + std::cerr << "Some duplication happened during polygon soup orientation" << std::endl; + } + + if(!PMP::is_polygon_soup_a_polygon_mesh(faces)) + { + if(verbose) + std::cerr << "Warning: polygon soup does not describe a polygon mesh" << std::endl; return false; } diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index ce14acf35e8..d18f2a10470 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1526,10 +1526,9 @@ Scene_surface_mesh_item::load_obj(std::istream& in) if(!failed) { CGAL::Polygon_mesh_processing::repair_polygon_soup(points, faces); - failed = !CGAL::Polygon_mesh_processing::orient_polygon_soup(points, faces); - } - if(!failed) + CGAL::Polygon_mesh_processing::orient_polygon_soup(points, faces); CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, faces, *(d->smesh_)); + } } if((!failed) && !isEmpty())