diff --git a/Stream_support/include/CGAL/IO/WKT.h b/Stream_support/include/CGAL/IO/WKT.h index 3a3eea129d64..bf53a7b33983 100644 --- a/Stream_support/include/CGAL/IO/WKT.h +++ b/Stream_support/include/CGAL/IO/WKT.h @@ -156,9 +156,9 @@ bool read_multi_point_WKT(std::istream& in, //! //! The first line starting with LINESTRING in the stream will be used. //! -//! \tparam Linestring must be a model of `RandomAccessRange` of `CGAL::Point_2`, +//! \tparam Linestring must be a model of `RandomAccessRange` of `CGAL::Point_2` or `CGAL::Point_3`, //! and have: -//! - a function `push_back()` that takes a `CGAL::Point_2`. +//! - a function `push_back()` that takes a point. //! - a function `clear()`, //! - a function `resize()` that takes a `size_type` //! - an `operator[]()` that takes a `size_type`. @@ -166,6 +166,7 @@ bool read_multi_point_WKT(std::istream& in, //! \attention Only %Cartesian Kernels with double or float as `FT` are supported. //! //! \see `CGAL::Point_2` +//! \see `CGAL::Point_3` template bool read_linestring_WKT(std::istream& in, LineString& polyline) @@ -209,7 +210,6 @@ bool read_linestring_WKT(std::istream& in, //! //! \attention Only %Cartesian Kernels with double or float as `FT` are supported. //! -//! \see `CGAL::Point_2` template bool read_multi_linestring_WKT(std::istream& in, MultiLineString& mls) @@ -359,11 +359,12 @@ bool read_multi_polygon_WKT(std::istream& in, //! //! \brief writes `point` into a WKT stream. //! -//! \tparam Point is a `CGAL::Point_2` +//! \tparam Point is a `CGAL::Point_2` or `CGAL::Point_3` //! //! \attention Only %Cartesian Kernels with double or float as `FT` are supported. //! //! \see `CGAL::Point_2` +//! \see `CGAL::Point_3` template std::ostream& write_point_WKT(std::ostream& out, const Point& point) @@ -399,11 +400,12 @@ std::ostream& write_polygon_WKT(std::ostream& out, //! //! \brief writes the content of `ls` into a WKT stream. //! -//! \tparam LineString must be a `RandomAccessRange` of `CGAL::Point_2`. +//! \tparam LineString must be a `RandomAccessRange` of `CGAL::Point_2` or `CGAL::Point_3`. //! //! \attention Only %Cartesian Kernels with double or float as `FT` are supported. //! //!\see `CGAL::Point_2` +//!\see `CGAL::Point_3` template std::ostream& write_linestring_WKT(std::ostream& out, LineString ls) @@ -420,11 +422,12 @@ std::ostream& write_linestring_WKT(std::ostream& out, //! //! \brief writes the content of `mp` into a WKT stream. //! -//! \tparam MultiPoint must be a `RandomAccessRange` of `CGAL::Point_2`. +//! \tparam MultiPoint must be a `RandomAccessRange` of `CGAL::Point_2` or `CGAL::Point_3`. //! //! \attention Only %Cartesian Kernels with double or float as `FT` are supported. //! //!\see `CGAL::Point_2` +//!\see `CGAL::Point_2` template std::ostream& write_multi_point_WKT(std::ostream& out, MultiPoint& mp) diff --git a/Stream_support/test/Stream_support/test_WKT.cpp b/Stream_support/test/Stream_support/test_WKT.cpp index 90d9b8da4b20..7af1e011668e 100644 --- a/Stream_support/test/Stream_support/test_WKT.cpp +++ b/Stream_support/test/Stream_support/test_WKT.cpp @@ -3,8 +3,8 @@ #include #include - #include +#include #include #include @@ -17,7 +17,69 @@ typedef std::vector MultiPoint typedef std::vector MultiLinestring; typedef std::vector MultiPolygon; + +typedef CGAL::Point_3 Point3; +typedef std::vector Linestring3; +typedef std::vector MultiPoint3; +typedef std::vector MultiLinestring3; //////////////////////////////////////////////////////////////////////////////////////////////////// + +bool test_WKT_3D() +{ + { + Point3 p(1,2,3), q(0,0,0); + std::stringstream ss; + CGAL::IO::write_point_WKT(ss, p); + bool b = CGAL::IO::read_point_WKT(ss, q); + assert(b); + CGAL_USE(b); + assert(p == q); + } + { + Point3 p(1,2,3), q(3,2,1); + MultiPoint3 mp, mq; + mp.push_back(p); + mp.push_back(q); + std::stringstream ss; + CGAL::IO::write_multi_point_WKT(ss, mp); + bool b = CGAL::IO::read_multi_point_WKT(ss, mq); + assert(b); + CGAL_USE(b); + assert(mp == mq); + } + { + Point3 p(1,2,3), q(3,2,1); + Linestring3 mp, mq; + mp.push_back(p); + mp.push_back(q); + std::stringstream ss; + CGAL::IO::write_linestring_WKT(ss, mp); + bool b = CGAL::IO::read_linestring_WKT(ss, mq); + assert(b); + CGAL_USE(b); + assert(mp == mq); + } + { + Point3 p(1,2,3), q(3,2,1), r(4,5,6); + Linestring3 mp, mq; + mp.push_back(p); + mp.push_back(q); + mq.push_back(p); + mq.push_back(r); + MultiLinestring3 mmp, mmq; + mmp.push_back(mp); + mmp.push_back(mq); + std::stringstream ss; + CGAL::IO::write_multi_linestring_WKT(ss, mmp); + bool b = CGAL::IO::read_multi_linestring_WKT(ss, mmq); + assert(b); + CGAL_USE(b); + assert(mmp == mmq); + } + return true; +} + + //////////////////////////////////////////////////////////////////////////////////////////////////// /// Read @@ -273,6 +335,8 @@ int main() assert(ok); ok = test_write_WKT(); assert(ok); + ok = test_WKT_3D(); + assert(ok); return EXIT_SUCCESS; }