mirror of https://github.com/CGAL/cgal
Stream_support: Document that WKT can also handle 3D points
This commit is contained in:
parent
078053314e
commit
ae81703f6c
|
|
@ -156,9 +156,9 @@ bool read_multi_point_WKT(std::istream& in,
|
||||||
//!
|
//!
|
||||||
//! The first line starting with LINESTRING in the stream will be used.
|
//! 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:
|
//! 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 `clear()`,
|
||||||
//! - a function `resize()` that takes a `size_type`
|
//! - a function `resize()` that takes a `size_type`
|
||||||
//! - an `operator[]()` 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.
|
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
|
||||||
//!
|
//!
|
||||||
//! \see `CGAL::Point_2`
|
//! \see `CGAL::Point_2`
|
||||||
|
//! \see `CGAL::Point_3`
|
||||||
template<typename LineString>
|
template<typename LineString>
|
||||||
bool read_linestring_WKT(std::istream& in,
|
bool read_linestring_WKT(std::istream& in,
|
||||||
LineString& polyline)
|
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.
|
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
|
||||||
//!
|
//!
|
||||||
//! \see `CGAL::Point_2`
|
|
||||||
template<typename MultiLineString>
|
template<typename MultiLineString>
|
||||||
bool read_multi_linestring_WKT(std::istream& in,
|
bool read_multi_linestring_WKT(std::istream& in,
|
||||||
MultiLineString& mls)
|
MultiLineString& mls)
|
||||||
|
|
@ -359,11 +359,12 @@ bool read_multi_polygon_WKT(std::istream& in,
|
||||||
//!
|
//!
|
||||||
//! \brief writes `point` into a WKT stream.
|
//! \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.
|
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
|
||||||
//!
|
//!
|
||||||
//! \see `CGAL::Point_2`
|
//! \see `CGAL::Point_2`
|
||||||
|
//! \see `CGAL::Point_3`
|
||||||
template<typename Point>
|
template<typename Point>
|
||||||
std::ostream& write_point_WKT(std::ostream& out,
|
std::ostream& write_point_WKT(std::ostream& out,
|
||||||
const Point& point)
|
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.
|
//! \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.
|
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
|
||||||
//!
|
//!
|
||||||
//!\see `CGAL::Point_2`
|
//!\see `CGAL::Point_2`
|
||||||
|
//!\see `CGAL::Point_3`
|
||||||
template<typename LineString>
|
template<typename LineString>
|
||||||
std::ostream& write_linestring_WKT(std::ostream& out,
|
std::ostream& write_linestring_WKT(std::ostream& out,
|
||||||
LineString ls)
|
LineString ls)
|
||||||
|
|
@ -420,11 +422,12 @@ std::ostream& write_linestring_WKT(std::ostream& out,
|
||||||
//!
|
//!
|
||||||
//! \brief writes the content of `mp` into a WKT stream.
|
//! \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.
|
//! \attention Only %Cartesian Kernels with double or float as `FT` are supported.
|
||||||
//!
|
//!
|
||||||
//!\see `CGAL::Point_2`
|
//!\see `CGAL::Point_2`
|
||||||
|
//!\see `CGAL::Point_2`
|
||||||
template<typename MultiPoint>
|
template<typename MultiPoint>
|
||||||
std::ostream& write_multi_point_WKT(std::ostream& out,
|
std::ostream& write_multi_point_WKT(std::ostream& out,
|
||||||
MultiPoint& mp)
|
MultiPoint& mp)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
#include <CGAL/IO/WKT.h>
|
#include <CGAL/IO/WKT.h>
|
||||||
|
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
|
@ -17,7 +17,69 @@ typedef std::vector<Point> MultiPoint
|
||||||
typedef std::vector<Linestring> MultiLinestring;
|
typedef std::vector<Linestring> MultiLinestring;
|
||||||
typedef std::vector<Poly> MultiPolygon;
|
typedef std::vector<Poly> MultiPolygon;
|
||||||
|
|
||||||
|
|
||||||
|
typedef CGAL::Point_3<Kernel> Point3;
|
||||||
|
typedef std::vector<Point3> Linestring3;
|
||||||
|
typedef std::vector<Point3> MultiPoint3;
|
||||||
|
typedef std::vector<Linestring3> 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
|
/// Read
|
||||||
|
|
||||||
|
|
@ -273,6 +335,8 @@ int main()
|
||||||
assert(ok);
|
assert(ok);
|
||||||
ok = test_write_WKT();
|
ok = test_write_WKT();
|
||||||
assert(ok);
|
assert(ok);
|
||||||
|
ok = test_WKT_3D();
|
||||||
|
assert(ok);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue