File: nn_coordinates_3.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 (87 lines) | stat: -rw-r--r-- 3,819 bytes parent folder | download | duplicates (5)
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
82
83
84
85
86
87
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/natural_neighbor_coordinates_3.h>

#include <fstream>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

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;
  }

  return EXIT_SUCCESS;
}