Add comments of PLY mesh in demo

This commit is contained in:
Simon Giraudot 2019-04-09 15:04:25 +02:00
parent e6fc07bf17
commit fe6f00203c
3 changed files with 14 additions and 3 deletions

View File

@ -91,11 +91,13 @@ Polyhedron_demo_ply_plugin::load(QFileInfo fileinfo) {
{ {
// First try mesh // First try mesh
SMesh *surface_mesh = new SMesh(); SMesh *surface_mesh = new SMesh();
std::string comments;
if (CGAL::read_ply (in, *surface_mesh))
if (CGAL::read_ply (in, *surface_mesh, comments))
{ {
Scene_surface_mesh_item* sm_item = new Scene_surface_mesh_item(surface_mesh); Scene_surface_mesh_item* sm_item = new Scene_surface_mesh_item(surface_mesh);
sm_item->setName(fileinfo.completeBaseName()); sm_item->setName(fileinfo.completeBaseName());
sm_item->comments() = comments;
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
return sm_item; return sm_item;
} }
@ -185,7 +187,7 @@ bool Polyhedron_demo_ply_plugin::save(const CGAL::Three::Scene_item* item, QFile
Scene_surface_mesh_item* sm_item = Scene_surface_mesh_item* sm_item =
const_cast<Scene_surface_mesh_item*>(qobject_cast<const Scene_surface_mesh_item*>(item)); const_cast<Scene_surface_mesh_item*>(qobject_cast<const Scene_surface_mesh_item*>(item));
if (sm_item) if (sm_item)
return CGAL::write_ply (out, *(sm_item->polyhedron())); return CGAL::write_ply (out, *(sm_item->polyhedron()), sm_item->comments());
return false; return false;
} }

View File

@ -209,6 +209,8 @@ struct Scene_surface_mesh_item_priv{
mutable QList<double> text_ids; mutable QList<double> text_ids;
mutable std::vector<TextItem*> targeted_id; mutable std::vector<TextItem*> targeted_id;
std::string comments;
mutable bool has_fpatch_id; mutable bool has_fpatch_id;
mutable bool has_feature_edges; mutable bool has_feature_edges;
mutable bool floated; mutable bool floated;
@ -1048,6 +1050,9 @@ Scene_surface_mesh_item::~Scene_surface_mesh_item()
SMesh* Scene_surface_mesh_item::polyhedron() { return d->smesh_; } SMesh* Scene_surface_mesh_item::polyhedron() { return d->smesh_; }
const SMesh* Scene_surface_mesh_item::polyhedron() const { return d->smesh_; } const SMesh* Scene_surface_mesh_item::polyhedron() const { return d->smesh_; }
std::string& Scene_surface_mesh_item::comments() { return d->comments; }
const std::string& Scene_surface_mesh_item::comments() const { return d->comments; }
void Scene_surface_mesh_item::compute_bbox()const void Scene_surface_mesh_item::compute_bbox()const
{ {
SMesh::Property_map<vertex_descriptor, Point_3> pprop = d->smesh_->points(); SMesh::Property_map<vertex_descriptor, Point_3> pprop = d->smesh_->points();

View File

@ -89,6 +89,10 @@ public:
Face_graph* face_graph() { return polyhedron(); } Face_graph* face_graph() { return polyhedron(); }
const Face_graph* face_graph() const { return polyhedron(); } const Face_graph* face_graph() const { return polyhedron(); }
// Gets PLY comments (empty if mesh not originated from PLY input)
std::string& comments();
const std::string& comments() const;
void invalidate_aabb_tree(); void invalidate_aabb_tree();
void invalidateOpenGLBuffers()Q_DECL_OVERRIDE; void invalidateOpenGLBuffers()Q_DECL_OVERRIDE;
void invalidate(Gl_data_names name); void invalidate(Gl_data_names name);