From 9247fdab0202240afc9718a6878780f04afb858f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sat, 25 Jan 2020 15:05:47 +0100 Subject: [PATCH] Add a polygon soup obj reader --- Stream_support/include/CGAL/IO/OBJ.h | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 6f9cca0dc62..a3b4b53e5a9 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -18,6 +18,10 @@ namespace CGAL { +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// Read + //! \ingroup IOstreamFunctions //! /// reads the content of `input` into `points` and `faces`, using the `OBJ` format. @@ -90,6 +94,48 @@ bool read_OBJ(std::istream& input, return !input.fail(); } +//////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// Write + + +/*! + * \ingroup IOstreamFunctions + * + * writes the content of `points` and `polygons` in `out`, in the OBJ format. + * + * \see \ref IOStreamOBJ + */ +template +bool write_OBJ(std::ostream& out, + std::vector& points, + std::vector& polygons) +{ + CGAL::File_writer_wavefront writer; + writer.write_header(out, points.size(), 0, polygons.size()); + + for(std::size_t i = 0, end = points.size(); i