File: p2t2_geometric_access.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 (41 lines) | stat: -rw-r--r-- 1,462 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
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Periodic_2_triangulation_traits_2.h>
#include <CGAL/Periodic_2_Delaunay_triangulation_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Periodic_2_triangulation_traits_2<K>          PK;
typedef CGAL::Periodic_2_Delaunay_triangulation_2<PK>       P2DT2;

typedef PK::Point_2        Point;
typedef PK::Triangle_2     Triangle;

typedef P2DT2::Periodic_triangle           Periodic_triangle;
typedef P2DT2::Periodic_triangle_iterator  Periodic_triangle_iterator;
typedef P2DT2::Iterator_type               Iterator_type;

int main()
{
  P2DT2 T;

  T.insert(Point(0, 0));
  T.insert(Point(0, 0.5));
  T.insert(Point(0.5, 0));

  Periodic_triangle pt;
  Triangle t_bd;

  // Extracting the triangles that have a non-empty intersection with
  // the original domain of the 1-sheeted covering space
  for (Periodic_triangle_iterator ptit = T.periodic_triangles_begin(P2DT2::UNIQUE_COVER_DOMAIN);
       ptit != T.periodic_triangles_end(P2DT2::UNIQUE_COVER_DOMAIN); ++ptit)
    {
      pt = *ptit;
      if (! (pt[0].second.is_null() && pt[1].second.is_null() && pt[2].second.is_null()) )
        {
          // Convert the current Periodic_triangle to a Triangle if it is
          // not strictly contained inside the original domain.
          // Note that this requires EXACT constructions to be exact!
          t_bd = T.triangle(pt);
        }
    }
}