Go to the documentation of this file.
3 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
4 #include <CGAL/Delaunay_triangulation_2.h>
6 #include <CGAL/Interpolation_traits_2.h>
7 #include <CGAL/natural_neighbor_coordinates_2.h>
8 #include <CGAL/interpolation_functions.h>
12 typedef CGAL::Exact_predicates_inexact_constructions_kernel
K;
14 typedef CGAL::Interpolation_traits_2<K>
Traits;
17 typedef std::map<Point, Coord_type, K::Less_xy_2>
Coord_map;
22 static const int pool_size = 10;
23 static bool cpool[pool_size]={
false,
false,
false,
false,
false,
false,
false,
false,
false,
false};
24 static std::vector< std::vector<std::pair<Point, Coord_type> >> cov[pool_size];
27 int cgal_nnc(
int nxy,
float *
x,
float *
y,
int nxyq,
float *xq,
float *yq)
32 for (
int i=0 ;
i<pool_size;
i++) {
33 if (cpool[
i] ==
false) {
41 std::cout <<
"Error: no NNC tags left\n";
45 for (
int i=0 ;
i<nxy ;
i++){
46 K::Point_2
p(
x[
i],
y[
i]);
53 for (
int i=0 ;
i<nxyq ;
i++) {
56 K::Point_2
p(xq[
i], yq[
i]);
57 std::vector<std::pair<Point, Coord_type> > coords;
59 CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>,
60 K::FT,
bool> nn_result =
61 CGAL::natural_neighbor_coordinates_2(T,
p, std::back_inserter(coords));
63 bool status = nn_result.third;
65 nrms[nnc_tag][
i] = nn_result.second;
67 nrms[nnc_tag][
i] = -1;
68 cov[nnc_tag].push_back(coords);
79 if(nnc_tag < 0 || nnc_tag >= pool_size) {
80 std::cout <<
"Error: bad NNC tag: " << nnc_tag << std::endl;
84 for (
int i=0 ;
i<nxy ;
i++){
85 K::Point_2
p(
x[
i],
y[
i]);
86 value_function.insert(std::make_pair(
p,
v[
i]));
90 for (
int i=0 ;
i<nxyq ;
i++) {
92 std::vector<std::pair<Point, Coord_type> > coords;
95 coords = cov[nnc_tag][
i];
96 norm = nrms[nnc_tag][
i];
98 if (coords.size() > 0) {
100 CGAL::linear_interpolation(coords.begin(), coords.end(),
norm,
113 if(nnc_tag < 0 || nnc_tag >= pool_size) {
114 std::cout <<
"Error: bad NNC tag: " << nnc_tag << std::endl;
118 if (cpool[nnc_tag] ==
true) {
120 cpool[nnc_tag] =
false;
121 delete[] nrms[nnc_tag];
122 cov[nnc_tag].clear();
124 std::cout <<
"Improper nnc tag: " << nnc_tag << std::endl;
int cgal_nnc(int nxy, float *x, float *y, int nxyq, float *xq, float *yq)
CGAL::Data_access< Coord_map > Value_access
std::map< Point, Coord_type, K::Less_xy_2 > Coord_map
int cgal_interp2(int nxy, float *x, float *y, float *v, int nxyq, float *vq, int nnc_tag)
CGAL::Exact_predicates_inexact_constructions_kernel K
CGAL::Delaunay_triangulation_2< K > Delaunay_triangulation
int cgal_release_tag(int nnc_tag)
CGAL::Interpolation_traits_2< K > Traits
std::vector< std::pair< Point, Coord_type > > Point_coordinate_vector