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 "Scene_points_with_normal_item.h"
|
||||||
#include <CGAL/Three/Polyhedron_demo_io_plugin_interface.h>
|
#include <CGAL/Three/Polyhedron_demo_io_plugin_interface.h>
|
||||||
|
#include <QInputDialog>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
class Polyhedron_demo_ply_to_xyz_plugin :
|
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")
|
if (extension != "ply" && extension != "PLY")
|
||||||
return false;
|
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
|
// This plugin supports point sets
|
||||||
const Scene_points_with_normal_item* point_set_item =
|
const Scene_points_with_normal_item* point_set_item =
|
||||||
qobject_cast<const Scene_points_with_normal_item*>(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
|
// Save point set as .xyz
|
||||||
std::ofstream out(fileinfo.filePath().toUtf8().data());
|
std::ofstream out(fileinfo.filePath().toUtf8().data());
|
||||||
out.precision (std::numeric_limits<double>::digits10 + 2);
|
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
|
// 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);
|
Q_ASSERT(d->m_points != NULL);
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (binary)
|
||||||
CGAL::set_binary_mode (stream);
|
CGAL::set_binary_mode (stream);
|
||||||
stream << *(d->m_points);
|
stream << *(d->m_points);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public:
|
||||||
bool read_las_point_set(std::istream& in);
|
bool read_las_point_set(std::istream& in);
|
||||||
#endif
|
#endif
|
||||||
bool read_ply_point_set(std::istream& in);
|
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 read_off_point_set(std::istream& in);
|
||||||
bool write_off_point_set(std::ostream& out) const;
|
bool write_off_point_set(std::ostream& out) const;
|
||||||
bool read_xyz_point_set(std::istream& in);
|
bool read_xyz_point_set(std::istream& in);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue