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
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
|
|
@ -70,11 +70,15 @@ typedef K::Vector_3 Vector_3;
|
|||
typedef K::Segment_3 Segment_3;
|
||||
typedef K::Triangle_3 Triangle_3;
|
||||
|
||||
typedef std::map<Point_2, Coord_type, K::Less_xy_2> Point_value_map ;
|
||||
typedef std::map<Point_2, Vector_2, K::Less_xy_2 > Point_vector_map;
|
||||
typedef std::map<Point_2, Coord_type, K::Less_xy_2> Point_value_map ;
|
||||
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_2> Point_vector_2;
|
||||
|
||||
typedef std::vector< std::pair< K::Point_2, K::FT > >
|
||||
Point_coordinate_vector;
|
||||
|
||||
typedef std::vector<Point_3> Point_vector_3;
|
||||
typedef std::vector<Point_2> Point_vector_2;
|
||||
|
||||
//////////////////////
|
||||
// VISU GEOMVIEW
|
||||
|
|
@ -207,47 +211,51 @@ int main(int argc, char* argv[])
|
|||
|
||||
|
||||
//INTERPOLATION:
|
||||
Point_coordinate_vector coords;
|
||||
std::pair<Coord_type, bool> interpolation_result;
|
||||
Coord_type value;
|
||||
std::pair<Coord_type, bool> res;
|
||||
std::vector< std::pair< Point_2, Coord_type > > coords;
|
||||
int n = points.size();
|
||||
ITraits traits;
|
||||
|
||||
std::cout << "Interpolation at "<<n <<" grid points " << std::endl;
|
||||
for(int i=0;i<n;i++){
|
||||
Coord_type norm =
|
||||
CGAL::natural_neighbor_coordinates_2(T, points[i],
|
||||
std::back_inserter(coords)).second;
|
||||
assert(norm>0);
|
||||
CGAL::Triple<
|
||||
std::back_insert_iterator<Point_coordinate_vector>,
|
||||
K::FT, bool> coordinate_result =
|
||||
CGAL::natural_neighbor_coordinates_2(T, points[i],
|
||||
std::back_inserter(coords));
|
||||
K::FT norm = coordinate_result.second;
|
||||
//test if the computation was successful
|
||||
assert(coordinate_result.third && norm>0);
|
||||
|
||||
switch(method){
|
||||
switch(method){
|
||||
case 0:
|
||||
value = CGAL::linear_interpolation(coords.begin(),coords.end(),norm,
|
||||
CGAL::Data_access<Point_value_map>(values));
|
||||
CGAL::Data_access<Point_value_map>(values));
|
||||
break;
|
||||
case 1:
|
||||
res = CGAL::quadratic_interpolation(coords.begin(),coords.end(),
|
||||
case 1:
|
||||
interpolation_result = CGAL::quadratic_interpolation(coords.begin(),coords.end(),
|
||||
norm, points[i],
|
||||
CGAL::Data_access< Point_value_map>
|
||||
(values),
|
||||
CGAL::Data_access< Point_vector_map>
|
||||
(gradients),traits); break;
|
||||
case 2:
|
||||
res = CGAL::sibson_c1_interpolation(coords.begin(),coords.end(),
|
||||
interpolation_result = CGAL::sibson_c1_interpolation(coords.begin(),coords.end(),
|
||||
norm, points[i],
|
||||
CGAL::Data_access<Point_value_map>
|
||||
(values),
|
||||
CGAL::Data_access<Point_vector_map>
|
||||
(gradients), traits); break;
|
||||
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],
|
||||
CGAL::Data_access<Point_value_map>
|
||||
(values),
|
||||
CGAL::Data_access<Point_vector_map>
|
||||
(gradients), traits); break;
|
||||
case 4:
|
||||
res = CGAL::farin_c1_interpolation(coords.begin(),coords.end(),
|
||||
interpolation_result = CGAL::farin_c1_interpolation(coords.begin(),coords.end(),
|
||||
norm, points[i],
|
||||
CGAL::Data_access<Point_value_map>
|
||||
(values),
|
||||
|
|
@ -259,8 +267,9 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
if(method==0)
|
||||
points_3.push_back(Point_3(points[i].x(), points[i].y(),value));
|
||||
else if(res.second)
|
||||
points_3.push_back(Point_3(points[i].x(), points[i].y(),res.first));
|
||||
else if(interpolation_result.second)
|
||||
points_3.push_back(Point_3(points[i].x(), points[i].y(),
|
||||
interpolation_result.first));
|
||||
else std::cout <<"Interpolation failed"<<std::endl;
|
||||
coords.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};
|
||||
typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation;
|
||||
typedef std::vector< std::pair< K::Point_2, K::FT > >
|
||||
Point_coordinate_vector;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -21,10 +23,21 @@ int main()
|
|||
|
||||
//coordinate computation
|
||||
K::Point_2 p(1.2, 0.7);
|
||||
std::vector< std::pair< K::Point_2, K::FT > > coords;
|
||||
K::FT norm =
|
||||
Coordinate_vector coords;
|
||||
CGAL::Triple<
|
||||
std::back_insert_iterator<Point_coordinate_vector>,
|
||||
K::FT, bool> result =
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue