Merge pull request #1354 from afabri/BGL_fix_input-GF

All examples now read from a file
This commit is contained in:
Laurent Rineau 2016-08-29 13:02:29 +02:00 committed by GitHub
commit 9257b803a2
4 changed files with 26 additions and 14 deletions

View File

@ -0,0 +1,5 @@
0 0
1 0
0.2 0.2
0 1
0 2

View File

@ -4,6 +4,7 @@
#include <CGAL/boost/graph/dijkstra_shortest_paths.h> #include <CGAL/boost/graph/dijkstra_shortest_paths.h>
#include <boost/graph/filtered_graph.hpp> #include <boost/graph/filtered_graph.hpp>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point; typedef K::Point_2 Point;
@ -44,17 +45,18 @@ typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map); VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int int
main(int,char*[]) main(int argc,char* argv[])
{ {
const char* filename = (argc > 1) ? argv[1] : "data/points.xy";
std::ifstream input(filename);
Triangulation t; Triangulation t;
Filter is_finite(t); Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite); Finite_triangulation ft(t, is_finite, is_finite);
t.insert(Point(0,0)); Point p ;
t.insert(Point(1,0)); while(input >> p){
t.insert(Point(0.2,0.2)); t.insert(p);
t.insert(Point(0,1)); }
t.insert(Point(0,2));
vertex_iterator vit, ve; vertex_iterator vit, ve;
// Associate indices to the vertices // Associate indices to the vertices

View File

@ -5,6 +5,7 @@
#include <CGAL/boost/graph/dijkstra_shortest_paths.h> #include <CGAL/boost/graph/dijkstra_shortest_paths.h>
#include <boost/graph/filtered_graph.hpp> #include <boost/graph/filtered_graph.hpp>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point; typedef K::Point_2 Point;
@ -42,17 +43,18 @@ typedef boost::graph_traits<Finite_triangulation>::vertex_iterator vertex_iterat
int int
main(int,char*[]) main(int argc,char* argv[])
{ {
const char* filename = (argc > 1) ? argv[1] : "data/points.xy";
std::ifstream input(filename);
Triangulation t; Triangulation t;
Filter is_finite(t); Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite); Finite_triangulation ft(t, is_finite, is_finite);
t.insert(Point(0,0)); Point p ;
t.insert(Point(1,0)); while(input >> p){
t.insert(Point(0.2,0.2)); t.insert(p);
t.insert(Point(0,1)); }
t.insert(Point(0,2));
vertex_iterator vit, ve; vertex_iterator vit, ve;
// associate indices to the vertices // associate indices to the vertices

View File

@ -4,6 +4,7 @@
#include <boost/graph/kruskal_min_spanning_tree.hpp> #include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/filtered_graph.hpp> #include <boost/graph/filtered_graph.hpp>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point; typedef K::Point_2 Point;
@ -48,14 +49,16 @@ typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map); VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int int
main(int,char*[]) main(int argc,char* argv[])
{ {
const char* filename = (argc > 1) ? argv[1] : "data/points.xy";
std::ifstream input(filename);
Triangulation t; Triangulation t;
Filter is_finite(t); Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite); Finite_triangulation ft(t, is_finite, is_finite);
Point p ; Point p ;
while(std::cin >> p){ while(input >> p){
t.insert(p); t.insert(p);
} }