File: triangulation.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 (43 lines) | stat: -rw-r--r-- 1,436 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
#include <CGAL/config.h>

#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Triangulation.h>
#include <CGAL/algorithm.h>

#include <iostream>
#include <iterator>
#include <vector>
#include <cassert>

typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag >  K;
typedef CGAL::Triangulation<K>                        Triangulation;

int main()
{
    const int D = 5;   // we work in Euclidean 5-space
    const int N = 100; // we will insert 100 points
    // - - - - - - - - - - - - - - - - - - - - - - - - STEP 1
    CGAL::Random_points_in_cube_d<Triangulation::Point> rand_it(D, 1.0);
    std::vector<Triangulation::Point> points;
    std::copy_n(rand_it, N, std::back_inserter(points));

    Triangulation t(D);                      // create triangulation
    assert(t.empty());
    t.insert(points.begin(), points.end());  // compute triangulation
    assert( t.is_valid() );
    // - - - - - - - - - - - - - - - - - - - - - - - - STEP 2
    typedef Triangulation::Face Face;
    typedef std::vector<Face> Faces;
    Faces edges;
    std::back_insert_iterator<Faces> out(edges);
    t.tds().incident_faces(t.infinite_vertex(), 1, out);
    // collect faces of dimension 1 (edges) incident to the infinite vertex
    std::cout << "There are " << edges.size()
              << " vertices on the convex hull." << std::endl;

#include "triangulation1.h" // See below
#include "triangulation2.h"

    return 0;
}