From 00ca0211e1743ef045522efa4dd400a89bc10302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 4 Aug 2020 12:59:08 +0200 Subject: [PATCH] IO documentation fixes --- BGL/include/CGAL/boost/graph/IO/GOCAD.h | 66 ++---- .../graph/IO/Generic_facegraph_builder.h | 2 +- BGL/include/CGAL/boost/graph/IO/INP.h | 4 +- BGL/include/CGAL/boost/graph/IO/OBJ.h | 40 +--- BGL/include/CGAL/boost/graph/IO/OFF.h | 41 +--- BGL/include/CGAL/boost/graph/IO/PLY.h | 58 +---- BGL/include/CGAL/boost/graph/IO/STL.h | 30 +-- BGL/include/CGAL/boost/graph/IO/VTK.h | 17 +- BGL/include/CGAL/boost/graph/IO/WRL.h | 10 +- .../CGAL/boost/graph/IO/polygon_mesh_io.h | 202 ++++++++---------- .../CGAL/General_polygon_2.h | 3 +- Point_set_3/include/CGAL/Point_set_3/IO.h | 143 +++++-------- Point_set_3/include/CGAL/Point_set_3/IO/LAS.h | 24 +-- Point_set_3/include/CGAL/Point_set_3/IO/OFF.h | 28 +-- Point_set_3/include/CGAL/Point_set_3/IO/PLY.h | 62 +----- Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h | 28 +-- .../include/CGAL/IO/read_las_points.h | 30 +-- .../include/CGAL/IO/read_off_points.h | 40 +--- .../include/CGAL/IO/read_ply_points.h | 32 +-- .../include/CGAL/IO/read_points.h | 78 +++---- .../include/CGAL/IO/read_xyz_points.h | 28 +-- .../include/CGAL/IO/write_las_points.h | 18 +- .../include/CGAL/IO/write_off_points.h | 18 +- .../include/CGAL/IO/write_ply_points.h | 18 +- .../include/CGAL/IO/write_points.h | 56 ++--- .../include/CGAL/IO/write_xyz_points.h | 18 +- .../CGAL/General_polygon_with_holes_2.h | 3 +- Polygon/include/CGAL/Polygon_with_holes_2.h | 3 +- .../Polygon_mesh_processing.txt | 9 + .../IO/polygon_mesh_io.h | 42 ++-- .../Polyhedron/CGAL/IO/Polyhedron_iostream.h | 3 - Polyhedron/include/CGAL/IO/scan_OFF.h | 2 +- .../File_formats/Supported_file_formats.txt | 16 +- .../doc/Stream_support/IOstream.txt | 2 +- Stream_support/include/CGAL/IO/3MF.h | 2 + Stream_support/include/CGAL/IO/GOCAD.h | 44 +--- Stream_support/include/CGAL/IO/OBJ.h | 50 ++--- Stream_support/include/CGAL/IO/OFF.h | 38 +--- Stream_support/include/CGAL/IO/PLY.h | 50 ++--- Stream_support/include/CGAL/IO/STL.h | 49 ++--- .../include/CGAL/IO/STL/STL_reader.h | 6 +- Stream_support/include/CGAL/IO/VTK.h | 33 +-- .../include/CGAL/IO/polygon_soup_io.h | 195 +++++++---------- .../include/CGAL/Surface_mesh/IO/OFF.h | 2 +- 44 files changed, 468 insertions(+), 1175 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/IO/GOCAD.h b/BGL/include/CGAL/boost/graph/IO/GOCAD.h index c781ff1d300..108f6fcd4de 100644 --- a/BGL/include/CGAL/boost/graph/IO/GOCAD.h +++ b/BGL/include/CGAL/boost/graph/IO/GOCAD.h @@ -84,7 +84,7 @@ public: /// /// The data is expected to represent a 2-manifold (possibly with borders). /// -/// \attention The graph `g` is not cleared, and the data from the stream is added. +/// \attention The graph `g` is not cleared, and the data from the stream are appended. /// /// \tparam Graph a model of `MutableFaceGraph` /// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -107,7 +107,7 @@ public: /// \cgalParamNBegin{verbose} /// \cgalParamDescription{whether extra information is printed when an incident occurs during reading} /// \cgalParamType{Boolean} -/// \cgalParamDefault{`true`} +/// \cgalParamDefault{`false`} /// \cgalParamNEnd /// \cgalNamedParamsEnd /// @@ -169,7 +169,7 @@ bool read_GOCAD(std::istream& is, Graph& g, /// /// The data is expected to represent a 2-manifold (possibly with borders). /// -/// \attention The graph `g` is not cleared, and the data from the stream is added. +/// \attention The graph `g` is not cleared, and the data from the file are appended. /// /// \tparam Graph a model of `MutableFaceGraph` /// \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -192,7 +192,7 @@ bool read_GOCAD(std::istream& is, Graph& g, /// \cgalParamNBegin{verbose} /// \cgalParamDescription{whether extra information is printed when an incident occurs during reading} /// \cgalParamType{Boolean} -/// \cgalParamDefault{`true`} +/// \cgalParamDefault{`false`} /// \cgalParamNEnd /// \cgalNamedParamsEnd /// @@ -202,7 +202,7 @@ bool read_GOCAD(std::istream& is, Graph& g, /// template -bool read_GOCAD(const char* fname, +bool read_GOCAD(const std::string& fname, std::pair& name_and_color, Graph& g, const CGAL_BGL_NP_CLASS& np @@ -219,34 +219,20 @@ bool read_GOCAD(const char* fname, /// \cond SKIP_IN_MANUAL template -bool read_GOCAD(const char* fname, std::pair& name_and_color, Graph& g, +bool read_GOCAD(const std::string& fname, std::pair& name_and_color, Graph& g, typename boost::disable_if >::type* = nullptr) { return read_GOCAD(fname, name_and_color, g, parameters::all_default()); } template -bool read_GOCAD(const char* fname, Graph& g, const CGAL_BGL_NP_CLASS& np, +bool read_GOCAD(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np, typename boost::disable_if >::type* = nullptr) { std::pair dummy; return read_GOCAD(fname, dummy, g, np); } -template -bool read_GOCAD(const char* fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_GOCAD(fname, g, parameters::all_default()); -} - -template -bool read_GOCAD(const std::string& fname, Graph& g, CGAL_BGL_NP_CLASS np, - typename boost::disable_if >::type* = nullptr) -{ - return read_GOCAD(fname.c_str(), g, np); -} - template bool read_GOCAD(const std::string& fname, Graph& g, typename boost::disable_if >::type* = nullptr) @@ -256,8 +242,6 @@ bool read_GOCAD(const std::string& fname, Graph& g, /// \endcond -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write @@ -368,13 +352,6 @@ bool write_GOCAD(std::ostream& os, const char* name, const Graph& g, return write_GOCAD(os, name, g, parameters::all_default()); } -template -bool write_GOCAD(std::ostream& os, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_GOCAD(os, "anonymous", g, parameters::all_default()); -} - /// \endcond /// \ingroup PkgBGLIoFuncsGOCAD @@ -422,6 +399,17 @@ bool write_GOCAD(std::ostream& os, return write_GOCAD(os, "anonymous", g, np); } +/// \cond SKIP_IN_MANUAL + +template +bool write_GOCAD(std::ostream& os, const Graph& g, + typename boost::disable_if >::type* = nullptr) +{ + return write_GOCAD(os, g, parameters::all_default()); +} + +/// \endcond + /// \ingroup PkgBGLIoFuncsGOCAD /// /// \brief writes the graph `g` into a file named `fname`, using the \ref IOStreamGocad. @@ -456,7 +444,7 @@ bool write_GOCAD(std::ostream& os, /// template -bool write_GOCAD(const char* fname, +bool write_GOCAD(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -466,25 +454,11 @@ bool write_GOCAD(const char* fname, { std::ofstream os(fname); CGAL::set_mode(os, CGAL::IO::ASCII); - return write_GOCAD(os, fname, g, np); + return write_GOCAD(os, fname.c_str(), g, np); } /// \cond SKIP_IN_MANUAL -template -bool write_GOCAD(const char* fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_GOCAD(fname, g, parameters::all_default()); -} - -template -bool write_GOCAD(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np, - typename boost::disable_if >::type* = nullptr) -{ - return write_GOCAD(fname.c_str(), g, np); -} - template bool write_GOCAD(const std::string& fname, const Graph& g, typename boost::disable_if >::type* = nullptr) diff --git a/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h b/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h index 36c15e904b1..759dc6c4795 100644 --- a/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h +++ b/BGL/include/CGAL/boost/graph/IO/Generic_facegraph_builder.h @@ -85,7 +85,7 @@ public: std::vector vertex_textures; std::vector face_colors; - const bool verbose = choose_parameter(get_parameter(np, internal_np::verbose), true); + const bool verbose = choose_parameter(get_parameter(np, internal_np::verbose), false); bool ok = static_cast(this)->read(m_is, m_points, m_faces, diff --git a/BGL/include/CGAL/boost/graph/IO/INP.h b/BGL/include/CGAL/boost/graph/IO/INP.h index 6822f341f9a..fbc15b04d96 100644 --- a/BGL/include/CGAL/boost/graph/IO/INP.h +++ b/BGL/include/CGAL/boost/graph/IO/INP.h @@ -75,7 +75,7 @@ bool write_INP(std::ostream& os, } template -bool write_INP(const char* fname, +bool write_INP(const std::string& fname, const std::string& type, const Graph& g, const CGAL_BGL_NP_CLASS& np) @@ -91,7 +91,7 @@ bool write_INP(std::ostream& os, const std::string& name, const std::string& typ } template -bool write_INP(const char* fname, const std::string& type, const Graph& g) +bool write_INP(const std::string& fname, const std::string& type, const Graph& g) { return write_INP(fname, type, g, parameters::all_default()); } diff --git a/BGL/include/CGAL/boost/graph/IO/OBJ.h b/BGL/include/CGAL/boost/graph/IO/OBJ.h index 115555c0c45..8e1c9b5ea89 100644 --- a/BGL/include/CGAL/boost/graph/IO/OBJ.h +++ b/BGL/include/CGAL/boost/graph/IO/OBJ.h @@ -79,7 +79,7 @@ public: Ignores comment lines which start with a hash, and lines with whitespace. - \attention The graph `g` is not cleared, and the data from the stream is added. + \attention The graph `g` is not cleared, and the data from the stream are appended. \tparam Graph a model of `MutableFaceGraph` \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -101,7 +101,7 @@ public: \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -146,7 +146,7 @@ bool read_OBJ(std::istream& is, Graph& g, Ignores comment lines which start with a hash, and lines with whitespace. - \attention The graph `g` is not cleared, and the data from the stream is added. + \attention The graph `g` is not cleared, and the data from the file are appended. \tparam Graph a model of `MutableFaceGraph` \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -168,7 +168,7 @@ bool read_OBJ(std::istream& is, Graph& g, \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -178,7 +178,7 @@ bool read_OBJ(std::istream& is, Graph& g, */ template -bool read_OBJ(const char* fname, +bool read_OBJ(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -193,20 +193,6 @@ bool read_OBJ(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_OBJ(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np, - typename boost::disable_if >::type* = nullptr) -{ - return read_OBJ(fname.c_str(), g, np); -} - -template -bool read_OBJ(const char* fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_OBJ(fname, g, parameters::all_default()); -} - template bool read_OBJ(const std::string& fname, Graph& g, typename boost::disable_if >::type* = nullptr) @@ -307,7 +293,7 @@ bool write_OBJ(std::ostream& os, const Graph& g, */ template -bool write_OBJ(const char* fname, +bool write_OBJ(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -322,20 +308,6 @@ bool write_OBJ(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool write_OBJ(const char* fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_OBJ(fname, g, parameters::all_default()); -} - -template -bool write_OBJ(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np, - typename boost::disable_if >::type* = nullptr) -{ - return write_OBJ(fname.c_str(), g, np); -} - template bool write_OBJ(const std::string& fname, const Graph& g, typename boost::disable_if >::type* = nullptr) diff --git a/BGL/include/CGAL/boost/graph/IO/OFF.h b/BGL/include/CGAL/boost/graph/IO/OFF.h index 9a24e2b443f..0c95c7ea570 100644 --- a/BGL/include/CGAL/boost/graph/IO/OFF.h +++ b/BGL/include/CGAL/boost/graph/IO/OFF.h @@ -98,7 +98,7 @@ bool read_OFF_BGL(std::istream& is, Ignores comment lines which start with a hash, and lines with whitespace. - \attention The graph `g` is not cleared, and the data from the stream is added. + \attention The graph `g` is not cleared, and the data from the stream are appended. \tparam Graph a model of `MutableFaceGraph` \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -148,7 +148,7 @@ bool read_OFF_BGL(std::istream& is, \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -193,7 +193,7 @@ bool read_OFF(std::istream& is, Graph& g, Ignores comment lines which start with a hash, and lines with whitespace. - \attention The graph `g` is not cleared, and the data from the stream is added. + \attention The graph `g` is not cleared, and the data from the file are appended. \tparam Graph a model of `MutableFaceGraph` \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -243,7 +243,7 @@ bool read_OFF(std::istream& is, Graph& g, \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -253,7 +253,7 @@ bool read_OFF(std::istream& is, Graph& g, */ template -bool read_OFF(const char* fname, +bool read_OFF(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -267,19 +267,6 @@ bool read_OFF(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_OFF(const char* fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_OFF(fname, g, parameters::all_default()); -} - -template -bool read_OFF(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np) -{ - return read_OFF(fname.c_str(), g, np); -} - template bool read_OFF(const std::string& fname, Graph& g, typename boost::disable_if >::type* = nullptr) @@ -482,7 +469,7 @@ bool write_OFF(std::ostream& os, const Graph& g, */ template -bool write_OFF(const char* fname, +bool write_OFF(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -501,25 +488,11 @@ bool write_OFF(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool write_OFF(const char* fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_OFF(fname, g, parameters::all_default()); -} - -template -bool write_OFF(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np, - typename boost::disable_if >::type* = nullptr) -{ - return write_OFF(fname.c_str(), g, np); -} - template bool write_OFF(const std::string& fname, const Graph& g, typename boost::disable_if >::type* = nullptr) { - return write_OFF(fname.c_str(), g, parameters::all_default()); + return write_OFF(fname, g, parameters::all_default()); } /// \endcond diff --git a/BGL/include/CGAL/boost/graph/IO/PLY.h b/BGL/include/CGAL/boost/graph/IO/PLY.h index 0391477ad35..4dbafb3cc80 100644 --- a/BGL/include/CGAL/boost/graph/IO/PLY.h +++ b/BGL/include/CGAL/boost/graph/IO/PLY.h @@ -128,7 +128,7 @@ bool read_PLY_BGL(std::istream& is, \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -214,7 +214,7 @@ bool read_PLY(std::istream& is, Graph& g, \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -224,7 +224,7 @@ bool read_PLY(std::istream& is, Graph& g, */ template -bool read_PLY(const char* fname, +bool read_PLY(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -249,25 +249,11 @@ bool read_PLY(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_PLY(const char* fname, Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return read_PLY(fname, g, parameters::all_default()); -} - -template -bool read_PLY(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np, - typename boost::disable_if >::type* = nullptr) -{ - return read_PLY(fname.c_str(), g, np); -} - template bool read_PLY(const std::string& fname, Graph& g, typename boost::disable_if >::type* = nullptr) { - return read_PLY(fname.c_str(), g, parameters::all_default()); + return read_PLY(fname, g, parameters::all_default()); } /// \endcond @@ -542,7 +528,7 @@ bool write_PLY(std::ostream& os, const Graph& g, \returns `true` if writing was successful, `false` otherwise. */ template -bool write_PLY(const char* fname, +bool write_PLY(const std::string& fname, const Graph& g, const std::string& comments, const CGAL_BGL_NP_CLASS& np @@ -569,52 +555,24 @@ bool write_PLY(const char* fname, /// \cond SKIP_IN_MANUAL template -bool write_PLY(const char* fname, const Graph& g, const std::string comments, +bool write_PLY(const std::string& fname, const Graph& g, const std::string comments, typename boost::disable_if >::type* = nullptr) { return write_PLY(fname, g, comments, parameters::all_default()); } template -bool write_PLY(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np, +bool write_PLY(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np, typename boost::disable_if >::type* = nullptr) { return write_PLY(fname, g, std::string(), np); } -template -bool write_PLY(const char* fname, const Graph& g, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(fname, g, std::string(), parameters::all_default()); -} - -template -bool write_PLY(const std::string& fname, const Graph& g, const std::string& comments, const CGAL_BGL_NP_CLASS& np, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(fname.c_str(), g, comments, np); -} - -template -bool write_PLY(const std::string& fname, const Graph& g, const std::string comments, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(fname.c_str(), g, comments, parameters::all_default()); -} - -template -bool write_PLY(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np, - typename boost::disable_if >::type* = nullptr) -{ - return write_PLY(fname.c_str(), g, std::string(), np); -} - template bool write_PLY(const std::string& fname, const Graph& g, typename boost::disable_if >::type* = nullptr) { - return write_PLY(fname.c_str(), g, std::string(), parameters::all_default()); + return write_PLY(fname, g, std::string(), parameters::all_default()); } /// \endcond diff --git a/BGL/include/CGAL/boost/graph/IO/STL.h b/BGL/include/CGAL/boost/graph/IO/STL.h index 49d47891982..71f97126c81 100644 --- a/BGL/include/CGAL/boost/graph/IO/STL.h +++ b/BGL/include/CGAL/boost/graph/IO/STL.h @@ -72,7 +72,7 @@ public: The data is expected to represent a 2-manifold (possibly with borders). - \attention The graph `g` is not cleared, and the data from the stream is added. + \attention The graph `g` is not cleared, and the data from the stream are appended. \attention When reading a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ifstream`. @@ -96,7 +96,7 @@ public: \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -123,7 +123,7 @@ bool read_STL(std::istream& is, The data is expected to represent a 2-manifold (possibly with borders). - \attention The graph `g` is not cleared, and the data from the stream is added. + \attention The graph `g` is not cleared, and the data from the file are appended. \tparam Graph a model of `MutableFaceGraph` \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -151,7 +151,7 @@ bool read_STL(std::istream& is, \cgalParamNBegin{verbose} \cgalParamDescription{whether extra information is printed when an incident occurs during reading} \cgalParamType{Boolean} - \cgalParamDefault{`true`} + \cgalParamDefault{`false`} \cgalParamNEnd \cgalNamedParamsEnd @@ -160,7 +160,9 @@ bool read_STL(std::istream& is, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template -bool read_STL(const char* fname, Graph& g, const CGAL_BGL_NP_CLASS& np) +bool read_STL(const std::string& fname, + Graph& g, const + CGAL_BGL_NP_CLASS& np) { const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); if(binary) @@ -179,17 +181,9 @@ bool read_STL(const char* fname, Graph& g, const CGAL_BGL_NP_CLASS& np) /// \cond SKIP_IN_MANUAL -template -bool read_STL(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np) -{ - return read_STL(fname.c_str(), g, np); -} - template bool read_STL(std::istream& is, Graph& g) { return read_STL(is, g, parameters::all_default()); } template -bool read_STL(const char* fname, Graph& g) { return read_STL(fname, g, parameters::all_default()); } -template bool read_STL(const std::string& fname, Graph& g) { return read_STL(fname, g, parameters::all_default()); } /// \endcond @@ -352,7 +346,7 @@ bool write_STL(std::ostream& os, \sa Overloads of this function for specific models of the concept `FaceGraph`. */ template -bool write_STL(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) +bool write_STL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) { const bool binary = CGAL::parameters::choose_parameter(CGAL::parameters::get_parameter(np, internal_np::use_binary_mode), true); if(binary) @@ -371,17 +365,9 @@ bool write_STL(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) /// \cond SKIP_IN_MANUAL -template -bool write_STL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) -{ - return write_STL(fname.c_str(), g, np); -} - template bool write_STL(std::ostream& os, const Graph& g) { return write_STL(os, g, parameters::all_default()); } template -bool write_STL(const char* fname, const Graph& g) { return write_STL(fname, g, parameters::all_default()); } -template bool write_STL(const std::string& fname, const Graph& g) { return write_STL(fname, g, parameters::all_default()); } /// \endcond diff --git a/BGL/include/CGAL/boost/graph/IO/VTK.h b/BGL/include/CGAL/boost/graph/IO/VTK.h index c4b6760e1f4..58b374a68f4 100644 --- a/BGL/include/CGAL/boost/graph/IO/VTK.h +++ b/BGL/include/CGAL/boost/graph/IO/VTK.h @@ -118,7 +118,7 @@ bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data, * * The data is expected to represent a 2-manifold (possibly with borders). * - * \attention The graph `g` is not cleared, and the data from the stream is added. + * \attention The graph `g` is not cleared, and the data from the file are appended. * * \tparam Graph a model of `MutableFaceGraph` * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -144,7 +144,7 @@ bool vtkPointSet_to_polygon_mesh(vtkPointSet* poly_data, */ template -bool read_VTP(const char* fname, +bool read_VTP(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np) { @@ -167,13 +167,6 @@ bool read_VTP(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_VTP(const std::string& fname, Graph& g, const CGAL_BGL_NP_CLASS& np) -{ - return read_VTP(fname.c_str(), g, np); -} -template -bool read_VTP(const char* fname, Graph& g) { return read_VTP(fname, g, parameters::all_default()); } template bool read_VTP(const std::string& fname, Graph& g) { return read_VTP(fname, g, parameters::all_default()); } @@ -532,7 +525,7 @@ bool write_VTP(std::ostream& os, * \returns `true` if writing was successful, `false` otherwise. */ template -bool write_VTP(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) +bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) { std::ofstream os(fname); return write_VTP(os, g, np); @@ -543,10 +536,6 @@ bool write_VTP(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) template bool write_VTP(std::ostream& os, const Graph& g) { return write_VTP(os, g, CGAL::parameters::all_default()); } template -bool write_VTP(const char* fname, const Graph& g) { return write_VTP(fname, g, parameters::all_default()); } -template -bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) { return write_VTP(fname.c_str(), g, np); } -template bool write_VTP(const std::string& fname, const Graph& g) { return write_VTP(fname, g, parameters::all_default()); } /// \endcond diff --git a/BGL/include/CGAL/boost/graph/IO/WRL.h b/BGL/include/CGAL/boost/graph/IO/WRL.h index 68090ffb966..c9d2f69b6b5 100644 --- a/BGL/include/CGAL/boost/graph/IO/WRL.h +++ b/BGL/include/CGAL/boost/graph/IO/WRL.h @@ -106,23 +106,15 @@ bool write_WRL(std::ostream& os, \returns `true` if writing was successful, `false` otherwise. */ template -bool write_WRL(const char* fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) +bool write_WRL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) { std::ifstream is(fname); return write_WRL(is, g, np); } -template -bool write_WRL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np) -{ - return write_WRL(fname.c_str(), g, np); -} - template bool write_WRL(std::ostream& os, const Graph& g) { return write_WRL(os, g, parameters::all_default()); } template -bool write_WRL(const char* fname, const Graph& g) { return write_WRL(fname, g, parameters::all_default()); } -template bool write_WRL(const std::string& fname, const Graph& g) { return write_WRL(fname, g, parameters::all_default()); } #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h b/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h index f00e86833b1..6fb5cdfec20 100644 --- a/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h +++ b/BGL/include/CGAL/boost/graph/IO/polygon_mesh_io.h @@ -76,8 +76,53 @@ bool read_polygon_mesh(std::istream& is, } */ -/// \cond SKIP_IN_MANUAL - +/*! + * \ingroup PkgBGLIOFct + * + * \brief reads a polygon mesh from a file. + * + * Supported file formats are the following: + * - \ref IOStreamOFF (`.off`) + * - \ref IOStreamOBJ (`.obj`) + * - \ref IOStreamSTL (`.stl`) + * - \ref IOStreamPLY (`.ply`) + * - \ref IOStreamGocad (`.ts`) + * - \ref IOStreamVTK (`.vtp`) + * + * The format is detected from the filename extension (letter case is not important). + * + * The data is expected to represent a 2-manifold (possibly with borders). + * + * \tparam Graph a model of `MutableFaceGraph` + * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * \param fname the name of the file + * \param g the mesh + * \param np optional \ref bgl_namedparameters "Named Parameters" described below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{vertex_point_map} + * \cgalParamDescription{a property map associating points to the vertices of `g`} + * \cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits::%vertex_descriptor` + * as key type and `%Point_3` as value type} + * \cgalParamDefault{`boost::get(CGAL::vertex_point, g)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` + * must be available in `Graph`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{verbose} + * \cgalParamDescription{whether extra information is printed when an incident occurs during reading} + * \cgalParamType{Boolean} + * \cgalParamDefault{`false`} + * \cgalParamNEnd + * \cgalNamedParamsEnd + * + * Other named parameters may be used according to the file extension, see \ref PkgBGLIOFct for an exhaustive list. + * + * \return `true` if reading was successful, `false` otherwise. + * + * \sa \link PMP_IO_grp `CGAL::Polygon_mesh_processing::read_polygon_mesh()`\endlink if the data is not 2-manifold +*/ template bool read_polygon_mesh(const std::string& fname, Graph& g, @@ -117,71 +162,10 @@ bool read_polygon_mesh(const std::string& fname, return false; } -template -bool read_polygon_mesh(const std::string& fname, Graph& g) -{ - return read_polygon_mesh(fname, g, parameters::all_default()); -} - -/// \endcond - -/*! - * \ingroup PkgBGLIOFct - * - * \brief reads a polygon mesh from a file. - * - * Supported file formats are the following: - * - \ref IOStreamOFF (`.off`) - * - \ref IOStreamOBJ (`.obj`) - * - \ref IOStreamSTL (`.stl`) - * - \ref IOStreamPLY (`.ply`) - * - \ref IOStreamGocad (`.ts`) - * - \ref IOStreamVTK (`.vtp`) - * - * The format is detected from the filename extension (letter case is not important). - * - * The data is expected to represent a 2-manifold (possibly with borders). - * - * \tparam Graph a model of `MutableFaceGraph` - * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - * - * \param fname the name of the file - * \param g the mesh - * \param np optional \ref bgl_namedparameters "Named Parameters" described below - * - * \cgalNamedParamsBegin - * \cgalParamNBegin{vertex_point_map} - * \cgalParamDescription{a property map associating points to the vertices of `g`} - * \cgalParamType{a class model of `WritablePropertyMap` with `boost::graph_traits::%vertex_descriptor` - * as key type and `%Point_3` as value type} - * \cgalParamDefault{`boost::get(CGAL::vertex_point, g)`} - * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` - * must be available in `Graph`.} - * \cgalParamNEnd - * - * \cgalParamNBegin{verbose} - * \cgalParamDescription{whether extra information is printed when an incident occurs during reading} - * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} - * \cgalParamNEnd - * \cgalNamedParamsEnd - * - * Other named parameters may be used according to the file extension, see \ref PkgBGLIOFct for an exhaustive list. - * - * \return `true` if reading was successful, `false` otherwise. - * - * \sa \link PMP_IO_grp `CGAL::Polygon_mesh_processing::read_polygon_mesh()`\endlink if the data is not 2-manifold -*/ -template -bool read_polygon_mesh(const char* fname, Graph& g, const NamedParameters& np) -{ - return read_polygon_mesh(std::string(fname), g, np); -} - /// \cond SKIP_IN_MANUAL template -bool read_polygon_mesh(const char* fname, Graph& g) +bool read_polygon_mesh(const std::string& fname, Graph& g) { return read_polygon_mesh(fname, g, parameters::all_default()); } @@ -192,55 +176,6 @@ bool read_polygon_mesh(const char* fname, Graph& g) //////////////////////////////////////////////////////////////////////////////////////////////////// // Write -/// \cond SKIP_IN_MANUAL - -template -bool write_polygon_mesh(const std::string& fname, - Graph& g, - const NamedParameters& np) -{ - const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); - - const std::string ext = IO::internal::get_file_extension(fname); - if(ext == std::string()) - { - if(verbose) - std::cerr << "Error: trying to output to file without extension" << std::endl; - return false; - } - - if(ext == "obj") - return write_OBJ(fname, g, np); - else if(ext == "off") - return write_OFF(fname, g, np); - else if(ext == "ply") - return write_PLY(fname, g, np); - else if(ext == "stl") - return write_STL(fname, g, np); - else if(ext == "ts") - return write_GOCAD(fname, g, np); -#ifdef CGAL_USE_VTK - else if(ext == "vtp") - return write_VTP(fname, g, np); -#endif - - if(verbose) - { - std::cerr << "Error: unknown output file extension: " << ext << "\n" - << "Please refer to the documentation for the list of supported file formats" << std::endl; - } - - return false; -} - -template -bool write_polygon_mesh(const std::string& fname, Graph& g) -{ - return write_polygon_mesh(fname, g, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup PkgBGLIOFct * @@ -283,7 +218,7 @@ bool write_polygon_mesh(const std::string& fname, Graph& g) * \cgalParamNBegin{verbose} * \cgalParamDescription{whether extra information is printed when an incident occurs during reading} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * @@ -292,15 +227,48 @@ bool write_polygon_mesh(const std::string& fname, Graph& g) * \return `true` if writing was successful, `false` otherwise. */ template -bool write_polygon_mesh(const char* fname, Graph& g, const NamedParameters& np) +bool write_polygon_mesh(const std::string& fname, + Graph& g, + const NamedParameters& np) { - return write_polygon_mesh(std::string(fname), g, np); + const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); + + const std::string ext = IO::internal::get_file_extension(fname); + if(ext == std::string()) + { + if(verbose) + std::cerr << "Error: trying to output to file without extension" << std::endl; + return false; + } + + if(ext == "obj") + return write_OBJ(fname, g, np); + else if(ext == "off") + return write_OFF(fname, g, np); + else if(ext == "ply") + return write_PLY(fname, g, np); + else if(ext == "stl") + return write_STL(fname, g, np); + else if(ext == "ts") + return write_GOCAD(fname, g, np); +#ifdef CGAL_USE_VTK + else if(ext == "vtp") + return write_VTP(fname, g, np); +#endif + + if(verbose) + { + std::cerr << "Error: unknown output file extension: " << ext << "\n" + << "Please refer to the documentation for the list of supported file formats" << std::endl; + } + + return false; } /// \cond SKIP_IN_MANUAL template -bool write_polygon_mesh(const char* fname, Graph& g) +bool write_polygon_mesh(const std::string& fname, Graph& g) { return write_polygon_mesh(fname, g, parameters::all_default()); } diff --git a/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/General_polygon_2.h b/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/General_polygon_2.h index 46724fe52b0..37b09e10ec0 100644 --- a/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/General_polygon_2.h +++ b/Boolean_set_operations_2/doc/Boolean_set_operations_2/CGAL/General_polygon_2.h @@ -84,8 +84,7 @@ Orientation orientation(); /*! This operator imports a general polygon from the input stream `in`. -An ASCII and a binary format exist. The stream detects the format -automatically and can read both. +Both ASCII and binary formats are supported, and the format is automatically detected. The format consists of the number of points of the outer boundary followed by the points themselves in counterclockwise order, followed by the number of holes, 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 8c7818621b3..fdcbe07026f 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO.h @@ -50,8 +50,8 @@ class Point_set_3; \attention When reading a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ifstream`. - \param is the input stream - \param ps the point set + \param is input stream + \param ps point set \return `is` @@ -81,8 +81,42 @@ std::istream& operator>>(std::istream& is, return is; } -/// \cond SKIP_IN_MANUAL +/*! + \ingroup PkgPointSet3IO + + \brief reads the point set from an input file. + + Supported file formats are the following: + - \ref IOStreamOFF (`.off`) + - \ref IOStreamPLY (`.ply`) + - \ref IOStreamLAS (`.las`) + - \ref IOStreamXYZ (`.xyz`) + + The format is detected from the filename extension (letter case is not important). + If the file contains normal vectors, the normal map is added to the point set. + For PLY input, all point properties found in the header are added. + + \tparam Point the point type of the `Point_set_3` + \tparam Vector the vector type of the `Point_set_3` + \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + + \param fname name of the input file + \param ps the point set + \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + + \cgalNamedParamsBegin + \cgalParamNBegin{use_binary_mode} + \cgalParamDescription{indicates whether data should be read in binary (`true`) or in ASCII (`false`)} + \cgalParamType{Boolean} + \cgalParamDefault{`true`} + \cgalParamExtra{This parameter is only relevant for `PLY` writing: the `OFF` and `XYZ` formats + are always ASCII, and the `LAS` format is always binary.} + \cgalParamNEnd + \cgalNamedParamsEnd + + \return `true` if the reading was successful, `false` otherwise. + */ template bool read_point_set(const std::string& fname, CGAL::Point_set_3& ps, @@ -104,61 +138,12 @@ bool read_point_set(const std::string& fname, return false; } -/// \endcond - -/*! - \ingroup PkgPointSet3IO - - \brief reads the point set from an input file. - - Supported file formats are the following: - - \ref IOStreamOFF (`.off`) - - \ref IOStreamPLY (`.ply`) - - \ref IOStreamLAS (`.las`) - - \ref IOStreamXYZ (`.xyz`) - - The format is detected from the filename extension (letter case is not important). - If the file contains normal vectors, the normal map is added to the point set. - For PLY input, all point properties found in the header are added. - - \tparam Point the point type of the `Point_set_3` - \tparam Vector the vector type of the `Point_set_3` - \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - - \param fname the path to the input file - \param ps the point set - \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below - - \cgalNamedParamsBegin - \cgalParamNBegin{use_binary_mode} - \cgalParamDescription{indicates whether data should be read in binary (`true`) or in ASCII (`false`)} - \cgalParamType{Boolean} - \cgalParamDefault{`true`} - \cgalParamExtra{This parameter is only relevant for `PLY` writing: the `OFF` and `XYZ` formats - are always ASCII, and the `LAS` format is always binary.} - \cgalParamNEnd - \cgalNamedParamsEnd - - \return `true` if the reading was successful, `false` otherwise. - */ -template -bool read_point_set(const char* fname, CGAL::Point_set_3& ps, const CGAL_BGL_NP_CLASS& np) -{ - return read_point_set(std::string(fname), ps, np); -} - /// \cond SKIP_IN_MANUAL -template -bool read_point_set(const char* fname, CGAL::Point_set_3& ps) -{ - return write_point_set(fname, ps, parameters::all_default()); -} - template bool read_point_set(const std::string& fname, CGAL::Point_set_3& ps) { - return write_point_set(fname.c_str(), ps, parameters::all_default()); + return write_point_set(fname, ps, parameters::all_default()); } /// \endcond @@ -189,31 +174,6 @@ std::ostream& operator<<(std::ostream& os, return os; } -/// \cond SKIP_IN_MANUAL - -template -bool write_point_set(const std::string& fname, - CGAL::Point_set_3& ps, - const CGAL_BGL_NP_CLASS& np) -{ - const std::string ext = IO::internal::get_file_extension(fname); - - if(ext == "xyz") - return write_XYZ(fname, ps, np); - else if(ext == "off") - return write_OFF(fname, ps, np); - else if(ext == "ply") - return write_PLY(fname, ps, np); -#ifdef CGAL_LINKED_WITH_LASLIB - else if(ext == "las") - return write_LAS(fname, ps, np); -#endif - - return false; -} - -/// \endcond - /*! \ingroup PkgPointSet3IO @@ -231,7 +191,7 @@ bool write_point_set(const std::string& fname, \tparam Vector the vector type of the `Point_set_3` \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - \param fname the path to the output file + \param fname name of the output file \param ps the point set \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below @@ -254,25 +214,32 @@ bool write_point_set(const std::string& fname, \return `true` if the writing was successful, `false` otherwise. */ template -bool write_point_set(const char* fname, +bool write_point_set(const std::string& fname, CGAL::Point_set_3& ps, const CGAL_BGL_NP_CLASS& np) { - return write_point_set(std::string(fname), ps, np); + const std::string ext = IO::internal::get_file_extension(fname); + + if(ext == "xyz") + return write_XYZ(fname, ps, np); + else if(ext == "off") + return write_OFF(fname, ps, np); + else if(ext == "ply") + return write_PLY(fname, ps, np); +#ifdef CGAL_LINKED_WITH_LASLIB + else if(ext == "las") + return write_LAS(fname, ps, np); +#endif + + return false; } /// \cond SKIP_IN_MANUAL -template -bool write_point_set(const char* fname, CGAL::Point_set_3& ps) -{ - return write_point_set(fname, ps, parameters::all_default()); -} - template bool write_point_set(const std::string& fname, CGAL::Point_set_3& ps) { - return write_point_set(fname.c_str(), ps, parameters::all_default()); + return write_point_set(fname, ps, parameters::all_default()); } /// \endcond diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h b/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h index 74bdcd23551..b9f4a07a2f6 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h @@ -157,23 +157,13 @@ bool read_LAS(std::istream& is, \return `true` if the reading was successful, `false` otherwise. */ template -bool read_LAS(const char* fname, CGAL::Point_set_3& point_set) +bool read_LAS(const std::string& fname, CGAL::Point_set_3& point_set) { std::ifstream is(fname, std::ios::binary); CGAL::set_mode(is, CGAL::IO::BINARY); return read_LAS(is, point_set); } -/// \cond SKIP_IN_MANUAL - -template -bool read_LAS(const std::string& fname, CGAL::Point_set_3& point_set) -{ - return read_LAS(fname.c_str(), point_set); -} - -/// \endcond - #ifndef CGAL_NO_DEPRECATED_CODE /*! @@ -398,7 +388,7 @@ bool write_LAS(std::ostream& os, \return `true` if the writing was successful, `false` otherwise. */ template -bool write_LAS(const char* fname, +bool write_LAS(const std::string& fname, CGAL::Point_set_3& point_set) { std::ofstream os(fname, std::ios::binary); @@ -406,16 +396,6 @@ bool write_LAS(const char* fname, return write_LAS(os, point_set); } -/// \cond SKIP_IN_MANUAL - -template -bool write_LAS(const std::string& fname, CGAL::Point_set_3& point_set) -{ - return write_LAS(fname.c_str(), point_set); -} - -/// \endcond - #ifndef CGAL_NO_DEPRECATED_CODE /*! diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h b/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h index c23b483814c..0b8230e460d 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h @@ -90,22 +90,12 @@ bool read_OFF(std::istream& is, \return `true` if the reading was successful, `false` otherwise. */ template -bool read_OFF(const char* fname, CGAL::Point_set_3& point_set) +bool read_OFF(const std::string& fname, CGAL::Point_set_3& point_set) { std::ifstream is(fname); return read_OFF(is, point_set); } -/// \cond SKIP_IN_MANUAL - -template -bool read_OFF(const std::string& fname, CGAL::Point_set_3& point_set) -{ - return read_OFF(fname.c_str(), point_set); -} - -/// \endcond - #ifndef CGAL_NO_DEPRECATED_CODE /*! @@ -202,7 +192,7 @@ bool write_OFF(std::ostream& os, const CGAL::Point_set_3& point_s \return `true` if the writing was successful, `false` otherwise. */ template -bool write_OFF(const char* fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +bool write_OFF(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) { std::ofstream os(fname); return write_OFF(os, point_set, np); @@ -211,24 +201,12 @@ bool write_OFF(const char* fname, const CGAL::Point_set_3& point_ /// \cond SKIP_IN_MANUAL template -bool write_OFF(const char* fname, const CGAL::Point_set_3& point_set) +bool write_OFF(const std::string& fname, const CGAL::Point_set_3& point_set) { std::ofstream os(fname); return write_OFF(os, point_set, parameters::all_default()); } -template -bool write_OFF(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) -{ - return write_OFF(fname.c_str(), point_set, np); -} - -template -bool write_OFF(const std::string& fname, const CGAL::Point_set_3& point_set) -{ - return write_OFF(fname.c_str(), point_set, parameters::all_default()); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h b/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h index 124713c0675..6306edd032c 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h @@ -344,7 +344,7 @@ bool read_PLY(std::istream& is, CGAL::Point_set_3& point_set) \return `true` if the reading was successful, `false` otherwise. */ template -bool read_PLY(const char* fname, +bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set, std::string& comments, const CGAL_BGL_NP_CLASS& np) @@ -366,44 +366,24 @@ bool read_PLY(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_PLY(const char* fname, CGAL::Point_set_3& point_set, std::string& comments) -{ - return read_PLY(fname, point_set, comments, parameters::all_default()); -} - -template -bool read_PLY(const char* fname, CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) -{ - std::string unused_comments; - return read_PLY(fname, point_set, unused_comments, np); -} - -template -bool read_PLY(const char* fname, CGAL::Point_set_3& point_set) -{ - std::string unused_comments; - return read_PLY(fname, point_set, unused_comments, parameters::all_default()); -} - template bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set, std::string& comments) { - return read_PLY(fname.c_str(), point_set, comments, parameters::all_default()); + return read_PLY(fname, point_set, comments, parameters::all_default()); } template bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) { std::string unused_comments; - return read_PLY(fname.c_str(), point_set, unused_comments, np); + return read_PLY(fname, point_set, unused_comments, np); } template bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_set) { std::string unused_comments; - return read_PLY(fname.c_str(), point_set, unused_comments, parameters::all_default()); + return read_PLY(fname, point_set, unused_comments, parameters::all_default()); } /// \endcond @@ -762,7 +742,7 @@ bool write_PLY(std::ostream& os, const CGAL::Point_set_3& point_s \return `true` if the reading was successful, `false` otherwise. */ template -bool write_PLY(const char* fname, +bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, const std::string& comments, const CGAL_BGL_NP_CLASS& np) @@ -785,46 +765,22 @@ bool write_PLY(const char* fname, /// \cond SKIP_IN_MANUAL template -bool write_PLY(const char* fname, const CGAL::Point_set_3& point_set, const std::string& comments) +bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, + const std::string& comments) { return write_PLY(fname, point_set, comments, parameters::all_default()); } template -bool write_PLY(const char* fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) { return write_PLY(fname, point_set, std::string(), np); } -template -bool write_PLY(const char* fname, const CGAL::Point_set_3& point_set) -{ - return write_PLY(fname, point_set, std::string(), parameters::all_default()); -} - -template -bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, - const std::string& comments, const CGAL_BGL_NP_CLASS& np) -{ - return write_PLY(fname.c_str(), point_set, comments, np); -} - -template -bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, const std::string& comments) -{ - return write_PLY(fname.c_str(), point_set, comments, parameters::all_default()); -} - -template -bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) -{ - return write_PLY(fname.c_str(), point_set, std::string(), np); -} - template bool write_PLY(const std::string& fname, const CGAL::Point_set_3& point_set) { - return write_PLY(fname.c_str(), point_set, std::string(), parameters::all_default()); + return write_PLY(fname, point_set, std::string(), parameters::all_default()); } /// \endcond diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h b/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h index 27dcf4c4316..65dcbe42eef 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h @@ -89,22 +89,12 @@ bool read_XYZ(std::istream& is, \return `true` if the reading was successful, `false` otherwise. */ template -bool read_XYZ(const char* fname, CGAL::Point_set_3& point_set) +bool read_XYZ(const std::string& fname, CGAL::Point_set_3& point_set) { std::ifstream is(fname); return read_XYZ(is, point_set); } -/// \cond SKIP_IN_MANUAL - -template -bool read_XYZ(const std::string& fname, CGAL::Point_set_3& point_set) -{ - return read_XYZ(fname.c_str(), point_set); -} - -/// \endcond - #ifndef CGAL_NO_DEPRECATED_CODE /*! @@ -199,7 +189,7 @@ bool write_XYZ(std::ostream& os, const CGAL::Point_set_3& point_s \return `true` if the writing was successful, `false` otherwise. */ template -bool write_XYZ(const char* fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) +bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) { std::ofstream os(fname); return write_XYZ(os, point_set, np); @@ -208,24 +198,12 @@ bool write_XYZ(const char* fname, const CGAL::Point_set_3& point_ /// \cond SKIP_IN_MANUAL template -bool write_XYZ(const char* fname, const CGAL::Point_set_3& point_set) +bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& point_set) { std::ofstream os(fname); return write_XYZ(os, point_set, parameters::all_default()); } -template -bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& point_set, const CGAL_BGL_NP_CLASS& np) -{ - return write_XYZ(fname.c_str(), point_set, np); -} - -template -bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& point_set) -{ - return write_XYZ(fname.c_str(), point_set, parameters::all_default()); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/read_las_points.h b/Point_set_processing_3/include/CGAL/IO/read_las_points.h index 2a90cb7f168..de5a53baf9d 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_las_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_las_points.h @@ -516,7 +516,7 @@ bool read_LAS(std::istream& is, OutputIterator output, \tparam PointOutputIterator iterator over output points. \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - \param filename the name of the input file + \param filename name of the input file \param output output iterator over points \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below @@ -541,7 +541,7 @@ bool read_LAS(std::istream& is, OutputIterator output, template -bool read_LAS(const char* filename, +bool read_LAS(const std::string& filename, PointOutputIterator output, const CGAL_BGL_NP_CLASS& np) { @@ -553,37 +553,13 @@ bool read_LAS(const char* filename, /// \cond SKIP_IN_MANUAL template -bool read_LAS(const char* fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +bool read_LAS(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) { std::ifstream is(fname, std::ios::binary); CGAL::set_mode(is, CGAL::IO::BINARY); return read_LAS::type>(is, output, np); } -template -bool read_LAS(const char* fname, OutputIterator output) -{ - return read_LAS(fname, output, parameters::all_default()); -} - -template -bool read_LAS(const char* fname, OutputIterator output) -{ - return read_LAS::type>(fname, output, parameters::all_default()); -} - -template -bool read_LAS(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) -{ - return read_LAS(fname.c_str(), output, np); -} - -template -bool read_LAS(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) -{ - return read_LAS::type>(fname.c_str(), output, np); -} - template bool read_LAS(const std::string& fname, OutputIterator output) { diff --git a/Point_set_processing_3/include/CGAL/IO/read_off_points.h b/Point_set_processing_3/include/CGAL/IO/read_off_points.h index 09990328175..b1a9e0e9410 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_off_points.h @@ -51,8 +51,8 @@ namespace CGAL { \tparam PointOutputIterator iterator over output points. \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - \param is input stream. - \param output output iterator over points. + \param is input stream + \param output output iterator over points \param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below \cgalNamedParamsBegin @@ -206,8 +206,8 @@ bool read_OFF(std::istream& is, \tparam PointOutputIterator iterator over output points. \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - \param fname input file name. - \param output output iterator over points. + \param fname input file name + \param output output iterator over points \param np optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below. \cgalNamedParamsBegin @@ -237,7 +237,7 @@ bool read_OFF(std::istream& is, template -bool read_OFF(const char* fname, +bool read_OFF(const std::string& fname, PointOutputIterator output, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -251,13 +251,6 @@ bool read_OFF(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_OFF(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF(fname.c_str(), output, np); -} - // variants with default NP template @@ -274,13 +267,6 @@ bool read_OFF(const std::string& fname, OutputIterator output, return read_OFF(fname, output, parameters::all_default()); } -template -bool read_OFF(const char* fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF(fname, output, parameters::all_default()); -} - // variants with default output iterator value type template @@ -291,20 +277,13 @@ bool read_OFF(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& } template -bool read_OFF(const char* fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, +bool read_OFF(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, typename std::enable_if::value>::type* = nullptr) { std::ifstream is(fname); return read_OFF::type>(is, output, np); } -template -bool read_OFF(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF::type>(fname.c_str(), output, np); -} - // variants with default NP and output iterator value type template bool read_OFF(std::istream& is, OutputIterator output, @@ -320,13 +299,6 @@ bool read_OFF(const std::string& fname, OutputIterator output, return read_OFF::type>(fname, output, parameters::all_default()); } -template -bool read_OFF(const char* fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_OFF::type>(fname, output, parameters::all_default()); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index d83fcf30d0e..caefb6c2922 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -324,7 +324,7 @@ bool read_PLY(std::istream& is, template -bool read_PLY(const char* fname, +bool read_PLY(const std::string& fname, PointOutputIterator output, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -349,13 +349,6 @@ bool read_PLY(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_PLY(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY(fname.c_str(), output, np); -} - // variants with default NP template bool read_PLY(std::istream& is, OutputIterator output, @@ -371,13 +364,6 @@ bool read_PLY(const std::string& fname, OutputIterator output, return read_PLY(fname, output, parameters::all_default()); } -template -bool read_PLY(const char* fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY(fname, output, parameters::all_default()); -} - // variants with default output iterator value type template bool read_PLY(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np, @@ -387,17 +373,10 @@ bool read_PLY(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& } template -bool read_PLY(const char* fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY::type>(fname, output, np); -} - -template bool read_PLY(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np, typename std::enable_if::value>::type* = nullptr) { - return read_PLY::type>(fname.c_str(), output, np); + return read_PLY::type>(fname, output, np); } // variants with default NP and output iterator value type @@ -415,13 +394,6 @@ bool read_PLY(const std::string& fname, OutputIterator output, return read_PLY::type>(fname, output, parameters::all_default()); } -template -bool read_PLY(const char* fname, OutputIterator output, - typename std::enable_if::value>::type* = nullptr) -{ - return read_PLY::type>(fname, output, parameters::all_default()); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/read_points.h b/Point_set_processing_3/include/CGAL/IO/read_points.h index 29227cf0cf4..f4f5fd4e480 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_points.h @@ -28,53 +28,6 @@ namespace CGAL { -/// \cond SKIP_IN_MANUAL - -template -bool read_points(const std::string& fname, - PointOutputIterator output, - const NamedParameters& np) -{ - const std::string ext = IO::internal::get_file_extension(fname); - - if(ext == "xyz") - return read_XYZ(fname, output, np); - else if(ext == "off") - return read_OFF(fname, output, np); - else if(ext == "ply") - return read_PLY(fname, output, np); -#ifdef CGAL_LINKED_WITH_LASLIB - else if(ext == "las") - return read_LAS(fname, output, np); -#endif - - return false; -} - -// variant with default OutputIteratorType -template -bool read_points(const std::string& fname, OutputIterator output, const NamedParameters& np) -{ - return read_points::type>(fname, output, np); -} - -template -bool read_points(const std::string& fname, OutputIterator output) -{ - return read_points(fname, output, parameters::all_default()); -} - -// variant with all default -template -bool read_points(const std::string& fname, OutputIterator output) -{ - return read_points::type>(fname, output, parameters::all_default()); -} - -/// \endcond - /** \ingroup PkgPointSetProcessing3IO @@ -128,28 +81,47 @@ bool read_points(const std::string& fname, OutputIterator output) \returns `true` if reading was successful, `false` otherwise. */ -template -bool read_points(const char* fname, PointOutputIterator output, const NamedParameters& np) +template +bool read_points(const std::string& fname, + PointOutputIterator output, + const NamedParameters& np) { - return read_points(std::string(fname), output, np); + const std::string ext = IO::internal::get_file_extension(fname); + + if(ext == "xyz") + return read_XYZ(fname, output, np); + else if(ext == "off") + return read_OFF(fname, output, np); + else if(ext == "ply") + return read_PLY(fname, output, np); +#ifdef CGAL_LINKED_WITH_LASLIB + else if(ext == "las") + return read_LAS(fname, output, np); +#endif + + return false; } /// \cond SKIP_IN_MANUAL +// variant with default OutputIteratorType template -bool read_points(const char* fname, OutputIterator output, const NamedParameters& np) +bool read_points(const std::string& fname, OutputIterator output, const NamedParameters& np) { return read_points::type>(fname, output, np); } template -bool read_points(const char* fname, OutputIterator output) +bool read_points(const std::string& fname, OutputIterator output) { return read_points(fname, output, parameters::all_default()); } +// variant with all default template -bool read_points(const char* fname, OutputIterator output) +bool read_points(const std::string& fname, OutputIterator output) { return read_points::type>(fname, output, parameters::all_default()); } diff --git a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h index b496edf32ff..ad8b2b7342d 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h @@ -223,7 +223,7 @@ bool read_XYZ(std::istream& is, template -bool read_XYZ(const char* fname, +bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) { @@ -233,12 +233,6 @@ bool read_XYZ(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) -{ - return read_XYZ(fname.c_str(), output, np); -} - // variants with default NP template bool read_XYZ(std::istream& is, OutputIterator output) @@ -252,12 +246,6 @@ bool read_XYZ(const std::string& fname, OutputIterator output) return read_XYZ(fname, output, parameters::all_default()); } -template -bool read_XYZ(const char* fname, OutputIterator output) -{ - return read_XYZ(fname, output, parameters::all_default()); -} - // variants with default output iterator value type template bool read_XYZ(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& np) @@ -266,18 +254,12 @@ bool read_XYZ(std::istream& is, OutputIterator output, const CGAL_BGL_NP_CLASS& } template -bool read_XYZ(const char* fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) +bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) { std::ifstream is(fname); return read_XYZ::type>(is, output, np); } -template -bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_BGL_NP_CLASS& np) -{ - return read_XYZ::type>(fname.c_str(), output, np); -} - // variants with default NP and output iterator value type template bool read_XYZ(std::istream& is, @@ -293,12 +275,6 @@ bool read_XYZ(const std::string& fname, OutputIterator output) return read_XYZ::type>(fname, output, parameters::all_default()); } -template -bool read_XYZ(const char* fname, OutputIterator output) -{ - return read_XYZ::type>(fname, output, parameters::all_default()); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/write_las_points.h b/Point_set_processing_3/include/CGAL/IO/write_las_points.h index 1de7458f18d..54223dbcc73 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_las_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_las_points.h @@ -337,7 +337,7 @@ bool write_LAS(std::ostream& os, \sa `write_LAS_with_properties()` */ template -bool write_LAS(const char* filename, +bool write_LAS(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -352,13 +352,6 @@ bool write_LAS(const char* filename, /// \cond SKIP_IN_MANUAL -template -bool write_LAS(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_LAS(filename.c_str(), points, np); -} - // variant with default NP template bool write_LAS(std::ostream& os, const PointRange& points, @@ -368,7 +361,7 @@ bool write_LAS(std::ostream& os, const PointRange& points, } template -bool write_LAS(const char* filename, const PointRange& points, +bool write_LAS(const std::string& filename, const PointRange& points, typename boost::enable_if >::type* = nullptr) { std::ofstream os(filename, std::ios::binary); @@ -376,13 +369,6 @@ bool write_LAS(const char* filename, const PointRange& points, return write_LAS(os, points, CGAL::Point_set_processing_3::parameters::all_default(points)()); } -template -bool write_LAS(const std::string& filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_LAS(filename, points, CGAL::Point_set_processing_3::parameters::all_default(points)); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index b0f6be29a6e..6b6981647fd 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -197,7 +197,7 @@ bool write_OFF(std::ostream& os, const PointRange& points, */ template -bool write_OFF(const char* filename, +bool write_OFF(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -212,27 +212,13 @@ bool write_OFF(const char* filename, /// \cond SKIP_IN_MANUAL template -bool write_OFF(const char* filename, const PointRange& points, +bool write_OFF(const std::string& filename, const PointRange& points, typename boost::enable_if >::type* = nullptr) { std::ofstream os(filename); return write_OFF(os, points, parameters::all_default()); } -template -bool write_OFF(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_OFF(filename.c_str(), points, np); -} - -template -bool write_OFF(const std::string& filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_OFF(filename, points, parameters::all_default()); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index c48a7ac2064..76bb398d88f 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -283,7 +283,7 @@ bool write_PLY(std::ostream& os, const PointRange& points, \sa `write_PLY_with_properties()` */ template -bool write_PLY(const char* filename, +bool write_PLY(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -308,25 +308,11 @@ bool write_PLY(const char* filename, /// \cond SKIP_IN_MANUAL -template -bool write_PLY(const char* filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(filename, points, parameters::all_default()); -} - -template -bool write_PLY(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(filename.c_str(), points, np); -} - template bool write_PLY(const std::string& filename, const PointRange& points, typename boost::enable_if >::type* = nullptr) { - return write_PLY(filename.c_str(), points, parameters::all_default()); + return write_PLY(filename, points, parameters::all_default()); } /// \endcond diff --git a/Point_set_processing_3/include/CGAL/IO/write_points.h b/Point_set_processing_3/include/CGAL/IO/write_points.h index 62859f63638..b86af019828 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_points.h @@ -33,39 +33,6 @@ namespace CGAL { -/// \cond SKIP_IN_MANUAL - -template -bool write_points(const std::string& fname, - const PointRange& points, - const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - const std::string ext = IO::internal::get_file_extension(fname); - - if(ext == "xyz") - return write_XYZ(fname, points, np); - else if(ext == "off") - return write_OFF(fname, points, np); - else if(ext == "ply") - return write_PLY(fname, points, np); -#ifdef CGAL_LINKED_WITH_LASLIB - else if(ext == "las") - return write_LAS(fname, points, np); - -#endif - return false; -} - -template -bool write_points(const std::string& fname,const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_points(fname, points, parameters::all_default()); -} - -/// \endcond - /** \ingroup PkgPointSetProcessing3IO @@ -125,19 +92,34 @@ bool write_points(const std::string& fname,const PointRange& points, \returns `true` if writing was successful, `false` otherwise. */ template -bool write_points(const char* fname, const PointRange& points, const CGAL_BGL_NP_CLASS& np +bool write_points(const std::string& fname, + const PointRange& points, + const CGAL_BGL_NP_CLASS& np, #ifndef DOXYGEN_RUNNING - , typename boost::enable_if >::type* = nullptr + typename boost::enable_if >::type* = nullptr #endif ) { - return write_points(std::string(fname), points, np); + const std::string ext = IO::internal::get_file_extension(fname); + + if(ext == "xyz") + return write_XYZ(fname, points, np); + else if(ext == "off") + return write_OFF(fname, points, np); + else if(ext == "ply") + return write_PLY(fname, points, np); +#ifdef CGAL_LINKED_WITH_LASLIB + else if(ext == "las") + return write_LAS(fname, points, np); + +#endif + return false; } /// \cond SKIP_IN_MANUAL template -bool write_points(const char* fname,const PointRange& points, +bool write_points(const std::string& fname,const PointRange& points, typename boost::enable_if >::type* = nullptr) { return write_points(fname, points, parameters::all_default()); diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index 2e3b27cb715..a49da0352db 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -191,7 +191,7 @@ bool write_XYZ(std::ostream& os, const PointRange& points, \returns `true` if writing was successful, `false` otherwise. */ template -bool write_XYZ(const char* filename, +bool write_XYZ(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING @@ -206,27 +206,13 @@ bool write_XYZ(const char* filename, /// \cond SKIP_IN_MANUAL template -bool write_XYZ(const char* filename, const PointRange& points, +bool write_XYZ(const std::string& filename, const PointRange& points, typename boost::enable_if >::type* = nullptr) { std::ofstream os(filename); return write_XYZ(os, points, parameters::all_default()); } -template -bool write_XYZ(const std::string& filename, const PointRange& points, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_XYZ(filename.c_str(), points, np); -} - -template -bool write_XYZ(const std::string& filename, const PointRange& points, - typename boost::enable_if >::type* = nullptr) -{ - return write_XYZ(filename, points, parameters::all_default()); -} - /// \endcond #ifndef CGAL_NO_DEPRECATED_CODE diff --git a/Polygon/include/CGAL/General_polygon_with_holes_2.h b/Polygon/include/CGAL/General_polygon_with_holes_2.h index c4eee1a53a3..9d086d4c485 100644 --- a/Polygon/include/CGAL/General_polygon_with_holes_2.h +++ b/Polygon/include/CGAL/General_polygon_with_holes_2.h @@ -217,8 +217,7 @@ std::ostream /*! This operator imports a General_polygon_with_holes_2 from the input stream `in`. -An ASCII and a binary format exist. The stream detects the format -automatically and can read both. +Both ASCII and binary formats are supported, and the format is automatically detected. The format consists of the number of curves of the outer boundary followed by the curves themselves, followed diff --git a/Polygon/include/CGAL/Polygon_with_holes_2.h b/Polygon/include/CGAL/Polygon_with_holes_2.h index 659ce3833cb..c0b93c7019e 100644 --- a/Polygon/include/CGAL/Polygon_with_holes_2.h +++ b/Polygon/include/CGAL/Polygon_with_holes_2.h @@ -146,8 +146,7 @@ std::ostream& operator<<(std::ostream &os, /*! This operator imports a polygon with holes from the input stream `in`. -An ASCII and a binary format exist. The stream detects the format -automatically and can read both. +Both ASCII and binary formats are supported, and the format is automatically detected. The format consists of the number of points of the outer boundary followed by the points themselves in counterclockwise order, followed by the number of holes, diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 8414ebb5546..20e39b29034 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -52,6 +52,15 @@ mesh, which includes point location and self intersection tests. - \ref PMPConnectedComponents : methods to deal with connected components of a polygon mesh (extraction, marks, removal, ...). +\subsection PMPIO Reading and Writing Polygon Meshes + +In all functions of this package, the polygon meshes are required to be models +of the graph concepts defined in the package \PkgBGLRef. Using common graph concepts +enables having common input/output functions for all the models of these concepts. +The page \ref PkgBGLIOFct provides an exhaustive description of the available I/O functions. +In addition, this package offers the function `CGAL::Polygon_mesh_processing::read_polygon_mesh()`, +which can perform some reparation if the input data do not represent a manifold surface. + **************************************** \section PMPMeshing Meshing diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h index db538a45e58..7473fb6183d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h @@ -37,8 +37,7 @@ namespace Polygon_mesh_processing { /*! \ingroup PMP_IO_grp - * \brief attempts to read a file as a polygon mesh; in case of failure, reads the file as a polygon soup, - * repairs and orients it to obtain a polygon mesh. + * \brief reads the file as a polygon soup, repairs, and orients it to obtain a polygon mesh. * * Supported file formats are the following: * - \ref IOStreamOFF (`.off`) @@ -77,16 +76,16 @@ namespace Polygon_mesh_processing { * \cgalParamNBegin{verbose} * \cgalParamDescription{whether extra information is printed when an incident occurs during reading} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * - * \return `true` if the reading and conversion were successful, `false` otherwise. + * \return `true` if the reading, repairing, and orientation operations were successful, `false` otherwise. * * \sa \link PkgBGLIOFct `CGAL::write_polygon_mesh()` \endlink */ template -bool read_polygon_mesh(const char* fname, +bool read_polygon_mesh(const std::string& fname, PolygonMesh& g, const NamedParameters& np) { @@ -98,31 +97,28 @@ bool read_polygon_mesh(const char* fname, using parameters::choose_parameter; using parameters::get_parameter; - bool ok = CGAL::read_polygon_mesh(fname, g, np); - - if(ok) - return true; - - clear(g); + const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); std::vector points; std::vector > faces; if(!CGAL::read_polygon_soup(fname, points, faces)) { - std::cerr << "Error: cannot read file\n"; + if(verbose) + std::cerr << "W: cannot read polygon soup\n"; return false; } - std::cout << "Cleaning polygon soup..." << std::endl; const bool do_repair = choose_parameter(get_parameter(np, internal_np::repair_polygon_soup), true); if(do_repair) PMP::repair_polygon_soup(points, faces, np); - if(!PMP::orient_polygon_soup(points, faces)) - std::cerr << "W: File does not describe a polygon mesh" << std::endl; - - if(!PMP::is_polygon_soup_a_polygon_mesh(faces)) + if(!PMP::orient_polygon_soup(points, faces) || + !PMP::is_polygon_soup_a_polygon_mesh(faces)) + { + if(verbose) + std::cerr << "W: File does not describe a polygon mesh" << std::endl; return false; + } PMP::polygon_soup_to_polygon_mesh(points, faces, g, parameters::all_default(), np); @@ -131,18 +127,6 @@ bool read_polygon_mesh(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_polygon_mesh(const char* fname, PolygonMesh& g) -{ - return CGAL::Polygon_mesh_processing::read_polygon_mesh(fname, g, parameters::all_default()); -} - -template -bool read_polygon_mesh(const std::string& fname, PolygonMesh& g, const NamedParameters& np) -{ - return CGAL::Polygon_mesh_processing::read_polygon_mesh(fname.c_str(), g, np); -} - template bool read_polygon_mesh(const std::string& fname, PolygonMesh& g) { diff --git a/Polyhedron/doc/Polyhedron/CGAL/IO/Polyhedron_iostream.h b/Polyhedron/doc/Polyhedron/CGAL/IO/Polyhedron_iostream.h index 55adea20854..af7130c6407 100644 --- a/Polyhedron/doc/Polyhedron/CGAL/IO/Polyhedron_iostream.h +++ b/Polyhedron/doc/Polyhedron/CGAL/IO/Polyhedron_iostream.h @@ -10,9 +10,6 @@ appends it to the polyhedral surface \f$ P\f$. Only the point coordinates and facets from the input stream are used to build the polyhedral surface. Neither normal vectors nor color attributes are evaluated. -For OFF an ASCII and a binary format exist. The stream detects the -format automatically and can read both. - \sa `CGAL::Polyhedron_3` \sa `CGAL::Polyhedron_incremental_builder_3` \sa \link PkgPolyhedronIOFunc `operator<<(std::ostream&, Polyhedron_3&)`\endlink diff --git a/Polyhedron/include/CGAL/IO/scan_OFF.h b/Polyhedron/include/CGAL/IO/scan_OFF.h index e1aa88846bc..f70feeee944 100644 --- a/Polyhedron/include/CGAL/IO/scan_OFF.h +++ b/Polyhedron/include/CGAL/IO/scan_OFF.h @@ -48,7 +48,7 @@ template void scan_OFF(std::istream& in, Polyhedron_3& P, - bool verbose = true) + bool verbose = false) { // reads a polyhedron from `in' and appends it to P. typedef Polyhedron_3 Polyhedron; diff --git a/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt b/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt index 71c22cc1db9..2985c12beb7 100644 --- a/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt +++ b/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt @@ -370,7 +370,8 @@ The `3MF`, using the file extension `.3mf`, is an open source file format create It is an XML-based format that aims to enhance the \ref IOStreamSTL by adding means to include extra information such as colors. -A precise specification of the format is available at 3mf.io. +A precise specification of the format is available at 3mf.io; +note that only version `1.x` is currently supported in \cgal. @@ -413,8 +414,17 @@ A WRL file includes data specifying 3-D details such as vertices, edges for a 3- A precise specification of the format is available here. -Any structure that is a model of the concept `FaceGraph` can be exported into the `.wrl` file format -using the function \link PkgBGLIoFuncsWRL `CGAL::write_WRL()` \endlink. +
+ + + + + + + + + +
3D Manufacturing Format (3MF)
OutputPolygon MeshAny model of `FaceGraph`\link PkgBGLIoFuncsWRL CGAL::write_WRL(const char*, Graph&)\endlink
\section IOStreamVTK VTK (VTU / VTP) File Formats diff --git a/Stream_support/doc/Stream_support/IOstream.txt b/Stream_support/doc/Stream_support/IOstream.txt index 7df3e7353e3..80de6e5a30f 100644 --- a/Stream_support/doc/Stream_support/IOstream.txt +++ b/Stream_support/doc/Stream_support/IOstream.txt @@ -463,7 +463,7 @@ Free functions are provided for reading and writing several \cgal types using th You can find more information about WKT \ref PkgStreamSupportRef "here". The following table summarizes the most useful functions. Note that the name deviates -from the standard \cgal I/O functions, for clarity reasons. +from the standard \cgal I/O functions. diff --git a/Stream_support/include/CGAL/IO/3MF.h b/Stream_support/include/CGAL/IO/3MF.h index 01f226945d6..f6438de0449 100644 --- a/Stream_support/include/CGAL/IO/3MF.h +++ b/Stream_support/include/CGAL/IO/3MF.h @@ -382,6 +382,8 @@ bool read_3MF(const std::string& fname, * * \brief reads ranges of points and triangles from an input file, using the \ref IOStream3MF. * + * \attention The ranges not cleared, and the data from the file are appended. + * * \tparam PointRanges a model of the concepts `RandomAccessContainer` and * `BackInsertionSequence` whose `value_type` is * a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` diff --git a/Stream_support/include/CGAL/IO/GOCAD.h b/Stream_support/include/CGAL/IO/GOCAD.h index 54a2e7fbc26..31a3a7074f2 100644 --- a/Stream_support/include/CGAL/IO/GOCAD.h +++ b/Stream_support/include/CGAL/IO/GOCAD.h @@ -48,7 +48,7 @@ bool read_GOCAD(std::istream& is, typedef typename boost::range_value::type Point; typedef typename boost::range_value::type Poly; - const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), true); + const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); if(!is) { @@ -160,6 +160,8 @@ bool read_GOCAD(std::istream& is, * * \brief reads the content of `is` into `points` and `polygons`, using the \ref IOStreamGocad. * + * \attention The polygon soup is not cleared, and the data from the stream are appended. + * * \tparam PointRange a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` * whose value type is the point type * \tparam PolygonRange a model of the concepts `SequenceContainer` and `BackInsertionSequence` @@ -178,7 +180,7 @@ bool read_GOCAD(std::istream& is, * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * @@ -215,6 +217,8 @@ bool read_GOCAD(std::istream& is, PointRange& points, PolygonRange& polygons, * * \brief reads the content of the file `fname` into `points` and `polygons`, using the \ref IOStreamGocad. * + * \attention The polygon soup is not cleared, and the data from the file are appended. + * * \tparam PointRange a model of the concepts `RandomAccessContainer` and `BackInsertionSequence` * whose value type is the point type * \tparam PolygonRange a model of the concepts `SequenceContainer` and `BackInsertionSequence` @@ -233,14 +237,14 @@ bool read_GOCAD(std::istream& is, PointRange& points, PolygonRange& polygons, * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * * \returns `true` if the reading was successful, `false` otherwise. */ template -bool read_GOCAD(const char* fname, +bool read_GOCAD(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -257,20 +261,6 @@ bool read_GOCAD(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_GOCAD(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return read_GOCAD(fname.c_str(), points, polygons, np); -} - -template -bool read_GOCAD(const char* fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_GOCAD(fname, points, polygons, parameters::all_default()); -} - template bool read_GOCAD(const std::string& fname, PointRange& points, PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) @@ -429,7 +419,7 @@ bool write_GOCAD(std::ostream& os, const PointRange& points, const PolygonRange& template -bool write_GOCAD(const char* fname, +bool write_GOCAD(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -440,29 +430,17 @@ bool write_GOCAD(const char* fname, { std::ofstream os(fname); CGAL::set_mode(os, CGAL::IO::ASCII); - return IO::internal::write_GOCAD(os, fname, points, polygons, np); + return IO::internal::write_GOCAD(os, fname.c_str(), points, polygons, np); } /// \cond SKIP_IN_MANUAL -template -bool write_GOCAD(const char* fname, const PointRange& points, const PolygonRange& polygons) -{ - return write_GOCAD(fname, points, polygons, parameters::all_default()); -} - -template -bool write_GOCAD(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_GOCAD(fname.c_str(), points, polygons, np); -} template bool write_GOCAD(const std::string& fname, const PointRange& points, const PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) { - return write_GOCAD(fname.c_str(), points, polygons, parameters::all_default()); + return write_GOCAD(fname, points, polygons, parameters::all_default()); } /// \endcond diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 36bc285274f..2837de86ee0 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -50,7 +50,7 @@ bool read_OBJ(std::istream& is, PolygonRange& polygons, VertexNormalOutputIterator, VertexTextureOutputIterator, - const bool verbose = true) + const bool verbose = false) { if(!is.good()) { @@ -190,6 +190,8 @@ bool read_OBJ(std::istream& is, /// /// \brief reads the content of `is` into `points` and `polygons`, using the \ref IOStreamOBJ. /// +/// \attention The polygon soup is not cleared, and the data from the stream are appended. +/// /// \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. /// \tparam PolygonRange a model of the concepts `SequenceContainer` and `BackInsertionSequence` /// whose `value_type` is itself a model of the concepts `SequenceContainer` @@ -207,7 +209,7 @@ bool read_OBJ(std::istream& is, /// \cgalParamNBegin{verbose} /// \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} /// \cgalParamType{Boolean} -/// \cgalParamDefault{`true`} +/// \cgalParamDefault{`false`} /// \cgalParamNEnd /// \cgalNamedParamsEnd /// @@ -222,7 +224,7 @@ bool read_OBJ(std::istream& is, #endif ) { - const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), true); + const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); return IO::internal::read_OBJ(is, points, polygons, CGAL::Emptyset_iterator(), CGAL::Emptyset_iterator(), @@ -244,6 +246,8 @@ bool read_OBJ(std::istream& is, PointRange& points, PolygonRange& polygons, /// /// \brief reads the content of the file `fname` into `points` and `polygons`, using the \ref IOStreamOBJ. /// +/// \attention The polygon soup is not cleared, and the data from the file are appended. +/// /// \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. /// \tparam PolygonRange a model of the concepts `SequenceContainer` and `BackInsertionSequence` /// whose `value_type` is itself a model of the concept `SequenceContainer` @@ -261,13 +265,13 @@ bool read_OBJ(std::istream& is, PointRange& points, PolygonRange& polygons, /// \cgalParamNBegin{verbose} /// \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} /// \cgalParamType{Boolean} -/// \cgalParamDefault{`true`} +/// \cgalParamDefault{`false`} /// \cgalParamNEnd /// \cgalNamedParamsEnd /// /// \returns `true` if the reading was successful, `false` otherwise. template -bool read_OBJ(const char* fname, +bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -276,27 +280,13 @@ bool read_OBJ(const char* fname, #endif ) { - std::ifstream in(fname); + std::ifstream is(fname); CGAL::set_mode(is, CGAL::IO::ASCII); - return read_OBJ(in, points, polygons, np); + return read_OBJ(is, points, polygons, np); } /// \cond SKIP_IN_MANUAL -template -bool read_OBJ(const char* fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_OBJ(fname, points, polygons, parameters::all_default()); -} - -template -bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return read_OBJ(fname.c_str(), points, polygons, np); -} - template bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) @@ -395,7 +385,7 @@ bool write_OBJ(std::ostream& os, const PointRange& points, const PolygonRange& p template -bool write_OBJ(const char* fname, +bool write_OBJ(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -411,25 +401,11 @@ bool write_OBJ(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool write_OBJ(const char* fname, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_OBJ(fname, points, polygons, parameters::all_default()); -} - -template -bool write_OBJ(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_OBJ(fname.c_str(), points, polygons, np); -} - template bool write_OBJ(const std::string& fname, const PointRange& points, const PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) { - return write_OBJ(fname.c_str(), points, polygons, parameters::all_default()); + return write_OBJ(fname, points, polygons, parameters::all_default()); } /// \endcond diff --git a/Stream_support/include/CGAL/IO/OFF.h b/Stream_support/include/CGAL/IO/OFF.h index 2b28bd710e9..11299c84d18 100644 --- a/Stream_support/include/CGAL/IO/OFF.h +++ b/Stream_support/include/CGAL/IO/OFF.h @@ -57,7 +57,7 @@ bool read_OFF(std::istream& is, VertexColorOutputIterator vc_out, VertexTextureOutputIterator vt_out, FaceColorOutputIterator fc_out, - const bool verbose = true) + const bool verbose = false) { typedef typename boost::range_value::type Point; typedef typename CGAL::Kernel_traits::Kernel Kernel; @@ -186,7 +186,7 @@ bool read_OFF(std::istream& is, * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * @@ -250,14 +250,14 @@ bool read_OFF(std::istream& is, PointRange& points, PolygonRange& polygons, * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * * \returns `true` if the reading was successful, `false` otherwise. */ template -bool read_OFF(const char* fname, +bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -272,20 +272,6 @@ bool read_OFF(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_OFF(const char* fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_OFF(fname, points, polygons, parameters::all_default()); -} - -template -bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return read_OFF(fname.c_str(), points, polygons, np); -} - template bool read_OFF(const std::string& fname, PointRange& points, PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) @@ -379,7 +365,7 @@ bool write_OFF(std::ostream& os, const PointRange& points, const PolygonRange& p * \return `true` if the writing was successful, `false` otherwise. */ template -bool write_OFF(const char* fname, +bool write_OFF(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -395,20 +381,6 @@ bool write_OFF(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool write_OFF(const char* fname, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_OFF(fname, points, polygons, parameters::all_default()); -} - -template -bool write_OFF(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_OFF(fname.c_str(), points, polygons, np); -} - template bool write_OFF(const std::string& fname, const PointRange& points, const PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) diff --git a/Stream_support/include/CGAL/IO/PLY.h b/Stream_support/include/CGAL/IO/PLY.h index e2c8052c9c1..ccf9245b31f 100644 --- a/Stream_support/include/CGAL/IO/PLY.h +++ b/Stream_support/include/CGAL/IO/PLY.h @@ -55,7 +55,7 @@ bool read_PLY(std::istream& is, ColorOutputIterator fc_out, ColorOutputIterator vc_out, HUVOutputIterator huvs_out, - const bool verbose = true, + const bool verbose = false, typename std::enable_if::value>::type* = nullptr) { typedef typename boost::range_value::type Point_3; @@ -237,7 +237,7 @@ bool read_PLY(std::istream& is, ColorRange& fcolors, ColorRange& vcolors, HUVRange& huvs, - const bool verbose = true, + const bool verbose = false, typename boost::enable_if >::type* = nullptr) { return IO::internal::read_PLY(is, points, polygons, @@ -254,7 +254,7 @@ bool read_PLY(std::istream& is, PolygonRange& polygons, ColorRange& fcolors, ColorRange& vcolors, - const bool verbose = true) + const bool verbose = false) { std::vector > dummy_pui; std::vector > dummy_pf; @@ -274,6 +274,8 @@ bool read_PLY(std::istream& is, * * \brief reads the content of `is` into `points` and `polygons`, using the \ref IOStreamPLY. * + * \attention The polygon soup is not cleared, and the data from the stream are appended. + * * \attention When reading a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ifstream`. * * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type @@ -299,7 +301,7 @@ bool read_PLY(std::istream& is, * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * @@ -346,6 +348,8 @@ bool read_PLY(std::istream& is, PointRange& points, PolygonRange& polygons, * * \brief reads the content of `fname` into `points` and `polygons`, using the \ref IOStreamPLY. * + * \attention The polygon soup is not cleared, and the data from the file are appended. + * * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. * \tparam PolygonRange a model of the concepts `SequenceContainer` and `BackInsertionSequence` * whose `value_type` is itself a model of the concept `SequenceContainer` @@ -368,14 +372,14 @@ bool read_PLY(std::istream& is, PointRange& points, PolygonRange& polygons, * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * * \returns `true` if the reading was successful, `false` otherwise. */ template -bool read_PLY(const char* fname, +bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -401,25 +405,11 @@ bool read_PLY(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool read_PLY(const char* fname, PointRange& points, PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return read_PLY(fname, points, polygons, parameters::all_default()); -} - -template -bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return read_PLY(fname.c_str(), points, polygons, np); -} - template bool read_PLY(const std::string& fname, PointRange& points, PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) { - return read_PLY(fname.c_str(), points, polygons, parameters::all_default()); + return read_PLY(fname, points, polygons, parameters::all_default()); } /// \endcond @@ -552,7 +542,7 @@ bool write_PLY(std::ostream& out, const PointRange& points, const PolygonRange& * \return `true` if the writing was successful, `false` otherwise. */ template -bool write_PLY(const char* fname, +bool write_PLY(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np @@ -578,25 +568,11 @@ bool write_PLY(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool write_PLY(const char* fname, const PointRange& points, const PolygonRange& polygons, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(fname, points, polygons, parameters::all_default()); -} - -template -bool write_PLY(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_PLY(fname.c_str(), points, polygons, np); -} - template bool write_PLY(const std::string& fname, const PointRange& points, const PolygonRange& polygons, typename boost::enable_if >::type* = nullptr) { - return write_PLY(fname.c_str(), points, polygons, parameters::all_default()); + return write_PLY(fname, points, polygons, parameters::all_default()); } /// \endcond diff --git a/Stream_support/include/CGAL/IO/STL.h b/Stream_support/include/CGAL/IO/STL.h index 44846711590..bd704dd90ca 100644 --- a/Stream_support/include/CGAL/IO/STL.h +++ b/Stream_support/include/CGAL/IO/STL.h @@ -45,6 +45,8 @@ namespace CGAL { * * \brief reads the content of `is` into `points` and `facets`, using the \ref IOStreamSTL. * + * \attention The polygon soup is not cleared, and the data from the stream are appended. + * * \attention When reading a binary file, the flag `std::ios::binary` flag must be set during the creation of the `ifstream`. * * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. @@ -62,7 +64,7 @@ namespace CGAL { * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * @@ -78,7 +80,7 @@ bool read_STL(std::istream& is, #endif ) { - const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), true); + const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); if(!is.good()) { @@ -178,6 +180,8 @@ bool read_STL(std::istream& is, PointRange& points, TriangleRange& facets, * * \brief reads the content of a file named `fname` into `points` and `facets`, using the \ref IOStreamSTL. * + * \attention The polygon soup is not cleared, and the data from the file are appended. + * * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. * \tparam TriangleRange a model of the concept `SequenceContainer` * whose `value_type` is itself a model of the concept `SequenceContainer` @@ -199,14 +203,17 @@ bool read_STL(std::istream& is, PointRange& points, TriangleRange& facets, * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * * \returns `true` if the reading was successful, `false` otherwise. */ template -bool read_STL(const char* fname, PointRange& points, TriangleRange& facets, const CGAL_BGL_NP_CLASS& np +bool read_STL(const std::string& fname, + PointRange& points, + TriangleRange& facets, + const CGAL_BGL_NP_CLASS& np #ifndef DOXYGEN_RUNNING , typename boost::enable_if >::type* = nullptr #endif @@ -229,20 +236,6 @@ bool read_STL(const char* fname, PointRange& points, TriangleRange& facets, cons /// \cond SKIP_IN_MANUAL -template -bool read_STL(const char* fname, PointRange& points, TriangleRange& facets, - typename boost::enable_if >::type* = nullptr) -{ - return read_STL(fname, points, facets, parameters::all_default()); -} - -template -bool read_STL(const std::string& fname, PointRange& points, TriangleRange& facets, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return read_STL(fname.c_str(), points, facets, np); -} - template bool read_STL(const std::string& fname, PointRange& points, TriangleRange& facets, typename boost::enable_if >::type* = nullptr) @@ -376,6 +369,8 @@ bool write_STL(std::ostream& os, const PointRange& points, const TriangleRange& * * \brief writes the content of `points` and `facets` in a file named `fname`, using the \ref IOStreamSTL. * + * \attention The polygon soup is not cleared, and the data from the file are appended. + * * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type. * \tparam TriangleRange a model of the concept `SequenceContainer` * whose `value_type` is itself a model of the concept `SequenceContainer` @@ -405,7 +400,7 @@ bool write_STL(std::ostream& os, const PointRange& points, const TriangleRange& * \return `true` if the writing was successful, `false` otherwise. */ template -bool write_STL(const char* fname, +bool write_STL(const std::string& fname, const PointRange& points, const TriangleRange& facets, const CGAL_BGL_NP_CLASS& np @@ -431,25 +426,11 @@ bool write_STL(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool write_STL(const char* fname, const PointRange& points, const TriangleRange& facets, - typename boost::enable_if >::type* = nullptr) -{ - return write_STL(fname, points, facets, parameters::all_default()); -} - -template -bool write_STL(const std::string& fname, const PointRange& points, const TriangleRange& facets, const CGAL_BGL_NP_CLASS& np, - typename boost::enable_if >::type* = nullptr) -{ - return write_STL(fname.c_str(), points, facets, np); -} - template bool write_STL(const std::string& fname, const PointRange& points, const TriangleRange& facets, typename boost::enable_if >::type* = nullptr) { - return write_STL(fname.c_str(), points, facets, parameters::all_default()); + return write_STL(fname, points, facets, parameters::all_default()); } /// \endcond diff --git a/Stream_support/include/CGAL/IO/STL/STL_reader.h b/Stream_support/include/CGAL/IO/STL/STL_reader.h index 5126e5a08d8..09aaf71f4ab 100644 --- a/Stream_support/include/CGAL/IO/STL/STL_reader.h +++ b/Stream_support/include/CGAL/IO/STL/STL_reader.h @@ -34,7 +34,7 @@ bool read_ASCII_facet(std::istream& is, TriangleRange& facets, int& index, IndexMap& index_map, - const bool verbose = true) + const bool verbose = false) { typedef typename boost::range_value::type Point; typedef typename boost::range_value::type Triangle; @@ -113,7 +113,7 @@ template bool parse_ASCII_STL(std::istream& is, PointRange& points, TriangleRange& facets, - const bool verbose = true) + const bool verbose = false) { typedef typename boost::range_value::type Point; bool solid_found = false; @@ -166,7 +166,7 @@ template bool parse_binary_STL(std::istream& is, PointRange& points, TriangleRange& facets, - const bool verbose = true) + const bool verbose = false) { typedef typename boost::range_value::type Point; typedef typename boost::range_value::type Triangle; diff --git a/Stream_support/include/CGAL/IO/VTK.h b/Stream_support/include/CGAL/IO/VTK.h index 4e07fb4c282..c161cfa4a61 100644 --- a/Stream_support/include/CGAL/IO/VTK.h +++ b/Stream_support/include/CGAL/IO/VTK.h @@ -97,7 +97,7 @@ bool vtkPointSet_to_polygon_soup(vtkPointSet* poly_data, // Read template -bool read_VTP(const char* fname, +bool read_VTP(const std::string& fname, PointRange& points, PolygonRange& polygons, const NamedParameters& np) @@ -125,6 +125,8 @@ bool read_VTP(const char* fname, * * \brief reads the content of `is` into `points` and `polygons`, using the \ref IOStreamVTK. * + * \attention The polygon soup is not cleared, and the data from the file are appended. + * * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type * \tparam PolygonRange a model of the concepts `SequenceContainer` and `BackInsertionSequence` * whose `value_type` is itself a model of the concept `SequenceContainer` @@ -139,20 +141,9 @@ bool read_VTP(const char* fname, * \returns `true` if the reading was successful, `false` otherwise. */ template -bool read_VTP(const char* fname, PointRange& points, PolygonRange& polygons) -{ - return read_VTP(fname, points, polygons, parameters::all_default()); -} - -template -bool read_VTP(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np) -{ - return read_VTP(fname.c_str(), points, polygons, np); -} -template bool read_VTP(const std::string& fname, PointRange& points, PolygonRange& polygons) { - return read_VTP(fname.c_str(), points, polygons, parameters::all_default()); + return read_VTP(fname, points, polygons, parameters::all_default()); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -489,7 +480,7 @@ bool write_VTP(std::ostream& os, const PointRange& points, const PolygonRange& p * \return `true` if the writing was successful, `false` otherwise. */ template -bool write_VTP(const char* fname, +bool write_VTP(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np) @@ -511,22 +502,10 @@ bool write_VTP(const char* fname, /// \cond SKIP_IN_MANUAL -template -bool write_VTP(const char* fname, const PointRange& points, const PolygonRange& polygons) -{ - return write_VTP(fname, points, polygons, parameters::all_default()); -} - -template -bool write_VTP(const std::string& fname, const PointRange& points, const PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np) -{ - return write_VTP(fname.c_str(), points, polygons, np); -} - template bool write_VTP(const std::string& fname, const PointRange& points, const PolygonRange& polygons) { - return write_VTP(fname.c_str(), points, polygons, parameters::all_default()); + return write_VTP(fname, points, polygons, parameters::all_default()); } /// \endcond diff --git a/Stream_support/include/CGAL/IO/polygon_soup_io.h b/Stream_support/include/CGAL/IO/polygon_soup_io.h index c443d4bae78..e424be4144c 100644 --- a/Stream_support/include/CGAL/IO/polygon_soup_io.h +++ b/Stream_support/include/CGAL/IO/polygon_soup_io.h @@ -37,15 +37,49 @@ namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// // Read -/// \cond SKIP_IN_MANUAL - +/*! + * \ingroup IOstreamFunctions + * + * \brief reads a polygon soup from a file. + * + * Supported file formats are the following: + * - \ref IOStreamOFF (`.off`) + * - \ref IOStreamOBJ (`.obj`) + * - \ref IOStreamSTL (`.stl`) + * - \ref IOStreamPLY (`.ply`) + * - \ref IOStreamGocad (`.ts`) + * - \ref IOStreamVTK (`.vtp`) + * + * The format is detected from the filename extension (letter case is not important). + * + * \tparam PolygonRange a model of the concept `RandomAccessContainer` + * whose `value_type` is a model of the concept `RandomAccessContainer` + * whose `value_type` is `std::size_t`. + * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type + * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * \param fname the name of the file. + * \param points points of the soup of polygons + * \param polygons each element in the range describes a polygon using the indices of the vertices. + * \param np optional \ref bgl_namedparameters "Named Parameters" described below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{verbose} + * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} + * \cgalParamType{Boolean} + * \cgalParamDefault{`false`} + * \cgalParamNEnd + * \cgalNamedParamsEnd + * + * \return `true` if reading was successful, `false` otherwise. + */ template bool read_polygon_soup(const std::string& fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np) { - const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), true); + const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); const std::string ext = IO::internal::get_file_extension(fname); if(ext == std::string()) @@ -79,6 +113,8 @@ bool read_polygon_soup(const std::string& fname, return false; } +/// \cond SKIP_IN_MANUAL + template bool read_polygon_soup(const std::string& fname, PointRange& points, PolygonRange& polygons) { @@ -87,117 +123,10 @@ bool read_polygon_soup(const std::string& fname, PointRange& points, PolygonRang /// \endcond -/*! - * \ingroup IOstreamFunctions - * - * \brief reads a polygon soup from a file. - * - * Supported file formats are the following: - * - \ref IOStreamOFF (`.off`) - * - \ref IOStreamOBJ (`.obj`) - * - \ref IOStreamSTL (`.stl`) - * - \ref IOStreamPLY (`.ply`) - * - \ref IOStreamGocad (`.ts`) - * - \ref IOStreamVTK (`.vtp`) - * - * The format is detected from the filename extension (letter case is not important). - * - * \tparam PolygonRange a model of the concept `RandomAccessContainer` - * whose `value_type` is a model of the concept `RandomAccessContainer` - * whose `value_type` is `std::size_t`. - * \tparam PointRange a model of the concept `RandomAccessContainer` whose value type is the point type - * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - * - * \param fname the name of the file. - * \param points points of the soup of polygons - * \param polygons each element in the range describes a polygon using the indices of the vertices. - * \param np optional \ref bgl_namedparameters "Named Parameters" described below - * - * \cgalNamedParamsBegin - * \cgalParamNBegin{verbose} - * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} - * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} - * \cgalParamNEnd - * \cgalNamedParamsEnd - * - * \return `true` if reading was successful, `false` otherwise. - */ -template -bool read_polygon_soup(const char* fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np) -{ - return read_OBJ(std::string(fname), points, polygons, np); -} - -/// \cond SKIP_IN_MANUAL - -template -bool read_polygon_soup(const char* fname, PointRange& points, PolygonRange& polygons) -{ - return read_OBJ(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Write -/// \cond SKIP_IN_MANUAL - -template -bool write_polygon_soup(const std::string& fname, - const PointRange& points, - const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) -{ - const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), true); - - const std::string ext = IO::internal::get_file_extension(fname); - if(ext == std::string()) - { - if(verbose) - std::cerr << "Error: trying to output to file without extension" << std::endl; - return false; - } - - if(ext == "obj") - return write_OBJ(fname, points, polygons, np); - else if(ext == "off") - return write_OFF(fname, points, polygons, np); - else if(ext == "ply") - return write_PLY(fname, points, polygons, np); - else if(ext == "stl") - return write_STL(fname, points, polygons, np); - else if(ext == "ts") - return write_GOCAD(fname, points, polygons, np); -#ifdef CGAL_USE_VTK - else if(ext == "vtp") - return write_VTP(fname, points, polygons, np); -#endif -#ifdef CGAL_LINKED_WITH_3MF - else if(ext == "3mf") - return write_3MF(fname, points, polygons); -#endif - - - if(verbose) - { - std::cerr << "Error: unknown output file extension: " << ext << "\n" - << "Please refer to the documentation for the list of supported file formats" << std::endl; - } - - return false; -} - -template -bool write_polygon_soup(const std::string& fname, PointRange& points, PolygonRange& polygons) -{ - return write_polygon_soup(fname, points, polygons, parameters::all_default()); -} - -/// \endcond - /*! * \ingroup IOstreamFunctions * @@ -228,22 +157,60 @@ bool write_polygon_soup(const std::string& fname, PointRange& points, PolygonRan * \cgalParamNBegin{verbose} * \cgalParamDescription{indicates whether output warnings and error messages should be printed or not.} * \cgalParamType{Boolean} - * \cgalParamDefault{`true`} + * \cgalParamDefault{`false`} * \cgalParamNEnd * \cgalNamedParamsEnd * * \return `true` if writing was successful, `false` otherwise. */ template -bool write_polygon_soup(const char* fname, PointRange& points, PolygonRange& polygons, const CGAL_BGL_NP_CLASS& np) +bool write_polygon_soup(const std::string& fname, + const PointRange& points, + const PolygonRange& polygons, + const CGAL_BGL_NP_CLASS& np) { - return write_polygon_soup(std::string(fname), points, polygons, np); + const bool verbose = parameters::choose_parameter(parameters::get_parameter(np, internal_np::verbose), false); + + const std::string ext = IO::internal::get_file_extension(fname); + if(ext == std::string()) + { + if(verbose) + std::cerr << "Error: trying to output to file without extension" << std::endl; + return false; + } + + if(ext == "obj") + return write_OBJ(fname, points, polygons, np); + else if(ext == "off") + return write_OFF(fname, points, polygons, np); + else if(ext == "ply") + return write_PLY(fname, points, polygons, np); + else if(ext == "stl") + return write_STL(fname, points, polygons, np); + else if(ext == "ts") + return write_GOCAD(fname, points, polygons, np); +#ifdef CGAL_USE_VTK + else if(ext == "vtp") + return write_VTP(fname, points, polygons, np); +#endif +#ifdef CGAL_LINKED_WITH_3MF + else if(ext == "3mf") + return write_3MF(fname, points, polygons); +#endif + + if(verbose) + { + std::cerr << "Error: unknown output file extension: " << ext << "\n" + << "Please refer to the documentation for the list of supported file formats" << std::endl; + } + + return false; } /// \cond SKIP_IN_MANUAL template -bool write_polygon_soup(const char* fname, PointRange& points, PolygonRange& polygons) +bool write_polygon_soup(const std::string& fname, PointRange& points, PolygonRange& polygons) { return write_polygon_soup(fname, points, polygons, parameters::all_default()); } diff --git a/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h b/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h index fcc3850f7d8..a635ebddfba 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/IO/OFF.h @@ -269,7 +269,7 @@ bool read_OFF_with_or_without_vnormals(std::istream& is, /// /// Ignores comment lines which start with a hash, and lines with whitespace. /// -/// \attention The graph `g` is not cleared, and the data from the stream is added. +/// \attention The graph `sm` is not cleared, and the data from the stream is added. /// /// \tparam Point The type of the \em point property of a vertex. There is no requirement on `P`, /// besides being default constructible and assignable.