diff --git a/Interpolation/examples/Interpolation/interpolation_vertex_with_info_2.cpp b/Interpolation/examples/Interpolation/interpolation_vertex_with_info_2.cpp index 6e5dd160759..83180cc3732 100644 --- a/Interpolation/examples/Interpolation/interpolation_vertex_with_info_2.cpp +++ b/Interpolation/examples/Interpolation/interpolation_vertex_with_info_2.cpp @@ -38,38 +38,6 @@ typedef CGAL::Interpolation_traits_2 Traits; typedef std::vector > Coordinate_vector; -template -struct Value_function -{ - typedef V argument_type; - typedef std::pair result_type; - - result_type operator()(const argument_type& a) const { - return result_type(a->info().value, true); - } -}; - -template -struct Gradient_function - : public std::iterator -{ - - typedef V argument_type; - typedef std::pair result_type; - - result_type operator()(const argument_type& a) const { - return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR); - } - - const Gradient_function& operator=(const std::pair& p) const { - p.first->info().gradient = p.second; - return *this; - } - - const Gradient_function& operator++(int) const { return *this; } - const Gradient_function& operator*() const { return *this; } -}; - int main() { //number of sample points: @@ -94,9 +62,15 @@ int main() Delaunay_triangulation T; - // Note that a supported alternative to creating the functors below is to use lambdas - Value_function value_function; - Gradient_function gradient_function; + auto value_function = [](const Vertex_handle& a) -> std::pair + { + return std::make_pair(a->info().value, true); + }; + + auto gradient_function = [](const Vertex_handle& a) -> std::pair + { + return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR); + }; //parameters for quadratic function: Coord_type alpha = Coord_type(1.0), diff --git a/Interpolation/examples/Interpolation/sibson_interpolation_rn_vertex_with_info_2.cpp b/Interpolation/examples/Interpolation/sibson_interpolation_rn_vertex_with_info_2.cpp index d86378ebf04..edd2c6698e2 100644 --- a/Interpolation/examples/Interpolation/sibson_interpolation_rn_vertex_with_info_2.cpp +++ b/Interpolation/examples/Interpolation/sibson_interpolation_rn_vertex_with_info_2.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include #include #include @@ -38,44 +40,26 @@ typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Regular_triangulation_2 Regular_triangulation; typedef Regular_triangulation::Vertex_handle Vertex_handle; -template -struct Value_function -{ - typedef V argument_type; - typedef std::pair result_type; - - result_type operator()(const argument_type& a) const { - return result_type(a->info().value, true); - } -}; - -template -struct Gradient_function - : public std::iterator -{ - typedef V argument_type; - typedef std::pair result_type; - - result_type operator()(const argument_type& a) const { - return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR); - } - - const Gradient_function& operator=(const std::pair& p) const { - p.first->info().gradient = p.second; - return *this; - } - - const Gradient_function& operator++(int) const { return *this; } - const Gradient_function& operator*() const { return *this; } -}; - int main() { Regular_triangulation rt; - // Note that a supported alternative to creating the functors below is to use lambdas - Value_function value_function; - Gradient_function gradient_function; + auto value_function = [](const Vertex_handle& a) -> std::pair + { + return std::make_pair(a->info().value, true); + }; + + auto gradient_function = [](const Vertex_handle& a) -> std::pair + { + return std::make_pair(a->info().gradient, a->info().gradient != CGAL::NULL_VECTOR); + }; + + auto gradient_output_iterator + = boost::make_function_output_iterator + ([](const std::pair& p) + { + p.first->info().gradient = p.second; + }); // parameters for spherical function: Coord_type a(0.25), bx(1.3), by(-0.7), c(0.2); @@ -89,7 +73,7 @@ int main() } CGAL::sibson_gradient_fitting_rn_2(rt, - gradient_function, + gradient_output_iterator, CGAL::Identity >(), value_function, Traits());