diff --git a/BGL/include/CGAL/boost/graph/IO/VTK.h b/BGL/include/CGAL/boost/graph/IO/VTK.h index dd63f23eb8a..c97815bc5b2 100644 --- a/BGL/include/CGAL/boost/graph/IO/VTK.h +++ b/BGL/include/CGAL/boost/graph/IO/VTK.h @@ -144,7 +144,8 @@ bool read_VTP(const char* fname, FaceGraph& g, const CGAL_BGL_NP_CLASS& np) vtkSmartPointer::New(); data = vtkPolyData::SafeDownCast(IO::internal::read_vtk_file(fname, obs)->GetOutput()); - + if (obs->GetError()) + return false; return IO::internal::vtkPointSet_to_polygon_mesh(data, g, np); } diff --git a/BGL/test/BGL/test_bgl_read_write.cpp b/BGL/test/BGL/test_bgl_read_write.cpp index 53a5f3de66a..76546f27849 100644 --- a/BGL/test/BGL/test_bgl_read_write.cpp +++ b/BGL/test/BGL/test_bgl_read_write.cpp @@ -571,6 +571,8 @@ void test_bgl_PLY(const std::string filename, assert(!ok); ok = CGAL::read_PLY("data/invalid_nv.ply", fg); // broken formatting assert(!ok); + ok = CGAL::read_PLY("data/binary_cut.ply", fg); // broken binary + assert(!ok); ok = CGAL::read_PLY("data/cube.off", fg); assert(!ok); ok = CGAL::read_PLY("data/pig.stl", fg); @@ -826,17 +828,30 @@ void test_bgl_VTP(const char* filename, // @fixme not finished } // test wrong inputs + std::cerr<<"Error text is expected to follow."< 1) ? argv[1] : "data/prim.off"; test_bgl_OFF(off_file); @@ -854,6 +869,8 @@ int main(int argc, char** argv) #ifdef CGAL_USE_OPENMESH test_bgl_OBJ(obj_file); #endif + + // PLY const char* ply_file_ascii = (argc > 3) ? argv[3] : "data/colored_tetra.ply"; test_bgl_PLY(ply_file_ascii, false); @@ -871,7 +888,6 @@ int main(int argc, char** argv) #ifdef CGAL_USE_OPENMESH test_bgl_STL(stl_file); #endif -*/ // GOCAD const char* gocad_file = (argc > 5) ? argv[5] : "data/2016206_MHT_surface.ts"; @@ -881,7 +897,7 @@ int main(int argc, char** argv) #ifdef CGAL_USE_OPENMESH test_bgl_GOCAD(gocad_file); #endif - return 0; + // VTP #ifdef CGAL_USE_VTK const char* vtp_file = (argc > 6) ? argv[6] : "data/bones.vtp"; diff --git a/Stream_support/include/CGAL/IO/VTK.h b/Stream_support/include/CGAL/IO/VTK.h index ad9cb7dc2b0..d37b96586eb 100644 --- a/Stream_support/include/CGAL/IO/VTK.h +++ b/Stream_support/include/CGAL/IO/VTK.h @@ -109,7 +109,8 @@ bool read_VTP(const char* fname, vtkSmartPointer::New(); data = vtkPolyData::SafeDownCast(IO::internal::read_vtk_file(fname, obs)->GetOutput()); - + if (obs->GetError()) + return false; return IO::internal::vtkPointSet_to_polygon_soup(data, points, polygons, np); }