File: map_3_simple_example.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 (45 lines) | stat: -rw-r--r-- 1,434 bytes parent folder | download
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
#include <CGAL/Combinatorial_map.h>
#include <CGAL/Combinatorial_map_constructors.h>
#include <iostream>
#include <cstdlib>

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

  int main()
  {
    CMap_3 cm;

    // Create two tetrahedra.
    Dart_const_handle dh1 = cm.make_combinatorial_tetrahedron();
    Dart_const_handle dh2 = cm.make_combinatorial_tetrahedron();

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

    unsigned int res = 0;
    // Iterate over all the darts of the first tetrahedron.
    // Note that CMap_3::Dart_of_orbit_range<1,2> in 3D is equivalent to
    // CMap_3::Dart_of_cell_range<3>.
    for  (CMap_3::Dart_of_orbit_range<1,2>::const_iterator
          it(cm.darts_of_orbit<1,2>(dh1).begin()),
          itend(cm.darts_of_orbit<1,2>(dh1).end()); it!=itend; ++it)
       ++res;

    std::cout<<"Number of darts of the first tetrahedron: "
             <<res<<std::endl;

    res = 0;
    // Iterate over all the darts of the facet containing dh2.
    for (CMap_3::Dart_of_orbit_range<1>::const_iterator
         it(cm.darts_of_orbit<1>(dh2).begin()),
         itend(cm.darts_of_orbit<1>(dh2).end()); it!=itend; ++it)
       ++res;

    std::cout<<"Number of darts of the facet containing dh2: "
             <<res<<std::endl;

    return EXIT_SUCCESS;
}