diff --git a/BGL/test/BGL/test_bgl_read_write.cpp b/BGL/test/BGL/test_bgl_read_write.cpp index 1ae5b23a6eb..c3f86c6c3d4 100644 --- a/BGL/test/BGL/test_bgl_read_write.cpp +++ b/BGL/test/BGL/test_bgl_read_write.cpp @@ -139,11 +139,11 @@ void test_bgl_OFF(const char* filename) // write with PM { - ok = CGAL::write_polygon_mesh("tmp.off", fg); + ok = CGAL::write_polygon_mesh("tmp.obj.off", fg); assert(ok); Mesh fg2; - ok = CGAL::read_polygon_mesh("tmp.off", fg2); + ok = CGAL::read_polygon_mesh("tmp.obj.off", fg2); assert(ok); assert(are_equal_meshes(fg, fg2)); } @@ -896,4 +896,3 @@ int main(int argc, char** argv) #endif return EXIT_SUCCESS; } -//@todo add some tests for read_polygon_mesh"XXX.off.obj" diff --git a/Point_set_3/include/CGAL/Point_set_3/point_set_io.h b/Point_set_3/include/CGAL/Point_set_3/point_set_io.h index 3de2cf4a0d3..62c8515f04a 100644 --- a/Point_set_3/include/CGAL/Point_set_3/point_set_io.h +++ b/Point_set_3/include/CGAL/Point_set_3/point_set_io.h @@ -14,6 +14,7 @@ #include #include +#include namespace CGAL { @@ -26,20 +27,22 @@ template & ps) { - if (fname.find(".xyz") != std::string::npos) { + const std::string ext = IO::internal::get_file_extension(fname); + + if (ext=="xyz") { return read_XYZ(fname, ps); } - if (fname.find(".off") != std::string::npos) { + if (ext == "off") { return read_OFF(fname, ps); } - if (fname.find(".ply") != std::string::npos) { + if (ext =="ply") { return read_PLY(fname, ps); } #ifdef CGAL_LINKED_WITH_LASLIB - if (fname.find(".las") != std::string::npos) { + if (ext == "las") { return read_LAS(fname, ps); } #endif @@ -63,20 +66,21 @@ template & ps) { - if (fname.find(".xyz") != std::string::npos) { + const std::string ext = IO::internal::get_file_extension(fname); + if (ext == "xyz") { return write_XYZ(fname, ps); } - if (fname.find(".off") != std::string::npos) { + if (ext == "off") { return write_OFF(fname, ps); } - if (fname.find(".ply") != std::string::npos) { + if (ext == "ply") { return write_PLY(fname, ps); } #ifdef CGAL_LINKED_WITH_LASLIB - if (fname.find(".las") != std::string::npos) { + if (ext == "las") { return write_LAS(fname, ps); } #endif diff --git a/Point_set_processing_3/include/CGAL/IO/read_points.h b/Point_set_processing_3/include/CGAL/IO/read_points.h index 0b9d16140ca..80478c0f45d 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_points.h @@ -54,20 +54,21 @@ bool read_points(const std::string& fname, OutputIterator output, const NamedParameters& np) { - if (fname.find(".xyz") != std::string::npos) { + const std::string ext = IO::internal::get_file_extension(fname); + if (ext == "xyz") { return read_XYZ(fname, output, np); } - if (fname.find(".off") != std::string::npos) { + if (ext == "off") { return read_OFF(fname, output, np); } - if (fname.find(".ply") != std::string::npos) { + if (ext == "ply") { return read_PLY(fname, output, np); } #ifdef CGAL_LINKED_WITH_LASLIB - if (fname.find(".las") != std::string::npos) { + if (ext == "las") { return read_LAS(fname, output, np); } #endif diff --git a/Point_set_processing_3/include/CGAL/IO/write_points.h b/Point_set_processing_3/include/CGAL/IO/write_points.h index 872c21470e7..65accc1bf3c 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_points.h @@ -62,20 +62,21 @@ bool write_points(const std::string& fname, const CGAL_BGL_NP_CLASS& np) #endif { - if (fname.find(".xyz") != std::string::npos) { + const std::string ext = IO::internal::get_file_extension(fname); + if (ext == "xyz") { return write_XYZ(fname, points, np); } - if (fname.find(".off") != std::string::npos) { + if (ext == "off") { return write_OFF(fname, points, np); } - if (fname.find(".ply") != std::string::npos) { + if (ext == "ply") { return write_PLY(fname, points, np); } #ifdef CGAL_LINKED_WITH_LASLIB - if (fname.find(".las") != std::string::npos) { + if (ext == "las") { return write_LAS(fname, points, np); } #endif