diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex index 2c833f94afe..d405de6c2c7 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex @@ -11,7 +11,7 @@ the provision of certain types in a \ccc{Kernel}. \ccNestedType{Type::type}{shall be a forward iterator (except that it may return an rvalue) whose \ccc{value_type} is \ccc{Kernel::Type::type}.} \ccNestedType{Functor>::type}{[Optional] A default converter it available to \ccc{Kernel_converter}, but may be unsuitable if your Point type is too original.} -\ccNestedType{Functor::type}{shall provide \ccc{Type::type operator()(Type::type const&, Extremity_tag)const} where \ccc{Extemity_tag} is \ccc{Begin_tag} or \ccc{End_tag}.} +\ccNestedType{Functor>::type}{shall provide \ccc{Type::type operator()(Type::type const&, Extremity_tag)const} where \ccc{Extemity_tag} is \ccc{Begin_tag} or \ccc{End_tag}.} \ccNestedType{Functor::type}{shall provide \ccc{FT operator()(Type::type,int k)const} which returns the $k$th Cartesian coordinate of the point.} \ccNestedType{Functor::type}{shall provide \ccc{int operator()(Type::type)const} which returns the dimension of a point.} \ccNestedType{Functor>::type}{shall provide:\\ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h index a37c849a2db..87fbced7624 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -86,10 +86,10 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Functor,D> { typedef CartesianDVectorBase::Construct_LA_vector type; }; - template struct Functor { + template struct Functor,D> { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; - template struct Functor { + template struct Functor,D> { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; #if 0 diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h index e781f63cb75..b7172ba543c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -62,8 +62,8 @@ struct Cartesian_change_FT_base : public return make_transforming_iterator(f(v,End_tag()),FT_converter()); } }; - typedef Construct_cartesian_const_iterator_ Construct_point_cartesian_const_iterator; - typedef Construct_cartesian_const_iterator_ Construct_vector_cartesian_const_iterator; + typedef Construct_cartesian_const_iterator_,Point_cartesian_const_iterator> Construct_point_cartesian_const_iterator; + typedef Construct_cartesian_const_iterator_,Vector_cartesian_const_iterator> Construct_vector_cartesian_const_iterator; template struct Compute_cartesian_coordinate { @@ -90,10 +90,10 @@ struct Cartesian_change_FT_base : public template struct Functor { typedef Compute_cartesian_coordinate type; }; - template struct Functor { + template struct Functor,D,Construct_iterator_tag> { typedef Construct_point_cartesian_const_iterator type; }; - template struct Functor { + template struct Functor,D,Construct_iterator_tag> { typedef Construct_vector_cartesian_const_iterator type; }; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h index c61a2b670cf..e21f0690bd1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -16,7 +16,7 @@ struct Point_converter_help { typedef typename K2::template Type::type result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { - typename K1::template Functor::type i(k1); + typename K1::template Functor >::type i(k1); typename K2::template Functor >::type cp(k2); return cp(conv(i(p,Begin_tag())),conv(i(p,End_tag()))); } @@ -57,7 +57,7 @@ template struct KO_converter{ typedef typename K2::template Type::type result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& v) const { - typename K1::template Functor::type i(k1); + typename K1::template Functor >::type i(k1); typename K2::template Functor >::type cp(k2); return cp(conv(i(v,Begin_tag())),conv(i(v,End_tag()))); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 6f499b3cefd..b4caa5ab14d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -2,6 +2,7 @@ #define CGAL_KERNEL_D_LAZY_CARTESIAN_H #include +#include #include #include #include @@ -9,6 +10,36 @@ namespace CGAL { +template +struct Nth_iterator_element : private Store_kernel { + Nth_iterator_element(){} + Nth_iterator_element(K const&k):Store_kernel(k){} + typedef typename Read_tag_type::value_tag>::type result_type; + template result_type operator()(CGAL_FORWARDABLE(U) u, int i) const { + typename K::template Functor >::type ci(this->kernel()); + return *cpp0x::next(ci(CGAL_FORWARD(U,u),Begin_tag()),i); + } +}; + //typedef typename Functor::nth_element>::type nth_elem; +template::has_nth_element> +struct Select_nth_element_functor { + typedef Nth_iterator_element type; +}; +template +struct Select_nth_element_functor : + K::template Functor::nth_element> {}; + +namespace internal { + template + struct Lazy_construction_maybe_nt { + typedef Lazy_construction type; + }; + template + struct Lazy_construction_maybe_nt { + typedef Lazy_construction_nt type; + }; +} + template struct Lazy_cartesian : Dimension_base { @@ -32,7 +63,7 @@ struct Lazy_cartesian : Dimension_base typedef Approx_converter C2A; typedef Exact_converter C2E; typedef CGAL::Lazy_exact_nt FT; - typedef FT RT; + typedef CGAL::Lazy_exact_nt RT; typedef typename Exact_kernel::Rep_tag Rep_tag; typedef typename Exact_kernel::Kernel_tag Kernel_tag; @@ -64,6 +95,9 @@ struct Lazy_cartesian : Dimension_base template struct Type { typedef FT type; }; + template struct Type { + typedef RT type; + }; typedef typename typeset_intersection< typename Approximate_kernel::Object_list, typename Exact_kernel::Object_list @@ -95,28 +129,19 @@ struct Lazy_cartesian : Dimension_base >::type Iterator_list; - //TODO: handle the case without nth_element -#if 0 - templatestruct Default_nth_element : private Store_kernel { - Default_nth_element(){} - Default_nth_element(Kernel const&k):Store_kernel(k){} - typedef /*???*/ result_type; - template result_type operator()(CGAL_FORWARDABLE(U) u, int i) { - typename /*???*/ ci(this->kernel()); - std::advance(ci, i); - return *i; - } - }; -#endif - template struct Iterator { - //WARNING: this fails because it is not lazy enough: - //typedef typename Read_tag_type::value_tag>::type V; - typedef typename Type::value_tag>::type V; + typedef typename iterator_tag_traits::value_tag Vt; + typedef typename Type::type V; + typedef typename Select_nth_element_functor::type AF; + typedef typename Select_nth_element_functor::type EF; + + typedef typename internal::Lazy_construction_maybe_nt< + Kernel, AF, EF, is_NT_tag::value + >::type nth_elem; + typedef Iterator_from_indices< const typename Type::container>::type, - const V, V, - typename Functor::nth_element>::type + const V, V, nth_elem > type; }; //typedef typename Iterator::type Point_cartesian_const_iterator; diff --git a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h index 52620ff3940..b66cff756d3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -300,7 +300,7 @@ template struct Construct_opposite_vector : private Store_kernel { typedef typename R_::FT FT; typedef typename R::template Type::type Vector; typedef typename R::template Functor >::type CV; - typedef typename R::template Functor::type CI; + typedef typename R::template Functor >::type CI; typedef Vector result_type; typedef Vector argument_type; result_type operator()(Vector const&v)const{ @@ -315,7 +315,7 @@ template struct Construct_sum_of_vectors : private Store_kernel { typedef typename R_::FT FT; typedef typename R::template Type::type Vector; typedef typename R::template Functor >::type CV; - typedef typename R::template Functor::type CI; + typedef typename R::template Functor >::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -331,7 +331,7 @@ template struct Construct_difference_of_vectors : private Store_kernel typedef typename R_::FT FT; typedef typename R::template Type::type Vector; typedef typename R::template Functor >::type CV; - typedef typename R::template Functor::type CI; + typedef typename R::template Functor >::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -347,7 +347,7 @@ template struct Construct_midpoint : private Store_kernel { typedef typename R_::FT FT; typedef typename R::template Type::type Point; typedef typename R::template Functor >::type CP; - typedef typename R::template Functor::type CI; + typedef typename R::template Functor >::type CI; typedef Point result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -369,7 +369,7 @@ template struct Compute_squared_length : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::template Type::type Vector; - typedef typename R::template Functor::type CI; + typedef typename R::template Functor >::type CI; typedef FT result_type; typedef Vector argument_type; result_type operator()(Vector const&a)const{ @@ -385,7 +385,7 @@ template struct Compute_squared_distance : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::template Type::type Point; - typedef typename R::template Functor::type CI; + typedef typename R::template Functor >::type CI; typedef FT result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -462,7 +462,7 @@ template struct Compare_lexicographically : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; - typedef typename R::template Functor::type CI; + typedef typename R::template Functor >::type CI; // TODO: This is_exact thing should be reengineered. // the goal is to have a way to tell: don't filter this typedef typename CGAL::Is_exact::type Is_exact; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 60bf7301811..276385ae3af 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -13,8 +13,9 @@ namespace CGAL { struct Misc_tag {}; struct No_filter_tag {}; - struct FT_tag {}; - struct RT_tag {}; + + templatestruct Construct_ttag {}; + templatestruct Convert_ttag {}; template struct map_functor_type { typedef Misc_tag type; }; template struct Typedef_tag_type; @@ -27,6 +28,10 @@ namespace CGAL { template \ struct Read_tag_type { typedef typename Kernel::X type; } + // Not exactly objects, but the extras can't hurt. + DECL_OBJ(FT); + DECL_OBJ(RT); + DECL_OBJ(Vector); DECL_OBJ(Point); DECL_OBJ(Segment); @@ -36,6 +41,10 @@ namespace CGAL { DECL_OBJ(Bbox); #undef DECL_OBJ + template struct is_NT_tag { enum { value = false }; }; + template<> struct is_NT_tag { enum { value = true }; }; + template<> struct is_NT_tag { enum { value = true }; }; + template struct iterator_tag_traits { enum { is_iterator = false, has_nth_element = false }; typedef Null_tag value_tag; @@ -66,11 +75,14 @@ namespace CGAL { DECL_ITER_OBJ(Point_cartesian_const_iterator, FT, Compute_point_cartesian_coordinate, Point); #undef DECL_ITER_OBJ - templatestruct Construct_ttag {}; - templatestruct Convert_ttag {}; templatestruct map_result_tag{typedef Null_type type;}; templatestruct map_result_tag >{typedef T type;}; - templatestruct map_functor_type >{typedef Construct_tag type;}; + + templatestruct map_functor_type > : + BOOSTD conditional::is_iterator, + Construct_iterator_tag, + Construct_tag> {}; + templatestruct map_functor_type >{typedef Misc_tag type;}; #define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ template<>struct map_result_tag{typedef Y##_tag type;}; \ @@ -87,12 +99,14 @@ namespace CGAL { DECL_CONSTRUCT(Construct_difference_of_vectors,Vector); DECL_CONSTRUCT(Construct_opposite_vector,Vector); #undef DECL_CONSTRUCT +#if 0 #define DECL_ITER_CONSTRUCT(X,Y) struct X##_tag {}; \ template<>struct map_result_tag{typedef Y##_tag type;}; \ template<>struct map_functor_type{typedef Construct_iterator_tag type;} DECL_ITER_CONSTRUCT(Construct_point_cartesian_const_iterator,Point_cartesian_const_iterator); DECL_ITER_CONSTRUCT(Construct_vector_cartesian_const_iterator,Vector_cartesian_const_iterator); #undef DECL_ITER_CONSTRUCT +#endif //FIXME: choose a convention: prefix with Predicate_ ? #define DECL_PREDICATE(X) struct X##_tag {}; \ diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 3166fd89733..bbc46f8ee43 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -76,7 +76,7 @@ typedef K1::Functor >::type CP; typedef K1::Functor >::type CV; typedef K1::Functor >::type CS; typedef K1::Functor::type CSE; -typedef K1::Functor::type CCI; +typedef K1::Functor >::type CCI; typedef K1::Functor::type PO; typedef K1::Functor::type SOS; //typedef K1::Point_cartesian_const_iterator CI;