Fix deprecation within Surface_mesh IO

This commit is contained in:
Mael Rouxel-Labbé 2020-06-23 12:51:53 +02:00
parent 8cab8d3a21
commit 239b01a546
5 changed files with 52 additions and 92 deletions

View File

@ -11,6 +11,9 @@
/// \defgroup PkgSurfaceMeshIOFunc I/O Functions
/// \ingroup PkgSurface_mesh
/// \defgroup PkgSurfaceMeshIOFuncDeprecated I/O Functions (Deprecated)
/// \ingroup PkgSurfaceMeshIOFunc
/*!
\addtogroup PkgSurface_mesh
\cgalPkgDescriptionBegin{Surface Mesh,PkgSurfaceMesh}

View File

@ -15,107 +15,37 @@
#include <CGAL/license/Surface_mesh.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <CGAL/Surface_mesh/Surface_mesh_fwd.h>
#include <CGAL/Surface_mesh/IO/3MF.h>
#include <CGAL/Surface_mesh/IO/OFF.h>
#include <CGAL/Surface_mesh/IO/PLY.h>
#include <CGAL/assertions.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/use.h>
#include <boost/array.hpp>
#include <CGAL/boost/graph/io.h>
#include <string>
#include <fstream>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stdexcept>
namespace CGAL {
// @todo move that to read_polygon_mesh in BGL
#ifndef CGAL_NO_DEPRECATED_CODE
/// \addtogroup PkgSurfaceMeshIO
///
/// I/O functionality for `Surface_mesh`. The top-level functions
/// `read_mesh()` and `write_mesh()` dispatch on the available readers
/// according to the file extension. Currently only `OFF` files are
/// supported.
///
/// @{
#if 0
/// Read a file into a `Surface_mesh`. The extension of the
/// filename determines which reader is used.
///
/// Mapping from extension to reader:
/// - off/OFF -> `read_OFF()`
///
/// @param mesh The mesh that should contain the input.
/// @param filename The name of the file to be read.
///
/// @return `true`, if reading succeeded, `false` otherwise
///
#endif
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_polygon_mesh()` should be used instead.
*/
template <typename K>
bool read_mesh(Surface_mesh<K>& mesh, const std::string& filename)
CGAL_DEPRECATED bool read_mesh(Surface_mesh<K>& sm, const std::string& filename)
{
// clear mesh before reading from file
mesh.clear();
// extract file extension
std::string::size_type dot(filename.rfind("."));
if(dot == std::string::npos) return false;
std::string ext = filename.substr(dot+1, filename.length()-dot-1);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
// extension determines reader
if(ext == "off")
{
return read_OFF(filename, mesh);
}
// we didn't find a reader module
return false;
return read_polygon_mesh(filename, sm);
}
#if 0
/// Write a `Surface_mesh` to a file. The extension of the
/// filename determines which writer is used.
///
/// Mapping from extension to writer:
/// - off/OFF -> `write_off()`
///
/// @param mesh The mesh to be written.
/// @param filename The name of the file to be written.
///
/// @return `true`, if writing succeeded, `false` otherwise
///
#endif
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_polygon_mesh()` should be used instead.
*/
template <typename K>
bool write_mesh(const Surface_mesh<K>& mesh, const std::string& filename)
CGAL_DEPRECATED bool write_mesh(const Surface_mesh<K>& mesh, const std::string& filename)
{
// extract file extension
std::string::size_type dot(filename.rfind("."));
if(dot == std::string::npos) return false;
std::string ext = filename.substr(dot+1, filename.length()-dot-1);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
// extension determines reader
if(ext == "off")
{
return write_OFF(filename, mesh);
}
// we didn't find a writer module
return false;
return write_polygon_mesh(filename, mesh);
}
/// @}
#endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL

View File

@ -130,6 +130,7 @@ int read_3MF(const std::string& filename,
#ifndef CGAL_NO_DEPRECATED_CODE
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_3MF()` should be used instead.
*/
template<typename Point>

View File

@ -346,23 +346,35 @@ bool read_OFF(std::istream& is,
#ifndef CGAL_NO_DEPRECATED_CODE
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF(std::istream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename Point, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool read_off(std::istream& is, Surface_mesh<Point>& sm, const CGAL_BGL_NP_CLASS& np)
CGAL_DEPRECATED bool read_off(std::istream& is, Surface_mesh<Point>& sm, const CGAL_BGL_NP_CLASS& np)
{
return read_OFF(is, sm, np);
}
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF(std::istream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename Point>
bool read_off(std::istream& is, Surface_mesh<Point>& sm)
CGAL_DEPRECATED bool read_off(std::istream& is, Surface_mesh<Point>& sm)
{
return read_OFF(is, sm, parameters::all_default());
}
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF(std::istream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename Point>
CGAL_DEPRECATED bool read_off(Surface_mesh<Point>& sm, const std::string& filename)
{
return read_OFF(filename, sm, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -573,23 +585,35 @@ bool write_OFF(std::ostream& os, const Surface_mesh<Point>& sm)
#ifndef CGAL_NO_DEPRECATED_CODE
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_OFF(std::ostream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename Point, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool write_off(std::ostream& os, const Surface_mesh<Point>& sm, const CGAL_BGL_NP_CLASS& np)
CGAL_DEPRECATED bool write_off(std::ostream& os, const Surface_mesh<Point>& sm, const CGAL_BGL_NP_CLASS& np)
{
return write_OFF(os, sm, np);
}
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_OFF(std::ostream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename Point>
bool write_off(std::ostream& os, const Surface_mesh<Point>& sm)
CGAL_DEPRECATED bool write_off(std::ostream& os, const Surface_mesh<Point>& sm)
{
return write_OFF(os, sm, parameters::all_default());
}
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_OFF(std::ostream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename Point>
CGAL_DEPRECATED bool write_off(const Surface_mesh<Point>& sm, const std::string& filename)
{
return write_OFF(filename, sm, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL

View File

@ -848,11 +848,12 @@ bool read_PLY(std::istream& is, Surface_mesh<P>& sm)
#ifndef CGAL_NO_DEPRECATED_CODE
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_PLY(std::ostream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename P>
bool read_ply(std::istream& is, Surface_mesh<P>& sm, std::string& comments)
CGAL_DEPRECATED bool read_ply(std::istream& is, Surface_mesh<P>& sm, std::string& comments)
{
return read_PLY(is, sm, comments);
}
@ -1116,11 +1117,12 @@ bool write_PLY(std::ostream& os, const Surface_mesh<P>& sm)
#ifndef CGAL_NO_DEPRECATED_CODE
/*!
\ingroup PkgSurfaceMeshIOFuncDeprecated
\deprecated This function is deprecated since \cgal 5.2, `CGAL::write_PLY(std::ostream&, const Surface_mesh<Point>&)` should be used instead.
*/
template <typename P>
bool write_ply(std::istream& is, Surface_mesh<P>& sm, std::string& comments)
CGAL_DEPRECATED bool write_ply(std::istream& is, Surface_mesh<P>& sm, std::string& comments)
{
return write_PLY(is, sm, comments);
}