File: triangulation_data_structure_static.cpp

package info (click to toggle)
cgal 4.9-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 85,584 kB
  • sloc: cpp: 640,841; ansic: 140,696; sh: 708; fortran: 131; makefile: 114; python: 92
file content (59 lines) | stat: -rw-r--r-- 2,080 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
55
56
57
58
59
#include <CGAL/Triangulation_data_structure.h>
#include <CGAL/assertions.h>

#include <vector>

int main()
{
  typedef CGAL::Triangulation_data_structure<CGAL::Dimension_tag<7> > TDS;

  TDS S;
  CGAL_assertion( 7 == S.maximal_dimension() );
  CGAL_assertion( -2 == S.current_dimension() );
  CGAL_assertion( S.is_valid() );

  std::vector<TDS::Vertex_handle> V(10);
  V[0] = S.insert_increase_dimension(); //insert first vertex
  CGAL_assertion( -1 == S.current_dimension() );

  for( int i = 1; i <= 5; ++i )
      V[i] = S.insert_increase_dimension(V[0]);
  // the first 6 vertices have created a triangulation
  // of the 4-dimensional topological sphere 
  // (the boundary of a five dimensional simplex).
  CGAL_assertion( 4 == S.current_dimension() );
  CGAL_assertion( 6 == S.number_of_vertices() );
  CGAL_assertion( 6 == S.number_of_full_cells() );

  TDS::Full_cell_handle c = V[5]->full_cell();
  V[6] = S.insert_in_full_cell(c);
  // full cell c is split in 5
  CGAL_assertion( 7 == S.number_of_vertices() );
  CGAL_assertion( 10 == S.number_of_full_cells() );

  c = V[3]->full_cell();
  TDS::Facet ft(c, 2); // the Facet opposite to vertex 2 in c
  V[7] = S.insert_in_facet(ft);
  // facet ft is split in 4 and the two incident cells are split accordingly
  CGAL_assertion( 8 == S.number_of_vertices() );
  CGAL_assertion( 16 == S.number_of_full_cells() );

  c = V[3]->full_cell();
  TDS::Face face(c);  
  // meant to contain the edge joining vertices 2 and 4 of full_cell c
  face.set_index(0, 2); // namely vertex 2
  face.set_index(1, 4); // and vertex 4
  V[8] = S.insert_in_face(face);
  // face is split in 2, and all incident full cells also
  CGAL_assertion( S.is_valid() );

  TDS::Full_cell_handle hole[2];
  hole[0] = V[8]->full_cell();
  hole[1] = hole[0]->neighbor(0);
  // the hole is made of two adjacent full cells
  ft = TDS::Facet(hole[0], 1);  // a face on the boundary of hole[0]
  V[9] = S.insert_in_hole(hole, hole+2, ft);
  // the hole is triangulated by linking a new vertex to its boundary
  CGAL_assertion( S.is_valid() );
  return 0;
}