File: nn_coordinates_3.cpp

package info (click to toggle)
cgal 4.0-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 65,068 kB
  • sloc: cpp: 500,870; ansic: 102,544; sh: 321; python: 92; makefile: 75; xml: 2
file content (81 lines) | stat: -rw-r--r-- 2,888 bytes parent folder | download | duplicates (4)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/natural_neighbor_coordinates_3.h>
#include <fstream>

typedef double NT; //Number Type

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef K::Point_3 Point3;
typedef K::Vector_3 Vector3;
typedef K::Sphere_3 Sphere_3;

typedef CGAL::Delaunay_triangulation_3<K, CGAL::Fast_location> Dh;

typedef Dh::Facet Facet;
typedef Dh::Vertex_handle Vertex_handle;
typedef Dh::Cell_handle Cell_handle;
typedef Dh::Finite_vertices_iterator Finite_vertices_iterator;
typedef Dh::Vertex_iterator Vertex_iterator;
typedef Dh::Facet_circulator Facet_circulator;
typedef Dh::Cell_iterator Cell_iterator;

typedef K::Construct_circumcenter_3 Construct_circumcenter_3;

int main()
{
  Dh triangulation;

  std::fstream iFile("data/points3", std::ios::in);
  Point3 p;

  while ( iFile >> p )
    triangulation.insert(p);

  Point3 pp[3];
  std::cout << "Consider the natural coordinates of P1, P2 and P3 with regard to the triangulation of data/points3 " << std::endl;
  pp[0]=Point3(106.55,112.57,110.4); //inside data/points3 convex hull
  std::cout << "P1 is inside the convex hull" << std::endl;
  pp[1]=Point3(250,100,140); //on data/points3 convex hull
  std::cout << "P2 is on a vertex of the triangulation" << std::endl;
  pp[2]=Point3(0,0,0); //outside data/points3 convex hull
  std::cout << "P2 is outside the convex hull" << std::endl;

  for(int ii=0;ii<3;ii++)
    {
      std::vector< std::pair< Vertex_handle,NT> > coor_laplace;
      std::vector< std::pair< Vertex_handle,NT> > coor_sibson;
      NT norm_coeff_laplace, norm_coeff_sibson;

      std::cout << "Point P"<< ii+1 << " : "<<pp[ii].x() << " "
		<< pp[ii].y() << " "
		<< pp[ii].z() << std::endl;

      laplace_natural_neighbor_coordinates_3(triangulation,pp[ii],
					     std::back_inserter(coor_laplace),
					     norm_coeff_laplace);

      std::cout << "Linear combination of natural neighbors with Laplace natural coordinates";
      std::cout << " + correctness (ensured only with an exact number type supporting sqrt)" << std::endl;
      std::cout << is_correct_natural_neighborhood(triangulation,pp[ii],
						   coor_laplace.begin(),
						   coor_laplace.end(),
						   norm_coeff_laplace)
		<< std::endl;

      sibson_natural_neighbor_coordinates_3(triangulation,pp[ii],
					    std::back_inserter(coor_sibson),
					    norm_coeff_sibson);
      std::cout << "Linear combination of natural neighbors with Sibson natural coordinates" << std::endl;
      std::cout << " + correctness (ensured only with an exact number type)" << std::endl;
      std::cout << is_correct_natural_neighborhood(triangulation,pp[ii],
						   coor_sibson.begin(),
						   coor_sibson.end(),
						   norm_coeff_sibson)
		<< std::endl;
    }

  std::cout << "done" << std::endl;
  return 0;
}