mirror of https://github.com/CGAL/cgal
- changements concerning signature of natural_neighbor_coordinates_2 (add. bool)
This commit is contained in:
parent
57b4a86f83
commit
f56c63da43
|
|
@ -1,6 +1,6 @@
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
//
|
//
|
||||||
// Copyright (c) 1998-1999 The CGAL Consortium
|
// Copyright (c) 2003 The CGAL Consortium
|
||||||
//
|
//
|
||||||
// This software and related documentation is part of an INTERNAL release
|
// This software and related documentation is part of an INTERNAL release
|
||||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||||
|
|
@ -76,6 +76,10 @@ typedef std::map<Point_2, Vector_2, K::Less_xy_2 > Point_vector_map;
|
||||||
typedef std::vector<Point_3> Point_vector_3;
|
typedef std::vector<Point_3> Point_vector_3;
|
||||||
typedef std::vector<Point_2> Point_vector_2;
|
typedef std::vector<Point_2> Point_vector_2;
|
||||||
|
|
||||||
|
typedef std::vector< std::pair< K::Point_2, K::FT > >
|
||||||
|
Point_coordinate_vector;
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// VISU GEOMVIEW
|
// VISU GEOMVIEW
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
@ -207,18 +211,22 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
|
|
||||||
//INTERPOLATION:
|
//INTERPOLATION:
|
||||||
|
Point_coordinate_vector coords;
|
||||||
|
std::pair<Coord_type, bool> interpolation_result;
|
||||||
Coord_type value;
|
Coord_type value;
|
||||||
std::pair<Coord_type, bool> res;
|
|
||||||
std::vector< std::pair< Point_2, Coord_type > > coords;
|
|
||||||
int n = points.size();
|
int n = points.size();
|
||||||
ITraits traits;
|
ITraits traits;
|
||||||
|
|
||||||
std::cout << "Interpolation at "<<n <<" grid points " << std::endl;
|
std::cout << "Interpolation at "<<n <<" grid points " << std::endl;
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
Coord_type norm =
|
CGAL::Triple<
|
||||||
|
std::back_insert_iterator<Point_coordinate_vector>,
|
||||||
|
K::FT, bool> coordinate_result =
|
||||||
CGAL::natural_neighbor_coordinates_2(T, points[i],
|
CGAL::natural_neighbor_coordinates_2(T, points[i],
|
||||||
std::back_inserter(coords)).second;
|
std::back_inserter(coords));
|
||||||
assert(norm>0);
|
K::FT norm = coordinate_result.second;
|
||||||
|
//test if the computation was successful
|
||||||
|
assert(coordinate_result.third && norm>0);
|
||||||
|
|
||||||
switch(method){
|
switch(method){
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -226,28 +234,28 @@ int main(int argc, char* argv[])
|
||||||
CGAL::Data_access<Point_value_map>(values));
|
CGAL::Data_access<Point_value_map>(values));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
res = CGAL::quadratic_interpolation(coords.begin(),coords.end(),
|
interpolation_result = CGAL::quadratic_interpolation(coords.begin(),coords.end(),
|
||||||
norm, points[i],
|
norm, points[i],
|
||||||
CGAL::Data_access< Point_value_map>
|
CGAL::Data_access< Point_value_map>
|
||||||
(values),
|
(values),
|
||||||
CGAL::Data_access< Point_vector_map>
|
CGAL::Data_access< Point_vector_map>
|
||||||
(gradients),traits); break;
|
(gradients),traits); break;
|
||||||
case 2:
|
case 2:
|
||||||
res = CGAL::sibson_c1_interpolation(coords.begin(),coords.end(),
|
interpolation_result = CGAL::sibson_c1_interpolation(coords.begin(),coords.end(),
|
||||||
norm, points[i],
|
norm, points[i],
|
||||||
CGAL::Data_access<Point_value_map>
|
CGAL::Data_access<Point_value_map>
|
||||||
(values),
|
(values),
|
||||||
CGAL::Data_access<Point_vector_map>
|
CGAL::Data_access<Point_vector_map>
|
||||||
(gradients), traits); break;
|
(gradients), traits); break;
|
||||||
case 3:
|
case 3:
|
||||||
res = CGAL::sibson_c1_interpolation_square(coords.begin(),coords.end(),
|
interpolation_result = CGAL::sibson_c1_interpolation_square(coords.begin(),coords.end(),
|
||||||
norm, points[i],
|
norm, points[i],
|
||||||
CGAL::Data_access<Point_value_map>
|
CGAL::Data_access<Point_value_map>
|
||||||
(values),
|
(values),
|
||||||
CGAL::Data_access<Point_vector_map>
|
CGAL::Data_access<Point_vector_map>
|
||||||
(gradients), traits); break;
|
(gradients), traits); break;
|
||||||
case 4:
|
case 4:
|
||||||
res = CGAL::farin_c1_interpolation(coords.begin(),coords.end(),
|
interpolation_result = CGAL::farin_c1_interpolation(coords.begin(),coords.end(),
|
||||||
norm, points[i],
|
norm, points[i],
|
||||||
CGAL::Data_access<Point_value_map>
|
CGAL::Data_access<Point_value_map>
|
||||||
(values),
|
(values),
|
||||||
|
|
@ -259,8 +267,9 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
if(method==0)
|
if(method==0)
|
||||||
points_3.push_back(Point_3(points[i].x(), points[i].y(),value));
|
points_3.push_back(Point_3(points[i].x(), points[i].y(),value));
|
||||||
else if(res.second)
|
else if(interpolation_result.second)
|
||||||
points_3.push_back(Point_3(points[i].x(), points[i].y(),res.first));
|
points_3.push_back(Point_3(points[i].x(), points[i].y(),
|
||||||
|
interpolation_result.first));
|
||||||
else std::cout <<"Interpolation failed"<<std::endl;
|
else std::cout <<"Interpolation failed"<<std::endl;
|
||||||
coords.clear();
|
coords.clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};
|
struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};
|
||||||
typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation;
|
typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation;
|
||||||
|
typedef std::vector< std::pair< K::Point_2, K::FT > >
|
||||||
|
Point_coordinate_vector;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
@ -21,10 +23,21 @@ int main()
|
||||||
|
|
||||||
//coordinate computation
|
//coordinate computation
|
||||||
K::Point_2 p(1.2, 0.7);
|
K::Point_2 p(1.2, 0.7);
|
||||||
std::vector< std::pair< K::Point_2, K::FT > > coords;
|
Coordinate_vector coords;
|
||||||
K::FT norm =
|
CGAL::Triple<
|
||||||
|
std::back_insert_iterator<Point_coordinate_vector>,
|
||||||
|
K::FT, bool> result =
|
||||||
CGAL::natural_neighbor_coordinates_2(dt, p,
|
CGAL::natural_neighbor_coordinates_2(dt, p,
|
||||||
std::back_inserter(coords)).second;
|
std::back_inserter(coords));
|
||||||
|
if(!result.third){
|
||||||
|
std::cout << "The coordinate computation was not successful."
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << "The point (" <<p << ") lies outside the convex hull."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
K::FT norm = result.second;
|
||||||
|
std::cout << "Coordinate computation successful." << std::endl;
|
||||||
|
std::cout << "Normalization factor: " <<norm << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue