diff --git a/Interpolation/include/CGAL/sibson_gradient_fitting.h b/Interpolation/include/CGAL/sibson_gradient_fitting.h index 0ec54b88e8c..3087a72de23 100644 --- a/Interpolation/include/CGAL/sibson_gradient_fitting.h +++ b/Interpolation/include/CGAL/sibson_gradient_fitting.h @@ -31,14 +31,20 @@ #include #include -#include -#include #include +#include +#include +#include #include #include #include +#ifdef CGAL_CXX11 + #include + #include +#endif + namespace CGAL { template < class ForwardIterator, class ValueFunctor, class Traits, class Point > @@ -221,6 +227,12 @@ sibson_gradient_fitting_internal(const Tr& tr, // -> _nn2: natural_neighbor_coordinates_2 // -> _rn2: regular_neighbor_coordinates_2 // -> _sn2_3: surface_neighbor_coordinates_2_3 + +// The ugly distinction below is needed to make it work with lambdas for C++11 because std::is_constructible +// is used, which is C++11 (there is a boost equivalent, but it is said (by boost) to be relying on C++11 features +// to properly work...) +#ifdef CGAL_CXX11 + template < class Dt, class OutputIterator, class OutputFunctor, class ValueFunctor, class Traits > OutputIterator sibson_gradient_fitting_nn_2(const Dt& dt, @@ -231,8 +243,8 @@ sibson_gradient_fitting_nn_2(const Dt& dt, // Some SFINAE to distinguish whether the argument type // of the value functor is 'DT::Point' or 'DT::Vertex_handle' typename boost::enable_if_c< - boost::is_constructible< - cpp11::function, + std::is_constructible< + std::function, ValueFunctor >::value>::type* = NULL) { @@ -257,8 +269,8 @@ sibson_gradient_fitting_nn_2(const Dt& dt, ValueFunctor value_function, const Traits& traits, typename boost::enable_if_c< - boost::is_constructible< - cpp11::function, + std::is_constructible< + std::function, ValueFunctor >::value>::type* = NULL) { @@ -275,6 +287,38 @@ sibson_gradient_fitting_nn_2(const Dt& dt, traits); } +#else // not CGAL_CXX11 + +template < class Dt, class OutputIterator, class OutputFunctor, class ValueFunctor, class Traits > +OutputIterator +sibson_gradient_fitting_nn_2(const Dt& dt, + OutputIterator out, + OutputFunctor fct, + ValueFunctor value_function, + const Traits& traits) +{ + typedef typename Traits::FT FT; + typedef typename ValueFunctor::argument_type VF_arg_type; + typedef typename std::back_insert_iterator > > CoordInserter; + + // If the functor evaluates at points (and not vertices), then we must convert + // the output of the coordinates computations - a pair - + // to a pair + typedef typename boost::mpl::if_< + boost::is_same, + Interpolation::internal::Extract_point_in_pair, + CGAL::Identity > + >::type Coord_OutputFunctor; + + return sibson_gradient_fitting_internal(dt, out, fct, value_function, + natural_neighbor_coordinates_2_object(), + traits); +} +#endif // CGAL_CXX11 + // Same as above but without OutputFunctor. // Defaults to extracting the point, for backward compatibility. template < class Dt, class OutputIterator, class ValueFunctor, class Traits > @@ -290,6 +334,9 @@ sibson_gradient_fitting_nn_2(const Dt& dt, return sibson_gradient_fitting_nn_2(dt, out, OutputFunctor(), value_function, traits); } +// See above for the explanation. +#ifdef CGAL_CXX11 + template < class Rt, class OutputIterator, class OutputFunctor, class ValueFunctor, class Traits > OutputIterator sibson_gradient_fitting_rn_2(const Rt& rt, @@ -300,8 +347,8 @@ sibson_gradient_fitting_rn_2(const Rt& rt, // Some SFINAE to distinguish whether the argument type // of the value functor is 'Rt::Point' (weighted point) or 'Rt::Vertex_handle' typename boost::enable_if_c< - boost::is_constructible< - cpp11::function, + std::is_constructible< + std::function, ValueFunctor >::value>::type* = NULL) { @@ -326,8 +373,8 @@ sibson_gradient_fitting_rn_2(const Rt& rt, ValueFunctor value_function, const Traits& traits, typename boost::enable_if_c< - boost::is_constructible< - cpp11::function, + std::is_constructible< + std::function, ValueFunctor >::value>::type* = NULL) { @@ -344,6 +391,39 @@ sibson_gradient_fitting_rn_2(const Rt& rt, traits); } +#else // CGAL_CXX11 + +template < class Rt, class OutputIterator, class OutputFunctor, class ValueFunctor, class Traits > +OutputIterator +sibson_gradient_fitting_rn_2(const Rt& rt, + OutputIterator out, + OutputFunctor fct, + ValueFunctor value_function, + const Traits& traits) +{ + typedef typename Traits::FT FT; + typedef typename ValueFunctor::argument_type VF_arg_type; + typedef typename std::back_insert_iterator > > CoordInserter; + + // If the functor evaluates at points (and not vertices), then we must convert + // the output of the coordinates computations - a pair - + // to a pair + typedef typename boost::mpl::if_< + boost::is_same, + Interpolation::internal::Extract_point_in_pair, + CGAL::Identity > + >::type Coord_OutputFunctor; + + return sibson_gradient_fitting_internal(rt, out, fct, value_function, + regular_neighbor_coordinates_2_object(), + traits); +} + +#endif + // Same as above but without OutputFunctor. Default to extracting the point, for backward compatibility. template < class Rt, class OutputIterator, class ValueFunctor, class Traits > OutputIterator