diff --git a/BGL/test/BGL/test_bgl_read_write.cpp b/BGL/test/BGL/test_bgl_read_write.cpp index 47a242d66f8..a1c7a834a03 100644 --- a/BGL/test/BGL/test_bgl_read_write.cpp +++ b/BGL/test/BGL/test_bgl_read_write.cpp @@ -290,7 +290,7 @@ bool test_soup_vtp(bool binary = false) #endif template -bool test_gocad() +bool test_bgl_gocad() { FaceGraph fg; CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0), @@ -333,6 +333,55 @@ bool test_gocad() return true; } +template +bool test_bgl_gocad_with_np() +{ + + typedef typename boost::property_map::type VertexPointMap; + FaceGraph fg; + CGAL::make_tetrahedron(Point(0, 0, 0), Point(1, 1, 0), + Point(2, 0, 1), Point(3, 0, 0), fg); + VertexPointMap vpm = get(CGAL::vertex_point, fg); + + std::ostringstream out; + CGAL::write_GOCAD(out, "tetrahedron", fg, CGAL::parameters::vertex_point_map(vpm)); + if(out.fail()) + { + std::cerr<<"Tetrahedron writing failed."< cnn; + CGAL::read_GOCAD(in, cnn, fg2, CGAL::parameters::vertex_point_map(vpm2)); + if(cnn.first != "tetrahedron"){ + std::cerr<<"reading error: tetrahedron != "<(filename); test_bgl_OFF(filename); @@ -575,23 +622,29 @@ int main(int argc, char** argv) if(!test_bgl_PLY_with_np(true)) return 1; - */ + // GOCAD - if(!test_gocad()) + if(!test_bgl_gocad()) return 1; - if(!test_gocad()) + if(!test_bgl_gocad()) return 1; - if(!test_gocad()) + if(!test_bgl_gocad()) + return 1; + if(!test_bgl_gocad_with_np()) + return 1; + if(!test_bgl_gocad_with_np()) + return 1; + if(!test_bgl_gocad_with_np()) return 1; if(!test_soup_gocad()) return 1; -/* + // STL - if(!test_STL()) + if(!test_bgl_stl()) return 1; - if(!test_STL()) + if(!test_bgl_stl()) return 1; - if(!test_STL()) + if(!test_bgl_stl()) return 1; // VTP @@ -614,6 +667,6 @@ int main(int argc, char** argv) if(!test_soup_vtp(true)) return 1; #endif -*/ + return EXIT_SUCCESS; } diff --git a/Stream_support/include/CGAL/IO/GOCAD.h b/Stream_support/include/CGAL/IO/GOCAD.h index 40fce28a33f..22da532ac60 100644 --- a/Stream_support/include/CGAL/IO/GOCAD.h +++ b/Stream_support/include/CGAL/IO/GOCAD.h @@ -102,13 +102,7 @@ bool read_GOCAD(std::istream& input, return !input.fail(); } -/*! - * \ingroup IOstreamFunctions - * - * reads the content of `is` into `points` and `polygons`, in the GOCAD format. - * - * \see \ref IOStreamGocad - */ + template bool read_GOCAD(std::istream& is, PointRange& points, @@ -119,13 +113,7 @@ bool read_GOCAD(std::istream& is, return read_GOCAD(is, dummy, points, polygons, np); } -/*! - * \ingroup IOstreamFunctions - * - * reads the content of the file `fname` into `points` and `polygons`, in the GOCAD format. - * - * \see \ref IOStreamGocad - */ + template bool read_GOCAD(const char* fname, PointRange& points, @@ -137,8 +125,21 @@ bool read_GOCAD(const char* fname, return read_GOCAD(in, dummy, points, polygons, np); } - - +template +bool read_GOCAD(const std::string& fname, + PointRange& points, + PolygonRange& polygons, + const NamedParameters& np) +{ + return read_GOCAD(fname.c_str(), points, polygons, np); +} +/*! + * \ingroup IOstreamFunctions + * + * reads the content of `is` into `points` and `polygons`, in the GOCAD format. + * + * \see \ref IOStreamGocad + */ template bool read_GOCAD(std::istream& is, PointRange& points, PolygonRange& polygons) { @@ -146,12 +147,24 @@ bool read_GOCAD(std::istream& is, PointRange& points, PolygonRange& polygons) return read_GOCAD(is, dummy, points, polygons, parameters::all_default()); } +/*! + * \ingroup IOstreamFunctions + * + * reads the content of the file `fname` into `points` and `polygons`, in the GOCAD format. + * + * \see \ref IOStreamGocad + */ template bool read_GOCAD(const char* fname, PointRange& points, PolygonRange& polygons) { return read_GOCAD(fname, points, polygons, parameters::all_default()); } +template +bool read_GOCAD(const std::string& fname, PointRange& points, PolygonRange& polygons) +{ + return read_GOCAD(fname, points, polygons, parameters::all_default()); +} //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -208,13 +221,7 @@ bool write_GOCAD(std::ostream& os, } } //end internal }//end IO -/*! - \ingroup IOstreamFunctions - * writes the content of `points` and `polygons` in `out`, in the TS format. - - \see \ref IOStreamGocad -*/ template @@ -226,7 +233,13 @@ bool write_GOCAD(std::ostream& os, return IO::internal::write_GOCAD(os, "anonymous", points, polygons, np); } +/*! + \ingroup IOstreamFunctions + * writes the content of `points` and `polygons` in `out`, in the TS format. + + \see \ref IOStreamGocad +*/ template bool write_GOCAD(std::ostream& os, @@ -237,13 +250,6 @@ bool write_GOCAD(std::ostream& os, } -/*! - \ingroup IOstreamFunctions - - * writes the content of `points` and `polygons` in a file named `fname`, in the TS format. - - \see \ref IOStreamGocad -*/ template @@ -256,6 +262,14 @@ bool write_GOCAD(const char* fname, return IO::internal::write_GOCAD(os, fname, points, polygons, np); } + +/*! + \ingroup IOstreamFunctions + + * writes the content of `points` and `polygons` in a file named `fname`, in the TS format. + + \see \ref IOStreamGocad +*/ template bool write_GOCAD(const char* fname, diff --git a/Stream_support/include/CGAL/IO/OBJ.h b/Stream_support/include/CGAL/IO/OBJ.h index 15c19b2f167..33472ecdfeb 100644 --- a/Stream_support/include/CGAL/IO/OBJ.h +++ b/Stream_support/include/CGAL/IO/OBJ.h @@ -114,14 +114,7 @@ bool read_OBJ(std::istream& is, } // namespace internal } // namespace IO -//! \ingroup IOstreamFunctions -//! -/// reads the content of `is` into `points` and `faces`, using the `OBJ` format. -/// -/// \tparam PointRange a `RandomAccessContainer` of `Point_3, -/// \tparam PolygonRange a `RandomAccessContainer` of `RandomAccessContainer` of `std::size_t` -/// -/// \see \ref IOStreamOBJ + template bool read_OBJ(std::istream& is, PointRange& points, @@ -136,14 +129,6 @@ bool read_OBJ(std::istream& is, CGAL::Emptyset_iterator())); } -//! \ingroup IOstreamFunctions -//! -/// reads the content of the file `fname` into `points` and `faces`, using the `OBJ` format. -/// -/// \tparam PointRange a `RandomAccessContainer` of `Point_3, -/// \tparam PolygonRange a `RandomAccessContainer` of `RandomAccessContainer` of `std::size_t` -/// -/// \see \ref IOStreamOBJ template bool read_OBJ(const char* fname, PointRange& points, @@ -160,12 +145,28 @@ bool read_OBJ(const std::string& fname, PointRange& points, PolygonRange& polygo return read_OBJ(fname.c_str(), points, polygons, np); } +//! \ingroup IOstreamFunctions +//! +/// reads the content of `is` into `points` and `faces`, using the `OBJ` format. +/// +/// \tparam PointRange a `RandomAccessContainer` of `Point_3, +/// \tparam PolygonRange a `RandomAccessContainer` of `RandomAccessContainer` of `std::size_t` +/// +/// \see \ref IOStreamOBJ template bool read_OBJ(std::istream& is, PointRange& points, PolygonRange& polygons) { return read_OBJ(is, points, polygons, parameters::all_default()); } +//! \ingroup IOstreamFunctions +//! +/// reads the content of the file `fname` into `points` and `faces`, using the `OBJ` format. +/// +/// \tparam PointRange a `RandomAccessContainer` of `Point_3, +/// \tparam PolygonRange a `RandomAccessContainer` of `RandomAccessContainer` of `std::size_t` +/// +/// \see \ref IOStreamOBJ template bool read_OBJ(const char* fname, PointRange& points, PolygonRange& polygons) { diff --git a/Stream_support/include/CGAL/IO/PLY.h b/Stream_support/include/CGAL/IO/PLY.h index bf567b667e8..0c7ef968a34 100644 --- a/Stream_support/include/CGAL/IO/PLY.h +++ b/Stream_support/include/CGAL/IO/PLY.h @@ -224,24 +224,6 @@ bool read_PLY(std::istream& is, } - -/*! - * \ingroup IOstreamFunctions - * - * reads the content of `is` into `points` and `polygons`, in the PLY format. - * - * `PointRange` is a model of the concepts `RandomAccessContainer` - * and `BackInsertionSequence` whose `value type` is a `CGAL::Point_3`. - * - * `PolygonRange` is a model of the concepts `RandomAccessContainer` - * and `BackInsertionSequence` whose `value type` is `std::size_t`. - * - \cgalNamedParamsBegin - \cgalParamBegin{face_color_map} the property map with the colors associated to the faces of `g`.\cgalParamEnd - \cgalParamBegin{vertex_color_map} the property map with the colors associated to the vertices of `g`.\cgalParamEnd - \cgalNamedParamsEnd - * \see \ref IOStreamPLY - */ template bool read_PLY(std::istream& is, PointRange& points, @@ -262,6 +244,21 @@ bool read_PLY(std::istream& is, std::back_inserter(dummy_pf)); } + + +/*! + * \ingroup IOstreamFunctions + * + * reads the content of `is` into `points` and `polygons`, in the PLY format. + * + * `PointRange` is a model of the concepts `RandomAccessContainer` + * and `BackInsertionSequence` whose `value type` is a `CGAL::Point_3`. + * + * `PolygonRange` is a model of the concepts `RandomAccessContainer` + * and `BackInsertionSequence` whose `value type` is `std::size_t`. + * + * \see \ref IOStreamPLY + */ template bool read_PLY(std::istream& is, @@ -352,6 +349,16 @@ read_PLY(std::istream& is, return !is.fail(); } +template +bool read_PLY(const char* fname, + PointRange& points, + PolygonRange& polygons, + const CGAL_BGL_NP_CLASS& np) +{ + std::ofstream os(fname); + return read_PLY(os, points, polygons, np); +} + /*! * \ingroup IOstreamFunctions * @@ -363,23 +370,8 @@ read_PLY(std::istream& is, * `PolygonRange` is a model of the concepts `RandomAccessContainer` * and `BackInsertionSequence` whose `value type` is `std::size_t`. - \cgalNamedParamsBegin - \cgalParamBegin{face_color_map} the property map with the colors associated to the faces of `g`.\cgalParamEnd - \cgalParamBegin{vertex_color_map} the property map with the colors associated to the vertices of `g`.\cgalParamEnd - \cgalNamedParamsEnd - * \see \ref IOStreamPLY */ -template -bool read_PLY(const char* fname, - PointRange& points, - PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) -{ - std::ofstream os(fname); - return read_PLY(os, points, polygons, np); -} - template bool read_PLY(const char* fname, PointRange& points, @@ -409,18 +401,6 @@ bool read_PLY(const std::string fname, //////////////////////////////////////////////////////////////////////////////////////////////////// /// Write -/*! - * \ingroup IOstreamFunctions - * - * writes the content of `points` and `polygons` in `out`, in the PLY format. - * - * `PointRange` is a model of the concepts `RandomAccessContainer` - * and `BackInsertionSequence` whose `value type` is a `CGAL::Point_3`. - * - * `PolygonRange` is a model of the concepts `RandomAccessContainer` - * and `BackInsertionSequence` whose `value type` is `std::size_t`. - * \see \ref IOStreamPLY - */ template bool write_PLY(std::ostream& out, const PointRange& points, @@ -472,6 +452,18 @@ bool write_PLY(std::ostream& out, } +/*! + * \ingroup IOstreamFunctions + * + * writes the content of `points` and `polygons` in `out`, in the PLY format. + * + * `PointRange` is a model of the concepts `RandomAccessContainer` + * and `BackInsertionSequence` whose `value type` is a `CGAL::Point_3`. + * + * `PolygonRange` is a model of the concepts `RandomAccessContainer` + * and `BackInsertionSequence` whose `value type` is `std::size_t`. + * \see \ref IOStreamPLY + */ template bool write_PLY(std::ostream& out, const PointRange& points, @@ -489,6 +481,17 @@ bool write_PLY(std::ostream& out, return write_PLY(out, points, polygons, parameters::all_default()); } +template +bool write_PLY(const char* fname, + const PointRange& points, + const PolygonRange& polygons, + const CGAL_BGL_NP_CLASS& np) +{ + std::ofstream os(fname); + return write_PLY(os, points, polygons, np); +} + + /*! * \ingroup IOstreamFunctions * @@ -501,16 +504,6 @@ bool write_PLY(std::ostream& out, * and `BackInsertionSequence` whose `value type` is `std::size_t`. * \see \ref IOStreamPLY */ -template -bool write_PLY(const char* fname, - const PointRange& points, - const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) -{ - std::ofstream os(fname); - return write_PLY(os, points, polygons, np); -} - template bool write_PLY(const char* fname, const PointRange& points, diff --git a/Stream_support/include/CGAL/IO/STL.h b/Stream_support/include/CGAL/IO/STL.h index c9df0f05868..5aeee3522bf 100644 --- a/Stream_support/include/CGAL/IO/STL.h +++ b/Stream_support/include/CGAL/IO/STL.h @@ -30,13 +30,6 @@ namespace CGAL { //////////////////////////////////////////////////////////////////////////////////////////////////// /// Read -/*! - * \ingroup IOstreamFunctions - * - * reads the content of `is` into `points` and `facets`, in the STL format. - * - * \see \ref IOStreamSTL - */ template bool read_STL(std::istream& is, PointRange& points, @@ -120,13 +113,6 @@ bool read_STL(std::istream& is, } } -/*! - * \ingroup IOstreamFunctions - * - * reads the content of a file named `fname` into `points` and `facets`, in the STL format. - * - * \see \ref IOStreamSTL - */ template bool read_STL(const char* fname, PointRange& points, @@ -143,12 +129,26 @@ bool read_STL(const std::string& fname, PointRange& points, TriangleRange& facet return read_STL(fname.c_str(), points, facets, np); } +/*! + * \ingroup IOstreamFunctions + * + * reads the content of `is` into `points` and `facets`, in the STL format. + * + * \see \ref IOStreamSTL + */ template bool read_STL(std::istream& is, PointRange& points, TriangleRange& facets) { return read_STL(is, points, facets, parameters::all_default()); } +/*! + * \ingroup IOstreamFunctions + * + * reads the content of a file named `fname` into `points` and `facets`, in the STL format. + * + * \see \ref IOStreamSTL + */ template bool read_STL(const char* fname, PointRange& points, TriangleRange& facets) { diff --git a/Stream_support/include/CGAL/IO/VTK.h b/Stream_support/include/CGAL/IO/VTK.h index 6ab6571c99b..bab6ae03f76 100644 --- a/Stream_support/include/CGAL/IO/VTK.h +++ b/Stream_support/include/CGAL/IO/VTK.h @@ -87,13 +87,6 @@ bool vtkPointSet_to_polygon_soup(vtkPointSet* poly_data, //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// /// Read -/*! - * \ingroup IOstreamFunctions - * - * reads the content of `is` into `points` and `polygons`, in the VTPformat. - * - * \see \ref IOStreamVTK - */ template bool read_VTP(const char* fname, PointRange& points, @@ -118,6 +111,13 @@ bool read_VTP(const std::string& fname, return read_VTP(fname.c_str(), points, polygons, np); } +/*! + * \ingroup IOstreamFunctions + * + * reads the content of `is` into `points` and `polygons`, in the VTPformat. + * + * \see \ref IOStreamVTK + */ template bool read_VTP(const char* fname, PointRange& points, @@ -338,18 +338,7 @@ void write_soup_polys_points(std::ostream& os, }//end internal }//end IO -/*! - * \ingroup IOstreamFunctions - * - * writes the content of `points` and `polygons` in `out`, in the VTP format. - * - * \cgalNamedParamsBegin - * \cgalParamBegin{use_binary_mode} a Boolean indicating if the - * data should be written in binary (`true`, the default) or in ASCII (`false`). - * \cgalParamEnd - * \cgalNamedParamsEnd - * \see \ref IOStreamVTK - */ + template bool write_VTP(std::ostream& os, const PointRange& points, @@ -398,6 +387,18 @@ bool write_VTP(std::ostream& os, os << "\n"; } +/*! + * \ingroup IOstreamFunctions + * + * writes the content of `points` and `polygons` in `out`, in the VTP format. + * + * \cgalNamedParamsBegin + * \cgalParamBegin{use_binary_mode} a Boolean indicating if the + * data should be written in binary (`true`, the default) or in ASCII (`false`). + * \cgalParamEnd + * \cgalNamedParamsEnd + * \see \ref IOStreamVTK + */ template bool write_VTP(std::ostream& os, const PointRange& points, @@ -406,6 +407,16 @@ bool write_VTP(std::ostream& os, return write_VTP(os, points, polygons, parameters::all_default()); } +template +bool write_VTP(const char* fname, + const PointRange& points, + const PolygonRange& polygons, + const CGAL_BGL_NP_CLASS& np) +{ + std::ofstream out(fname); + return write_VTP(out, points, polygons, np); +} + /*! * \ingroup IOstreamFunctions * @@ -418,16 +429,6 @@ bool write_VTP(std::ostream& os, * \cgalNamedParamsEnd * \see \ref IOStreamVTK */ -template -bool write_VTP(const char* fname, - const PointRange& points, - const PolygonRange& polygons, - const CGAL_BGL_NP_CLASS& np) -{ - std::ofstream out(fname); - return write_VTP(out, points, polygons, np); -} - template bool write_VTP(const char* fname, const PointRange& points,