diff --git a/Point_set_3/include/CGAL/Point_set_3/IO.h b/Point_set_3/include/CGAL/Point_set_3/IO.h index c84d91c8477..735eb6f5116 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO.h @@ -295,19 +295,32 @@ read_off_point_set( #if (!defined(CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE) && !defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES)) || defined(DOXYGEN_RUNNING) +/// \cond SKIP_IN_MANUAL +template +bool +read_ply_point_set( + std::istream& stream, ///< input stream. + CGAL::Point_set_3& point_set) ///< point set +{ + std::string dummy; + return read_ply_point_set (stream, point_set, dummy); +} + +/// \endcond /*! \ingroup PkgPointSet3IO + + The `comments` parameter can be omitted. If provided, it will be + used to store the potential comments found in the PLY + header. Each line starting by "comment " in the header is + appended to the `comments` string (without the "comment " word). */ template bool read_ply_point_set( std::istream& stream, ///< input stream. -#ifdef DOXYGEN_RUNNING - CGAL::Point_set_3& point_set) ///< point set -#else CGAL::Point_set_3& point_set, ///< point set - std::string* comments = NULL) ///< recover PLY comments -#endif + std::string& comments) ///< PLY comments. { if(!stream) { @@ -324,8 +337,7 @@ read_ply_point_set( return false; } - if (comments != NULL) - *comments = reader.comments(); + comments = reader.comments(); for (std::size_t i = 0; i < reader.number_of_elements(); ++ i) { @@ -358,17 +370,17 @@ read_ply_point_set( /*! \ingroup PkgPointSet3IO + + If provided, the `comments` string is included line by line in + the header of the PLY stream (each line will be precedeed by + "comment "). */ template bool write_ply_point_set( std::ostream& stream, ///< output stream. -#ifdef DOXYGEN_RUNNING - const CGAL::Point_set_3& point_set) ///< point set -#else - const CGAL::Point_set_3& point_set, ///< point set - std::string* comments = NULL) ///< write PLY comments -#endif + const CGAL::Point_set_3& point_set, ///< point set. + const std::string& comments = std::string()) ///< PLY comments. { typedef CGAL::Point_set_3 Point_set; typedef typename Point_set::Index Index; @@ -389,9 +401,9 @@ write_ply_point_set( << ((get_mode(stream) == IO::BINARY) ? "format binary_little_endian 1.0" : "format ascii 1.0") << std::endl << "comment Generated by the CGAL library" << std::endl; - if (comments != NULL) + if (comments != std::string()) { - std::istringstream iss (*comments); + std::istringstream iss (comments); std::string line; while (getline(iss, line)) { diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index bcf4b4c34fa..8c4c3484567 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -619,7 +619,7 @@ bool Scene_points_with_normal_item::read_ply_point_set(std::istream& stream) d->m_points->clear(); bool ok = stream && - CGAL::read_ply_point_set (stream, *(d->m_points), &(d->m_comments)) && + CGAL::read_ply_point_set (stream, *(d->m_points), d->m_comments) && !isEmpty(); d->point_Slider->setValue(CGAL::Three::Three::getDefaultPointSize()); std::cerr << d->m_points->info(); @@ -653,7 +653,7 @@ bool Scene_points_with_normal_item::write_ply_point_set(std::ostream& stream, bo if (binary) CGAL::set_binary_mode (stream); - CGAL::write_ply_point_set (stream, *(d->m_points), &(d->m_comments)); + CGAL::write_ply_point_set (stream, *(d->m_points), d->m_comments); return true; } diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index 690a8818886..873d03929fd 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -2167,6 +2167,11 @@ private: //------------------------------------------------------- private data /// property with simple type: if they do, all edge properties with /// simple types are inserted in the stream. The halfedges follow /// the same behavior. + /// + /// If provided, the `comments` string is included line by line in + /// the header of the PLY stream (each line will be precedeed by + /// "comment "). + /// /// \relates Surface_mesh template bool write_ply(std::ostream& os, const Surface_mesh

& sm, const std::string& comments = std::string()) @@ -2521,7 +2526,6 @@ private: //------------------------------------------------------- private data } /// \endcond - /// \relates Surface_mesh /// Extracts the surface mesh from an input stream in Ascii or /// Binary PLY format and appends it to the surface mesh `sm`. /// @@ -2540,6 +2544,11 @@ private: //------------------------------------------------------- private data /// added, where `[s]` is `v` for vertex and `f` for face, and /// `[name]` is the name of PLY property. /// + /// The `comments` parameter can be omitted. If provided, it will be + /// used to store the potential comments found in the PLY + /// header. Each line starting by "comment " in the header is + /// appended to the `comments` string (without the "comment " word). + /// /// \pre The data in the stream must represent a two-manifold. If this is not the case /// the `failbit` of `is` is set and the mesh cleared. /// \relates Surface_mesh