Fixed trailing whitespace and (some of the) inconsistent indentation

No real changes.
This commit is contained in:
Mael Rouxel-Labbé 2018-01-10 15:51:05 +01:00
parent 118e5dc9c3
commit 67f99cc53d
17 changed files with 592 additions and 591 deletions

View File

@ -208,6 +208,5 @@ int main()
<< CGAL::to_double(ssquare_total)/n << " max " << CGAL::to_double(ssquare_total)/n << " max "
<< CGAL::to_double(ssquare_max) << std::endl; << CGAL::to_double(ssquare_max) << std::endl;
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -20,18 +20,17 @@ typedef K::FT Coord_type;
typedef K::Vector_2 Vector; typedef K::Vector_2 Vector;
typedef K::Point_2 Point; typedef K::Point_2 Point;
template <typename V, typename G> template <typename V, typename G>
struct Value_and_gradient { struct Value_and_gradient
Value_and_gradient() {
: value(), gradient(CGAL::NULL_VECTOR) Value_and_gradient() : value(), gradient(CGAL::NULL_VECTOR) {}
{}
V value; V value;
G gradient; G gradient;
}; };
typedef CGAL::Triangulation_vertex_base_with_info_2<Value_and_gradient<Coord_type,Vector>, K> Vb; typedef CGAL::Triangulation_vertex_base_with_info_2<
Value_and_gradient<Coord_type, Vector>, K> Vb;
typedef CGAL::Triangulation_data_structure_2<Vb> Tds; typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay_triangulation; typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay_triangulation;
typedef Delaunay_triangulation::Vertex_handle Vertex_handle; typedef Delaunay_triangulation::Vertex_handle Vertex_handle;
@ -40,48 +39,35 @@ typedef CGAL::Interpolation_traits_2<K> Traits;
typedef std::vector< std::pair<Point, Coord_type> > Coordinate_vector; typedef std::vector< std::pair<Point, Coord_type> > Coordinate_vector;
template <typename V, typename T> template <typename V, typename T>
struct Function_value { struct Function_value
{
typedef V argument_type; typedef V argument_type;
typedef std::pair<T, bool> result_type; typedef std::pair<T, bool> result_type;
result_type operator()(const argument_type& a)const result_type operator()(const argument_type& a) const {
{
return result_type(a->info().value, true); return result_type(a->info().value, true);
} }
}; };
template <typename V, typename G> template <typename V, typename G>
struct Function_gradient struct Function_gradient
: public std::iterator<std::output_iterator_tag,void,void,void,void> { : public std::iterator<std::output_iterator_tag, void, void, void, void>
{
typedef V argument_type; typedef V argument_type;
typedef std::pair<G, bool> result_type; typedef std::pair<G, bool> result_type;
result_type operator()(const argument_type& a) const {
result_type
operator()(const argument_type& a)const
{
return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR); return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR);
} }
const Function_gradient& operator=(const std::pair<V, G>& p) const {
const Function_gradient& operator=(const std::pair<V, G>& p) const
{
p.first->info().gradient = p.second; p.first->info().gradient = p.second;
return *this; return *this;
} }
const Function_gradient& operator++(int) const const Function_gradient& operator++(int) const { return *this; }
{ const Function_gradient& operator*() const { return *this; }
return *this;
}
const Function_gradient& operator*() const
{
return *this;
}
}; };
int main() int main()
@ -120,7 +106,8 @@ int main()
gamma3 = Coord_type(0.0), gamma3 = Coord_type(0.0),
gamma4 = Coord_type(0.3); gamma4 = Coord_type(0.3);
for(int j=0; j<n ; j++){ for(int j=0; j<n ; j++)
{
Vertex_handle vh = T.insert(points[j]); Vertex_handle vh = T.insert(points[j]);
//determine function value/gradient: //determine function value/gradient:
@ -146,7 +133,8 @@ int main()
int failure(0); int failure(0);
//interpolation + error statistics //interpolation + error statistics
for(int i=n;i<n+m;i++){ for(int i=n; i<n+m; i++)
{
Coord_type x(points[i].x()); Coord_type x(points[i].x());
Coord_type y(points[i].y()); Coord_type y(points[i].y());
@ -155,32 +143,23 @@ int main()
total_value += exact_value; total_value += exact_value;
//Coordinate_vector: //Coordinate_vector:
std::vector< std::pair<Vertex_handle, Coord_type> > coords; std::vector< std::pair<Vertex_handle, Coord_type> > coords;
typedef CGAL::Identity<std::pair< Vertex_handle, Coord_type> > Identity; typedef CGAL::Identity<std::pair< Vertex_handle, Coord_type> > Identity;
Coord_type norm = Coord_type norm = CGAL::natural_neighbor_coordinates_2(T,
CGAL::natural_neighbor_coordinates_2(T,
points[i], points[i],
std::back_inserter(coords), std::back_inserter(coords),
Identity()).second; Identity()).second;
assert(norm > 0); assert(norm > 0);
//linear interpolant: //linear interpolant:
l_value = l_value = CGAL::linear_interpolation(coords.begin(), coords.end(),
CGAL::linear_interpolation(coords.begin(), coords.end(), norm, function_value);
norm,
function_value);
error = CGAL_NTS abs(l_value - exact_value); error = CGAL_NTS abs(l_value - exact_value);
l_total += error; l_total += error;
if (error > l_max) l_max = error; if (error > l_max) l_max = error;
//Farin interpolant: //Farin interpolant:
res = CGAL::farin_c1_interpolation(coords.begin(), res = CGAL::farin_c1_interpolation(coords.begin(),
coords.end(), norm,points[i], coords.end(), norm,points[i],
@ -189,11 +168,17 @@ int main()
Traits()); Traits());
if(res.second){ if(res.second)
{
error = CGAL_NTS abs(res.first - exact_value); error = CGAL_NTS abs(res.first - exact_value);
f_total += error; f_total += error;
if (error > f_max) f_max = error; if (error > f_max)
} else ++failure; f_max = error;
}
else
{
++failure;
}
//quadratic interpolant: //quadratic interpolant:
res = CGAL::quadratic_interpolation(coords.begin(), coords.end(), res = CGAL::quadratic_interpolation(coords.begin(), coords.end(),
@ -201,13 +186,18 @@ int main()
function_value, function_value,
function_gradient, function_gradient,
Traits()); Traits());
if(res.second){
if(res.second)
{
error = CGAL_NTS abs(res.first - exact_value); error = CGAL_NTS abs(res.first - exact_value);
q_total += error; q_total += error;
if (error > q_max) q_max = error; if (error > q_max)
} else ++failure; q_max = error;
}
else
{
++failure;
}
//Sibson interpolant: version without sqrt: //Sibson interpolant: version without sqrt:
res = CGAL::sibson_c1_interpolation_square(coords.begin(), res = CGAL::sibson_c1_interpolation_square(coords.begin(),
@ -217,11 +207,17 @@ int main()
function_gradient, function_gradient,
Traits()); Traits());
//error statistics //error statistics
if(res.second){ if(res.second)
{
error = CGAL_NTS abs(res.first - exact_value); error = CGAL_NTS abs(res.first - exact_value);
ssquare_total += error; ssquare_total += error;
if (error > ssquare_max) ssquare_max = error; if (error > ssquare_max)
} else ++failure; ssquare_max = error;
}
else
{
++failure;
}
//with sqrt(the traditional): //with sqrt(the traditional):
res = CGAL::sibson_c1_interpolation(coords.begin(), res = CGAL::sibson_c1_interpolation(coords.begin(),
@ -232,15 +228,18 @@ int main()
Traits()); Traits());
//error statistics //error statistics
if(res.second){ if(res.second)
{
error = CGAL_NTS abs(res.first - exact_value); error = CGAL_NTS abs(res.first - exact_value);
s_total += error; s_total += error;
if (error > s_max) s_max = error; if (error > s_max)
} else ++failure; s_max = error;
}
else
{
++failure;
}
} }
/************** end of Interpolation: dump statistics **************/ /************** end of Interpolation: dump statistics **************/
std::cout << "Result: -----------------------------------" << std::endl; std::cout << "Result: -----------------------------------" << std::endl;
@ -270,7 +269,5 @@ int main()
<< CGAL::to_double(ssquare_total)/n << " max " << CGAL::to_double(ssquare_total)/n << " max "
<< CGAL::to_double(ssquare_max) << std::endl; << CGAL::to_double(ssquare_max) << std::endl;
return EXIT_SUCCESS;
std::cout << "done" << std::endl;
return 0;
} }

View File

@ -14,10 +14,11 @@ typedef K::Point_2 Point;
int main() int main()
{ {
Delaunay_triangulation T; Delaunay_triangulation T;
std::map<Point, Coord_type, K::Less_xy_2> function_values;
typedef CGAL::Data_access< std::map<Point, Coord_type, K::Less_xy_2 > >
Value_access;
typedef std::map<Point, Coord_type, K::Less_xy_2> Coord_map;
typedef CGAL::Data_access<Coord_map> Value_access;
Coord_map function_values;
Coord_type a(0.25), bx(1.3), by(-0.7); Coord_type a(0.25), bx(1.3), by(-0.7);
for (int y=0 ; y<3 ; y++){ for (int y=0 ; y<3 ; y++){
@ -31,17 +32,13 @@ int main()
//coordinate computation //coordinate computation
K::Point_2 p(1.3, 0.34); K::Point_2 p(1.3, 0.34);
std::vector<std::pair<Point, Coord_type> > coords; std::vector<std::pair<Point, Coord_type> > coords;
Coord_type norm =
CGAL::natural_neighbor_coordinates_2
(T, p,std::back_inserter(coords)).second;
Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(), Coord_type norm = CGAL::natural_neighbor_coordinates_2(T, p, std::back_inserter(coords)).second;
norm, Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(), norm,
Value_access(function_values)); Value_access(function_values));
std::cout << "Tested interpolation on " << p << " interpolation: " std::cout << "Tested interpolation on " << p << " interpolation: "
<< res << " exact: " << a + bx*p.x() + by*p.y() << std::endl; << res << " exact: " << a + bx*p.x() + by*p.y() << std::endl;
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -1,7 +1,13 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h> #include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/natural_neighbor_coordinates_2.h> #include <CGAL/natural_neighbor_coordinates_2.h>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
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; typedef std::vector< std::pair<K::Point_2, K::FT> > Point_coordinate_vector;
@ -17,20 +23,18 @@ int main()
//coordinate computation //coordinate computation
K::Point_2 p(1.2, 0.7); K::Point_2 p(1.2, 0.7);
Point_coordinate_vector coords; Point_coordinate_vector coords;
CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>, CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>, K::FT, bool> result =
K::FT, bool> result =
CGAL::natural_neighbor_coordinates_2(dt, p, std::back_inserter(coords)); CGAL::natural_neighbor_coordinates_2(dt, p, std::back_inserter(coords));
if(!result.third){ if(!result.third)
std::cout << "The coordinate computation was not successful." {
<< std::endl; std::cout << "The coordinate computation was not successful." << std::endl;
std::cout << "The point (" <<p << ") lies outside the convex hull." std::cout << "The point (" << p << ") lies outside the convex hull." << std::endl;
<< std::endl;
} }
K::FT norm = result.second; K::FT norm = result.second;
std::cout << "Coordinate computation successful." << std::endl; std::cout << "Coordinate computation successful." << std::endl;
std::cout << "Normalization factor: " << norm << std::endl; std::cout << "Normalization factor: " << norm << std::endl;
std::cout << "done" << std::endl;
return 0; return EXIT_SUCCESS;
} }

View File

@ -1,7 +1,13 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h> #include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/natural_neighbor_coordinates_3.h> #include <CGAL/natural_neighbor_coordinates_3.h>
#include <fstream> #include <fstream>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>
typedef double NT; //Number Type typedef double NT; //Number Type
@ -67,6 +73,7 @@ int main()
sibson_natural_neighbor_coordinates_3(triangulation,pp[ii], sibson_natural_neighbor_coordinates_3(triangulation,pp[ii],
std::back_inserter(coor_sibson), std::back_inserter(coor_sibson),
norm_coeff_sibson); norm_coeff_sibson);
std::cout << "Linear combination of natural neighbors with Sibson natural coordinates" << std::endl; 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 << " + correctness (ensured only with an exact number type)" << std::endl;
std::cout << is_correct_natural_neighborhood(triangulation,pp[ii], std::cout << is_correct_natural_neighborhood(triangulation,pp[ii],
@ -76,6 +83,5 @@ int main()
<< std::endl; << std::endl;
} }
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -1,7 +1,13 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_2.h> #include <CGAL/Regular_triangulation_2.h>
#include <CGAL/regular_neighbor_coordinates_2.h> #include <CGAL/regular_neighbor_coordinates_2.h>
#include <iostream>
#include <iterator>
#include <vector>
#include <utility>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Regular_triangulation_2<K> Regular_triangulation; typedef CGAL::Regular_triangulation_2<K> Regular_triangulation;
@ -20,21 +26,17 @@ int main()
//coordinate computation //coordinate computation
Weighted_point wp(Bare_point(1.2, 0.7), 2); Weighted_point wp(Bare_point(1.2, 0.7), 2);
Point_coordinate_vector coords; Point_coordinate_vector coords;
CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>, CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>, K::FT, bool> result =
K::FT, bool> result =
CGAL::regular_neighbor_coordinates_2(rt, wp, std::back_inserter(coords)); CGAL::regular_neighbor_coordinates_2(rt, wp, std::back_inserter(coords));
if(!result.third){ if(!result.third){
std::cout << "The coordinate computation was not successful." std::cout << "The coordinate computation was not successful." << std::endl;
<< std::endl; std::cout << "The point (" <<wp.point() << ") lies outside the convex hull." << std::endl;
std::cout << "The point (" <<wp.point() << ") lies outside the convex hull."
<< std::endl;
} }
K::FT norm = result.second; K::FT norm = result.second;
std::cout << "Coordinate computation successful." << std::endl; std::cout << "Coordinate computation successful." << std::endl;
std::cout << "Normalization factor: " << norm << std::endl; std::cout << "Normalization factor: " << norm << std::endl;
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -6,6 +6,12 @@
#include <CGAL/sibson_gradient_fitting.h> #include <CGAL/sibson_gradient_fitting.h>
#include <CGAL/interpolation_functions.h> #include <CGAL/interpolation_functions.h>
#include <iostream>
#include <iterator>
#include <map>
#include <utility>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation; typedef CGAL::Delaunay_triangulation_2<K> Delaunay_triangulation;
typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits; typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits;
@ -50,8 +56,7 @@ int main()
//Sibson interpolant: version without sqrt: //Sibson interpolant: version without sqrt:
std::pair<Coord_type, bool> res = std::pair<Coord_type, bool> res =
CGAL::sibson_c1_interpolation_square( CGAL::sibson_c1_interpolation_square(coords.begin(),
coords.begin(),
coords.end(),norm,p, coords.end(),norm,p,
CGAL::Data_access<Point_value_map>(function_values), CGAL::Data_access<Point_value_map>(function_values),
CGAL::Data_access<Point_vector_map>(function_gradients), CGAL::Data_access<Point_vector_map>(function_gradients),
@ -67,6 +72,5 @@ int main()
<< " not all function_gradients are provided." << std::endl << " not all function_gradients are provided." << std::endl
<< " You may resort to linear interpolation." << std::endl; << " You may resort to linear interpolation." << std::endl;
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -1,11 +1,18 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/natural_neighbor_coordinates_2.h> #include <CGAL/natural_neighbor_coordinates_2.h>
#include <CGAL/Interpolation_gradient_fitting_traits_2.h> #include <CGAL/Interpolation_gradient_fitting_traits_2.h>
#include <CGAL/sibson_gradient_fitting.h> #include <CGAL/sibson_gradient_fitting.h>
#include <CGAL/interpolation_functions.h> #include <CGAL/interpolation_functions.h>
#include <CGAL/Regular_triangulation_2.h>
#include <iostream>
#include <iterator>
#include <map>
#include <utility>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Regular_triangulation_2<K> Regular_triangulation; typedef CGAL::Regular_triangulation_2<K> Regular_triangulation;
typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits; typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits;
@ -13,14 +20,13 @@ typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits;
typedef K::FT Coord_type; typedef K::FT Coord_type;
typedef K::Weighted_point_2 Point; typedef K::Weighted_point_2 Point;
struct Less { struct Less
bool operator()(const Point& p, const Point& q) const
{ {
bool operator()(const Point& p, const Point& q) const {
return K::Less_xy_2()(p.point(), q.point()); return K::Less_xy_2()(p.point(), q.point());
} }
}; };
typedef std::map<Point, Coord_type, Less> Point_value_map ; typedef std::map<Point, Coord_type, Less> Point_value_map ;
typedef std::map<Point, K::Vector_2 , Less> Point_vector_map; typedef std::map<Point, K::Vector_2 , Less> Point_vector_map;
@ -46,22 +52,21 @@ int main()
CGAL::Data_access<Point_value_map>(function_values), CGAL::Data_access<Point_value_map>(function_values),
Traits()); Traits());
for(Point_vector_map::iterator it = function_gradients.begin(); it != function_gradients.end(); ++it) for(Point_vector_map::iterator it = function_gradients.begin();
{ it != function_gradients.end(); ++it) {
std::cout << it->first << " " << it->second << std::endl; std::cout << it->first << " " << it->second << std::endl;
} }
//coordinate computation //coordinate computation
Point p(1.6, 1.4); Point p(1.6, 1.4);
std::vector<std::pair<Point, Coord_type> > coords; std::vector<std::pair<Point, Coord_type> > coords;
Coord_type norm = CGAL::regular_neighbor_coordinates_2(T, p, std::back_inserter Coord_type norm = CGAL::regular_neighbor_coordinates_2(T, p, std::back_inserter(coords)).second;
(coords)).second;
//Sibson interpolant: version without sqrt: //Sibson interpolant: version without sqrt:
std::pair<Coord_type, bool> res = std::pair<Coord_type, bool> res = CGAL::sibson_c1_interpolation_square(coords.begin(),
CGAL::sibson_c1_interpolation_square( coords.end(),
coords.begin(), norm,
coords.end(),norm,p, p,
CGAL::Data_access<Point_value_map>(function_values), CGAL::Data_access<Point_value_map>(function_values),
CGAL::Data_access<Point_vector_map>(function_gradients), CGAL::Data_access<Point_vector_map>(function_gradients),
Traits()); Traits());
@ -76,6 +81,5 @@ int main()
<< " not all function_gradients are provided." << std::endl << " not all function_gradients are provided." << std::endl
<< " You may resort to linear interpolation." << std::endl; << " You may resort to linear interpolation." << std::endl;
std::cout << "done" << std::endl;
return 0; return 0;
} }

View File

@ -1,12 +1,18 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/natural_neighbor_coordinates_2.h> #include <CGAL/natural_neighbor_coordinates_2.h>
#include <CGAL/Interpolation_gradient_fitting_traits_2.h> #include <CGAL/Interpolation_gradient_fitting_traits_2.h>
#include <CGAL/sibson_gradient_fitting.h> #include <CGAL/sibson_gradient_fitting.h>
#include <CGAL/interpolation_functions.h> #include <CGAL/interpolation_functions.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Regular_triangulation_2.h>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits; typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits;
@ -15,65 +21,51 @@ typedef K::Weighted_point_2 Point;
typedef K::Vector_2 Vector; typedef K::Vector_2 Vector;
template <typename V, typename G> template <typename V, typename G>
struct Value_and_gradient { struct Value_and_gradient
Value_and_gradient() {
: value(), gradient(CGAL::NULL_VECTOR) Value_and_gradient() : value(), gradient(CGAL::NULL_VECTOR) {}
{}
V value; V value;
G gradient; G gradient;
}; };
typedef CGAL::Triangulation_vertex_base_with_info_2<Value_and_gradient<Coord_type,Vector>, K, CGAL::Regular_triangulation_vertex_base_2<K> > Vb; typedef CGAL::Triangulation_vertex_base_with_info_2<
Value_and_gradient<Coord_type, Vector>, K,
CGAL::Regular_triangulation_vertex_base_2<K> > Vb;
typedef CGAL::Regular_triangulation_face_base_2<K> Fb; typedef CGAL::Regular_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds; typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
typedef CGAL::Regular_triangulation_2<K, Tds> Regular_triangulation; typedef CGAL::Regular_triangulation_2<K, Tds> Regular_triangulation;
typedef Regular_triangulation::Vertex_handle Vertex_handle; typedef Regular_triangulation::Vertex_handle Vertex_handle;
template <typename V, typename T> template <typename V, typename T>
struct Function_value { struct Function_value
{
typedef V argument_type; typedef V argument_type;
typedef std::pair<T, bool> result_type; typedef std::pair<T, bool> result_type;
result_type operator()(const argument_type& a)const result_type operator()(const argument_type& a) const {
{
return result_type(a->info().value, true); return result_type(a->info().value, true);
} }
}; };
template <typename V, typename G> template <typename V, typename G>
struct Function_gradient struct Function_gradient
: public std::iterator<std::output_iterator_tag,void,void,void,void> { : public std::iterator<std::output_iterator_tag, void, void, void, void>
{
typedef V argument_type; typedef V argument_type;
typedef std::pair<G, bool> result_type; typedef std::pair<G, bool> result_type;
result_type operator()(const argument_type& a) const {
result_type
operator()(const argument_type& a)const
{
return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR); return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR);
} }
const Function_gradient& operator=(const std::pair<V, G>& p) const {
const Function_gradient& operator=(const std::pair<V, G>& p) const
{
p.first->info().gradient = p.second; p.first->info().gradient = p.second;
return *this; return *this;
} }
const Function_gradient& operator++(int) const const Function_gradient& operator++(int) const { return *this; }
{ const Function_gradient& operator*() const { return *this; }
return *this;
}
const Function_gradient& operator*() const
{
return *this;
}
}; };
int main() int main()
@ -99,6 +91,7 @@ int main()
function_value, function_value,
CGAL::Identity<std::pair<Vertex_handle, Vector> >(), CGAL::Identity<std::pair<Vertex_handle, Vector> >(),
Traits()); Traits());
//coordinate computation //coordinate computation
Point p(1.6,1.4); Point p(1.6,1.4);
std::vector<std::pair<Vertex_handle, Coord_type> > coords; std::vector<std::pair<Vertex_handle, Coord_type> > coords;
@ -108,7 +101,6 @@ int main()
std::back_inserter(coords), std::back_inserter(coords),
Identity()).second; Identity()).second;
//Sibson interpolant: version without sqrt: //Sibson interpolant: version without sqrt:
std::pair<Coord_type, bool> res = CGAL::sibson_c1_interpolation_square(coords.begin(), std::pair<Coord_type, bool> res = CGAL::sibson_c1_interpolation_square(coords.begin(),
coords.end(), coords.end(),
@ -128,6 +120,5 @@ int main()
<< " not all function_gradients are provided." << std::endl << " not all function_gradients are provided." << std::endl
<< " You may resort to linear interpolation." << std::endl; << " You may resort to linear interpolation." << std::endl;
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -7,6 +7,11 @@
#include <CGAL/sibson_gradient_fitting.h> #include <CGAL/sibson_gradient_fitting.h>
#include <CGAL/interpolation_functions.h> #include <CGAL/interpolation_functions.h>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits; typedef CGAL::Interpolation_gradient_fitting_traits_2<K> Traits;
@ -15,64 +20,49 @@ typedef K::Point_2 Point;
typedef K::Vector_2 Vector; typedef K::Vector_2 Vector;
template <typename V, typename G> template <typename V, typename G>
struct Value_and_gradient { struct Value_and_gradient
Value_and_gradient() {
: value(), gradient(CGAL::NULL_VECTOR) Value_and_gradient() : value(), gradient(CGAL::NULL_VECTOR) {}
{}
V value; V value;
G gradient; G gradient;
}; };
typedef CGAL::Triangulation_vertex_base_with_info_2<Value_and_gradient<Coord_type,Vector>, K> Vb; typedef CGAL::Triangulation_vertex_base_with_info_2<
Value_and_gradient<Coord_type, Vector>, K> Vb;
typedef CGAL::Triangulation_data_structure_2<Vb> Tds; typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
typedef CGAL::Delaunay_triangulation_2<K,Tds> Delaunay_triangulation; typedef CGAL::Delaunay_triangulation_2<K,Tds> Delaunay_triangulation;
typedef Delaunay_triangulation::Vertex_handle Vertex_handle; typedef Delaunay_triangulation::Vertex_handle Vertex_handle;
template <typename V, typename T> template <typename V, typename T>
struct Function_value { struct Function_value
{
typedef V argument_type; typedef V argument_type;
typedef std::pair<T, bool> result_type; typedef std::pair<T, bool> result_type;
result_type operator()(const argument_type& a)const result_type operator()(const argument_type& a) const {
{
return result_type(a->info().value, true); return result_type(a->info().value, true);
} }
}; };
template <typename V, typename G> template <typename V, typename G>
struct Function_gradient struct Function_gradient
: public std::iterator<std::output_iterator_tag,void,void,void,void> { : public std::iterator<std::output_iterator_tag, void, void, void, void>
{
typedef V argument_type; typedef V argument_type;
typedef std::pair<G, bool> result_type; typedef std::pair<G, bool> result_type;
result_type operator()(const argument_type& a) const {
result_type
operator()(const argument_type& a)const
{
return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR); return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR);
} }
const Function_gradient& operator=(const std::pair<V, G>& p) const {
const Function_gradient& operator=(const std::pair<V, G>& p) const
{
p.first->info().gradient = p.second; p.first->info().gradient = p.second;
return *this; return *this;
} }
const Function_gradient& operator++(int) const const Function_gradient& operator++(int) const { return *this; }
{ const Function_gradient& operator*() const { return *this; }
return *this;
}
const Function_gradient& operator*() const
{
return *this;
}
}; };
int main() int main()
@ -108,7 +98,6 @@ int main()
std::back_inserter(coords), std::back_inserter(coords),
Identity()).second; Identity()).second;
//Sibson interpolant: version without sqrt: //Sibson interpolant: version without sqrt:
std::pair<Coord_type, bool> res = CGAL::sibson_c1_interpolation_square(coords.begin(), std::pair<Coord_type, bool> res = CGAL::sibson_c1_interpolation_square(coords.begin(),
coords.end(), coords.end(),
@ -128,6 +117,5 @@ int main()
<< " not all function_gradients are provided." << std::endl << " not all function_gradients are provided." << std::endl
<< " You may resort to linear interpolation." << std::endl; << " You may resort to linear interpolation." << std::endl;
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -32,17 +32,18 @@ int main()
Vector_3 normal(p - CGAL::ORIGIN); Vector_3 normal(p - CGAL::ORIGIN);
std::cout << "Compute surface neighbor coordinates for " << p << std::endl; std::cout << "Compute surface neighbor coordinates for " << p << std::endl;
Point_coordinate_vector coords; Point_coordinate_vector coords;
CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>, CGAL::Triple<std::back_insert_iterator<Point_coordinate_vector>, K::FT, bool> result =
K::FT, bool> result =
CGAL::surface_neighbor_coordinates_3(points.begin(), points.end(), CGAL::surface_neighbor_coordinates_3(points.begin(), points.end(),
p, normal, p, normal,
std::back_inserter(coords), std::back_inserter(coords),
K()); K());
if(!result.third){ if(!result.third)
{
//Undersampling: //Undersampling:
std::cout << "The coordinate computation was not successful." << std::endl; std::cout << "The coordinate computation was not successful." << std::endl;
return 0; return 0;
} }
K::FT norm = result.second; K::FT norm = result.second;
std::cout << "Testing the barycentric property " << std::endl; std::cout << "Testing the barycentric property " << std::endl;
@ -54,6 +55,5 @@ int main()
std::cout << " weighted barycenter: " << b <<std::endl; std::cout << " weighted barycenter: " << b <<std::endl;
std::cout << " squared distance: " << CGAL::squared_distance(p,b) << std::endl; std::cout << " squared distance: " << CGAL::squared_distance(p,b) << std::endl;
std::cout << "done" << std::endl; return EXIT_SUCCESS;
return 0;
} }

View File

@ -23,7 +23,6 @@
#include <CGAL/license/Interpolation.h> #include <CGAL/license/Interpolation.h>
namespace CGAL { namespace CGAL {
namespace Interpolation { namespace Interpolation {
namespace internal { namespace internal {
@ -60,7 +59,8 @@ namespace internal {
template < typename Dt, typename T2 > template < typename Dt, typename T2 >
struct Vertex2Point { struct Vertex2Point
{
typedef typename Dt::Vertex_handle Vertex_handle; typedef typename Dt::Vertex_handle Vertex_handle;
typedef typename Dt::Point Point; typedef typename Dt::Point Point;
@ -73,8 +73,10 @@ namespace internal {
} }
}; };
template < typename Dt, typename T2 > template < typename Dt, typename T2 >
struct Vertex2WPoint { struct Vertex2WPoint
{
typedef typename Dt::Vertex_handle Vertex_handle; typedef typename Dt::Vertex_handle Vertex_handle;
typedef typename Dt::Weighted_point Point; typedef typename Dt::Weighted_point Point;
@ -89,7 +91,8 @@ namespace internal {
template < typename Dt, typename Map > template < typename Dt, typename Map >
struct Vertex2Vertex { struct Vertex2Vertex
{
typedef typename Dt::Vertex_handle Vertex_handle; typedef typename Dt::Vertex_handle Vertex_handle;
typedef typename Dt::Geom_traits::FT FT; typedef typename Dt::Geom_traits::FT FT;
typedef std::pair<Vertex_handle, FT> argument_type; typedef std::pair<Vertex_handle, FT> argument_type;
@ -111,6 +114,7 @@ namespace internal {
} }
}; };
// the struct "Project_vertex_output_iterator" // the struct "Project_vertex_output_iterator"
// is used in the (next two) functions // is used in the (next two) functions
// as well as in regular_neighbor_coordinates_2 and // as well as in regular_neighbor_coordinates_2 and
@ -143,14 +147,13 @@ namespace internal {
Project_vertex_output_iterator& operator*(){return *this;} Project_vertex_output_iterator& operator*(){return *this;}
template<class Vertex_pair> template<class Vertex_pair>
Project_vertex_output_iterator& Project_vertex_output_iterator& operator=(const Vertex_pair& vp)
operator=(const Vertex_pair& vp){ {
*_base = fct(vp); *_base = fct(vp);
return *this; return *this;
} }
}; };
} // namespace internal } // namespace internal
} // namespace Interpolation } // namespace Interpolation
} // namespace CGAL } // namespace CGAL

View File

@ -22,19 +22,21 @@
#define CGAL_NATURAL_NEIGHBOR_COORDINATES_2_H #define CGAL_NATURAL_NEIGHBOR_COORDINATES_2_H
#include <CGAL/license/Interpolation.h> #include <CGAL/license/Interpolation.h>
#include <CGAL/Interpolation/internal/helpers.h> #include <CGAL/Interpolation/internal/helpers.h>
#include <CGAL/Iterator_project.h> #include <CGAL/Iterator_project.h>
#include <CGAL/Polygon_2.h> #include <CGAL/Polygon_2.h>
#include <CGAL/number_utils_classes.h> #include <CGAL/number_utils_classes.h>
#include <CGAL/utility.h> #include <CGAL/utility.h>
#include <iterator>
#include <list> #include <list>
#include <utility> #include <utility>
#include <vector>
namespace CGAL { namespace CGAL {
// The following natural_neighbor_coordinate_2 functions fix the // The following natural_neighbor_coordinate_2 functions fix the
// traits class to be Dt::Geom_traits. The following signatures could // traits class to be Dt::Geom_traits. The following signatures could
// be used if one wants to pass a traits class as argument: // be used if one wants to pass a traits class as argument:
@ -60,8 +62,8 @@ template < class Dt, class OutputIterator >
Triple< OutputIterator, typename Dt::Geom_traits::FT, bool > Triple< OutputIterator, typename Dt::Geom_traits::FT, bool >
natural_neighbors_2(const Dt& dt, natural_neighbors_2(const Dt& dt,
const typename Dt::Geom_traits::Point_2& p, const typename Dt::Geom_traits::Point_2& p,
OutputIterator out, typename Dt::Face_handle start OutputIterator out,
= typename Dt::Face_handle()) typename Dt::Face_handle start = typename Dt::Face_handle())
{ {
typedef typename Dt::Geom_traits Traits; typedef typename Dt::Geom_traits Traits;
typedef typename Traits::FT Coord_type; typedef typename Traits::FT Coord_type;
@ -148,6 +150,7 @@ natural_neighbors_2(const Dt& dt,
Coord_type area_sum(0); Coord_type area_sum(0);
EdgeIterator hit = hole_end; EdgeIterator hit = hole_end;
--hit; --hit;
//in the beginning: prev is the "last" vertex of the hole: //in the beginning: prev is the "last" vertex of the hole:
// later: prev is the last vertex processed (previously) // later: prev is the last vertex processed (previously)
Vertex_handle prev = hit->first->vertex(dt.cw(hit->second)); Vertex_handle prev = hit->first->vertex(dt.cw(hit->second));
@ -205,8 +208,7 @@ natural_neighbor_coordinates_2(const Dt& dt,
Interpolation::internal::Project_vertex_output_iterator<OutputIterator, Fct> op(out, fct); Interpolation::internal::Project_vertex_output_iterator<OutputIterator, Fct> op(out, fct);
Triple<Interpolation::internal::Project_vertex_output_iterator<OutputIterator,Fct>, Triple<Interpolation::internal::Project_vertex_output_iterator<OutputIterator,Fct>,
typename Dt::Geom_traits::FT, bool > result = typename Dt::Geom_traits::FT, bool > result = natural_neighbors_2(dt, p, op, start);
natural_neighbors_2(dt, p, op, start);
return make_triple(result.first.base(), result.second, result.third); return make_triple(result.first.base(), result.second, result.third);
} }
@ -255,6 +257,7 @@ natural_neighbor_coordinates_2(const Dt& dt,
return make_triple(result.first.base(), result.second, result.third); return make_triple(result.first.base(), result.second, result.third);
} }
//OutputIterator has value type //OutputIterator has value type
// std::pair< Dt::Geom_traits::Point_2, Dt::Geom_traits::FT> // std::pair< Dt::Geom_traits::Point_2, Dt::Geom_traits::FT>
//function call if the conflict zone is known: //function call if the conflict zone is known:
@ -270,6 +273,7 @@ natural_neighbor_coordinates_2(const Dt& dt,
Interpolation::internal::Vertex2Point<Dt, typename Dt::Geom_traits::FT>()); Interpolation::internal::Vertex2Point<Dt, typename Dt::Geom_traits::FT>());
} }
/**********************************************************/ /**********************************************************/
//compute the coordinates for a vertex of the triangulation //compute the coordinates for a vertex of the triangulation
// with respect to the other points in the triangulation // with respect to the other points in the triangulation
@ -340,7 +344,6 @@ public:
} }
}; };
} //namespace CGAL } //namespace CGAL
#endif // CGAL_NATURAL_NEIGHBOR_COORDINATES_2_H #endif // CGAL_NATURAL_NEIGHBOR_COORDINATES_2_H

View File

@ -108,8 +108,9 @@ laplace_natural_neighbor_coordinates_3(const Dt& dt,
std::set<Cell_handle> cells; std::set<Cell_handle> cells;
// To replace the forbidden access to the "in conflict" flag : // To replace the forbidden access to the "in conflict" flag :
// std::find operations on this set // std::find operations on this set
std::vector<Facet> bound_facets; bound_facets.reserve(32); std::vector<Facet> bound_facets;
typename std::vector<Facet>::iterator bound_it; bound_facets.reserve(32);
// Find the cells in conflict with Q // Find the cells in conflict with Q
dt.find_conflicts(Q, c, dt.find_conflicts(Q, c,
std::back_inserter(bound_facets), std::back_inserter(bound_facets),
@ -118,6 +119,7 @@ laplace_natural_neighbor_coordinates_3(const Dt& dt,
std::map<Vertex_handle,Coord_type> coordinate; std::map<Vertex_handle,Coord_type> coordinate;
typename std::map<Vertex_handle,Coord_type>::iterator coor_it; typename std::map<Vertex_handle,Coord_type>::iterator coor_it;
typename std::vector<Facet>::iterator bound_it;
for (bound_it = bound_facets.begin(); bound_it != bound_facets.end(); ++bound_it) for (bound_it = bound_facets.begin(); bound_it != bound_facets.end(); ++bound_it)
{ {
//for each facet on the boundary //for each facet on the boundary

View File

@ -120,8 +120,7 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
rt.get_boundary_of_conflicts_and_hidden_vertices(p, rt.get_boundary_of_conflicts_and_hidden_vertices(p,
std::back_inserter(hole), std::back_inserter(hole),
std::back_inserter std::back_inserter(hidden_vertices),
(hidden_vertices),
fh); fh);
return regular_neighbor_coordinates_vertex_2(rt, p, out, vor_vertices, return regular_neighbor_coordinates_vertex_2(rt, p, out, vor_vertices,
hole.begin(),hole.end(), hole.begin(),hole.end(),
@ -217,6 +216,7 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
area += polygon_area_2(vor.begin(), vor.end(), rt.geom_traits()); area += polygon_area_2(vor.begin(), vor.end(), rt.geom_traits());
vor[1] = vor[2]; vor[1] = vor[2];
} }
//the second Voronoi vertex of the cell of p: //the second Voronoi vertex of the cell of p:
vor[2] = vor[2] =
rt.geom_traits().construct_weighted_circumcenter_2_object() rt.geom_traits().construct_weighted_circumcenter_2_object()
@ -239,8 +239,8 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
// vor1: dual of first triangle // vor1: dual of first triangle
// vor2, vor 3: duals of two consecutive triangles // vor2, vor 3: duals of two consecutive triangles
Face_circulator fc, fc_begin; Face_circulator fc, fc_begin;
for(; hidden_vertices_begin != hidden_vertices_end; for(; hidden_vertices_begin != hidden_vertices_end; ++hidden_vertices_begin)
++hidden_vertices_begin){ {
Coord_type area(0); Coord_type area(0);
fc_begin = rt.incident_faces(*hidden_vertices_begin); fc_begin = rt.incident_faces(*hidden_vertices_begin);
vor[0] = rt.dual(fc_begin); vor[0] = rt.dual(fc_begin);
@ -248,7 +248,8 @@ regular_neighbor_coordinates_vertex_2(const Rt& rt,
++fc; ++fc;
vor[1] = rt.dual(fc); vor[1] = rt.dual(fc);
++fc; ++fc;
while(fc != fc_begin){ while(fc != fc_begin)
{
vor[2] = rt.dual(fc); vor[2] = rt.dual(fc);
area += polygon_area_2(vor.begin(), vor.end(), rt.geom_traits()); area += polygon_area_2(vor.begin(), vor.end(), rt.geom_traits());