File: plane_graph_to_lcc_2.cpp

package info (click to toggle)
cgal 4.5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 69,700 kB
  • ctags: 118,537
  • sloc: cpp: 571,870; ansic: 110,997; sh: 725; python: 92; makefile: 87
file content (54 lines) | stat: -rw-r--r-- 1,766 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_constructors.h>
#include <iostream>
#include <fstream>
#include <cstring>

typedef CGAL::Linear_cell_complex<2,2> LCC_2;
typedef LCC_2::Dart_handle             Dart_handle;
typedef LCC_2::Point                   Point;

int main(int narg, char** argv)
{
  if ( narg>1 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"-?")) )
  {
    std::cout<<"Usage: a.out filename"<<std::endl
             <<"  with filename the name of the file containing a 2D "
             <<"plane graph."<<std::endl<<std::endl
             <<"File must be in text mode, respecting the following format:"
             <<std::endl
             <<"***********************************************"<<std::endl
             <<"nbvertices nbedges"<<std::endl
             <<"x y //coordinates, one pair for each vertex"<<std::endl
             <<"..."<<std::endl
             <<"i j //edge betwen vertices number i and j,"
             <<" one pair for each edge"<<std::endl
             <<"..."<<std::endl
             <<"***********************************************"<<std::endl
             <<std::endl;
    return EXIT_FAILURE;
  }

  std::string filename;
  if ( narg==1 )
  {
    filename=std::string("data/graph.txt");
    std::cout<<"No filename given: use data/graph.txt by default."<<std::endl;
  }
  else
    filename=std::string(argv[1]);
  
  LCC_2 lcc;

  std::ifstream is(filename.c_str());
  std::cout<<"Import plane graph from "<<filename<<std::endl;
  CGAL::import_from_plane_graph(lcc, is);
  
  // Display the lcc characteristics.
  std::cout<<"LCC characteristics:"<<std::endl<<"  ";
  lcc.display_characteristics(std::cout) 
    << ", valid=" << lcc.is_valid() << std::endl;
  
  return EXIT_SUCCESS;
}