File: p2t2_find_conflicts.cpp

package info (click to toggle)
cgal 4.5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 69,700 kB
  • ctags: 118,537
  • sloc: cpp: 571,870; ansic: 110,997; sh: 725; python: 92; makefile: 87
file content (52 lines) | stat: -rw-r--r-- 1,558 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
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Periodic_2_triangulation_filtered_traits_2.h>
#include <CGAL/Periodic_2_Delaunay_triangulation_2.h>
#include <CGAL/point_generators_2.h>

#include <vector>
#include <cassert>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Periodic_2_triangulation_filtered_traits_2<K> GT;

typedef CGAL::Periodic_2_Delaunay_triangulation_2<GT> Delaunay;
typedef Delaunay::Point                               Point;
typedef Delaunay::Face_handle                         Face_handle;

int main()
{
  Delaunay T;
  CGAL::Random_points_in_iso_rectangle_2<Point> rnd(Point(0, 0), Point(1, 1));

  // First, make sure the triangulation is 2D.
  T.insert(Point(0, 0));
  T.insert(Point(.1, 0));
  T.insert(Point(0, .1));

  // Gets the conflict region of 100 random points
  // in the Delaunay tetrahedralization
  for (int i = 0; i != 100; ++i)
    {
      Point p = (*rnd++);

      // Locate the point
      Delaunay::Locate_type lt;
      int li;
      Face_handle f = T.locate(p, lt, li);
      if (lt == Delaunay::VERTEX)
        continue; // Point already exists

      // Get the cells that conflict with p in a vector V,
      // and a facet on the boundary of this hole in f.
      std::vector<Face_handle> V;

      T.get_conflicts(p,
                      std::back_inserter(V), // Conflict cells in V
                      f);
    }

  std::cout << "Final triangulation has " << T.number_of_vertices()
            << " vertices." << std::endl;

  return 0;
}