From d0bfde79661151a95845f05feef59f7ceb8b2321 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 25 May 2020 17:03:05 +0200 Subject: [PATCH] Fix some OBJ reading --- Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp | 10 ++++++++-- Stream_support/include/CGAL/IO/OBJ.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 728cfd81aa7..71704d20e4b 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "triangulate_primitive.h" #include @@ -1494,11 +1495,16 @@ Scene_surface_mesh_item::load_obj(std::istream& in) bool failed = !CGAL::read_OBJ(in, *(d->smesh_)); if(failed) { + in.clear(); + in.seekg(0); std::vector points; std::vector > faces; failed = !CGAL::read_OBJ(in, points, faces); - - failed = !CGAL::Polygon_mesh_processing::orient_polygon_soup(points, faces); + 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::polygon_soup_to_polygon_mesh(points, faces, *(d->smesh_)); } diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index c81cef5f8b7..0427f71a151 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -111,7 +111,7 @@ bool read_OBJ(std::istream& is, continue; } } - if(maxi<0) + if(maxi==-1 && mini == 1) { if(verbose) std::cerr<<"No face detected."<