File: low_dimensional.cpp

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (74 lines) | stat: -rw-r--r-- 2,414 bytes parent folder | download | duplicates (4)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_2<K>          Triangulation;
typedef Triangulation::Vertex_handle      Vertex_handle;
typedef Triangulation::Face_handle        Face_handle;
typedef Triangulation::All_faces_iterator All_faces_iterator;
typedef Triangulation::All_edges_iterator All_edges_iterator;
typedef Triangulation::Point              Point;

int main() {

  Point p(0,0), q(1,0);

  Triangulation t;

  Vertex_handle inf = t.infinite_vertex();
  Face_handle fh = inf->face();
  assert(fh->vertex(0) == inf);
  assert(fh->vertex(1) == Vertex_handle());
  assert(fh->vertex(2) == Vertex_handle());

  assert(t.all_faces_begin() == t.all_faces_end());
  assert(t.all_edges_begin() == t.all_edges_end());

  t.insert(p);
  Vertex_handle pvh = t.finite_vertices_begin();
  Face_handle pfh = pvh->face();
  assert(pfh->neighbor(0) == fh);

  t.insert(q);

  assert(t.infinite_vertex()->face() == fh);

  assert( (fh->vertex(0) == inf) || (fh->vertex(1) == inf) );

  std::cout << "After the insertion of the second point" <<std::endl;
  std::cout << "|V| = " << t.number_of_vertices() << std::endl;
  std::cout << "|F| = " << t.number_of_faces() << std::endl;


  // Even now we have not really faces
  assert(t.all_faces_begin() == t.all_faces_end());

  for (Triangulation::All_edges_iterator it = t.all_edges_begin();
      it != t.all_edges_end();  ++it) {
    Face_handle fh = it->first;
    Vertex_handle v0 = fh->vertex(0);
    Vertex_handle v1 = fh->vertex(1);
    std::cout << "Edge: ";
    if (v0 == inf) {std::cout << "inf -- ";}else{ std::cout<< v0->point() << " -- ";}
    if (v1 == inf) {std::cout << "inf\n";}else{ std::cout<< v1->point() << std::endl;}
  }

  std::cout << "Edge traversal by hand" << std::endl;
  Face_handle done = fh;
  do {
      assert(fh->vertex(2) == Vertex_handle());
      assert(fh->neighbor(2) == Face_handle());
      Vertex_handle v0 = fh->vertex(0);
      Vertex_handle v1 = fh->vertex(1);
      std::cout << "Edge: ";
      if (v0 == inf) {std::cout << "inf -- ";}else{ std::cout<< v0->point() << " -- ";}
      if (v1 == inf) {std::cout << "inf\n";}else{ std::cout<< v1->point() << std::endl;}
      fh = fh->neighbor(0);
  } while (fh != done);

  std::cout << std::endl;

  return 0;
}