COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
linear_interpolation.cpp
Go to the documentation of this file.
1 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
2 #include <CGAL/Delaunay_triangulation_2.h>
3 
4 #include <CGAL/Interpolation_traits_2.h>
5 #include <CGAL/natural_neighbor_coordinates_2.h>
6 #include <CGAL/interpolation_functions.h>
7 
8 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
9 typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation;
10 typedef CGAL::Interpolation_traits_2<K> Traits;
11 typedef K::FT Coord_type;
12 typedef K::Point_2 Point;
13 
14 int main()
15 {
17  std::map<Point, Coord_type, K::Less_xy_2> function_values;
18  typedef CGAL::Data_access< std::map<Point, Coord_type, K::Less_xy_2 > >
19  Value_access;
20 
21  Coord_type a(0.25), bx(1.3), by(-0.7);
22 
23  for (int y=0 ; y<3 ; y++)
24  for (int x=0 ; x<3 ; x++){
25  K::Point_2 p(x,y);
26  T.insert(p);
27  function_values.insert(std::make_pair(p,a + bx* x+ by*y));
28  }
29  //coordinate computation
30  K::Point_2 p(1.3,0.34);
31  std::vector< std::pair< Point, Coord_type > > coords;
33  CGAL::natural_neighbor_coordinates_2
34  (T, p,std::back_inserter(coords)).second;
35 
36  Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(),
37  norm,
38  Value_access(function_values));
39 
40  std::cout << " Tested interpolation on " << p << " interpolation: "
41  << res << " exact: " << a + bx* p.x()+ by* p.y()<< std::endl;
42 
43  std::cout << "done" << std::endl;
44 
46 // own version
47 
48 
49 
50 
51 
52 
53  return 0;
54 }
CGAL::Exact_predicates_inexact_constructions_kernel K
CGAL::Delaunay_triangulation_2< K > Delaunay_triangulation
K::FT Coord_type
K::Point_2 Point
CGAL::Interpolation_traits_2< K > Traits
int main()
Send comments to:
COOLFluiD Web Admin