mirror of https://github.com/CGAL/cgal
Give option to write PLY either as binary or ascii
This commit is contained in:
parent
d65127e0a9
commit
f2ec26622b
|
|
@ -1,6 +1,6 @@
|
|||
#include "Scene_points_with_normal_item.h"
|
||||
#include <CGAL/Three/Polyhedron_demo_io_plugin_interface.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <fstream>
|
||||
|
||||
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<const Scene_points_with_normal_item*>(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<double>::digits10 + 2);
|
||||
return point_set_item->write_ply_point_set(out);
|
||||
return point_set_item->write_ply_point_set(out, (choice == tr("Binary")));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -584,13 +584,14 @@ 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;
|
||||
|
||||
if (binary)
|
||||
CGAL::set_binary_mode (stream);
|
||||
stream << *(d->m_points);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue