diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_to_xyz_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_to_xyz_io_plugin.cpp index 260f691013d..f80ebff38a8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_to_xyz_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_to_xyz_io_plugin.cpp @@ -1,6 +1,6 @@ #include "Scene_points_with_normal_item.h" #include - +#include #include class Polyhedron_demo_ply_to_xyz_plugin : @@ -57,6 +57,16 @@ bool Polyhedron_demo_ply_to_xyz_plugin::save(const CGAL::Three::Scene_item* item if (extension != "ply" && extension != "PLY") return false; + QStringList list; + list << tr("Binary"); + list << tr("Ascii"); + bool ok = false; + QString choice + = QInputDialog::getItem(NULL, tr("Save PLY file"), tr("Format"), list, 0, false, &ok); + + if (!ok) + return false; + // This plugin supports point sets const Scene_points_with_normal_item* point_set_item = qobject_cast(item); @@ -66,7 +76,7 @@ bool Polyhedron_demo_ply_to_xyz_plugin::save(const CGAL::Three::Scene_item* item // Save point set as .xyz std::ofstream out(fileinfo.filePath().toUtf8().data()); out.precision (std::numeric_limits::digits10 + 2); - return point_set_item->write_ply_point_set(out); + return point_set_item->write_ply_point_set(out, (choice == tr("Binary"))); } diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index 967147f4ac6..e4dc4f07c18 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -584,14 +584,15 @@ bool Scene_points_with_normal_item::read_ply_point_set(std::istream& stream) } // Write point set to .PLY file -bool Scene_points_with_normal_item::write_ply_point_set(std::ostream& stream) const +bool Scene_points_with_normal_item::write_ply_point_set(std::ostream& stream, bool binary) const { Q_ASSERT(d->m_points != NULL); if (!stream) return false; - CGAL::set_binary_mode (stream); + if (binary) + CGAL::set_binary_mode (stream); stream << *(d->m_points); return true; diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h index 5104b2e9894..326e3068d09 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h @@ -49,7 +49,7 @@ public: bool read_las_point_set(std::istream& in); #endif bool read_ply_point_set(std::istream& in); - bool write_ply_point_set(std::ostream& out) const; + bool write_ply_point_set(std::ostream& out, bool binary) const; bool read_off_point_set(std::istream& in); bool write_off_point_set(std::ostream& out) const; bool read_xyz_point_set(std::istream& in);