mirror of https://github.com/CGAL/cgal
Clarified functor names
This commit is contained in:
parent
751395e4fe
commit
c88b17f92e
|
|
@ -39,7 +39,7 @@ 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 Value_function
|
||||||
{
|
{
|
||||||
typedef V argument_type;
|
typedef V argument_type;
|
||||||
typedef std::pair<T, bool> result_type;
|
typedef std::pair<T, bool> result_type;
|
||||||
|
|
@ -50,7 +50,7 @@ struct Function_value
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename V, typename G>
|
template <typename V, typename G>
|
||||||
struct Function_gradient
|
struct Gradient_function
|
||||||
: public std::iterator<std::output_iterator_tag, void, void, void, void>
|
: public std::iterator<std::output_iterator_tag, void, void, void, void>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -61,13 +61,13 @@ struct Function_gradient
|
||||||
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 Gradient_function& 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 { return *this; }
|
const Gradient_function& operator++(int) const { return *this; }
|
||||||
const Function_gradient& operator*() const { return *this; }
|
const Gradient_function& operator*() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|
@ -94,8 +94,8 @@ int main()
|
||||||
|
|
||||||
Delaunay_triangulation T;
|
Delaunay_triangulation T;
|
||||||
|
|
||||||
Function_value<Vertex_handle, Coord_type> function_value;
|
Value_function<Vertex_handle, Coord_type> value_function;
|
||||||
Function_gradient<Vertex_handle, Vector> function_gradient;
|
Gradient_function<Vertex_handle, Vector> gradient_function;
|
||||||
|
|
||||||
//parameters for quadratic function:
|
//parameters for quadratic function:
|
||||||
Coord_type alpha = Coord_type(1.0),
|
Coord_type alpha = Coord_type(1.0),
|
||||||
|
|
@ -154,7 +154,7 @@ int main()
|
||||||
|
|
||||||
//linear interpolant:
|
//linear interpolant:
|
||||||
l_value = CGAL::linear_interpolation(coords.begin(), coords.end(),
|
l_value = CGAL::linear_interpolation(coords.begin(), coords.end(),
|
||||||
norm, function_value);
|
norm, value_function);
|
||||||
|
|
||||||
error = CGAL_NTS abs(l_value - exact_value);
|
error = CGAL_NTS abs(l_value - exact_value);
|
||||||
l_total += error;
|
l_total += error;
|
||||||
|
|
@ -163,8 +163,8 @@ int main()
|
||||||
//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],
|
||||||
function_value,
|
value_function,
|
||||||
function_gradient,
|
gradient_function,
|
||||||
Traits());
|
Traits());
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -183,8 +183,8 @@ int main()
|
||||||
//quadratic interpolant:
|
//quadratic interpolant:
|
||||||
res = CGAL::quadratic_interpolation(coords.begin(), coords.end(),
|
res = CGAL::quadratic_interpolation(coords.begin(), coords.end(),
|
||||||
norm, points[i],
|
norm, points[i],
|
||||||
function_value,
|
value_function,
|
||||||
function_gradient,
|
gradient_function,
|
||||||
Traits());
|
Traits());
|
||||||
|
|
||||||
if(res.second)
|
if(res.second)
|
||||||
|
|
@ -203,8 +203,8 @@ int main()
|
||||||
res = CGAL::sibson_c1_interpolation_square(coords.begin(),
|
res = CGAL::sibson_c1_interpolation_square(coords.begin(),
|
||||||
coords.end(), norm,
|
coords.end(), norm,
|
||||||
points[i],
|
points[i],
|
||||||
function_value,
|
value_function,
|
||||||
function_gradient,
|
gradient_function,
|
||||||
Traits());
|
Traits());
|
||||||
//error statistics
|
//error statistics
|
||||||
if(res.second)
|
if(res.second)
|
||||||
|
|
@ -223,8 +223,8 @@ int main()
|
||||||
res = CGAL::sibson_c1_interpolation(coords.begin(),
|
res = CGAL::sibson_c1_interpolation(coords.begin(),
|
||||||
coords.end(), norm,
|
coords.end(), norm,
|
||||||
points[i],
|
points[i],
|
||||||
function_value,
|
value_function,
|
||||||
function_gradient,
|
gradient_function,
|
||||||
Traits());
|
Traits());
|
||||||
|
|
||||||
//error statistics
|
//error statistics
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ int main()
|
||||||
typedef std::map<Point, Coord_type, K::Less_xy_2> Coord_map;
|
typedef std::map<Point, Coord_type, K::Less_xy_2> Coord_map;
|
||||||
typedef CGAL::Data_access<Coord_map> Value_access;
|
typedef CGAL::Data_access<Coord_map> Value_access;
|
||||||
|
|
||||||
Coord_map function_values;
|
Coord_map value_function;
|
||||||
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++){
|
||||||
for (int x=0 ; x<3 ; x++){
|
for (int x=0 ; x<3 ; x++){
|
||||||
K::Point_2 p(x,y);
|
K::Point_2 p(x,y);
|
||||||
T.insert(p);
|
T.insert(p);
|
||||||
function_values.insert(std::make_pair(p, a + bx*x + by*y));
|
value_function.insert(std::make_pair(p, a + bx*x + by*y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ int main()
|
||||||
|
|
||||||
Coord_type norm = CGAL::natural_neighbor_coordinates_2(T, p, std::back_inserter(coords)).second;
|
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(), norm,
|
Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(), norm,
|
||||||
Value_access(function_values));
|
Value_access(value_function));
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ int main()
|
||||||
{
|
{
|
||||||
Delaunay_triangulation T;
|
Delaunay_triangulation T;
|
||||||
|
|
||||||
Point_value_map function_values;
|
Point_value_map value_function;
|
||||||
Point_vector_map function_gradients;
|
Point_vector_map gradient_function;
|
||||||
|
|
||||||
//parameters for spherical function:
|
//parameters for spherical function:
|
||||||
Coord_type a(0.25), bx(1.3), by(-0.7), c(0.2);
|
Coord_type a(0.25), bx(1.3), by(-0.7), c(0.2);
|
||||||
|
|
@ -34,32 +34,31 @@ int main()
|
||||||
for (int x=0; x<4; x++) {
|
for (int x=0; x<4; x++) {
|
||||||
K::Point_2 p(x,y);
|
K::Point_2 p(x,y);
|
||||||
T.insert(p);
|
T.insert(p);
|
||||||
function_values.insert(std::make_pair(p,a + bx* x+ by*y + c*(x*x+y*y)));
|
value_function.insert(std::make_pair(p,a + bx* x+ by*y + c*(x*x+y*y)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sibson_gradient_fitting_nn_2(T, std::inserter(function_gradients,
|
sibson_gradient_fitting_nn_2(T, std::inserter(gradient_function,
|
||||||
function_gradients.begin()),
|
gradient_function.begin()),
|
||||||
CGAL::Data_access<Point_value_map>(function_values),
|
CGAL:: Data_access<Point_value_map>(value_function),
|
||||||
Traits());
|
Traits());
|
||||||
|
|
||||||
for(Point_vector_map::iterator it = function_gradients.begin(); it != function_gradients.end(); ++it)
|
for(Point_vector_map::iterator it = gradient_function.begin(); it != gradient_function.end(); ++it)
|
||||||
{
|
{
|
||||||
std::cout << it->first << " " << it->second << std::endl;
|
std::cout << it->first << " " << it->second << std::endl;
|
||||||
}
|
}
|
||||||
// coordinate computation
|
// coordinate computation
|
||||||
K::Point_2 p(1.6, 1.4);
|
K::Point_2 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::natural_neighbor_coordinates_2(T, p, std::back_inserter
|
Coord_type norm = CGAL::natural_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.begin(),
|
||||||
coords.end(), norm, p,
|
coords.end(), norm, p,
|
||||||
CGAL::Data_access<Point_value_map>(function_values),
|
CGAL::Data_access<Point_value_map>(value_function),
|
||||||
CGAL::Data_access<Point_vector_map>(function_gradients),
|
CGAL::Data_access<Point_vector_map>(gradient_function),
|
||||||
Traits());
|
Traits());
|
||||||
|
|
||||||
if(res.second)
|
if(res.second)
|
||||||
|
|
@ -69,7 +68,7 @@ int main()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else
|
else
|
||||||
std::cout << "C^1 Interpolation not successful." << std::endl
|
std::cout << "C^1 Interpolation not successful." << std::endl
|
||||||
<< " not all function_gradients are provided." << std::endl
|
<< " not all gradients are provided." << std::endl
|
||||||
<< " You may resort to linear interpolation." << std::endl;
|
<< " You may resort to linear interpolation." << std::endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ typedef CGAL::Delaunay_triangulation_2<K,Tds> Delaunay_triangulati
|
||||||
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 Value_function
|
||||||
{
|
{
|
||||||
typedef V argument_type;
|
typedef V argument_type;
|
||||||
typedef std::pair<T, bool> result_type;
|
typedef std::pair<T, bool> result_type;
|
||||||
|
|
@ -46,7 +46,7 @@ struct Function_value
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename V, typename G>
|
template <typename V, typename G>
|
||||||
struct Function_gradient
|
struct Gradient_function
|
||||||
: 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;
|
||||||
|
|
@ -56,21 +56,21 @@ struct Function_gradient
|
||||||
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 Gradient_function& 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 { return *this; }
|
const Gradient_function& operator++(int) const { return *this; }
|
||||||
const Function_gradient& operator*() const { return *this; }
|
const Gradient_function& operator*() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Delaunay_triangulation dt;
|
Delaunay_triangulation dt;
|
||||||
|
|
||||||
Function_value<Vertex_handle, Coord_type> function_value;
|
Value_function<Vertex_handle, Coord_type> value_function;
|
||||||
Function_gradient<Vertex_handle, Vector> function_gradient;
|
Gradient_function<Vertex_handle, Vector> gradient_function;
|
||||||
|
|
||||||
//parameters for spherical function:
|
//parameters for spherical function:
|
||||||
Coord_type a(0.25), bx(1.3), by(-0.7), c(0.2);
|
Coord_type a(0.25), bx(1.3), by(-0.7), c(0.2);
|
||||||
|
|
@ -84,9 +84,9 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
sibson_gradient_fitting_nn_2(dt,
|
sibson_gradient_fitting_nn_2(dt,
|
||||||
function_gradient,
|
gradient_function,
|
||||||
function_value,
|
|
||||||
CGAL::Identity<std::pair<Vertex_handle, Vector> >(),
|
CGAL::Identity<std::pair<Vertex_handle, Vector> >(),
|
||||||
|
value_function,
|
||||||
Traits());
|
Traits());
|
||||||
|
|
||||||
//coordinate computation
|
//coordinate computation
|
||||||
|
|
@ -103,8 +103,8 @@ int main()
|
||||||
coords.end(),
|
coords.end(),
|
||||||
norm,
|
norm,
|
||||||
p,
|
p,
|
||||||
function_value,
|
value_function,
|
||||||
function_gradient,
|
gradient_function,
|
||||||
Traits());
|
Traits());
|
||||||
|
|
||||||
if(res.second)
|
if(res.second)
|
||||||
|
|
|
||||||
|
|
@ -57,21 +57,21 @@ struct Data_access
|
||||||
};
|
};
|
||||||
|
|
||||||
//the interpolation functions:
|
//the interpolation functions:
|
||||||
template < class ForwardIterator, class Functor >
|
template < class ForwardIterator, class ValueFunctor >
|
||||||
typename Functor::result_type::first_type
|
typename ValueFunctor::result_type::first_type
|
||||||
linear_interpolation(ForwardIterator first, ForwardIterator beyond,
|
linear_interpolation(ForwardIterator first, ForwardIterator beyond,
|
||||||
const typename
|
const typename std::iterator_traits<ForwardIterator>::value_type::second_type& norm,
|
||||||
std::iterator_traits<ForwardIterator>::value_type::
|
ValueFunctor value_function)
|
||||||
second_type& norm,
|
|
||||||
Functor function_value)
|
|
||||||
{
|
{
|
||||||
CGAL_precondition(norm > 0);
|
CGAL_precondition(norm > 0);
|
||||||
typedef typename Functor::result_type::first_type Value_type;
|
|
||||||
|
typedef typename ValueFunctor::result_type::first_type Value_type;
|
||||||
|
|
||||||
Value_type result(0);
|
Value_type result(0);
|
||||||
typename Functor::result_type val;
|
typename ValueFunctor::result_type val;
|
||||||
for(; first !=beyond; ++first)
|
for(; first !=beyond; ++first)
|
||||||
{
|
{
|
||||||
val = function_value(first->first);
|
val = value_function(first->first);
|
||||||
CGAL_assertion(val.second);
|
CGAL_assertion(val.second);
|
||||||
result += (first->second/norm) * val.first;
|
result += (first->second/norm) * val.first;
|
||||||
}
|
}
|
||||||
|
|
@ -79,30 +79,28 @@ linear_interpolation(ForwardIterator first, ForwardIterator beyond,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template < class ForwardIterator, class Functor, class GradFunctor,
|
template < class ForwardIterator, class ValueFunctor, class GradFunctor,
|
||||||
class Traits, class Point >
|
class Traits, class Point >
|
||||||
std::pair< typename Functor::result_type::first_type, bool>
|
std::pair< typename ValueFunctor::result_type::first_type, bool>
|
||||||
quadratic_interpolation(ForwardIterator first, ForwardIterator beyond,
|
quadratic_interpolation(ForwardIterator first, ForwardIterator beyond,
|
||||||
const typename
|
const typename std::iterator_traits<ForwardIterator>::value_type::second_type& norm,
|
||||||
std::iterator_traits<ForwardIterator>::
|
|
||||||
value_type::second_type& norm,
|
|
||||||
const Point& p,
|
const Point& p,
|
||||||
Functor function_value,
|
ValueFunctor value_function,
|
||||||
GradFunctor function_gradient,
|
GradFunctor gradient_function,
|
||||||
const Traits& traits)
|
const Traits& traits)
|
||||||
{
|
{
|
||||||
CGAL_precondition(norm > 0);
|
CGAL_precondition(norm > 0);
|
||||||
typedef typename Functor::result_type::first_type Value_type;
|
typedef typename ValueFunctor::result_type::first_type Value_type;
|
||||||
|
|
||||||
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
||||||
Value_type result(0);
|
Value_type result(0);
|
||||||
typename Functor::result_type f;
|
typename ValueFunctor::result_type f;
|
||||||
typename GradFunctor::result_type grad;
|
typename GradFunctor::result_type grad;
|
||||||
|
|
||||||
for(; first !=beyond; ++first)
|
for(; first !=beyond; ++first)
|
||||||
{
|
{
|
||||||
f = function_value(first->first);
|
f = value_function(first->first);
|
||||||
grad = function_gradient(first->first);
|
grad = gradient_function(first->first);
|
||||||
//test if value and gradient are correctly retrieved:
|
//test if value and gradient are correctly retrieved:
|
||||||
CGAL_assertion(f.second);
|
CGAL_assertion(f.second);
|
||||||
if(!grad.second)
|
if(!grad.second)
|
||||||
|
|
@ -115,32 +113,31 @@ quadratic_interpolation(ForwardIterator first, ForwardIterator beyond,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template < class ForwardIterator, class Functor, class GradFunctor,
|
template < class ForwardIterator, class ValueFunctor, class GradFunctor,
|
||||||
class Traits, class Point >
|
class Traits, class Point >
|
||||||
std::pair< typename Functor::result_type::first_type, bool>
|
std::pair< typename ValueFunctor::result_type::first_type, bool>
|
||||||
sibson_c1_interpolation(ForwardIterator first, ForwardIterator beyond,
|
sibson_c1_interpolation(ForwardIterator first, ForwardIterator beyond,
|
||||||
const typename
|
const typename std::iterator_traits<ForwardIterator>::value_type::second_type& norm,
|
||||||
std::iterator_traits<ForwardIterator>::
|
|
||||||
value_type::second_type& norm,
|
|
||||||
const Point& p,
|
const Point& p,
|
||||||
Functor function_value,
|
ValueFunctor value_function,
|
||||||
GradFunctor function_gradient,
|
GradFunctor gradient_function,
|
||||||
const Traits& traits)
|
const Traits& traits)
|
||||||
{
|
{
|
||||||
CGAL_precondition(norm >0);
|
CGAL_precondition(norm >0);
|
||||||
typedef typename Functor::result_type::first_type Value_type;
|
|
||||||
|
typedef typename ValueFunctor::result_type::first_type Value_type;
|
||||||
typedef typename Traits::FT Coord_type;
|
typedef typename Traits::FT Coord_type;
|
||||||
|
|
||||||
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
||||||
Coord_type term1(0), term2(term1), term3(term1), term4(term1);
|
Coord_type term1(0), term2(term1), term3(term1), term4(term1);
|
||||||
Value_type linear_int(0), gradient_int(0);
|
Value_type linear_int(0), gradient_int(0);
|
||||||
typename Functor::result_type f;
|
typename ValueFunctor::result_type f;
|
||||||
typename GradFunctor::result_type grad;
|
typename GradFunctor::result_type grad;
|
||||||
|
|
||||||
for(; first !=beyond; ++first)
|
for(; first !=beyond; ++first)
|
||||||
{
|
{
|
||||||
f = function_value(first->first);
|
f = value_function(first->first);
|
||||||
grad = function_gradient(first->first);
|
grad = gradient_function(first->first);
|
||||||
CGAL_assertion(f.second);
|
CGAL_assertion(f.second);
|
||||||
if(!grad.second)
|
if(!grad.second)
|
||||||
return std::make_pair(Value_type(0), false); //the values are not correct
|
return std::make_pair(Value_type(0), false); //the values are not correct
|
||||||
|
|
@ -187,32 +184,31 @@ sibson_c1_interpolation(ForwardIterator first, ForwardIterator beyond,
|
||||||
// term3 += coeff*(squared_dist/inv_weight);
|
// term3 += coeff*(squared_dist/inv_weight);
|
||||||
// gradient_int += (coeff/inv_weight) * (vh->get_value()+ vh->get_gradient() * (p - vh->point()));
|
// gradient_int += (coeff/inv_weight) * (vh->get_value()+ vh->get_gradient() * (p - vh->point()));
|
||||||
|
|
||||||
template < class ForwardIterator, class Functor, class GradFunctor,
|
template < class ForwardIterator, class ValueFunctor, class GradFunctor,
|
||||||
class Traits, class Point >
|
class Traits, class Point >
|
||||||
std::pair< typename Functor::result_type::first_type, bool >
|
std::pair< typename ValueFunctor::result_type::first_type, bool >
|
||||||
sibson_c1_interpolation_square(ForwardIterator first, ForwardIterator beyond,
|
sibson_c1_interpolation_square(ForwardIterator first, ForwardIterator beyond,
|
||||||
const typename
|
const typename std::iterator_traits<ForwardIterator>::value_type::second_type& norm,
|
||||||
std::iterator_traits<ForwardIterator>::
|
|
||||||
value_type::second_type& norm,
|
|
||||||
const Point& p,
|
const Point& p,
|
||||||
Functor function_value,
|
ValueFunctor value_function,
|
||||||
GradFunctor function_gradient,
|
GradFunctor gradient_function,
|
||||||
const Traits& traits)
|
const Traits& traits)
|
||||||
{
|
{
|
||||||
CGAL_precondition(norm > 0);
|
CGAL_precondition(norm > 0);
|
||||||
typedef typename Functor::result_type::first_type Value_type;
|
|
||||||
|
typedef typename ValueFunctor::result_type::first_type Value_type;
|
||||||
typedef typename Traits::FT Coord_type;
|
typedef typename Traits::FT Coord_type;
|
||||||
|
|
||||||
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
||||||
Coord_type term1(0), term2(term1), term3(term1), term4(term1);
|
Coord_type term1(0), term2(term1), term3(term1), term4(term1);
|
||||||
Value_type linear_int(0), gradient_int(0);
|
Value_type linear_int(0), gradient_int(0);
|
||||||
typename Functor::result_type f;
|
typename ValueFunctor::result_type f;
|
||||||
typename GradFunctor::result_type grad;
|
typename GradFunctor::result_type grad;
|
||||||
|
|
||||||
for(; first!=beyond; ++first)
|
for(; first!=beyond; ++first)
|
||||||
{
|
{
|
||||||
f = function_value(first->first);
|
f = value_function(first->first);
|
||||||
grad = function_gradient(first->first);
|
grad = gradient_function(first->first);
|
||||||
CGAL_assertion(f.second);
|
CGAL_assertion(f.second);
|
||||||
|
|
||||||
if(!grad.second)
|
if(!grad.second)
|
||||||
|
|
@ -249,33 +245,32 @@ sibson_c1_interpolation_square(ForwardIterator first, ForwardIterator beyond,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template < class RandomAccessIterator, class Functor, class
|
template < class RandomAccessIterator, class ValueFunctor, class GradFunctor,
|
||||||
GradFunctor, class Traits, class Point_>
|
class Traits, class Point_>
|
||||||
std::pair< typename Functor::result_type::first_type, bool>
|
std::pair< typename ValueFunctor::result_type::first_type, bool>
|
||||||
farin_c1_interpolation(RandomAccessIterator first,
|
farin_c1_interpolation(RandomAccessIterator first,
|
||||||
RandomAccessIterator beyond,
|
RandomAccessIterator beyond,
|
||||||
const typename
|
const typename std::iterator_traits<RandomAccessIterator>::value_type::second_type& norm,
|
||||||
std::iterator_traits<RandomAccessIterator>::
|
|
||||||
value_type::second_type& norm,
|
|
||||||
const Point_& /*p*/,
|
const Point_& /*p*/,
|
||||||
Functor function_value, GradFunctor
|
ValueFunctor value_function,
|
||||||
function_gradient,
|
GradFunctor gradient_function,
|
||||||
const Traits& traits)
|
const Traits& traits)
|
||||||
{
|
{
|
||||||
CGAL_precondition(norm >0);
|
CGAL_precondition(norm >0);
|
||||||
|
|
||||||
// the function value is available for all points
|
// the function value is available for all points
|
||||||
// if a gradient value is not availble: function returns false
|
// if a gradient value is not availble: function returns false
|
||||||
typedef typename Functor::result_type::first_type Value_type;
|
typedef typename ValueFunctor::result_type::first_type Value_type;
|
||||||
typedef typename Traits::FT Coord_type;
|
typedef typename Traits::FT Coord_type;
|
||||||
|
|
||||||
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
Interpolation::internal::Extract_bare_point<Traits> cp(traits);
|
||||||
typename Functor::result_type f;
|
typename ValueFunctor::result_type f;
|
||||||
typename GradFunctor::result_type grad;
|
typename GradFunctor::result_type grad;
|
||||||
|
|
||||||
int n = static_cast<int>(beyond - first);
|
int n = static_cast<int>(beyond - first);
|
||||||
if(n == 1)
|
if(n == 1)
|
||||||
{
|
{
|
||||||
f = function_value(first->first);
|
f = value_function(first->first);
|
||||||
CGAL_assertion(f.second);
|
CGAL_assertion(f.second);
|
||||||
return std::make_pair(f.first, true);
|
return std::make_pair(f.first, true);
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +291,7 @@ farin_c1_interpolation(RandomAccessIterator first,
|
||||||
Coord_type coord_i_square = CGAL_NTS square(it->second);
|
Coord_type coord_i_square = CGAL_NTS square(it->second);
|
||||||
|
|
||||||
// for later: the function value of it->first:
|
// for later: the function value of it->first:
|
||||||
f = function_value(it->first);
|
f = value_function(it->first);
|
||||||
CGAL_assertion(f.second);
|
CGAL_assertion(f.second);
|
||||||
ordinates[i][i] = f.first;
|
ordinates[i][i] = f.first;
|
||||||
|
|
||||||
|
|
@ -311,7 +306,7 @@ farin_c1_interpolation(RandomAccessIterator first,
|
||||||
{
|
{
|
||||||
it2 = first + j;
|
it2 = first + j;
|
||||||
|
|
||||||
grad = function_gradient(it->first);
|
grad = gradient_function(it->first);
|
||||||
if(!grad.second)
|
if(!grad.second)
|
||||||
return std::make_pair(Value_type(0), false); // the gradient is not known
|
return std::make_pair(Value_type(0), false); // the gradient is not known
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue