cgal/Stream_support/examples/Stream_support/read_WKT.cpp

43 lines
1.0 KiB
C++

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Projection_traits_xy_3.h>
#include <CGAL/IO/WKT.h>
#include <iostream>
#include <fstream>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Projection_traits_xy_3<K> Kernel;
int main(int argc, char* argv[])
{
typedef Kernel::Point_2 Point;
typedef std::vector<Point> MultiPoint;
typedef std::vector<Point> LineString;
typedef std::vector<LineString> MultiLineString;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon;
typedef std::vector<Polygon> MultiPolygon;
{
std::ifstream is((argc>1)?argv[1]:"data/multiple.wkt");
MultiPoint points;
MultiLineString polylines;
MultiPolygon polygons;
CGAL::IO::read_WKT(is, points,polylines,polygons);
for(Point p : points)
std::cout<<p<<std::endl;
for(LineString ls : polylines)
for(Point p : ls)
std::cout<<p<<std::endl;
for(Polygon p : polygons){
std::cout<<p<<std::endl;
}
}
return 0;
}