diff options
author | Gard Spreemann <gspreemann@gmail.com> | 2017-04-20 11:10:45 +0200 |
---|---|---|
committer | Gard Spreemann <gspreemann@gmail.com> | 2017-04-20 11:10:45 +0200 |
commit | 8d7329f3e5ad843e553c3c5503cecc28ef2eead6 (patch) | |
tree | 6d80d83a7c4bcd3296e12a28404bfe84ef84ed55 /include/gudhi_patches/CGAL/NewKernel_d/Wrapper | |
parent | 55c7181126aa7defce38c9b82872d14223d4c1dd (diff) |
GUDHI 2.0.0 as released by upstream in a tarball.upstream/2.0.0
Diffstat (limited to 'include/gudhi_patches/CGAL/NewKernel_d/Wrapper')
8 files changed, 1498 insertions, 0 deletions
diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h new file mode 100644 index 00000000..44e9aa96 --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h @@ -0,0 +1,305 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_KERNEL_D_CARTESIAN_WRAP_H +#define CGAL_KERNEL_D_CARTESIAN_WRAP_H + +#include <CGAL/basic.h> +#include <CGAL/is_iterator.h> + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable:4003) // not enough actual parameters for macro 'BOOST_PP_EXPAND_I' + // http://lists.boost.org/boost-users/2014/11/83291.php +#endif +#include <CGAL/NewKernel_d/Wrapper/Point_d.h> +#include <CGAL/NewKernel_d/Wrapper/Vector_d.h> +#include <CGAL/NewKernel_d/Wrapper/Segment_d.h> +#include <CGAL/NewKernel_d/Wrapper/Sphere_d.h> +#include <CGAL/NewKernel_d/Wrapper/Hyperplane_d.h> +#include <CGAL/NewKernel_d/Wrapper/Weighted_point_d.h> + +#include <CGAL/NewKernel_d/Wrapper/Ref_count_obj.h> + +#include <boost/mpl/or.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/vector.hpp> + +//TODO: do we want to store the kernel ref in the Object wrappers? It would allow for additions and operator[] and things like that to work, but objects would still need to be created by functors. + +namespace CGAL { +namespace internal { +BOOST_MPL_HAS_XXX_TRAIT_DEF(Is_wrapper) +template<class T,bool=has_Is_wrapper<T>::value> struct Is_wrapper { + enum { value=false }; + typedef Tag_false type; +}; +template<class T> struct Is_wrapper<T,true> { + typedef typename T::Is_wrapper type; + enum { value=type::value }; +}; + +template<class T,bool=is_iterator_type<T,std::input_iterator_tag>::value> struct Is_wrapper_iterator { + enum { value=false }; + typedef Tag_false type; +}; +template<class T> struct Is_wrapper_iterator<T,true> : + Is_wrapper<typename std::iterator_traits<typename CGAL::decay<T>::type>::value_type> +{ }; + +struct Forward_rep { +//TODO: make a good C++0X version with perfect forwarding +//#ifdef CGAL_CXX11 +//template <class T,class=typename std::enable_if<!Is_wrapper<typename std::decay<T>::type>::value&&!Is_wrapper_iterator<typename std::decay<T>::type>::value>::type> +//T&& operator()(typename std::remove_reference<T>::type&& t) const {return static_cast<T&&>(t);}; +//template <class T,class=typename std::enable_if<!Is_wrapper<typename std::decay<T>::type>::value&&!Is_wrapper_iterator<typename std::decay<T>::type>::value>::type> +//T&& operator()(typename std::remove_reference<T>::type& t) const {return static_cast<T&&>(t);}; +// +//template <class T,class=typename std::enable_if<Is_wrapper<typename std::decay<T>::type>::value>::type> +//typename Type_copy_cvref<T,typename std::decay<T>::type::Rep>::type&& +//operator()(T&& t) const { +// return static_cast<typename Type_copy_cvref<T,typename std::decay<T>::type::Rep>::type&&>(t.rep()); +//}; +// +//template <class T,class=typename std::enable_if<Is_wrapper_iterator<typename std::decay<T>::type>::value>::type> +//transforming_iterator<Forward_rep,typename std::decay<T>::type> +//operator()(T&& t) const { +// return make_transforming_iterator(std::forward<T>(t),Forward_rep()); +//}; +//#else +template <class T,bool=Is_wrapper<T>::value,bool=Is_wrapper_iterator<T>::value> struct result_; +template <class T> struct result_<T,false,false>{typedef T const& type;}; +template <class T> struct result_<T,true,false>{typedef typename decay<T>::type::Rep const& type;}; +template <class T> struct result_<T,false,true>{typedef transforming_iterator<Forward_rep,typename decay<T>::type> type;}; +template<class> struct result; +template<class T> struct result<Forward_rep(T)> : result_<T> {}; + +template <class T> typename boost::disable_if<boost::mpl::or_<Is_wrapper<T>,Is_wrapper_iterator<T> >,T>::type const& operator()(T const& t) const {return t;} +template <class T> typename boost::disable_if<boost::mpl::or_<Is_wrapper<T>,Is_wrapper_iterator<T> >,T>::type& operator()(T& t) const {return t;} + +template <class T> typename T::Rep const& operator()(T const& t, typename boost::enable_if<Is_wrapper<T> >::type* = 0) const {return t.rep();} + +template <class T> transforming_iterator<Forward_rep,typename boost::enable_if<Is_wrapper_iterator<T>,T>::type> operator()(T const& t) const {return make_transforming_iterator(t,Forward_rep());} +//#endif +}; +} + +template <class B, class K, class T, bool = Provides_type<B, T>::value> +struct Map_wrapping_type : Get_type<B, T> {}; +#define CGAL_REGISTER_OBJECT_WRAPPER(X) \ + template <class B, class K> \ + struct Map_wrapping_type <B, K, X##_tag, true> { \ + typedef Wrap::X##_d<K> type; \ + } +CGAL_REGISTER_OBJECT_WRAPPER(Point); +CGAL_REGISTER_OBJECT_WRAPPER(Vector); +CGAL_REGISTER_OBJECT_WRAPPER(Segment); +CGAL_REGISTER_OBJECT_WRAPPER(Sphere); +CGAL_REGISTER_OBJECT_WRAPPER(Hyperplane); +CGAL_REGISTER_OBJECT_WRAPPER(Weighted_point); +#undef CGAL_REGISTER_OBJECT_WRAPPER + +// Note: this tends to be an all or nothing thing currently, wrapping +// only some types breaks, probably because we don't check whether the +// return type is indeed wrapped. +template < typename Base_ , typename Derived_ = Default > +struct Cartesian_wrap : public Base_ +{ + CGAL_CONSTEXPR Cartesian_wrap(){} + CGAL_CONSTEXPR Cartesian_wrap(int d):Base_(d){} + typedef Base_ Kernel_base; + typedef Cartesian_wrap Self; + // TODO: pass the 2 types Self and Derived to the wrappers, they can use Self for most purposes and Derived only for Kernel_traits' typedef R. + typedef typename Default::Get<Derived_, Self>::type Derived; + // FIXME: The list doesn't belong here. + typedef boost::mpl::vector<Point_tag,Segment_tag,Sphere_tag,Vector_tag,Hyperplane_tag> Wrapped_list; + + template <class T> + struct Type : Map_wrapping_type<Base_, Derived, T> {}; + + //Translate the arguments + template <class T, class D = void, + class=typename Get_functor_category<Derived,T>::type, + bool=Provides_functor<Kernel_base, T>::value, + bool=boost::mpl::contains<Wrapped_list,typename map_result_tag<T>::type>::type::value> + struct Functor { + typedef typename Get_functor<Kernel_base, T>::type B; + struct type { + B b; + type(){} + type(Self const&k):b(k){} + typedef typename B::result_type result_type; +#ifdef CGAL_CXX11 + template<class...U> result_type operator()(U&&...u)const{ + return b(internal::Forward_rep()(u)...); + } +#else +#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class U)> result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return b(BOOST_PP_ENUM(N,CGAL_VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE +#undef CGAL_VAR +// In case the last argument needs to be non-const. Fragile... +#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class U),class V> result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u),V&v)const{ \ + return b(BOOST_PP_ENUM(N,CGAL_VAR,),internal::Forward_rep()(v)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,8,CGAL_CODE,_) +#undef CGAL_CODE +#undef CGAL_VAR +#endif + }; + }; + + // Preserve the difference between Null_functor and nothing. + template <class T, class D, class C, bool b> + struct Functor <T, D, C, false, b> + : Get_functor <Kernel_base, T> {}; + + //Translate both the arguments and the result + //TODO: Check Is_wrapper instead of relying on map_result_tag? + template<class T,class D> struct Functor<T,D,Construct_tag,true,true> { + typedef typename Get_functor<Kernel_base, T>::type B; + struct type { + B b; + type(){} + type(Self const&k):b(k){} + typedef typename map_result_tag<T>::type result_tag; + // FIXME: Self or Derived? + typedef typename Get_type<Self,result_tag>::type result_type; +#ifdef CGAL_CXX11 + template<class...U> result_type operator()(U&&...u)const{ + return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); + } +#else +#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class U)> result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,CGAL_VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE +#undef CGAL_VAR +#endif + }; + }; + +}; + +template < typename Base_ > +struct Cartesian_refcount : public Base_ +{ + CGAL_CONSTEXPR Cartesian_refcount(){} + CGAL_CONSTEXPR Cartesian_refcount(int d):Base_(d){} + typedef Base_ Kernel_base; + typedef Cartesian_refcount Self; + + // FIXME: Use object_list, or a list passed as argument, or anything + // automatic. + template <class T, class=void> struct Type : Get_type<Base_, T> {}; +#define CGAL_Kernel_obj(X,Y) \ + template <class D> struct Type<X##_tag, D> { typedef Ref_count_obj<Cartesian_refcount, X##_tag> type; }; + + CGAL_Kernel_obj(Point,point) + CGAL_Kernel_obj(Vector,vector) +#undef CGAL_Kernel_obj + + template<class T> struct Dispatch { + //typedef typename map_functor_type<T>::type f_t; + typedef typename map_result_tag<T>::type r_t; + enum { + is_nul = boost::is_same<typename Get_functor<Kernel_base, T>::type,Null_functor>::value, + ret_rcobj = boost::is_same<r_t,Point_tag>::value || boost::is_same<r_t,Vector_tag>::value + }; + }; + + //Translate the arguments + template<class T,class D=void,bool=Dispatch<T>::is_nul,bool=Dispatch<T>::ret_rcobj> struct Functor { + typedef typename Get_functor<Kernel_base, T>::type B; + struct type { + B b; + type(){} + type(Self const&k):b(k){} + typedef typename B::result_type result_type; +#ifdef CGAL_CXX11 + template<class...U> result_type operator()(U&&...u)const{ + return b(internal::Forward_rep()(u)...); + } +#else + result_type operator()()const{ + return b(); + } +#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class U)> result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return b(BOOST_PP_ENUM(N,CGAL_VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE +#undef CGAL_VAR +#endif + }; + }; + + //Translate both the arguments and the result + template<class T,class D,bool b> struct Functor<T,D,true,b> { + typedef Null_functor type; + }; + + template<class T,class D> struct Functor<T,D,false,true> { + typedef typename Get_functor<Kernel_base, T>::type B; + struct type { + B b; + type(){} + type(Self const&k):b(k){} + typedef typename map_result_tag<T>::type result_tag; + typedef typename Get_type<Self,result_tag>::type result_type; +#ifdef CGAL_CXX11 + template<class...U> result_type operator()(U&&...u)const{ + return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); + } +#else + result_type operator()()const{ + return result_type(Eval_functor(),b); + } +#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class U)> result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,CGAL_VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE +#undef CGAL_VAR +#endif + }; + }; + +}; + +} //namespace CGAL + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +#endif // CGAL_KERNEL_D_CARTESIAN_WRAP_H diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h new file mode 100644 index 00000000..54fd50bd --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h @@ -0,0 +1,131 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_WRAPPER_HYPERPLANE_D_H +#define CGAL_WRAPPER_HYPERPLANE_D_H + +#include <CGAL/representation_tags.h> +#include <CGAL/assertions.h> +#include <boost/type_traits.hpp> +#include <CGAL/Kernel/Return_base_tag.h> +#include <CGAL/Dimension.h> +#ifndef CGAL_CXX11 +#include <boost/preprocessor/repetition.hpp> +#endif +#include <boost/utility/result_of.hpp> + +namespace CGAL { +namespace Wrap { + +template <class R_> +class Hyperplane_d : public Get_type<typename R_::Kernel_base, Hyperplane_tag>::type +{ + typedef typename Get_type<R_, FT_tag>::type FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type<R_, Vector_tag>::type Vector_; + typedef typename Get_functor<Kbase, Construct_ttag<Hyperplane_tag> >::type CHBase; + typedef typename Get_functor<Kbase, Orthogonal_vector_tag>::type OVBase; + typedef typename Get_functor<Kbase, Hyperplane_translation_tag>::type HTBase; + + typedef Hyperplane_d Self; + CGAL_static_assertion((boost::is_same<Self, typename Get_type<R_, Hyperplane_tag>::type>::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef typename Increment_dimension<Ambient_dimension,-1>::type Feature_dimension; + + typedef typename Get_type<Kbase, Hyperplane_tag>::type Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX11 + template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Hyperplane_d> >::value>::type> explicit Hyperplane_d(U&&...u) + : Rep(CHBase()(std::forward<U>(u)...)){} + +// // called from Construct_point_d +// template<class...U> explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward<U>(u)...){} + template<class F,class...U> explicit Hyperplane_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward<F>(f)(std::forward<U>(u)...)){} + +#if 0 + // the new standard may make this necessary + Point_d(Point_d const&)=default; + Point_d(Point_d &);//=default; + Point_d(Point_d &&)=default; +#endif + + // try not to use these + Hyperplane_d(Rep const& v) : Rep(v) {} + Hyperplane_d(Rep& v) : Rep(static_cast<Rep const&>(v)) {} + Hyperplane_d(Rep&& v) : Rep(std::move(v)) {} + +#else + + Hyperplane_d() : Rep(CHBase()()) {} + + Hyperplane_d(Rep const& v) : Rep(v) {} // try not to use it + +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + explicit Hyperplane_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CHBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \ + Hyperplane_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} + /* + template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} + */ + + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE + +#endif + + //TODO: if OVBase returns a reference to a base vector, cast it to a + //reference to a wrapper vector. Ugly but should be safe. + Vector_ orthogonal_vector()const{ + return Vector_(Eval_functor(),OVBase(),rep()); + } + FT_ translation()const{ + return HTBase()(rep()); + } + + +}; + +} //namespace Wrap +} //namespace CGAL + +#endif // CGAL_WRAPPER_SPHERE_D_H diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Point_d.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Point_d.h new file mode 100644 index 00000000..0718c947 --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -0,0 +1,284 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_WRAPPER_POINT_D_H +#define CGAL_WRAPPER_POINT_D_H + +#include <ostream> +#include <CGAL/Origin.h> +#include <CGAL/Kernel/mpl.h> +#include <CGAL/representation_tags.h> +#include <CGAL/assertions.h> +#include <boost/type_traits.hpp> +#include <CGAL/Kernel/Return_base_tag.h> +#include <CGAL/Dimension.h> +#ifndef CGAL_CXX11 +#include <boost/preprocessor/repetition.hpp> +#endif +#include <boost/utility/result_of.hpp> + +namespace CGAL { +namespace Wrap { + +template <class R_> +class Point_d : public Get_type<typename R_::Kernel_base, Point_tag>::type + // Deriving won't work if the point is just a __m256d. + // Test boost/std::is_class for instance +{ + typedef typename Get_type<R_, RT_tag>::type RT_; + typedef typename Get_type<R_, FT_tag>::type FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type<R_, Vector_tag>::type Vector_; + typedef typename Get_functor<Kbase, Construct_ttag<Point_tag> >::type CPBase; + typedef typename Get_functor<Kbase, Compute_point_cartesian_coordinate_tag>::type CCBase; + typedef typename Get_functor<Kbase, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CPI; + + + typedef Point_d Self; + CGAL_static_assertion((boost::is_same<Self, typename Get_type<R_, Point_tag>::type>::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef Dimension_tag<0> Feature_dimension; + + typedef typename Get_type<Kbase, Point_tag>::type Rep; + //typedef typename CGAL::decay<typename boost::result_of<CPI(Rep,Begin_tag)>::type>::type Cartesian_const_iterator; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX11 + template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Point_d> >::value>::type> explicit Point_d(U&&...u) + : Rep(CPBase()(std::forward<U>(u)...)){} + +// // called from Construct_point_d +// template<class...U> explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward<U>(u)...){} + template<class F,class...U> explicit Point_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward<F>(f)(std::forward<U>(u)...)){} + +#if 0 + // the new standard may make this necessary + Point_d(Point_d const&)=default; + Point_d(Point_d &);//=default; + Point_d(Point_d &&)=default; +#endif + + // try not to use these + Point_d(Rep const& v) : Rep(v) {} + Point_d(Rep& v) : Rep(static_cast<Rep const&>(v)) {} + Point_d(Rep&& v) : Rep(std::move(v)) {} + + // this one should be implicit + Point_d(Origin const& v) + : Rep(CPBase()(v)) {} + Point_d(Origin& v) + : Rep(CPBase()(v)) {} + Point_d(Origin&& v) + : Rep(CPBase()(std::move(v))) {} + +#else + + Point_d() : Rep(CPBase()()) {} + + Point_d(Rep const& v) : Rep(v) {} // try not to use it + +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + explicit Point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CPBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \ + Point_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} + /* + template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} + */ + + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE + + // this one should be implicit + Point_d(Origin const& o) + : Rep(CPBase()(o)) {} + +#endif + + typename boost::result_of<CCBase(Rep,int)>::type cartesian(int i)const{ + return CCBase()(rep(),i); + } + typename boost::result_of<CCBase(Rep,int)>::type operator[](int i)const{ + return CCBase()(rep(),i); + } + + typename boost::result_of<CPI(Rep,Begin_tag)>::type cartesian_begin()const{ + return CPI()(rep(),Begin_tag()); + } + + typename boost::result_of<CPI(Rep,End_tag)>::type cartesian_end()const{ + return CPI()(rep(),End_tag()); + } + + int dimension() const { + typedef typename Get_functor<Kbase, Point_dimension_tag>::type PDBase; + return PDBase()(rep()); + } + + /* + Direction_d direction() const + { + return R().construct_direction_d_object()(*this); + } + + Vector_d transform(const Aff_transformation_d &t) const + { + return t.transform(*this); + } + + Vector_d operator/(const RT& c) const + { + return R().construct_divided_vector_d_object()(*this,c); + } + + Vector_d operator/(const typename First_if_different<FT_,RT>::Type & c) const + { + return R().construct_divided_vector_d_object()(*this,c); + } + + typename Qualified_result_of<typename R::Compute_x_3, Vector_3>::type + x() const + { + return R().compute_x_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_y_3, Vector_3>::type + y() const + { + return R().compute_y_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_z_3, Vector_3>::type + z() const + { + return R().compute_z_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hx_3, Vector_3>::type + hx() const + { + return R().compute_hx_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hy_3, Vector_3>::type + hy() const + { + return R().compute_hy_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hz_3, Vector_3>::type + hz() const + { + return R().compute_hz_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hw_3, Vector_3>::type + hw() const + { + return R().compute_hw_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_x_3, Vector_3>::type + cartesian(int i) const + { + CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); + if (i==0) return x(); + if (i==1) return y(); + return z(); + } + + typename Qualified_result_of<typename R::Compute_hw_3, Vector_3>::type + homogeneous(int i) const + { + CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); + if (i==0) return hx(); + if (i==1) return hy(); + if (i==2) return hz(); + return hw(); + } + + typename Qualified_result_of<typename R::Compute_squared_length_3, Vector_3>::type + squared_length() const + { + return R().compute_squared_length_3_object()(*this); + } +*/ +}; +#if 0 +template <class R_> Point_d<R_>::Point_d(Point_d &)=default; +#endif + +//TODO: IO + +template <class R_> +std::ostream& operator <<(std::ostream& os, const Point_d<R_>& p) +{ + typedef typename R_::Kernel_base Kbase; + typedef typename Get_functor<Kbase, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CPI; + // Should just be "auto"... + typename CGAL::decay<typename boost::result_of< + CPI(typename Point_d<R_>::Rep,Begin_tag) + >::type>::type + b = p.cartesian_begin(), + e = p.cartesian_end(); + os << p.dimension(); + for(; b != e; ++b){ + os << " " << *b; + } + return os; +} + +//template <class R_> +//Vector_d<R_> operator+(const Vector_d<R_>& v,const Vector_d<R_>& w) const +//{ +// return typename R::template Construct<Sum_of_vectors_tag>::type()(v,w); +//} +// +//template <class R_> +//Vector_d<R_> operator-(const Vector_d<R_>& v,const Vector_d<R_>& w) const +//{ +// return typename R::template Construct<Difference_of_vectors_tag>::type()(v,w); +//} + +} //namespace Wrap +} //namespace CGAL + +#endif // CGAL_WRAPPER_POINT_D_H diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h new file mode 100644 index 00000000..f33e14c0 --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h @@ -0,0 +1,120 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_WRAPPER_REF_COUNT_OBJ_H +#define CGAL_WRAPPER_REF_COUNT_OBJ_H + +#include <CGAL/Origin.h> +#include <CGAL/Handle_for.h> +#include <CGAL/Kernel/mpl.h> +#include <CGAL/representation_tags.h> +#include <CGAL/assertions.h> +#include <boost/type_traits.hpp> +#include <CGAL/Kernel/Return_base_tag.h> +#include <CGAL/Dimension.h> +#ifndef CGAL_CXX11 +#include <boost/preprocessor/repetition.hpp> +#endif +#include <boost/utility/result_of.hpp> + +// no need for a fancy interface here, people can use the Point_d wrapper on +// top. + +namespace CGAL { + +template <class R_, class Tag_> +class Ref_count_obj +{ + typedef typename R_::Kernel_base Kbase; + typedef typename Get_functor<Kbase, Construct_ttag<Tag_> >::type CBase; + + typedef Ref_count_obj Self; + CGAL_static_assertion((boost::is_same<Self, typename Get_type<R_, Tag_>::type>::value)); + +public: + typedef R_ R; + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + //typedef Dimension_tag<0> Feature_dimension; + + typedef typename Get_type<Kbase, Tag_>::type Rep; + typedef Handle_for<Rep> Data; + +private: + Data data; +public: + + const Rep& rep() const + { + return CGAL::get_pointee_or_identity(data); + } + +#ifdef CGAL_CXX11 + template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Ref_count_obj> >::value>::type> explicit Ref_count_obj(U&&...u) + : data(Eval_functor(),CBase(),std::forward<U>(u)...){} + + template<class F,class...U> explicit Ref_count_obj(Eval_functor&&,F&&f,U&&...u) + : data(Eval_functor(),std::forward<F>(f),std::forward<U>(u)...){} + + // try not to use these + Ref_count_obj(Rep const& v) : data(v) {} + Ref_count_obj(Rep& v) : data(static_cast<Rep const&>(v)) {} + Ref_count_obj(Rep&& v) : data(std::move(v)) {} + + // Do we really need this for point? +// // this one should be implicit +// Ref_count_obj(Origin const& v) +// : data(Eval_functor(),CBase(),v) {} +// Ref_count_obj(Origin& v) +// : data(Eval_functor(),CBase(),v) {} +// Ref_count_obj(Origin&& v) +// : data(Eval_functor(),CBase(),std::move(v)) {} + +#else + + Ref_count_obj() : data(Eval_functor(),CBase()) {} + + Ref_count_obj(Rep const& v) : data(v) {} // try not to use it + +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + explicit Ref_count_obj(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : data(Eval_functor(),CBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ + \ + template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \ + Ref_count_obj(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : data(Eval_functor(),f,BOOST_PP_ENUM_PARAMS(N,t)) {} + + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE + template<class F> + Ref_count_obj(Eval_functor,F const& f) + : data(Eval_functor(),f) {} + +// // this one should be implicit +// Ref_count_obj(Origin const& o) +// : data(Eval_functor(),CBase(),o) {} + +#endif + +}; + +} //namespace CGAL + +#endif diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Segment_d.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Segment_d.h new file mode 100644 index 00000000..bfb20a77 --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Segment_d.h @@ -0,0 +1,133 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_WRAPPER_SEGMENT_D_H +#define CGAL_WRAPPER_SEGMENT_D_H + +#include <CGAL/Origin.h> +#include <CGAL/Kernel/mpl.h> +#include <CGAL/representation_tags.h> +#include <CGAL/assertions.h> +#include <boost/type_traits.hpp> +#include <CGAL/Kernel/Return_base_tag.h> +#include <CGAL/Dimension.h> +#ifndef CGAL_CXX11 +#include <boost/preprocessor/repetition.hpp> +#endif +#include <boost/utility/result_of.hpp> + +namespace CGAL { +namespace Wrap { + +template <class R_> +class Segment_d : public Get_type<typename R_::Kernel_base, Segment_tag>::type +{ + typedef typename Get_type<R_, RT_tag>::type RT_; + typedef typename Get_type<R_, FT_tag>::type FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type<R_, Point_tag>::type Point_; + typedef typename Get_functor<Kbase, Construct_ttag<Point_tag> >::type CPBase; + typedef typename Get_functor<Kbase, Construct_ttag<Segment_tag> >::type CSBase; + typedef typename Get_functor<Kbase, Segment_extremity_tag>::type CSEBase; + + typedef Segment_d Self; + CGAL_static_assertion((boost::is_same<Self, typename Get_type<R_, Segment_tag>::type>::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef Dimension_tag<1> Feature_dimension; + + typedef typename Get_type<Kbase, Segment_tag>::type Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX11 + template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Segment_d> >::value>::type> explicit Segment_d(U&&...u) + : Rep(CSBase()(std::forward<U>(u)...)){} + +// // called from Construct_point_d +// template<class...U> explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward<U>(u)...){} + template<class F,class...U> explicit Segment_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward<F>(f)(std::forward<U>(u)...)){} + +#if 0 + // the new standard may make this necessary + Point_d(Point_d const&)=default; + Point_d(Point_d &);//=default; + Point_d(Point_d &&)=default; +#endif + + // try not to use these + Segment_d(Rep const& v) : Rep(v) {} + Segment_d(Rep& v) : Rep(static_cast<Rep const&>(v)) {} + Segment_d(Rep&& v) : Rep(std::move(v)) {} + +#else + + Segment_d() : Rep(CSBase()()) {} + + Segment_d(Rep const& v) : Rep(v) {} // try not to use it + +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + explicit Segment_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CSBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \ + Segment_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} + /* + template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} + */ + + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE + +#endif + + //TODO: if CSEBase returns a reference to a base point, cast it to a + //reference to a wrapper point. Ugly but should be safe. + Point_ source()const{ + return Point_(Eval_functor(),CSEBase(),rep(),0); + } + Point_ target()const{ + return Point_(Eval_functor(),CSEBase(),rep(),1); + } + +}; + +} //namespace Wrap +} //namespace CGAL + +#endif // CGAL_WRAPPER_SEGMENT_D_H diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Sphere_d.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Sphere_d.h new file mode 100644 index 00000000..87f0c66e --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Sphere_d.h @@ -0,0 +1,130 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_WRAPPER_SPHERE_D_H +#define CGAL_WRAPPER_SPHERE_D_H + +#include <CGAL/representation_tags.h> +#include <CGAL/assertions.h> +#include <boost/type_traits.hpp> +#include <CGAL/Kernel/Return_base_tag.h> +#include <CGAL/Dimension.h> +#ifndef CGAL_CXX11 +#include <boost/preprocessor/repetition.hpp> +#endif +#include <boost/utility/result_of.hpp> + +namespace CGAL { +namespace Wrap { + +template <class R_> +class Sphere_d : public Get_type<typename R_::Kernel_base, Sphere_tag>::type +{ + typedef typename Get_type<R_, FT_tag>::type FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type<R_, Point_tag>::type Point_; + typedef typename Get_functor<Kbase, Construct_ttag<Sphere_tag> >::type CSBase; + typedef typename Get_functor<Kbase, Center_of_sphere_tag>::type COSBase; + typedef typename Get_functor<Kbase, Squared_radius_tag>::type SRBase; + + typedef Sphere_d Self; + CGAL_static_assertion((boost::is_same<Self, typename Get_type<R_, Sphere_tag>::type>::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef typename Increment_dimension<Ambient_dimension,-1>::type Feature_dimension; + + typedef typename Get_type<Kbase, Sphere_tag>::type Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX11 + template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Sphere_d> >::value>::type> explicit Sphere_d(U&&...u) + : Rep(CSBase()(std::forward<U>(u)...)){} + +// // called from Construct_point_d +// template<class...U> explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward<U>(u)...){} + template<class F,class...U> explicit Sphere_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward<F>(f)(std::forward<U>(u)...)){} + +#if 0 + // the new standard may make this necessary + Point_d(Point_d const&)=default; + Point_d(Point_d &);//=default; + Point_d(Point_d &&)=default; +#endif + + // try not to use these + Sphere_d(Rep const& v) : Rep(v) {} + Sphere_d(Rep& v) : Rep(static_cast<Rep const&>(v)) {} + Sphere_d(Rep&& v) : Rep(std::move(v)) {} + +#else + + Sphere_d() : Rep(CSBase()()) {} + + Sphere_d(Rep const& v) : Rep(v) {} // try not to use it + +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + explicit Sphere_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CSBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \ + Sphere_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} + /* + template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} + */ + + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE + +#endif + + //TODO: if COSBase returns a reference to a base point, cast it to a + //reference to a wrapper point. Ugly but should be safe. + Point_ center()const{ + return Point_(Eval_functor(),COSBase(),rep()); + } + FT_ squared_radius()const{ + return SRBase()(rep()); + } + +}; + +} //namespace Wrap +} //namespace CGAL + +#endif // CGAL_WRAPPER_SPHERE_D_H diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Vector_d.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Vector_d.h new file mode 100644 index 00000000..b7d1f0d0 --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -0,0 +1,266 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_WRAPPER_VECTOR_D_H +#define CGAL_WRAPPER_VECTOR_D_H + +#include <CGAL/Origin.h> +#include <CGAL/Kernel/mpl.h> +#include <CGAL/representation_tags.h> +#include <CGAL/assertions.h> +#include <boost/type_traits.hpp> +#include <CGAL/Kernel/Return_base_tag.h> +#include <CGAL/Dimension.h> +#ifndef CGAL_CXX11 +#include <boost/preprocessor/repetition.hpp> +#endif +#include <boost/utility/result_of.hpp> + +namespace CGAL { +namespace Wrap { + +template <class R_> +class Vector_d : public Get_type<typename R_::Kernel_base, Vector_tag>::type +{ + typedef typename Get_type<R_, RT_tag>::type RT_; + typedef typename Get_type<R_, FT_tag>::type FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type<R_, Point_tag>::type Point_; + typedef typename Get_functor<Kbase, Construct_ttag<Vector_tag> >::type CVBase; + typedef typename Get_functor<Kbase, Compute_vector_cartesian_coordinate_tag>::type CCBase; + typedef typename Get_functor<Kbase, Construct_ttag<Vector_cartesian_const_iterator_tag> >::type CVI; + typedef typename Get_functor<Kbase, Squared_length_tag>::type SLBase; + + typedef Vector_d Self; + CGAL_static_assertion((boost::is_same<Self, typename Get_type<R_, Vector_tag>::type>::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef Dimension_tag<0> Feature_dimension; + + //typedef typename R_::Vector_cartesian_const_iterator Cartesian_const_iterator; + typedef typename Get_type<Kbase, Vector_tag>::type Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX11 + template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Vector_d> >::value>::type> explicit Vector_d(U&&...u) + : Rep(CVBase()(std::forward<U>(u)...)){} + +// // called from Construct_vector_d +// template<class...U> explicit Vector_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward<U>(u)...){} + template<class F,class...U> explicit Vector_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward<F>(f)(std::forward<U>(u)...)){} + +#if 0 + // the new standard may make this necessary + Vector_d(Vector_d const&)=default; + Vector_d(Vector_d &);//=default; + Vector_d(Vector_d &&)=default; +#endif + + // try not to use these + Vector_d(Rep const& v) : Rep(v) {} + Vector_d(Rep& v) : Rep(static_cast<Rep const&>(v)) {} + Vector_d(Rep&& v) : Rep(std::move(v)) {} + + // this one should be implicit + Vector_d(Null_vector const& v) + : Rep(CVBase()(v)) {} + Vector_d(Null_vector& v) + : Rep(CVBase()(v)) {} + Vector_d(Null_vector&& v) + : Rep(CVBase()(std::move(v))) {} + +#else + + Vector_d() : Rep(CVBase()()) {} + + Vector_d(Rep const& v) : Rep(v) {} // try not to use it + +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + explicit Vector_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CVBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \ + Vector_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} + /* + template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + Vector_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} + */ + + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE + + // this one should be implicit + Vector_d(Null_vector const& v) + : Rep(CVBase()(v)) {} + +#endif + + typename boost::result_of<CCBase(Rep,int)>::type cartesian(int i)const{ + return CCBase()(rep(),i); + } + + typename boost::result_of<CCBase(Rep,int)>::type operator[](int i)const{ + return CCBase()(rep(),i); + } + + typename boost::result_of<CVI(Rep,Begin_tag)>::type cartesian_begin()const{ + return CVI()(rep(),Begin_tag()); + } + + typename boost::result_of<CVI(Rep,End_tag)>::type cartesian_end()const{ + return CVI()(rep(),End_tag()); + } + + Vector_d operator-() const + { + return typename Get_functor<R, Opposite_vector_tag>::type()(*this); + } + + /* + Direction_d direction() const + { + return R().construct_direction_d_object()(*this); + } + + Vector_d transform(const Aff_transformation_d &t) const + { + return t.transform(*this); + } + + Vector_d operator/(const RT& c) const + { + return R().construct_divided_vector_d_object()(*this,c); + } + + Vector_d operator/(const typename First_if_different<FT_,RT>::Type & c) const + { + return R().construct_divided_vector_d_object()(*this,c); + } + + typename Qualified_result_of<typename R::Compute_x_3, Vector_3>::type + x() const + { + return R().compute_x_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_y_3, Vector_3>::type + y() const + { + return R().compute_y_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_z_3, Vector_3>::type + z() const + { + return R().compute_z_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hx_3, Vector_3>::type + hx() const + { + return R().compute_hx_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hy_3, Vector_3>::type + hy() const + { + return R().compute_hy_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hz_3, Vector_3>::type + hz() const + { + return R().compute_hz_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_hw_3, Vector_3>::type + hw() const + { + return R().compute_hw_3_object()(*this); + } + + typename Qualified_result_of<typename R::Compute_x_3, Vector_3>::type + cartesian(int i) const + { + CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); + if (i==0) return x(); + if (i==1) return y(); + return z(); + } + + typename Qualified_result_of<typename R::Compute_hw_3, Vector_3>::type + homogeneous(int i) const + { + CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); + if (i==0) return hx(); + if (i==1) return hy(); + if (i==2) return hz(); + return hw(); + } + + int dimension() const // bad idea? + { + return rep.dimension(); + } +*/ + typename boost::result_of<SLBase(Rep)>::type squared_length()const{ + return SLBase()(rep()); + } +}; +#if 0 +template <class R_> Vector_d<R_>::Vector_d(Vector_d &)=default; +#endif + +//TODO: IO + +template <class R_> +Vector_d<R_> operator+(const Vector_d<R_>& v,const Vector_d<R_>& w) +{ + return typename Get_functor<R_, Sum_of_vectors_tag>::type()(v,w); +} + +template <class R_> +Vector_d<R_> operator-(const Vector_d<R_>& v,const Vector_d<R_>& w) +{ + return typename Get_functor<R_, Difference_of_vectors_tag>::type()(v,w); +} + +} //namespace Wrap +} //namespace CGAL + +#endif // CGAL_WRAPPER_VECTOR_D_H diff --git a/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h new file mode 100644 index 00000000..877eea21 --- /dev/null +++ b/include/gudhi_patches/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h @@ -0,0 +1,129 @@ +// Copyright (c) 2014 +// INRIA Saclay-Ile de France (France) +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Marc Glisse + +#ifndef CGAL_WRAPPER_WEIGHTED_POINT_D_H +#define CGAL_WRAPPER_WEIGHTED_POINT_D_H + +#include <CGAL/representation_tags.h> +#include <boost/static_assert.hpp> +#include <boost/type_traits.hpp> +#include <CGAL/Kernel/Return_base_tag.h> +#include <CGAL/Dimension.h> +#ifndef CGAL_CXX11 +#include <boost/preprocessor/repetition.hpp> +#endif +#include <boost/utility/result_of.hpp> + +namespace CGAL { +namespace Wrap { + +template <class R_> +class Weighted_point_d : public Get_type<typename R_::Kernel_base, Weighted_point_tag>::type +{ + typedef typename Get_type<R_, FT_tag>::type FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type<R_, Point_tag>::type Point_; + typedef typename Get_functor<Kbase, Construct_ttag<Weighted_point_tag> >::type CWPBase; + typedef typename Get_functor<Kbase, Point_drop_weight_tag>::type PDWBase; + typedef typename Get_functor<Kbase, Point_weight_tag>::type PWBase; + + typedef Weighted_point_d Self; + BOOST_STATIC_ASSERT((boost::is_same<Self, typename Get_type<R_, Weighted_point_tag>::type>::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef Dimension_tag<0> Feature_dimension; + + typedef typename Get_type<Kbase, Weighted_point_tag>::type Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX11 + template<class...U,class=typename std::enable_if<!std::is_same<std::tuple<typename std::decay<U>::type...>,std::tuple<Weighted_point_d> >::value>::type> explicit Weighted_point_d(U&&...u) + : Rep(CWPBase()(std::forward<U>(u)...)){} + +// // called from Construct_point_d +// template<class...U> explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward<U>(u)...){} + template<class F,class...U> explicit Weighted_point_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward<F>(f)(std::forward<U>(u)...)){} + +#if 0 + // the new standard may make this necessary + Point_d(Point_d const&)=default; + Point_d(Point_d &);//=default; + Point_d(Point_d &&)=default; +#endif + + // try not to use these + Weighted_point_d(Rep const& v) : Rep(v) {} + Weighted_point_d(Rep& v) : Rep(static_cast<Rep const&>(v)) {} + Weighted_point_d(Rep&& v) : Rep(std::move(v)) {} + +#else + + Weighted_point_d() : Rep(CWPBase()()) {} + + Weighted_point_d(Rep const& v) : Rep(v) {} // try not to use it + +#define CGAL_CODE(Z,N,_) template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + explicit Weighted_point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CWPBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template<class F,BOOST_PP_ENUM_PARAMS(N,class T)> \ + Weighted_point_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} + /* + template<BOOST_PP_ENUM_PARAMS(N,class T)> \ + Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} + */ + + BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) +#undef CGAL_CODE + +#endif + + //TODO: use references? + Point_ point()const{ + return Point_(Eval_functor(),PDWBase(),rep()); + } + FT_ weight()const{ + return PWBase()(rep()); + } + +}; + +} //namespace Wrap +} //namespace CGAL + +#endif // CGAL_WRAPPER_SPHERE_D_H |