fix extension detection

This commit is contained in:
Maxime Gimeno 2020-06-11 16:17:32 +02:00
parent 3383282d06
commit ff63531c3d
4 changed files with 24 additions and 19 deletions

View File

@ -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"

View File

@ -14,6 +14,7 @@
#include <string>
#include <CGAL/Point_set_3/IO.h>
#include <CGAL/IO/polygon_soup_io.h>
namespace CGAL {
@ -26,20 +27,22 @@ template <typename Point,
bool read_point_set(const std::string& fname,
CGAL::Point_set_3<Point, Vector>& 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 <typename Point,
bool write_point_set(const std::string& fname,
CGAL::Point_set_3<Point, Vector>& 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

View File

@ -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<OutputIteratorValueType>(fname, output, np);
}
if (fname.find(".off") != std::string::npos) {
if (ext == "off") {
return read_OFF<OutputIteratorValueType>(fname, output, np);
}
if (fname.find(".ply") != std::string::npos) {
if (ext == "ply") {
return read_PLY<OutputIteratorValueType>(fname, output, np);
}
#ifdef CGAL_LINKED_WITH_LASLIB
if (fname.find(".las") != std::string::npos) {
if (ext == "las") {
return read_LAS<OutputIteratorValueType>(fname, output, np);
}
#endif

View File

@ -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