File: map_3_operations.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 (67 lines) | stat: -rw-r--r-- 1,957 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
60
61
62
63
64
65
66
67
#include <CGAL/Combinatorial_map.h>
#include <iostream>
#include <cstdlib>
#include <cassert>

typedef CGAL::Combinatorial_map<3> CMap_3;
typedef CMap_3::Dart_descriptor    Dart_descriptor;

int main()
{
  CMap_3 cm;

  // Create one combinatorial hexahedron.
  Dart_descriptor d1 = cm.make_combinatorial_hexahedron();

  // Add two edges along two opposite facets.
  assert( cm.is_insertable_cell_1_in_cell_2
          (cm.beta(d1,1),cm.beta(d1,0)) );

  cm.insert_cell_1_in_cell_2(cm.beta(d1,1), cm.beta(d1,0));
  assert( cm.is_valid() );

  Dart_descriptor d2=cm.beta(d1,2,1,1,2);

  assert( cm.is_insertable_cell_1_in_cell_2
          (d2,cm.beta(d2,1,1)) );

  cm.insert_cell_1_in_cell_2(d2, cm.beta(d2,1,1));
  assert( cm.is_valid() );

  // Insert a facet along these two new edges plus two initial edges
  // of the hexahedron.
  std::vector<Dart_descriptor> path;
  path.push_back(cm.beta(d1,1));
  path.push_back(cm.beta(d1,0,2,1));
  path.push_back(cm.beta(d2,0));
  path.push_back(cm.beta(d2,2,1));

  assert( (cm.is_insertable_cell_2_in_cell_3
                               (path.begin(),path.end())) );

  Dart_descriptor d3=cm.insert_cell_2_in_cell_3(path.begin(),path.end());
  assert( cm.is_valid() );

  // Display the combinatorial map characteristics.
  cm.display_characteristics(std::cout) << ", valid=" <<
    cm.is_valid() << std::endl;

  // We use the removal operations to get back to the initial hexahedron.
  assert( (cm.is_removable<2>(d3)) );
  cm.remove_cell<2>(d3);
  assert( cm.is_valid() );

  assert( (cm.is_removable<1>(cm.beta(d1,1))) );
  cm.remove_cell<1>(cm.beta(d1,1));
  assert( cm.is_valid() );

  assert( (cm.is_removable<1>(cm.beta(d2,0))) );
  cm.remove_cell<1>(cm.beta(d2,0));
  assert( cm.is_valid() );

  // Display the combinatorial map characteristics.
  cm.display_characteristics(std::cout) << ", valid="
                                        << cm.is_valid() << std::endl;

  return EXIT_SUCCESS;
}