File: triangulation_projection_traits.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 (39 lines) | stat: -rw-r--r-- 1,199 bytes parent folder | download | duplicates (3)
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
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Projection_traits_3.h>

#include <iostream>
#include <vector>

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

typedef CGAL::Exact_predicates_tag                                         Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<GT, CGAL::Default, Itag> CDT;
typedef CDT::Point                                                         Point;
typedef CDT::Edge                                                          Edge;

int main()
{
  //4 points on the diagonal plane of a cube
  std::vector<Point> ps(4);
  ps[0] = Point(0,0,0);
  ps[1] = Point(3,1,-1);
  ps[2] = Point(-1, 3, -3);
  ps[3] = Point(1,0.5,-0.5);

  GT gt{ { 0, 1, 1} };
  CDT cdt(gt);
  for(int i = 0; i< 4; ++i)
    cdt.insert(ps[i]);

  for(int i = 1; i < 3; ++i)
    cdt.insert_constraint(ps[i], ps[i+1]);

  for(CDT::Face_handle f : cdt.all_face_handles())
  {
   for(int i=0; i<3; ++i)
     std::cout << f->vertex(i)->point() << " ";
   std::cout << std::endl;
  }
}