From ddbfbe839896b594d986d1e22223b5a4dc388b60 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 29 Apr 2011 19:49:09 +0000 Subject: [PATCH 002/210] directories --- NewKernel_d/package_info/Kernel_d/description.txt | 1 + NewKernel_d/package_info/Kernel_d/maintainer | 1 + 2 files changed, 2 insertions(+) create mode 100644 NewKernel_d/package_info/Kernel_d/description.txt create mode 100644 NewKernel_d/package_info/Kernel_d/maintainer diff --git a/NewKernel_d/package_info/Kernel_d/description.txt b/NewKernel_d/package_info/Kernel_d/description.txt new file mode 100644 index 00000000000..ad14cf1d649 --- /dev/null +++ b/NewKernel_d/package_info/Kernel_d/description.txt @@ -0,0 +1 @@ +d-dimensional Geometry Kernel diff --git a/NewKernel_d/package_info/Kernel_d/maintainer b/NewKernel_d/package_info/Kernel_d/maintainer new file mode 100644 index 00000000000..a9ff63ce1ce --- /dev/null +++ b/NewKernel_d/package_info/Kernel_d/maintainer @@ -0,0 +1 @@ +Marc Glisse From 1cd3febf83e5f24ab670174f65b14ef60b720dd5 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 9 May 2011 14:08:39 +0000 Subject: [PATCH 003/210] A beginning. --- NewKernel_d/test/NewKernel_d/Makefile | 13 +++++++++ NewKernel_d/test/NewKernel_d/test.cpp | 40 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 NewKernel_d/test/NewKernel_d/Makefile create mode 100644 NewKernel_d/test/NewKernel_d/test.cpp diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile new file mode 100644 index 00000000000..3ef9d72421c --- /dev/null +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -0,0 +1,13 @@ +all: normal cxx0x + +CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include + +normal: + g++ test.cpp -O2 -g -lCGAL -frounding-math -Wall -I. -lgmp -I../../include -I/usr/include/eigen2 -DCGAL_USE_EIGEN ${CGAL_INC} + ./a.out + +cxx0x: + /usr/lib/gcc-snapshot/bin/g++ -std=c++0x -O2 -g test.cpp -lCGAL -frounding-math -Wall -I. -lgmp -DCGAL_CXX0X -I../../include -I/usr/include/eigen2 -DCGAL_USE_EIGEN ${CGAL_INC} + ./a.out + +#-DBOOST_RESULT_OF_USE_DECLTYPE diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp new file mode 100644 index 00000000000..db0d696196d --- /dev/null +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include +#include +typedef CGAL::Cartesian_base_d > K0; +typedef CGAL::Cartesian_filter_NT K1; +//typedef CGAL::Cartesian_change_FT K1; +typedef K1::Point P; +typedef K1::Vector V; +typedef K1::Segment S; +//typedef K1::Construct_point CP; +typedef K1::Construct::type CP; +typedef K1::Construct_vector CV; +typedef K1::Construct_cartesian_const_iterator CCI; +typedef K1::Predicate::type PO; +typedef K1::Cartesian_const_iterator CI; +typedef K1::Compute_cartesian_coordinate CC; + +int main(){ + CP cp; CCI ci; CC cc; PO po; + P a=cp(3,4); + P b=cp(5,6,7); + int rr[]={3,5,2}; + int* r=rr; + P c=cp(r,r+2); + P d=cp(r,r+3,CGAL::Homogeneous_tag()); + S s(c,d); + std::cout << cc(a,1) << std::endl; + std::cout << cc(b,1) << std::endl; + std::cout << cc(s[0],1) << std::endl; + std::cout << cc(s[1],1) << std::endl; + for(CI i=ci.begin(a);i!=ci.end(a);++i) + std::cout << *i << ' '; + std::cout << '\n'; + P tab[]={a,b,c}; + std::cout << po(&tab[0],tab+3) << std::endl; +} From 146ee6dbd1a99b7a9a077a0950ff1c26d6e6b752 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 9 May 2011 14:08:57 +0000 Subject: [PATCH 004/210] A beginning. --- NewKernel_d/include/CGAL/Dimension.h | 123 +++++++++++ .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 112 ++++++++++ .../CGAL/Kernel_d/Cartesian_LA_functors.h | 192 ++++++++++++++++++ .../include/CGAL/Kernel_d/Cartesian_base.h | 28 +++ .../CGAL/Kernel_d/Cartesian_change_FT.h | 92 +++++++++ .../CGAL/Kernel_d/Cartesian_complete.h | 118 +++++++++++ .../CGAL/Kernel_d/Cartesian_filter_NT.h | 77 +++++++ .../include/CGAL/Kernel_d/Dimension_base.h | 23 +++ NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 45 ++++ .../Kernel_d/function_objects_cartesian.h | 183 +++++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 69 +++++++ NewKernel_d/include/CGAL/LA_eigen/LA.h | 92 +++++++++ .../include/CGAL/LA_eigen/constructors.h | 110 ++++++++++ NewKernel_d/include/CGAL/argument_swaps.h | 69 +++++++ NewKernel_d/include/CGAL/exactness.h | 19 ++ NewKernel_d/include/CGAL/functor_tags.h | 37 ++++ .../include/CGAL/iterator_from_indices.h | 41 ++++ NewKernel_d/include/CGAL/marcutils.h | 129 ++++++++++++ NewKernel_d/include/CGAL/myeigen.h | 43 ++++ NewKernel_d/include/CGAL/static_int.h | 42 ++++ .../include/CGAL/transforming_iterator.h | 92 +++++++++ .../include/CGAL/transforming_pair_iterator.h | 107 ++++++++++ 22 files changed, 1843 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Dimension.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Segmentd.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/interface_macros.h create mode 100644 NewKernel_d/include/CGAL/LA_eigen/LA.h create mode 100644 NewKernel_d/include/CGAL/LA_eigen/constructors.h create mode 100644 NewKernel_d/include/CGAL/argument_swaps.h create mode 100644 NewKernel_d/include/CGAL/exactness.h create mode 100644 NewKernel_d/include/CGAL/functor_tags.h create mode 100644 NewKernel_d/include/CGAL/iterator_from_indices.h create mode 100644 NewKernel_d/include/CGAL/marcutils.h create mode 100644 NewKernel_d/include/CGAL/myeigen.h create mode 100644 NewKernel_d/include/CGAL/static_int.h create mode 100644 NewKernel_d/include/CGAL/transforming_iterator.h create mode 100644 NewKernel_d/include/CGAL/transforming_pair_iterator.h diff --git a/NewKernel_d/include/CGAL/Dimension.h b/NewKernel_d/include/CGAL/Dimension.h new file mode 100644 index 00000000000..66609cf95c3 --- /dev/null +++ b/NewKernel_d/include/CGAL/Dimension.h @@ -0,0 +1,123 @@ +// Copyright (c) 2008 INRIA Sophia-Antipolis (France). +// Aviv University (Israel). All rights reserved. +// +// 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; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// 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) : Sylvain Pion + +#ifndef CGAL_DIMENSION_H +#define CGAL_DIMENSION_H + +#include +#include +#include +#ifdef CGAL_USE_EIGEN +#include +#endif + +namespace CGAL { + +#ifdef CGAL_USE_EIGEN +const int UNKNOWN_DIMENSION=Eigen::Dynamic; +#else +const int UNKNOWN_DIMENSION=std::numeric_limits::max(); +#endif + +bool check_dimension(int d1, int d2){ + //return (d2==UNKNOWN_DIMENSION)||(d1<=d2); + return d1<=d2; +} + +// These tag classes help dispatching functions based on a geometric dimension. + +template < int dim > +struct Dimension_tag +{ + static const int value = dim; +}; + +struct Dynamic_dimension_tag { + static const int value = UNKNOWN_DIMENSION; +}; + + +namespace internal { + + template < typename D > + struct Dim_value { + static const int value = D::value; + }; + + template <> + struct Dim_value {}; + +} // namespace internal + + +// Ambient_dimension gives access to the dimension of the ambient space of an object. + +template < typename T, typename K = typename Kernel_traits::Kernel > +struct Ambient_dimension + : public internal::Dim_value< typename K::template Ambient_dimension::type > +{ + typedef typename K::template Ambient_dimension::type type; +}; + + +// Feature_dimension gives access to the dimension of an object. + +template < typename T, typename K = typename Kernel_traits::Kernel > +struct Feature_dimension + : public internal::Dim_value< typename K::template Feature_dimension::type > +{ + typedef typename K::template Feature_dimension::type type; +}; + +// Change the dimension +templatestruct Increment_dimension { + typedef Dynamic_dimension_tag type; +}; +templatestruct Increment_dimension,i> { + typedef Dimension_tag type; +}; + +templatestruct Product_dimension { + typedef Dynamic_dimension_tag type; +}; +templatestruct Product_dimension,Dimension_tag > { + typedef Dimension_tag type; +}; + +#ifdef CGAL_USE_EIGEN +// Convert to Eigen's notion of dimension +template struct Eigen_dimension { + enum { value=Eigen::Dynamic }; +}; +template struct Eigen_dimension > { + enum { value=d }; +}; + +// and convert back +template struct Dimension_eigen { + typedef Dimension_tag type; +}; +template <> struct Dimension_eigen { + typedef Dynamic_dimension_tag type; +}; +#endif + +} //namespace CGAL + +#endif // CGAL_DIMENSION_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h new file mode 100644 index 00000000000..518d9957514 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -0,0 +1,112 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_LA_BASE_H +#define CGAL_KERNEL_D_CARTESIAN_LA_BASE_H + +#include + +#include +#include +#include +#include +#include +#ifdef CGAL_USE_EIGEN +#include +#else +#include +#endif + +namespace CGAL { + +template < typename FT_, typename Dim_> +struct Cartesian_LA_base_d : public Dimension_base +{ + typedef FT_ FT; + typedef Cartesian_LA_base_d Self; + typedef Cartesian_tag Rep_tag; + typedef Cartesian_tag Kernel_tag; + typedef Dim_ Default_ambient_dimension; + typedef Dim_ Max_ambient_dimension; +#ifdef CGAL_USE_EIGEN + typedef CGAL::LA_eigen LA; +#else + typedef CGAL::LA_default LA; +#endif + + typedef typename Same_uncertainty_nt::type + Boolean; + typedef typename Same_uncertainty_nt::type + Sign; + typedef typename Same_uncertainty_nt::type + Comparison_result; + typedef typename Same_uncertainty_nt::type + Orientation; + typedef typename Same_uncertainty_nt::type + Oriented_side; + typedef typename Same_uncertainty_nt::type + Bounded_side; + typedef typename Same_uncertainty_nt::type + Angle; + + typedef typename LA::template Vector LA_vector_selector; + typedef typename LA_vector_selector::type LA_vector; + typedef typename LA_vector_selector::Constructor Constructor; + typedef typename LA_vector_selector::const_iterator Cartesian_const_iterator; + + // convert types to the new way? painful to use... + typedef LA_vector Point; + typedef LA_vector Vector; + + // old way + typedef CartesianDVectorBase::Construct_LA_vector Construct_point; + typedef CartesianDVectorBase::Construct_LA_vector Construct_vector; + typedef CartesianDVectorBase::Construct_cartesian_const_iterator Construct_cartesian_const_iterator; + typedef CartesianDVectorBase::Construct_sum_of_vectors Construct_sum_of_vectors; + typedef CartesianDVectorBase::Construct_difference_of_vectors Construct_difference_of_vectors; + typedef CartesianDVectorBase::Construct_opposite_vector Construct_opposite_vector; + typedef CartesianDVectorBase::Construct_midpoint Construct_midpoint; + + typedef CartesianDVectorBase::Compute_cartesian_coordinate Compute_cartesian_coordinate; + + // new way + template struct Construct { + typedef Null_functor type; + }; + template struct Construct { + typedef CartesianDVectorBase::Construct_LA_vector type; + }; + template struct Construct { + typedef CartesianDVectorBase::Construct_LA_vector type; + }; + template struct Construct { + typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; + }; + template struct Construct { + typedef CartesianDVectorBase::Construct_sum_of_vectors type; + }; + template struct Construct { + typedef CartesianDVectorBase::Construct_difference_of_vectors type; + }; + template struct Construct { + typedef CartesianDVectorBase::Construct_opposite_vector type; + }; + template struct Construct { + typedef CartesianDVectorBase::Construct_midpoint type; + }; + + template struct Compute { + typedef Null_functor type; + }; + template struct Compute { + typedef CartesianDVectorBase::Compute_cartesian_coordinate type; + }; + + template struct Predicate { + typedef Null_functor type; + }; + + CGAL_CONSTEXPR Cartesian_LA_base_d(){} + CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} +}; + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_CARTESIAN_LA_BASE_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h new file mode 100644 index 00000000000..84f0f045b1e --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -0,0 +1,192 @@ +#ifndef CGAL_CARTESIAN_LA_FUNCTORS_H +#define CGAL_CARTESIAN_LA_FUNCTORS_H + +#include +#include +#include +#include +#include + +namespace CGAL { +namespace CartesianDVectorBase { +#ifndef CGAL_CXX0X +namespace internal { +template struct Construct_LA_vector_; +#define CODE(Z,N,_) template struct Construct_LA_vector_ { \ + typedef typename R::Constructor Constructor; \ + typedef typename R::FT FT; \ + typedef typename R::LA_vector result_type; \ + result_type operator() \ + (BOOST_PP_ENUM_PARAMS(N,FT const& t)) const { \ + return typename Constructor::Values()(BOOST_PP_ENUM_PARAMS(N,t)); \ + } \ + result_type operator() \ + (BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N),FT const& t)) const { \ + return typename Constructor::Values_divide()(t##N,BOOST_PP_ENUM_PARAMS(N,t)); \ + } \ + }; +BOOST_PP_REPEAT_FROM_TO(2, 11, CODE, _ ) +#undef CODE +} +#endif + +template struct Construct_LA_vector +#ifndef CGAL_CXX0X +: internal::Construct_LA_vector_ +#endif +{ + typedef R_ R; + typedef typename R::Constructor Constructor; + typedef typename R::FT FT; + typedef typename R::LA_vector result_type; + typedef typename R_::Default_ambient_dimension Dimension; + static const int dim=Dimension::value; + result_type operator()(int d)const{ + CGAL_assertion(d==dim); + return typename Constructor::Dimension()(d); + } + result_type operator()()const{ + return typename Constructor::Dimension()(dim); + } + result_type operator()(result_type const& v)const{ + return v; + } +#ifdef CGAL_CXX0X + result_type operator()(result_type&& v)const{ + return std::move(v); + } +#endif +#ifdef CGAL_CXX0X + template + typename std::enable_if::value && + (sizeof...(U)==dim), result_type>::type + operator()(U&&...u)const{ + return typename Constructor::Values()(std::forward(u)...); + } + //template::value>::type,class=typename std::enable_if<(sizeof...(U)==dim+1)>::type,class=void> + template + typename std::enable_if::value && + (sizeof...(U)==dim+1), result_type>::type + operator()(U&&...u)const{ + return Apply_to_last_then_rest()(typename Constructor::Values_divide(),std::forward(u)...); + } +#else + using internal::Construct_LA_vector_::operator(); +#endif + template typename boost::enable_if,result_type>::type operator() + (Iter const&f,Iter const&g,Cartesian_tag)const + { + int d=std::distance(f,g); + CGAL_assertion(d==dim); + return typename Constructor::Iterator()(dim,f,g); + } + template typename boost::enable_if,result_type>::type operator() + (Iter const&f,Iter g,Homogeneous_tag)const + { + --g; + return this->operator()(f,g,*g); + } + template typename boost::enable_if,result_type>::type operator() + (Iter const&f,Iter const&g)const + { + return this->operator()(f,g,typename R::Rep_tag()); + } + template typename boost::enable_if,result_type>::type operator() + (Iter const&f,Iter const&g,NT const&l)const + { + int d=std::distance(f,g); + CGAL_assertion(d==dim); + return typename Constructor::Iterator()(dim,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); + } +}; + +template struct Compute_cartesian_coordinate { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::LA_vector first_argument_type; + typedef int second_argument_type; + typedef Tag_true Is_exact; +#ifdef CGAL_CXX0X + typedef decltype(std::declval()[0]) result_type; +#else + typedef FT result_type; // FT const& doesn't work with some LA +#endif + + result_type operator()(first_argument_type const& v,int i)const{ + return v[i]; + } +}; + +template struct Construct_cartesian_const_iterator { + typedef R_ R; + typedef typename R::LA_vector argument_type; + typedef typename R::LA_vector_selector S_; + typedef typename R::Cartesian_const_iterator result_type; + + result_type begin(argument_type const& v)const{ + return S_::vector_begin(v); + } + result_type end(argument_type const& v)const{ + return S_::vector_end(v); + } +}; + +template struct Construct_midpoint { + typedef R_ R; + typedef typename R::Point first_argument_type; + typedef typename R::Point second_argument_type; + typedef typename R::Point result_type; + + result_type operator()(result_type const& a, result_type const& b)const{ + return (a+b)/2; + } +}; + +template struct Construct_sum_of_vectors { + typedef R_ R; + typedef typename R::Vector first_argument_type; + typedef typename R::Vector second_argument_type; + typedef typename R::Vector result_type; + + result_type operator()(result_type const& a, result_type const& b)const{ + return a+b; + } +}; + +template struct Construct_difference_of_vectors { + typedef R_ R; + typedef typename R::Vector first_argument_type; + typedef typename R::Vector second_argument_type; + typedef typename R::Vector result_type; + + result_type operator()(result_type const& a, result_type const& b)const{ + return a-b; + } +}; + +template struct Construct_opposite_vector { + typedef R_ R; + typedef typename R::Vector result_type; + typedef typename R::Vector argument_type; + + result_type operator()(result_type const& v)const{ + return -v; + } +}; + +template struct Compute_scalar_product { + typedef R_ R; + typedef typename R::LA LA; + typedef typename R::FT result_type; + typedef typename R::Vector first_argument_type; + typedef typename R::Vector second_argument_type; + + result_type operator()(first_argument_type const& a, second_argument_type const& b)const{ + return LA::dot_product(a,b); + } +}; + + +} +} // namespace CGAL +#endif // CGAL_CARTESIAN_LA_FUNCTORS_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h new file mode 100644 index 00000000000..c86cc88a8f3 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h @@ -0,0 +1,28 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_BASE_H +#define CGAL_KERNEL_D_CARTESIAN_BASE_H + +#include +#include +#include + +namespace CGAL { + +template < typename FT_, typename Dim_> +struct Cartesian_base_d : public +Cartesian_complete_predicates< +Cartesian_complete_constructors< +Cartesian_complete_computes< +Cartesian_complete_types< + Cartesian_LA_base_d +>, false, Cartesian_base_d +>, false, Cartesian_base_d +>, false, Cartesian_base_d +> +{ + CGAL_CONSTEXPR Cartesian_base_d(){} + CGAL_CONSTEXPR Cartesian_base_d(int d):Dimension_base(d){} +}; + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_CARTESIAN_BASE_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h new file mode 100644 index 00000000000..21883e6c454 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -0,0 +1,92 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_CHANGE_FT_H +#define CGAL_KERNEL_D_CARTESIAN_CHANGE_FT_H + +#include +#include +#include +#include + +namespace CGAL { + +template < typename Base_, typename FT_> +struct Cartesian_change_FT_base : public + Base_ +{ + CGAL_CONSTEXPR Cartesian_change_FT_base(){} + CGAL_CONSTEXPR Cartesian_change_FT_base(int d):Base_(d){} + + typedef Base_ Kernel_base; + typedef FT_ RT; + typedef FT_ FT; + typedef CGAL::LA_eigen LA; + + typedef typename Same_uncertainty_nt::type + Boolean; + typedef typename Same_uncertainty_nt::type + Sign; + typedef typename Same_uncertainty_nt::type + Comparison_result; + typedef typename Same_uncertainty_nt::type + Orientation; + typedef typename Same_uncertainty_nt::type + Oriented_side; + typedef typename Same_uncertainty_nt::type + Bounded_side; + typedef typename Same_uncertainty_nt::type + Angle; + + typedef NT_converter FT_converter; + typedef transforming_iterator Cartesian_const_iterator; + + //FIXME: what if the functor's constructor takes a kernel as argument? + struct Construct_cartesian_const_iterator { + typedef typename Kernel_base::template Construct::type Functor_base; + Functor_base f; + typedef Cartesian_const_iterator result_type; + template + result_type begin(T const& v)const{ + return make_transforming_iterator(f.begin(v),FT_converter()); + } + template + result_type end(T const& v)const{ + return make_transforming_iterator(f.end(v),FT_converter()); + } + }; + + struct Compute_cartesian_coordinate { + typedef typename Kernel_base::template Compute::type Functor_base; + Functor_base f; + typedef FT result_type; + template + result_type operator()(Obj_ const& v,int i)const{ + return FT_converter()(f(v,i)); + } + }; + + template struct Compute { typedef Null_functor type; }; + template struct Compute { + typedef Compute_cartesian_coordinate type; + }; + template struct Predicate { typedef Null_functor type; }; + template struct Construct : + Kernel_base::template Construct { }; + template struct Construct { + typedef Construct_cartesian_const_iterator type; + }; +}; + +template < typename Base_, typename FT_> +struct Cartesian_change_FT : public +Cartesian_complete_predicates< +Cartesian_complete_computes< + Cartesian_change_FT_base +, true, Cartesian_change_FT > +, true, Cartesian_change_FT > +{ + CGAL_CONSTEXPR Cartesian_change_FT(){} + CGAL_CONSTEXPR Cartesian_change_FT(int d):Cartesian_change_FT_base(d){} +}; + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_CARTESIAN_CHANGE_FT_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h new file mode 100644 index 00000000000..683931c6174 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -0,0 +1,118 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_COMPLETE_H +#define CGAL_KERNEL_D_CARTESIAN_COMPLETE_H + +#include +#include +#include +#include +#include + + +namespace CGAL { +namespace internal { +BOOST_MPL_HAS_XXX_TRAIT_DEF(Segment) +BOOST_MPL_HAS_XXX_TRAIT_DEF(Ray) +BOOST_MPL_HAS_XXX_TRAIT_DEF(Direction) +BOOST_MPL_HAS_XXX_TRAIT_DEF(Line) +} + +template struct Cartesian_complete_types +: public R_ +{ + typedef R_ Kernel_base; +#define CGAL_Kernel_obj2(X) typedef typename boost::mpl::if_c::value,X##Cd,R_>::type::X X; +#include +}; + + +template struct Cartesian_complete_constructors +: public R_ +{ + typedef R_ Kernel_base; + template struct Construct { + typedef typename Kernel_base::template Construct::type Base_functor; + typedef typename boost::mpl::if_, + typename Cartesian_complete_constructors::template Construct::type, + Base_functor>::type type; + }; + +}; + +template struct Cartesian_complete_constructors +: public R_ +{ + typedef R_ Kernel_base; + template struct Construct + : Kernel_base::template Construct + { }; +#define CGAL_Kernel_cons2(F,f) \ + template struct Construct { \ + typedef CartesianDKernelFunctors::F type; \ + type f() const { return type(); } \ + }; +#include + +}; + + +template struct Cartesian_complete_predicates +: public R_ +{ + typedef R_ Kernel_base; + template struct Predicate { + typedef typename Kernel_base::template Predicate::type Base_functor; + typedef typename boost::mpl::if_, + typename Cartesian_complete_predicates::template Predicate::type, + Base_functor>::type type; + }; + +}; + +template struct Cartesian_complete_predicates +: public R_ +{ + typedef R_ Kernel_base; + template struct Predicate + : Kernel_base::template Predicate + { }; +#define CGAL_Kernel_pred(F,f) \ + template struct Predicate { \ + typedef CartesianDKernelFunctors::F type; \ + type f() const { return type(); } \ + }; +#include + +}; + + +template struct Cartesian_complete_computes +: public R_ +{ + typedef R_ Kernel_base; + template struct Compute { + typedef typename Kernel_base::template Compute::type Base_functor; + typedef typename boost::mpl::if_, + typename Cartesian_complete_computes::template Compute::type, + Base_functor>::type type; + }; + +}; + +template struct Cartesian_complete_computes +: public R_ +{ + typedef R_ Kernel_base; + template struct Compute + : Kernel_base::template Compute + { }; +#define CGAL_Kernel_comp2(F,f) \ + template struct Compute { \ + typedef CartesianDKernelFunctors::F type; \ + type f() const { return type(); } \ + }; +#include + +}; +} + +#endif // CGAL_KERNEL_D_CARTESIAN_COMPLETE_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h new file mode 100644 index 00000000000..29c70024ce6 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -0,0 +1,77 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_FILTER_NT_H +#define CGAL_KERNEL_D_CARTESIAN_FILTER_NT_H + +#include +#include +#include + +namespace CGAL { + +template < typename Base_ > +struct Cartesian_filter_NT : public Base_ +{ + CGAL_CONSTEXPR Cartesian_filter_NT(){} + CGAL_CONSTEXPR Cartesian_filter_NT(int d):Base_(d){} + typedef Base_ Kernel_base; + typedef Cartesian_change_FT K1; + typedef typename internal::Exact_type_selector::Type Exact_nt; + typedef Cartesian_change_FT K2; + + template struct Predicate { + struct type { + //TODO: use compression (derive from a compressed_pair?) + typedef typename K1::template Predicate::type P1; P1 p1; + typedef typename K2::template Predicate::type P2; P2 p2; + typedef typename P2::result_type result_type; + + //FIXME: if predicate's constructor takes a kernel as argument, how do we translate that? +#ifdef CGAL_CXX0X + template type(U&&...u):p1(std::forward(u)...),p2(std::forward(u)...){} +#else + //FIXME: usual boost preprocessor magic +#endif + +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + { + Protect_FPU_rounding p; + try { + typename P1::result_type res=p1(u...); // don't forward as u may be reused + if(is_certain(res)) return get_certain(res); + } catch (Uncertain_conversion_exception) {} + } + return p2(std::forward(u)...); + } +#else + //FIXME: usual boost preprocessor magic + result_type operator()()const{ // does it make sense to have 0 argument? + { + Protect_FPU_rounding p; + try { + typename P1::result_type res=p1(); + if(is_certain(res)) return get_certain(res); + } catch (Uncertain_conversion_exception) {} + } + return p2(); + } +#define CODE(Z,N,_) template result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t))const{ \ + { \ + Protect_FPU_rounding p; \ + try { \ + typename P1::result_type res=p1(BOOST_PP_ENUM_PARAMS(N,t)); \ + if(is_certain(res)) return get_certain(res); \ + } catch (Uncertain_conversion_exception) {} \ + } \ + return p2(BOOST_PP_ENUM_PARAMS(N,t)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE + +#endif + }; + }; +}; + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_CARTESIAN_FILTER_NT_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h new file mode 100644 index 00000000000..9788ee1867e --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h @@ -0,0 +1,23 @@ +#ifndef bd_h +#define db_h +#include +#include +#include +namespace CGAL { +template struct Dimension_base { + //TODO: add some assertions + Dimension_base(int dim=-1):dim_(dim){} + int dimension()const{return dim_;} + void set_dimension(int dim){dim_=dim;} + private: + int dim_; +}; +template struct Dimension_base > { + Dimension_base(){} + Dimension_base(int dim){CGAL_assertion(dim_==dim);} + int dimension()const{return dim_;} + void set_dimension(int dim){CGAL_assertion(dim_==dim);} +}; +} +#endif + diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h new file mode 100644 index 00000000000..875fe3f6c51 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -0,0 +1,45 @@ +#ifndef CGAL_KERNELD_SEGMENTD_H +#define CGAL_KERNELD_SEGMENTD_H +#include +#define Segmentd SegmentCd +namespace CGAL { +template class Segmentd { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef typename R_::Vector Vector_; + typedef typename R_::Construct_vector Cv_; +// typedef typename R_::Compute_squared_distance Csd_; + typedef std::pair Data_; + Data_ data; + public: + typedef Segmentd Segment; +#ifdef CGAL_CXX0X + template + Segmentd(U&&...u):data(std::forward(u)...){} +#else + Segmentd(){} + Segmentd(Point_ const&a, Point_ const&b): data(a,b) {} +#endif + Point_ source()const{return data.first;} + Point_ target()const{return data.second;} + Point_ operator[](int i)const{ + if((i%2)==0) + return data.first; + else + return data.second; + } + Segmentd opposite()const{ + return Segmentd(data.second,data.first); + } + Vector_ vector()const{ + return Cv_()(data.first,data.second); + } +// FT_ squared_length()const{ +// return Csd_()(data.first,data.second); +// } +}; + +} // namespace CGAL + +#undef Segmentd +#endif // CGAL_KERNELD_SEGMENTD_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h new file mode 100644 index 00000000000..80f158a999c --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -0,0 +1,183 @@ +#ifndef CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H +#define CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace CGAL { +namespace CartesianDKernelFunctors { + +template struct Orientation { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::Point Point; + typedef typename R::Orientation result_type; + typedef typename R::LA::template Matrix::type Matrix; + + template + result_type operator()(Iter f, Iter const& e, Vector_tag)const{ + typename R::template Compute::type c; + Matrix m(R().dimension(),R().dimension()); + for(int i=0;f!=e;++f,++i) { + for(int j=0;j + result_type operator()(Iter f, Iter const& e, Point_tag)const{ + typename R::template Compute::type c; + Matrix m(R().dimension(),R().dimension()); + Point const& p0=*f++; + for(int i=0;f!=e;++f,++i) { + for(int j=0;j + result_type operator()(Iter const&f, Iter const& e)const{ + typename std::iterator_traits::difference_type d=std::distance(f,e); + int dim=R().dimension(); + if(d==dim) return operator()(f,e,Vector_tag()); + CGAL_assertion(d==dim+1); + return operator()(f,e,Point_tag()); + } + + //TODO: version that takes objects directly instead of iterators +}; + + +template struct Construct_opposite_vector { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::template Construct::type CV; + typedef typename R::template Construct::type CI; + typedef Vector result_type; + typedef Vector argument_type; + result_type operator()(Vector const&v)const{ + CI ci; + return CV()(make_transforming_iterator(ci.begin(v),std::negate()),make_transforming_iterator(ci.end(v),std::negate())); + } +}; + +template struct Construct_sum_of_vectors { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::template Construct::type CV; + typedef typename R::template Construct::type CI; + typedef Vector result_type; + typedef Vector first_argument_type; + typedef Vector second_argument_type; + result_type operator()(Vector const&a, Vector const&b)const{ + CI ci; + return CV()(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::plus()),make_transforming_pair_iterator(ci.end(a),ci.end(b),std::plus())); + } +}; + +template struct Construct_difference_of_vectors { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::template Construct::type CV; + typedef typename R::template Construct::type CI; + typedef Vector result_type; + typedef Vector first_argument_type; + typedef Vector second_argument_type; + result_type operator()(Vector const&a, Vector const&b)const{ + CI ci; + return CV()(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::minus()),make_transforming_pair_iterator(ci.end(a),ci.end(b),std::minus())); + } +}; + +template struct Construct_midpoint { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Point Point; + typedef typename R::template Construct::type CP; + typedef typename R::template Construct::type CI; + typedef Point result_type; + typedef Point first_argument_type; + typedef Point second_argument_type; + struct Average : std::binary_function { + FT operator()(FT const&a, FT const&b)const{ + return (a+b)/2; + } + }; + result_type operator()(Point const&a, Point const&b)const{ + CI ci; + //Divide half(2); + //return CP()(make_transforming_iterator(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::plus()),half),make_transforming_iterator(make_transforming_pair_iterator(ci.end(a),ci.end(b),std::plus()),half)); + return CP()(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),Average()),make_transforming_pair_iterator(ci.end(a),ci.end(b),Average())); + } +}; + +template struct Compute_squared_length { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::template Construct::type CI; + typedef FT result_type; + typedef Vector argument_type; + result_type operator()(Vector const&a)const{ + CI ci; + typename Algebraic_structure_traits::Square f; + // TODO: avoid this FT(0)+... + return std::accumulate(make_transforming_iterator(ci.begin(a),f),make_transforming_iterator(ci.end(a),f),FT(0)); + } +}; + +template struct Compute_squared_distance { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Point Point; + typedef typename R::template Construct::type CI; + typedef FT result_type; + typedef Point first_argument_type; + typedef Point second_argument_type; + struct Sq_diff : std::binary_function { + FT operator()(FT const&a, FT const&b)const{ + return CGAL::square(a-b); + } + }; + result_type operator()(Point const&a, Point const&b)const{ + CI ci; + Sq_diff f; + // TODO: avoid this FT(0)+... + return std::accumulate(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),f),make_transforming_pair_iterator(ci.end(a),ci.end(b),f),FT(0)); + } +}; + +template struct Less_coordinate { + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Comparison_result result_type; + typedef typename R::template Compute::type Cc; + typedef typename CGAL::Is_exact::type Is_exact; + + template + result_type operator()(V const&a, V const&b, I i)const{ + Cc c; + return c(a,i) +#include +#include +#include +#include +#include + +namespace CGAL { + +template struct LA_eigen { + typedef NT_ NT; + // Dim_ real dimension + // Max_dim_ upper bound on the dimension + template struct Vector { + typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> type; + typedef Construct_eigen Constructor; + //typedef NT const* const_iterator; + //FIXME: use Matrix_base instead in the iterator? + typedef Iterator_from_indices const_iterator; + + templatestatic const_iterator vector_begin(Vec_ const&a){ + return const_iterator(a,0); + } + + templatestatic const_iterator vector_end(Vec_ const&a){ + return const_iterator(a,a.size()); + } + + }; + template struct Matrix { + //TODO: don't pass on the values of Max_* for an expensive NT + typedef Eigen::Matrix::value,Eigen_dimension::value,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,Eigen_dimension::value> type; + // typedef ... Constructor + // typedef ... Accessor + }; + private: + template class Canonicalize_vector { + typedef typename Dimension_eigen::type S1; + typedef typename Dimension_eigen::type S2; + public: + typedef typename Vector::type type; + }; + public: + + templatestatic NT dot_product(Vec_ const&a,Vec_ const&b){ + return a.dot(b); + } + + template static NT determinant(Mat_ const&m,bool=false){ + return m.determinant(); + } + + template static typename + Same_uncertainty_nt::type + sign_of_determinant(Mat_ const&m,bool=false) + { + return CGAL::sign(m.determinant()); + } + + template static typename Canonicalize_vector::type homogeneous_add(Vec1 const&a,Vec2 const&b){ + //TODO: use compile-time size when available + int d=a.size(); + typename Canonicalize_vector::type v(d); + v << b[d-1]*a.topRows(d-1)+a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; + return v; + } + + template static typename Canonicalize_vector::type homogeneous_sub(Vec1 const&a,Vec2 const&b){ + int d=a.size(); + typename Canonicalize_vector::type v(d); + v << b[d-1]*a.topRows(d-1)-a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; + return v; + } + + template static std::pair homogeneous_dot_product(Vec1 const&a,Vec2 const&b){ + int d=a.size(); + return make_pair(a.topRows(d-1).dot(b.topRows(d-1)), a[d-1]*b[d-1]); + } + +}; +} +#endif diff --git a/NewKernel_d/include/CGAL/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/LA_eigen/constructors.h new file mode 100644 index 00000000000..d30a3637ddf --- /dev/null +++ b/NewKernel_d/include/CGAL/LA_eigen/constructors.h @@ -0,0 +1,110 @@ +#ifndef ecs_h +#define ecs_h +#include +#include +#include +#include + +namespace CGAL { +template struct Construct_eigen { + typedef Vector_ result_type; + typedef typename Vector_::Scalar NT; + + struct Dimension { + result_type operator()(int d) const { + return result_type(d); + } + }; + + struct Iterator { + template + result_type operator()(int d,Iter const& f,Iter const& e) const { + CGAL_assertion(d==std::distance(f,e)); + CGAL_assertion(d<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); + result_type a(d); + // TODO: check the right way to do this + std::copy(f,e,&a[0]); + return a; + } + }; + +#if 0 + struct Iterator_add_one { + template + result_type operator()(int d,Iter const& f,Iter const& e) const { + CGAL_assertion(d==std::distance(f,e)+1); + CGAL_assertion(d<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); + result_type a; + std::copy(f,e,&a[0]); + a[d-1]=1; + return a; + } + }; +#endif + + struct Iterator_and_last { + template + result_type operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + CGAL_assertion(d==std::distance(f,e)+1); + CGAL_assertion(d<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); + result_type a; + std::copy(f,e,&a[0]); + a[d-1]=CGAL_FORWARD(T,t); + return a; + } + }; + +#ifdef CGAL_CXX0X + struct Initializer_list { + template + result_type operator()(std::initializer_list l) const { + return Iterator()(l.size(),l.begin(),l.end()); + } + }; +#endif + + struct Values { +#ifdef CGAL_CXX0X + template + result_type operator()(U&&...u) const { + return Initializer_list()({forward_safe(u)...}); + } +#else + +#define CODE(Z,N,_) result_type operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ + CGAL_assertion(N<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); \ + result_type a(N); \ + a << BOOST_PP_ENUM_PARAMS(N,t); \ + return a; \ +} +BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) +#undef CODE + +#endif + }; + + struct Values_divide { +#ifdef CGAL_CXX0X + template + result_type operator()(H const&h,U&&...u) const { + return Initializer_list()({Rational_traits().make_rational(std::forward(u),h)...}); + } +#else + +#define VAR(Z,N,_) ( t##N / h ) +#define CODE(Z,N,_) template result_type \ + operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ + CGAL_assertion(N<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); \ + result_type a(N); \ + a << BOOST_PP_ENUM(N,VAR,); \ + return a; \ +} +BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) +#undef CODE +#undef VAR + +#endif + }; +}; +} +#endif diff --git a/NewKernel_d/include/CGAL/argument_swaps.h b/NewKernel_d/include/CGAL/argument_swaps.h new file mode 100644 index 00000000000..66192f0ec9f --- /dev/null +++ b/NewKernel_d/include/CGAL/argument_swaps.h @@ -0,0 +1,69 @@ +#ifndef CGAL_ARGUMENT_SWAPS_H +#define CGAL_ARGUMENT_SWAPS_H + +#include +#include + +#ifndef CGAL_CXX0X +#include +#include +#endif + +namespace CGAL { + +#ifdef CGAL_CXX0X + +namespace internal { + +template struct Apply_to_last_then_rest_; + +template +struct Apply_to_last_then_rest_ { + typedef typename Apply_to_last_then_rest_::result_type result_type; + inline result_type operator()(F&&f,T&&t,U&&...u)const{ + return Apply_to_last_then_rest_()( + std::forward(f), + std::forward(u)..., + std::forward(t)); + } +}; + +template +struct Apply_to_last_then_rest_<0,F,T,U...> { + typedef decltype(std::declval()(std::declval(), std::declval()...)) result_type; + inline result_type operator()(F&&f,T&&t,U&&...u)const{ + return std::forward(f)(std::forward(t), std::forward(u)...); + } +}; + +} // namespace internal + + +struct Apply_to_last_then_rest { + template inline + typename internal::Apply_to_last_then_rest_::result_type + operator()(F&&f,T&&t,U&&...u)const{ + return internal::Apply_to_last_then_rest_()( + std::forward(f), + std::forward(t), + std::forward(u)...); + } +}; + +#else // CGAL_CXX0X + +struct Apply_to_last_then_rest { +#define CODE(Z,N,_) template \ + typename boost::result_of::type \ + operator()(F const&f, BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t), T const&t) const { \ + return f(t,BOOST_PP_ENUM_PARAMS(N,t)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +}; + +#endif // CGAL_CXX0X + +} // namespace CGAL + +#endif // CGAL_ARGUMENT_SWAPS_H diff --git a/NewKernel_d/include/CGAL/exactness.h b/NewKernel_d/include/CGAL/exactness.h new file mode 100644 index 00000000000..3dddca8123b --- /dev/null +++ b/NewKernel_d/include/CGAL/exactness.h @@ -0,0 +1,19 @@ +#ifndef CGAL_EXACTNESS_H +#define CGAL_EXACTNESS_H +#include +#include +namespace CGAL { +namespace internal { +BOOST_MPL_HAS_XXX_TRAIT_DEF(Is_exact) +} +template::value> struct Is_exact { + enum { value=false }; + typedef Tag_false type; +}; +template struct Is_exact { + typedef typename T::Is_exact type; + enum { value=type::value }; +}; + +} +#endif // CGAL_EXACTNESS_H diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h new file mode 100644 index 00000000000..c9ca87e58a9 --- /dev/null +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -0,0 +1,37 @@ +#ifndef CGAL_FUNCTOR_TAGS_H +#define CGAL_FUNCTOR_TAGS_H +namespace CGAL { + class Null_type {~Null_type();}; // no such object should be created + + struct Vector_tag {}; + struct Point_tag {}; + struct Segment_tag {}; + struct Line_tag {}; + struct Direction_tag {}; + struct Ray_tag {}; + struct Bbox_tag {}; + + struct Construct_vector_tag {}; + struct Construct_point_tag {}; + struct Construct_segment_tag {}; + struct Construct_line_tag {}; + struct Construct_direction_tag {}; + struct Construct_ray_tag {}; + struct Construct_cartesian_const_iterator_tag {}; + struct Construct_midpoint_tag {}; + struct Construct_sum_of_vectors_tag {}; + struct Construct_difference_of_vectors_tag {}; + struct Construct_opposite_vector_tag {}; + + struct Compute_cartesian_coordinate_tag {}; + struct Compute_homogeneous_coordinate_tag {}; + struct Compute_squared_distance_tag {}; + struct Compute_squared_length_tag {}; + + struct Predicate_less_cartesian_coordinate_tag {}; + //FIXME: choose a convention + struct Predicate_orientation_tag {}; + struct Orientation_tag {}; + struct Predicate_in_sphere_tag {}; +} +#endif // CGAL_FUNCTOR_TAGS_H diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h new file mode 100644 index 00000000000..bdea272a71b --- /dev/null +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -0,0 +1,41 @@ +#ifndef CGAL_ITERATOR_FROM_INDICES_H +#define CGAL_ITERATOR_FROM_INDICES_H +#include +namespace CGAL { +//TODO: default type for Value_: typename same_cv::type::value_type>::type +template ()[0]) +#else + Value_& +#endif + > +class Iterator_from_indices +: public boost::iterator_facade, + Value_, std::bidirectional_iterator_tag, Ref_> +{ + friend class boost::iterator_core_access; + //FIXME: use int to save space + //FIXME: use a signed type + typedef std::size_t index_t; + Container_& cont; + index_t index; + void increment(){ ++index; } + void decrement(){ --index; } + void advance(std::ptrdiff_t n){ index+=n; } + ptrdiff_t distance_to(Iterator_from_indices const& other)const{ + return static_cast(other.index) + -static_cast(index); + } + bool equal(Iterator_from_indices const& other)const{ + return index==other.index; + } + Ref_ dereference()const{ + return cont[index]; + } + public: + Iterator_from_indices(Container_& cont_,std::size_t n) + : cont(cont_), index(n) {} +}; +} +#endif // CGAL_ITERATOR_FROM_INDICES_H diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h new file mode 100644 index 00000000000..b12db5ff1ae --- /dev/null +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -0,0 +1,129 @@ +#ifndef marcutils +#define marcutils + +#ifdef CGAL_CXX0X +#include +#include +#define CGAL_FORWARDABLE(T) T&& +#define CGAL_FORWARD(T,t) std::forward(t) +#define CGAL_MOVE(t) std::move(t) +#define CGAL_CONSTEXPR constexpr +#else +#define CGAL_FORWARDABLE(T) T const& +#define CGAL_FORWARD(T,t) t +#define CGAL_MOVE(t) t +#define CGAL_CONSTEXPR +#endif +#include +#include +#include + + +namespace CGAL { + // tell a function f(a,b,c) that its real argument is a(b,c) + struct Eval_functor {}; + + // forget the first argument. Useful to make something dependant + // (and thus usable in SFINAE), although that's not a great design. + template struct Second_arg { + typedef B type; + }; + + // like std::forward, except for basic types where it does a cast, to + // avoid issues with narrowing conversions +#ifdef CGAL_CXX0X + template + typename std::conditional::value&&std::is_arithmetic::type>::value,T,U&&>::type + forward_safe(V&& u) { return std::forward(u); } +#else + template U const& forward_safe(U const& u) { + return u; + } +#endif + +#ifdef CGAL_CXX0X + template struct Constructible_from_each; + template struct Constructible_from_each{ + enum { value=std::is_convertible::value&&Constructible_from_each::value }; + }; + template struct Constructible_from_each{ + enum { value=true }; + }; +#else +// currently only used in C++0X code +#endif + + template struct Scale { + T const& scale; + Scale(T const& t):scale(t){} + template +#ifdef CGAL_CXX0X + auto operator()(FT&& x)const->decltype(scale*std::forward(x)) +#else + FT operator()(FT const& x)const +#endif + { + return scale*CGAL_FORWARD(FT,x); + } + }; + template struct Divide { +#if !defined(CGAL_CXX0X) || !defined(BOOST_RESULT_OF_USE_DECLTYPE) + // requires boost > 1.44 + // shouldn't be needed with C++0X + //template struct result; + //template struct result { + // typedef FT type; + //}; + typedef NT result_type; +#endif + T const& scale; + Divide(T const& t):scale(t){} + template +#ifdef CGAL_CXX0X + //FIXME: gcc complains for Gmpq + //auto operator()(FT&& x)const->decltype(Rational_traits().make_rational(std::forward(x),scale)) + NT operator()(FT&& x)const +#else + NT operator()(FT const& x)const +#endif + { + return Rational_traits(). + make_rational(CGAL_FORWARD(FT,x),scale); + } + }; + + template struct has_cheap_constructor : boost::is_arithmetic{}; + template struct has_cheap_constructor > { + enum { value=true }; + }; + + // like std::multiplies but allows mixing types + // in C++0x in doesn't need to be a template + template < class Ret > + struct multiplies { + template +#ifdef CGAL_CXX0X + auto operator()(A&&a,B&&b)const->decltype(std::forward(a)*std::forward(b)) +#else + Ret operator()(A const& a, B const& b)const +#endif + { + return CGAL_FORWARD(A,a)*CGAL_FORWARD(B,b); + } + }; + template < class Ret > + struct division { + template +#ifdef CGAL_CXX0X + auto operator()(A&&a,B&&b)const->decltype(std::forward(a)/std::forward(b)) +#else + Ret operator()(A const& a, B const& b)const +#endif + { + return CGAL_FORWARD(A,a)/CGAL_FORWARD(B,b); + } + }; + +} + +#endif diff --git a/NewKernel_d/include/CGAL/myeigen.h b/NewKernel_d/include/CGAL/myeigen.h new file mode 100644 index 00000000000..c8f2af8fa63 --- /dev/null +++ b/NewKernel_d/include/CGAL/myeigen.h @@ -0,0 +1,43 @@ +#ifndef myeigen_h +#define myeigen_h +#include +#include +#include + +namespace Eigen { + + template<> struct NumTraits + { + typedef CGAL::Gmpq Real; + typedef CGAL::Gmpq NonInteger; + typedef CGAL::Gmpq Nested; + + enum { + IsComplex = 0, + IsInteger = 0, + IsSigned, + ReadCost = 10, + AddCost = 100, + MulCost = 1000 + }; + }; + + template<> struct NumTraits + { + typedef CGAL::Interval_nt_advanced Real; + typedef CGAL::Interval_nt_advanced NonInteger; + typedef CGAL::Interval_nt_advanced Nested; + + enum { + IsComplex = 0, + IsInteger = 0, + IsSigned, + ReadCost = 2, + AddCost = 2, + MulCost = 10 + }; + }; + +} + +#endif diff --git a/NewKernel_d/include/CGAL/static_int.h b/NewKernel_d/include/CGAL/static_int.h new file mode 100644 index 00000000000..16a8f174c9d --- /dev/null +++ b/NewKernel_d/include/CGAL/static_int.h @@ -0,0 +1,42 @@ +#ifndef CGAL_STATIC_INT_H +#define CGAL_STATIC_INT_H +#include + +namespace CGAL { +template struct static_zero { + operator NT() const { return constant(); } +}; +template struct static_one { + operator NT() const { return constant(); } +}; + +template static_zero operator-(static_zero) { return static_zero(); } + +template NT operator+(NT const& x, static_zero) { return x; } +template NT operator+(static_zero, NT const& x) { return x; } +template static_zero operator+(static_zero, static_zero) { return static_zero(); } +template static_one operator+(static_zero, static_one) { return static_one(); } +template static_one operator+(static_one, static_zero) { return static_one(); } + +template NT operator-(NT const& x, static_zero) { return x; } +template NT operator-(static_zero, NT const& x) { return -x; } +template static_zero operator-(static_zero, static_zero) { return static_zero(); } +template static_zero operator-(static_one, static_one) { return static_zero(); } +template static_one operator-(static_one, static_zero) { return static_one(); } + +template NT operator*(NT const& x, static_one) { return x; } +template NT operator*(static_one, NT const& x) { return x; } +template static_zero operator*(NT const&, static_zero) { return static_zero(); } +template static_zero operator*(static_zero, NT const&) { return static_zero(); } +template static_zero operator*(static_zero, static_zero) { return static_zero(); } +template static_one operator*(static_one, static_one) { return static_one(); } +template static_zero operator*(static_zero, static_one) { return static_zero(); } +template static_zero operator*(static_one, static_zero) { return static_zero(); } + +template NT operator/(NT const& x, static_one) { return x; } +template static_zero operator/(static_zero, NT const&) { return static_zero(); } +template static_zero operator/(static_zero, static_one) { return static_zero(); } +template static_one operator/(static_one, static_one) { return static_one(); } + +} +#endif // CGAL_STATIC_INT_H diff --git a/NewKernel_d/include/CGAL/transforming_iterator.h b/NewKernel_d/include/CGAL/transforming_iterator.h new file mode 100644 index 00000000000..2e5473b0476 --- /dev/null +++ b/NewKernel_d/include/CGAL/transforming_iterator.h @@ -0,0 +1,92 @@ +#ifndef CGAL_TRANSFORMING_ITERATOR_H +#define CGAL_TRANSFORMING_ITERATOR_H +#include +#include +#include +#include +#include + +// Inspired by the boost version, but more compact and +// without any iterator_category games. + +namespace CGAL { +namespace internal { + +// non-empty case +template::value> struct Functor_as_base { + Functor_as_base(){} + Functor_as_base(T const& t):f(t){} + //template Functor_as_base(Functor_as_base const&g):f(g.functor()){} + T const& functor()const{return f;} + T & functor() {return f;} + private: + T f; +}; + +// empty case +template struct Functor_as_base : public T { + Functor_as_base(){} + Functor_as_base(T const& t):T(t){} + //template Functor_as_base(Functor_as_base const&g):T(g.functor()){} + T const& functor()const{return *this;} + T & functor() {return *this;} +}; + +template +class transforming_iterator_helper +{ + typedef typename Default::Get()(std::declval::reference>())) +#else + typename boost::result_of::value_type)>::type + // should be reference instead of value_type +#endif + >::type reference; + + typedef typename Default::Get::type>::type>::type value_type; + + public: + typedef boost::iterator_adaptor< + Derived, + Iter, + value_type, + typename std::iterator_traits::iterator_category, + reference + > type; +}; +} + +template +class transforming_iterator +: public internal::transforming_iterator_helper,F,Iter,Ref,Val>::type, +private internal::Functor_as_base +{ + friend class boost::iterator_core_access; + typedef typename internal::transforming_iterator_helper::type Base; + typedef internal::Functor_as_base Functor_base; + typename Base::reference dereference()const{ + return functor()(*this->base_reference()); + } + public: + using Functor_base::functor; + transforming_iterator(){} + explicit transforming_iterator(Iter const&i,F const& f=F()) + :Base(i),Functor_base(f){} + template + transforming_iterator( + transforming_iterator const&i, + typename boost::enable_if_convertible::type* = 0, + typename boost::enable_if_convertible::type* = 0) + : Base(i.base()),Functor_base(i.functor()) {} + +}; + +template +transforming_iterator make_transforming_iterator(Iter const&i, F const&f=F()) { + return transforming_iterator(i,f); +} + +} + +#endif // CGAL_TRANSFORMING_ITERATOR_H diff --git a/NewKernel_d/include/CGAL/transforming_pair_iterator.h b/NewKernel_d/include/CGAL/transforming_pair_iterator.h new file mode 100644 index 00000000000..45908b10640 --- /dev/null +++ b/NewKernel_d/include/CGAL/transforming_pair_iterator.h @@ -0,0 +1,107 @@ +#ifndef CGAL_TRANSFORMING_PAIR_ITERATOR_H +#define CGAL_TRANSFORMING_PAIR_ITERATOR_H +// Should be a combination of transform_iterator and zip_iterator, +// but boost's iterator_category games are a pain. + +#include +#include +#include + + + +namespace CGAL { +namespace internal { +template ::value> +struct Min_category { + BOOST_STATIC_ASSERT((boost::is_convertible::value)); + typedef Cat1 type; +}; + +template +struct Min_category { + typedef Cat2 type; +}; + + +template +class transforming_pair_iterator_helper +{ + typedef typename Min_category< + typename std::iterator_traits::iterator_category, + typename std::iterator_traits::iterator_category> + ::type iterator_category; + + typedef typename Default::Get()(std::declval::reference>(),std::declval::reference>())) +#else + typename boost::result_of::value_type,typename std::iterator_traits::value_type)>::type + // should be reference instead of value_type +#endif + >::type reference; + + typedef typename Default::Get::type>::type>::type value_type; + + public: + typedef boost::iterator_facade< + Derived, + value_type, + iterator_category, + reference + // expect ptrdiff_t is good enough for difference + > type; +}; +} + +template +class transforming_pair_iterator +: public internal::transforming_pair_iterator_helper,F,It1,It2,Ref,Val>::type, +private internal::Functor_as_base +{ + It1 iter1; It2 iter2; + friend class boost::iterator_core_access; + typedef typename internal::transforming_pair_iterator_helper::type Base; + typedef internal::Functor_as_base Functor_base; + typename Base::reference dereference()const{ + return functor()(*iter1,*iter2); + } + bool equal(transforming_pair_iterator const&i)const{ + bool b=(iter1==i.iter1); + CGAL_assertion(b==(iter2==i.iter2)); + //FIXME: or do we want only one driving iterator + return b; + } + void increment(){ ++iter1; ++iter2; } + void decrement(){ --iter1; --iter2; } + void advance(std::ptrdiff_t n){ + std::advance(iter1,n); + std::advance(iter2,n); + } + std::ptrdiff_t distance_to(transforming_pair_iterator const&i)const{ + std::ptrdiff_t dist=std::distance(iter1,i.iter1); + CGAL_assertion(dist==std::distance(iter2,i.iter2)); + return dist; + } + public: + using Functor_base::functor; + transforming_pair_iterator(){} + explicit transforming_pair_iterator(It1 const&i1,It2 const&i2,F const& f=F()) + :Functor_base(f),iter1(i1),iter2(i2){} + template + transforming_pair_iterator( + transforming_pair_iterator const&i, + typename boost::enable_if_convertible::type* = 0, + typename boost::enable_if_convertible::type* = 0, + typename boost::enable_if_convertible::type* = 0) + : Functor_base(i.functor()),iter1(i.iter1),iter2(i.iter2) {} + +}; + +template +transforming_pair_iterator make_transforming_pair_iterator(It1 const&i1, It2 const&i2, F const&f=F()) { + return transforming_pair_iterator(i1,i2,f); +} + +} + +#endif // CGAL_TRANSFORMING_PAIR_ITERATOR_H From 6eeb2259a439cda87fdceb44ade22355a61f1043 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 10 May 2011 15:47:00 +0000 Subject: [PATCH 005/210] Why shouldn't I use empty commit messages? --- .../CGAL/Kernel_d/Cartesian_converter.h | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h new file mode 100644 index 00000000000..a9c2948f240 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -0,0 +1,68 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_CONVERTER_H +#define CGAL_KERNEL_D_CARTESIAN_CONVERTER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace CGAL { +template class CartesianD_converter { + typedef typename K1::FT FT1; + typedef typename K2::FT FT2; + typedef NT_converter NTc; + NTc c; + // TODO: store a K1 and a K2 and have a suitable constructor + public: + Origin operator()(Origin const&o)const{return o;} + Null_vector operator()(Null_vector const&v)const{return v;} + FT2 operator()(FT1 const&x)const{return c(x);} + //RT2 operator()(typename First_if_different::Type const&x)const{return cr(x);} + + template + transforming_iterator,It>::type> + operator()(It const& it)const { + return make_transforming_iterator(it,c); + } + + typename K2::Point operator()(typename K1::Point const& p){ + typename K1::template Construct::type i; + return K2::template Construct::type()(operator()(i.begin(p)),operator()(i.end(p))); + } + + typename K2::Vector operator()(typename First_if_different::Type const& p){ + typename K1::template Construct::type i; + return K2::template Construct::type()(operator()(i.begin(p)),operator()(i.end(p))); + } + + typename K2::Object_2 + operator()(const typename K1::Object_2 &obj) const + { +#define CGAL_Kernel_obj(X) \ + if (const typename K1::X * ptr = object_cast(&obj)) \ + return make_object(operator()(*ptr)); + +#include + /* + if (const std::vector * ptr = object_cast >(&obj)) { + std::vector res ( + operator()(ptr->begin()), + operator()(ptr->end()) ); + return make_object(res); + } + */ + + CGAL_error_msg("Cartesiand_converter is unable to determine what is wrapped in the Object"); + return Object(); + } + + +}; + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_CARTESIAN_CONVERTER_H From b63f32ccdd753195e15f88ccc766e18203dbfdf0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 11 May 2011 10:10:48 +0000 Subject: [PATCH 006/210] Add possibility to filter on kernels instead of number-types. --- .../CGAL/Kernel_d/Cartesian_converter.h | 38 +++++++++++++++---- NewKernel_d/test/NewKernel_d/test.cpp | 8 +++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index a9c2948f240..26a1013005e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -12,35 +12,57 @@ namespace CGAL { template class CartesianD_converter { + typedef CartesianD_converter Self; typedef typename K1::FT FT1; typedef typename K2::FT FT2; typedef NT_converter NTc; NTc c; // TODO: store a K1 and a K2 and have a suitable constructor public: + // For boost::result_of, used in transforming_iterator + template struct result; + template struct result{ + //assert that T is an iterator, or better yet make sure + //we don't get here otherwise +#ifdef CGAL_CXX0X + static_assert(is_iterator::value,"OUIN!"); +#endif + typedef transforming_iterator type; + }; + template struct result{typedef int type;}; + template struct result{typedef Origin type;}; + template struct result{typedef Null_vector type;}; + template struct result{typedef Object type;}; + template struct result{typedef FT2 type;}; + template struct result{typedef typename K2::Point type;}; + template struct result::Type),i>{typedef typename K2::Vector type;}; + + int operator()(int i)const{return i;} Origin operator()(Origin const&o)const{return o;} Null_vector operator()(Null_vector const&v)const{return v;} FT2 operator()(FT1 const&x)const{return c(x);} //RT2 operator()(typename First_if_different::Type const&x)const{return cr(x);} template - transforming_iterator,It>::type> + transforming_iterator,It>::type> operator()(It const& it)const { - return make_transforming_iterator(it,c); + return make_transforming_iterator(it,*this); } - typename K2::Point operator()(typename K1::Point const& p){ + typename K2::Point operator()(typename K1::Point const& p)const{ typename K1::template Construct::type i; - return K2::template Construct::type()(operator()(i.begin(p)),operator()(i.end(p))); + typename K2::template Construct::type cp; + return cp(operator()(i.begin(p)),operator()(i.end(p))); } - typename K2::Vector operator()(typename First_if_different::Type const& p){ + typename K2::Vector operator()(typename First_if_different::Type const& p)const{ typename K1::template Construct::type i; - return K2::template Construct::type()(operator()(i.begin(p)),operator()(i.end(p))); + typename K2::template Construct::type cv; + return cv(operator()(i.begin(p)),operator()(i.end(p))); } - typename K2::Object_2 - operator()(const typename K1::Object_2 &obj) const + Object + operator()(const Object &obj) const { #define CGAL_Kernel_obj(X) \ if (const typename K1::X * ptr = object_cast(&obj)) \ diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index db0d696196d..763f75b5dbe 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -2,12 +2,18 @@ #include #include #include +#include #include #include #include typedef CGAL::Cartesian_base_d > K0; +#if 0 typedef CGAL::Cartesian_filter_NT K1; -//typedef CGAL::Cartesian_change_FT K1; +#elif 1 +typedef CGAL::Cartesian_base_d > KA; +typedef CGAL::Cartesian_base_d > KE; +typedef CGAL::Cartesian_filter_K K1; +#endif typedef K1::Point P; typedef K1::Vector V; typedef K1::Segment S; From a5cdca3cdfc1f9242834242b1934534916d22f5f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 11 May 2011 10:12:48 +0000 Subject: [PATCH 007/210] =?UTF-8?q?&=C3=A9"#{[|^@]}^$=C2=A3*=C2=B5=C3=B9%!?= =?UTF-8?q?=C2=A7(-=C3=A8=5F=C3=A7=C3=A0)=3D=C2=BF=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CGAL/Kernel_d/Cartesian_filter_K.h | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h new file mode 100644 index 00000000000..343c1eac928 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -0,0 +1,30 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_FILTER_K_H +#define CGAL_KERNEL_D_CARTESIAN_FILTER_K_H + +#include +#include +#include + +namespace CGAL { + +template < typename Base_, typename AK_, typename EK_ > +struct Cartesian_filter_K : public Base_ +{ + CGAL_CONSTEXPR Cartesian_filter_K(){} + CGAL_CONSTEXPR Cartesian_filter_K(int d):Base_(d){} + typedef Base_ Kernel_base; + typedef AK_ AK; + typedef EK_ EK; + typedef CartesianD_converter C2A; + typedef CartesianD_converter C2E; + + template struct Predicate { + typedef typename AK::template Predicate::type AP; + typedef typename EK::template Predicate::type EP; + typedef Filtered_predicate type; + }; +}; + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_CARTESIAN_FILTER_K_H From 217ed569f279e0e92503c9a7cbb5514793e8e172 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 11 May 2011 15:14:26 +0000 Subject: [PATCH 008/210] =?UTF-8?q?pou=C3=ABt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 78 +++++++++++++++++++ NewKernel_d/test/NewKernel_d/test.cpp | 17 ++-- 2 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h new file mode 100644 index 00000000000..fb6b2660ab3 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -0,0 +1,78 @@ +#ifndef CGAL_KERNEL_D_LAZY_CARTESIAN_H +#define CGAL_KERNEL_D_LAZY_CARTESIAN_H + +#include +#include +#include + +namespace CGAL { + +template +struct Lazy_cartesian +{ + //CGAL_CONSTEXPR Lazy_cartesian(){} + //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} + + typedef AK_ Approximate_kernel; + typedef EK_ Exact_kernel; + typedef E2A_ E2A; + typedef Approx_converter C2A; + typedef Exact_converter C2E; + typedef CGAL::Lazy_exact_nt FT; + typedef FT RT; + + typedef typename Exact_kernel::Rep_tag Rep_tag; + typedef typename Exact_kernel::Kernel_tag Kernel_tag; + + typedef typename Same_uncertainty_nt::type + Boolean; + typedef typename Same_uncertainty_nt::type + Sign; + typedef typename Same_uncertainty_nt::type + Comparison_result; + typedef typename Same_uncertainty_nt::type + Orientation; + typedef typename Same_uncertainty_nt::type + Oriented_side; + typedef typename Same_uncertainty_nt::type + Bounded_side; + typedef typename Same_uncertainty_nt::type + Angle; + +#define CGAL_Kernel_obj(X) \ + typedef Lazy X; + +#include + + template struct Predicate { + typedef typename Approximate_kernel::template Predicate::type FA; + typedef typename Exact_kernel::template Predicate::type FE; + typedef Filtered_predicate type; + }; + template struct Compute { + typedef typename Approximate_kernel::template Compute::type FA; + typedef typename Exact_kernel::template Compute::type FE; + typedef Lazy_construction_nt type; + }; + template struct Construct { + typedef typename Approximate_kernel::template Construct::type FA; + typedef typename Exact_kernel::template Construct::type FE; + typedef Lazy_construction type; + }; + + //TODO: + //typedef ????????? Cartesian_const_iterator; + //typedef ????????? Construct_cartesian_const_iterator +// +// template struct Compute { +// typedef Compute_cartesian_coordinate type; +// }; +// template struct Construct { +// typedef Construct_cartesian_const_iterator type; +// }; +}; + + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_LAZY_CARTESIAN_H diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 763f75b5dbe..35b05255fdd 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -3,27 +3,32 @@ #include #include #include +#include #include #include #include typedef CGAL::Cartesian_base_d > K0; -#if 0 -typedef CGAL::Cartesian_filter_NT K1; -#elif 1 typedef CGAL::Cartesian_base_d > KA; typedef CGAL::Cartesian_base_d > KE; +#if 0 +typedef K0 K1; +#elif 0 +typedef CGAL::Cartesian_filter_NT K1; +#elif 1 typedef CGAL::Cartesian_filter_K K1; +#elif 1 +struct K1: CGAL::Lazy_cartesian,K1>{}; #endif typedef K1::Point P; typedef K1::Vector V; typedef K1::Segment S; //typedef K1::Construct_point CP; typedef K1::Construct::type CP; -typedef K1::Construct_vector CV; -typedef K1::Construct_cartesian_const_iterator CCI; +typedef K1::Construct::type CV; +typedef K1::Construct::type CCI; typedef K1::Predicate::type PO; typedef K1::Cartesian_const_iterator CI; -typedef K1::Compute_cartesian_coordinate CC; +typedef K1::Compute::type CC; int main(){ CP cp; CCI ci; CC cc; PO po; From dc29aebfd22887c1f1aa43f83bc2bc81c3dd1c86 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 11 May 2011 20:15:08 +0000 Subject: [PATCH 009/210] ploum (but obscenities may come to fill in for empty commit messages) --- NewKernel_d/include/CGAL/Lazy.h | 1864 +++++++++++++++++++++++++ NewKernel_d/include/CGAL/marcutils.h | 5 + NewKernel_d/test/NewKernel_d/Makefile | 4 +- 3 files changed, 1871 insertions(+), 2 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Lazy.h diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h new file mode 100644 index 00000000000..fa73986e13c --- /dev/null +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -0,0 +1,1864 @@ +// Copyright (c) 2005,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// 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; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// 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) : Andreas Fabri, Sylvain Pion + +#ifndef CGAL_LAZY_H +#define CGAL_LAZY_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CGAL_HAS_THREADS +# include +#endif + +namespace CGAL { + +template class Lazy; + +template +class Lazy_exact_nt; + +template +inline +const AT& +approx(const Lazy& l) +{ + return l.approx(); +} + +// Where is this one (non-const) needed ? Is it ? +template +inline +AT& +approx(Lazy& l) +{ + return l.approx(); +} + + +template +inline +const ET& +exact(const Lazy& l) +{ + return l.exact(); +} + + +template +inline +unsigned +depth(const Lazy& l) +{ + return l.depth(); +} + + +#define CGAL_LAZY_FORWARD(T) \ + inline const T & approx(const T& d) { return d; } \ + inline const T & exact (const T& d) { return d; } \ + inline unsigned depth (const T& ) { return 0; } + + +CGAL_LAZY_FORWARD(double) +CGAL_LAZY_FORWARD(float) +CGAL_LAZY_FORWARD(int) +CGAL_LAZY_FORWARD(unsigned) +CGAL_LAZY_FORWARD(Return_base_tag) +CGAL_LAZY_FORWARD(Null_vector) +CGAL_LAZY_FORWARD(Origin) +CGAL_LAZY_FORWARD(Orientation) +CGAL_LAZY_FORWARD(Bbox_2) +CGAL_LAZY_FORWARD(Bbox_3) + + + +#ifdef CGAL_LAZY_KERNEL_DEBUG +template +void +print_at(std::ostream& os, const T& at) +{ + os << at; +} + +template +void +print_at(std::ostream& os, const std::vector& at) +{ + os << "std::vector"; +} + +template <> +void +print_at(std::ostream& os, const Object& o) +{ + os << "Object"; +} + +template +void +print_at(std::ostream& os, const std::pair & at) +{ + os << "[ " << at.first << " | " << at.second << " ]" << std::endl ; +} + + +template +inline +void +print_dag(const Lazy& l, std::ostream& os, int level = 0) +{ + l.print_dag(os, level); +} + +inline +void +print_dag(double d, std::ostream& os, int level) +{ + for(int i = 0; i < level; i++) + os << " "; + os << d << std::endl; +} + +inline +void +msg(std::ostream& os, int level, char* s) +{ + for(int i = 0; i < level; i++) + os << " "; + os << s << std::endl; +} + +inline +void +print_dag(const Null_vector& nv, std::ostream& os, int level) +{ + for(int i = 0; i < level; i++) + os << " "; + os << "Null_vector" << std::endl; +} + +inline +void +print_dag(const Origin& nv, std::ostream& os, int level) +{ + for(int i = 0; i < level; i++) + os << " "; + os << "Origin" << std::endl; +} +#endif + + +struct Depth_base { +#ifdef CGAL_PROFILE + unsigned depth_; + Depth_base() { set_depth(0); } + unsigned depth() const { return depth_; } + void set_depth(unsigned i) + { + depth_ = i; + CGAL_HISTOGRAM_PROFILER(std::string("[Lazy_kernel DAG depths]"), i); + //(unsigned) ::log2(double(i))); + } +#else + unsigned depth() const { return 0; } + void set_depth(unsigned) {} +#endif +}; + + +// Abstract base class for lazy numbers and lazy objects +template +class Lazy_rep : public Rep, public Depth_base +{ + Lazy_rep (const Lazy_rep&); // cannot be copied. + +public: + + typedef AT_ AT; + + mutable AT at; + mutable ET *et; + + Lazy_rep () + : at(), et(NULL) {} + + Lazy_rep (const AT& a) + : at(a), et(NULL) {} + + Lazy_rep (const AT& a, const ET& e) + : at(a), et(new ET(e)) {} + + const AT& approx() const + { + return at; + } + + AT& approx() + { + return at; + } + + const ET & exact() const + { + if (et==NULL) + update_exact(); + return *et; + } + + ET & exact() + { + if (et==NULL) + update_exact(); + return *et; + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void print_at_et(std::ostream& os, int level) const + { + for(int i = 0; i < level; i++){ + os << " "; + } + os << "Approximation: "; + print_at(os, at); + os << std::endl; + if(! is_lazy()){ + for(int i = 0; i < level; i++){ + os << " "; + } + os << "Exact: "; + print_at(os, *et); + os << std::endl; + } + } + + virtual void print_dag(std::ostream& os, int level) const {} +#endif + + bool is_lazy() const { return et == NULL; } + virtual void update_exact() const = 0; + virtual ~Lazy_rep() { delete et; } +}; + + +//____________________________________________________________ +// The rep for the leaf node +// FIXME TODO : Factorize all the Lazy_rep_[0-8] !!! + +template +class Lazy_rep_0 : public Lazy_rep +{ + + typedef Lazy_rep Base; +public: + + void + update_exact() const + { + this->et = new ET(); + } + + Lazy_rep_0() + : Lazy_rep() {} + + Lazy_rep_0(const AT& a, const ET& e) + : Lazy_rep(a, e) {} + + Lazy_rep_0(const AT& a, void*) + : Lazy_rep(a) {} + + Lazy_rep_0(const ET& e) + : Lazy_rep(E2A()(e), e) {} + + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + } +}; + + +//____________________________________________________________ + +template +class Lazy_rep_1 + : public Lazy_rep::type, typename decay::type, E2A> + , private EC +{ + typedef typename decay::type AT; + typedef typename decay::type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + } + + Lazy_rep_1(const AC& ac, const EC& ec, const L1& l1) + : Lazy_rep(ac(CGAL::approx(l1))), EC(ec), l1_(l1) + { + this->set_depth(CGAL::depth(l1_) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with one child node:"); + CGAL::print_dag(l1_, os, level+1); + } + } +#endif +}; + + + +//____________________________________________________________ + +template +class Lazy_rep_2 + : public Lazy_rep::type, typename decay::type, E2A> + , private EC +{ + typedef typename decay::type AT; + typedef typename decay::type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + } + + Lazy_rep_2(const AC& ac, const EC& /*ec*/, const L1& l1, const L2& l2) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2))), + l1_(l1), l2_(l2) + { + this->set_depth(max_n(CGAL::depth(l1_), CGAL::depth(l2_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with two child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + } + } +#endif +}; + + +//____________________________________________________________ + +template +class Lazy_rep_3 + : public Lazy_rep + , private EC +{ + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + mutable L3 l3_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), + CGAL::exact(l3_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + l3_ = L3(); + } + + Lazy_rep_3(const AC& ac, const EC& /*ec*/, + const L1& l1, const L2& l2, const L3& l3) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), + CGAL::approx(l3))), + l1_(l1), l2_(l2), l3_(l3) + { + this->set_depth(max_n(CGAL::depth(l1_), + CGAL::depth(l2_), + CGAL::depth(l3_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with three child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + CGAL::print_dag(l3_, os, level+1); + } + } +#endif +}; + + +//____________________________________________________________ + +template +class Lazy_rep_4 + : public Lazy_rep + , private EC +{ + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + mutable L3 l3_; + mutable L4 l4_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), + CGAL::exact(l3_), CGAL::exact(l4_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + l3_ = L3(); + l4_ = L4(); + } + + Lazy_rep_4(const AC& ac, const EC& /*ec*/, + const L1& l1, const L2& l2, const L3& l3, const L4& l4) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), + CGAL::approx(l3), CGAL::approx(l4))), + l1_(l1), l2_(l2), l3_(l3), l4_(l4) + { + this->set_depth(max_n(CGAL::depth(l1_), + CGAL::depth(l2_), + CGAL::depth(l3_), + CGAL::depth(l4_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with four child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + CGAL::print_dag(l3_, os, level+1); + CGAL::print_dag(l4_, os, level+1); + } + } +#endif +}; + +//____________________________________________________________ + + +template +class Lazy_rep_5 + : public Lazy_rep + , private EC +{ + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + mutable L3 l3_; + mutable L4 l4_; + mutable L5 l5_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), + CGAL::exact(l3_), CGAL::exact(l4_), + CGAL::exact(l5_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + l3_ = L3(); + l4_ = L4(); + l5_ = L5(); + } + + Lazy_rep_5(const AC& ac, const EC& /*ec*/, + const L1& l1, const L2& l2, const L3& l3, const L4& l4, + const L5& l5) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), + CGAL::approx(l3), CGAL::approx(l4), + CGAL::approx(l5))), + l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5) + { + this->set_depth(max_n(CGAL::depth(l1_), + CGAL::depth(l2_), + CGAL::depth(l3_), + CGAL::depth(l4_), + CGAL::depth(l5_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with five child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + CGAL::print_dag(l3_, os, level+1); + CGAL::print_dag(l4_, os, level+1); + CGAL::print_dag(l5_, os, level+1); + } + } +#endif +}; + +template +class Lazy_rep_6 + : public Lazy_rep + , private EC +{ + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + mutable L3 l3_; + mutable L4 l4_; + mutable L5 l5_; + mutable L6 l6_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), + CGAL::exact(l3_), CGAL::exact(l4_), + CGAL::exact(l5_), CGAL::exact(l6_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + l3_ = L3(); + l4_ = L4(); + l5_ = L5(); + l6_ = L6(); + } + + Lazy_rep_6(const AC& ac, const EC& /*ec*/, + const L1& l1, const L2& l2, const L3& l3, const L4& l4, + const L5& l5, const L6& l6) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), + CGAL::approx(l3), CGAL::approx(l4), + CGAL::approx(l5), CGAL::approx(l6))), + l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5), l6_(l6) + { + this->set_depth(max_n(CGAL::depth(l1_), + CGAL::depth(l2_), + CGAL::depth(l3_), + CGAL::depth(l4_), + CGAL::depth(l5_), + CGAL::depth(l6_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with 6 child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + CGAL::print_dag(l3_, os, level+1); + CGAL::print_dag(l4_, os, level+1); + CGAL::print_dag(l5_, os, level+1); + CGAL::print_dag(l6_, os, level+1); + } + } +#endif +}; + +template +class Lazy_rep_7 + : public Lazy_rep + , private EC +{ + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + mutable L3 l3_; + mutable L4 l4_; + mutable L5 l5_; + mutable L6 l6_; + mutable L7 l7_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), + CGAL::exact(l3_), CGAL::exact(l4_), + CGAL::exact(l5_), CGAL::exact(l6_), + CGAL::exact(l7_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + l3_ = L3(); + l4_ = L4(); + l5_ = L5(); + l6_ = L6(); + l7_ = L7(); + } + + Lazy_rep_7(const AC& ac, const EC& /*ec*/, + const L1& l1, const L2& l2, const L3& l3, const L4& l4, + const L5& l5, const L6& l6, const L7& l7) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), + CGAL::approx(l3), CGAL::approx(l4), + CGAL::approx(l5), CGAL::approx(l6), + CGAL::approx(l7))), + l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5), l6_(l6), l7_(l7) + { + this->set_depth(max_n(CGAL::depth(l1_), + CGAL::depth(l2_), + CGAL::depth(l3_), + CGAL::depth(l4_), + CGAL::depth(l5_), + CGAL::depth(l6_), + CGAL::depth(l7_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with 7 child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + CGAL::print_dag(l3_, os, level+1); + CGAL::print_dag(l4_, os, level+1); + CGAL::print_dag(l5_, os, level+1); + CGAL::print_dag(l6_, os, level+1); + CGAL::print_dag(l7_, os, level+1); + } + } +#endif +}; + +template +class Lazy_rep_8 + : public Lazy_rep + , private EC +{ + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + mutable L3 l3_; + mutable L4 l4_; + mutable L5 l5_; + mutable L6 l6_; + mutable L7 l7_; + mutable L8 l8_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), + CGAL::exact(l3_), CGAL::exact(l4_), + CGAL::exact(l5_), CGAL::exact(l6_), + CGAL::exact(l7_), CGAL::exact(l8_))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + l3_ = L3(); + l4_ = L4(); + l5_ = L5(); + l6_ = L6(); + l7_ = L7(); + l8_ = L8(); + } + + Lazy_rep_8(const AC& ac, const EC& /*ec*/, + const L1& l1, const L2& l2, const L3& l3, const L4& l4, + const L5& l5, const L6& l6, const L7& l7, const L8& l8) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), + CGAL::approx(l3), CGAL::approx(l4), + CGAL::approx(l5), CGAL::approx(l6), + CGAL::approx(l7), CGAL::approx(l8))), + l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5), l6_(l6), l7_(l7), l8_(l8) + { + this->set_depth(max_n(CGAL::depth(l1_), + CGAL::depth(l2_), + CGAL::depth(l3_), + CGAL::depth(l4_), + CGAL::depth(l5_), + CGAL::depth(l6_), + CGAL::depth(l7_), + CGAL::depth(l8_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with 8 child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + CGAL::print_dag(l3_, os, level+1); + CGAL::print_dag(l4_, os, level+1); + CGAL::print_dag(l5_, os, level+1); + CGAL::print_dag(l6_, os, level+1); + CGAL::print_dag(l7_, os, level+1); + CGAL::print_dag(l8_, os, level+1); + } + } +#endif +}; + + +template < typename K1, typename K2 > +struct Approx_converter +{ + typedef K1 Source_kernel; + typedef K2 Target_kernel; + //typedef Converter Number_type_converter; + + template < typename T > + const typename T::AT& + operator()(const T&t) const + { return t.approx(); } + + //TODO: a transforming_iterator version + + const Null_vector& + operator()(const Null_vector& n) const + { return n; } + + const Bbox_2& + operator()(const Bbox_2& b) const + { return b; } + + const Bbox_3& + operator()(const Bbox_3& b) const + { return b; } +}; + +template < typename K1, typename K2 > +struct Exact_converter +{ + typedef K1 Source_kernel; + typedef K2 Target_kernel; + //typedef Converter Number_type_converter; + + template < typename T > + const typename T::ET& + operator()(const T&t) const + { return t.exact(); } + + const Null_vector& + operator()(const Null_vector& n) const + { return n; } + + const Bbox_2& + operator()(const Bbox_2& b) const + { return b; } + + const Bbox_3& + operator()(const Bbox_3& b) const + { return b; } +}; + +//____________________________________________________________ + + + +template +class Lazy_rep_with_vector_1 + : public Lazy_rep, std::vector, E2A> + , private EC +{ + typedef std::vector AT; + typedef std::vector ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { +// TODO : This looks really unfinished... + std::vector vec; + this->et = new ET(); + //this->et->reserve(this->at.size()); + ec()(CGAL::exact(l1_), std::back_inserter(*(this->et))); + if(this->et==NULL) + E2A()(*(this->et)); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + } + + Lazy_rep_with_vector_1(const AC& ac, const EC& /*ec*/, const L1& l1) + : l1_(l1) + { + ac(CGAL::approx(l1), std::back_inserter(this->at)); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + os << "A Lazy_rep_with_vector_1 of size " << this->at.size() << std::endl; + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with one child node:"); + CGAL::print_dag(l1_, os, level+1); + + } + } +#endif +}; + + +template +class Lazy_rep_with_vector_2 + : public Lazy_rep, std::vector, E2A> + , private EC +{ + typedef std::vector AT; + typedef std::vector ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(); + this->et->reserve(this->at.size()); + ec()(CGAL::exact(l1_), CGAL::exact(l2_), std::back_inserter(*(this->et))); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + } + + Lazy_rep_with_vector_2(const AC& ac, const EC& /*ec*/, const L1& l1, const L2& l2) + : l1_(l1), l2_(l2) + { + ac(CGAL::approx(l1), CGAL::approx(l2), std::back_inserter(this->at)); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + os << "A Lazy_rep_with_vector_2 of size " << this->at.size() << std::endl; + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with two child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + } + } +#endif +}; + + +template +class Lazy_rep_2_1 + : public Lazy_rep + , private EC +{ + typedef typename R1::AT AT; + typedef typename R1::ET ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(); + ec()(CGAL::exact(l1_), CGAL::exact(l2_), *(this->et)); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + } + + Lazy_rep_2_1(const AC& ac, const EC& /*ec*/, const L1& l1, const L2& l2) + : Lazy_rep(), l1_(l1), l2_(l2) + { + ac(CGAL::approx(l1), CGAL::approx(l2), this->at); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + os << "A Lazy_rep_2_1" << std::endl; + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with two child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + } + } +#endif +}; + + +//____________________________________________________________________________________ +// The following rep class stores two non-const reference parameters of type R1 and R2 + +template +class Lazy_rep_2_2 + : public Lazy_rep, std::pair, E2A> + , private EC +{ + typedef std::pair AT; + typedef std::pair ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + + const EC& ec() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(); + ec()(CGAL::exact(l1_), CGAL::exact(l2_), this->et->first, this->et->second ); + this->at = E2A()(*(this->et)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + } + + Lazy_rep_2_2(const AC& ac, const EC& /*ec*/, const L1& l1, const L2& l2) + : Lazy_rep(), l1_(l1), l2_(l2) + { + ac(CGAL::approx(l1), CGAL::approx(l2), this->at.first, this->at.second); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + os << "A Lazy_rep_2_2" << std::endl; + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with two child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + } + } +#endif +}; + + +//____________________________________________________________ +// The handle class +template +class Lazy : public Handle +{ +public : + + typedef Lazy Self; + typedef Lazy_rep Self_rep; + + typedef AT_ AT; // undocumented + typedef ET_ ET; // undocumented + + typedef AT Approximate_type; + typedef ET Exact_type; + +/* + typedef Self Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } +*/ + + Lazy() + : Handle(zero()) {} + + // Before Lazy::zero() used Boost.Thread, the definition of Lazy() was: + // Lazy() + // #ifndef CGAL_HAS_THREAD + // : Handle(zero()) {} + // #else + // { + // PTR = new Lazy_rep_0(); + // } + // #endif + + Lazy(Self_rep *r) + { + PTR = r; + } + + Lazy(const ET& e) + { + PTR = new Lazy_rep_0(e); + } + + const AT& approx() const + { return ptr()->approx(); } + + const ET& exact() const + { return ptr()->exact(); } + + AT& approx() + { return ptr()->approx(); } + + ET& exact() + { return ptr()->exact(); } + + unsigned depth() const + { + return ptr()->depth(); + } + + void print_dag(std::ostream& os, int level) const + { + ptr()->print_dag(os, level); + } + +private: + + // We have a static variable for optimizing the default constructor, + // which is in particular heavily used for pruning DAGs. + static const Self & zero() + { +#ifdef CGAL_HAS_THREADS + static boost::thread_specific_ptr z; + if (z.get() == NULL) { + z.reset(new Self(new Lazy_rep_0())); + } + return * z.get(); +#else + static const Self z = new Lazy_rep_0(); + return z; +#endif + } + + Self_rep * ptr() const { return (Self_rep*) PTR; } +}; + + + + + +// The magic functor for Construct_bbox_[2,3], as there is no Lazy + +template +struct Lazy_construction_bbox +{ + static const bool Protection = true; + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename AC::result_type result_type; + + AC ac; + EC ec; + + template + result_type operator()(const L1& l1) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG + Protect_FPU_rounding P; + try { + return ac(CGAL::approx(l1)); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return ec(CGAL::exact(l1)); + } + } +}; + +template +struct Lazy_construction_nt { + + static const bool Protection = true; + + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::E2A E2A; + typedef typename decay::type AT; + typedef typename decay::type ET; + typedef Lazy_exact_nt result_type; + + AC ac; + EC ec; + + template + result_type operator()(const L1& l1) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_1, L1>(ac, ec, l1); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0 >(ec(CGAL::exact(l1))); + } + } + + template + result_type operator()(const L1& l1, const L2& l2) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_2, L1,L2>(ac, ec, l1,l2); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2))); + } + } + + template + result_type operator()(const L1& l1, const L2& l2, const L3& l3) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_3, L1,L2,L3>(ac, ec, l1,l2,l3); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3))); + } + } + + template + result_type operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_4, L1,L2,L3,L4>(ac, ec, l1,l2,l3,l4); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4))); + } + } + + template + result_type operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_5, L1,L2,L3,L4,L5>(ac, ec, l1,l2,l3,l4,l5); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5))); + } + } +}; + + +template +Object +make_lazy(const Object& eto) +{ + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::E2A E2A; + + if (eto.is_empty()) + return Object(); + +#define CGAL_Kernel_obj(X) \ + if (const typename EK::X* ptr = object_cast(&eto)) \ + return make_object(typename LK::X(new Lazy_rep_0(*ptr))); + +#include + + std::cerr << "object_cast inside Lazy_construction_rep::operator() failed. It needs more else if's (#2)" << std::endl; + std::cerr << "dynamic type of the Object : " << eto.type().name() << std::endl; + + return Object(); +} + + +// This functor selects the i'th element in a vector of Object's +// and casts it to what is in the Object + +template +struct Ith { + typedef T2 result_type; + + // We keep a Sign member object + // for future utilisation, in case + // we have pairs of 2 T2 objects e.g. + // for a numeric_point vector returned + // from a construction of a possible + // lazy algebraic kernel + + int i; + Sign sgn; + + Ith(int i_) + : i(i_) + {sgn=NEGATIVE;} + + Ith(int i_, bool b_) + : i(i_) + { sgn= (b_) ? POSITIVE : ZERO;} + + const T2& + operator()(const std::vector& v) const + { + if(sgn==NEGATIVE) + return *object_cast(&v[i]); + + typedef std::pair Pair_type_1; + typedef std::pair > Pair_type_2; + + if(const Pair_type_1 *p1 = object_cast(&v[i])) + return p1->first; + else if(const Pair_type_2 *p2 = object_cast(&v[i])) + return p2->first; + + CGAL_error_msg( " Unexpected encapsulated type "); + } +}; + + +template +struct Lazy_cartesian_const_iterator_2 +{ + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::Cartesian_const_iterator_2 result_type; + + AC ac; + EC ec; + +public: + + template < typename L1> + result_type + operator()(const L1& l1) const + { + return result_type(&l1); + } + + template < typename L1> + result_type + operator()(const L1& l1, int i) const + { + return result_type(&l1,i); + } + +}; + + +template +struct Lazy_cartesian_const_iterator_3 +{ + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::Cartesian_const_iterator_3 result_type; + + AC ac; + EC ec; + +public: + + template < typename L1> + result_type + operator()(const L1& l1) const + { + return result_type(&l1); + } + + template < typename L1> + result_type + operator()(const L1& l1, int i) const + { + return result_type(&l1,i); + } + +}; + + +// This is the magic functor for functors that write their result in a reference argument +// In a first version we assume that the references are of type Lazy, +// and that the result type is void + +template +struct Lazy_functor_2_1 +{ + static const bool Protection = true; + typedef void result_type; + + AC ac; + EC ec; + +public: + + template + void + operator()(const L1& l1, const L2& l2, R1& r1) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + // we suppose that R1 is a Lazy + r1 = R1(new Lazy_rep_2_1(ac, ec, l1, l2)); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + typename R1::ET et; + ec(CGAL::exact(l1), CGAL::exact(l2), et); + r1 = R1(new Lazy_rep_0(et)); + } + } +}; + + +template +struct First +{ + typedef typename T::first_type result_type; + + const typename T::first_type& + operator()(const T& p) const + { + return p.first; + } + }; + +template +struct Second +{ + typedef typename T::second_type result_type; + + const typename T::second_type& + operator()(const T& p) const + { + return p.second; + } +}; + +// This is the magic functor for functors that write their result in a reference argument +// In a first version we assume that the references are of type Lazy, +// and that the result type is void + +//template +template +struct Lazy_functor_2_2 +{ + static const bool Protection = true; + + typedef void result_type; + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename EK::FT EFT; + typedef typename LK::E2A E2A; + + AC ac; + EC ec; + +public: + + template + void + operator()(const L1& l1, const L2& l2, R1& r1, R2& r2) const + { + typedef Lazy Handle_1; + typedef Lazy Handle_2; + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + typedef Lazy, std::pair, EFT, E2A> Lazy_pair; + Lazy_pair lv(new Lazy_rep_2_2(ac, ec, l1, l2)); + // lv->approx() is a std::pair; + r1 = R1(Handle_1(new Lazy_rep_1 >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); + r2 = R2(Handle_2(new Lazy_rep_1 >, Second >, E2A, Lazy_pair>(Second >(), Second >(), lv))); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + typename R1::ET et1, et2; + ec(CGAL::exact(l1), CGAL::exact(l2), et1, et2); + r1 = R1(Handle_1(new Lazy_rep_0(et1))); + r2 = R2(Handle_2(new Lazy_rep_0(et2))); + } + } +}; + + +// This is the magic functor for functors that write their result as Objects into an output iterator + +template +struct Lazy_intersect_with_iterators +{ + static const bool Protection = true; + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename EK::FT EFT; + typedef typename LK::E2A E2A; + typedef void result_type; + typedef Lazy Lazy_object; + typedef Lazy, std::vector, EFT, E2A> Lazy_vector; + + AC ac; + EC ec; + +public: + + // In the example we intersect two Lazys + // and write into a back_inserter(list,Lazy]) >) + template + OutputIterator + operator()(const L1& l1, const L2& l2, OutputIterator it) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + Lazy_vector lv(new Lazy_rep_with_vector_2(ac, ec, l1, l2)); + // lv.approx() is a std::vector + // that is, when we get here we have constructed all approximate results + for (unsigned int i = 0; i < lv.approx().size(); i++) { +// FIXME : I'm not sure how this work... +#define CGAL_Kernel_obj(X) if (object_cast(& (lv.approx()[i]))) { \ + *it++ = make_object(typename LK::X(new Lazy_rep_1, \ + Ith, E2A, Lazy_vector> \ + (Ith(i), Ith(i), lv))); \ + continue; \ + } + +#include + + std::cerr << "we need more casts" << std::endl; + } + + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + // TODO: Instead of using a vector, write an iterator adapter + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + std::vector exact_objects; + ec(CGAL::exact(l1), CGAL::exact(l2), std::back_inserter(exact_objects)); + for (std::vector::const_iterator oit = exact_objects.begin(); + oit != exact_objects.end(); + ++oit){ + *it++ = make_lazy(*oit); + } + } + return it; + } +}; + + +template +struct Object_cast +{ + typedef T result_type; + + const T& + operator()(const Object& o) const + { + return *object_cast(&o); + } +}; + +// The following functor returns an Object with a Lazy inside +// As the nested kernels return Objects of AK::Something and EK::Something +// we have to unwrap them from the Object, and wrap them in a Lazy +// +// TODO: write operators for other than two arguments. For the current kernel we only need two for Intersect_2 + +template +struct Lazy_construction_object +{ + static const bool Protection = true; + + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename EK::FT EFT; + typedef typename LK::E2A E2A; + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Object result_type; + + typedef Lazy Lazy_object; + + AC ac; + EC ec; + +public: + + template + result_type + operator()(const L1& l1) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + Lazy_object lo(new Lazy_rep_1(ac, ec, l1)); + + if(lo.approx().is_empty()) + return Object(); + +#define CGAL_Kernel_obj(X) \ + if (object_cast(& (lo.approx()))) { \ + typedef Lazy_rep_1, Object_cast, E2A, Lazy_object> Lcr; \ + Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ + return make_object(typename LK::X(lcr)); \ + } + +#include + + std::cerr << "object_cast inside Lazy_construction_rep::operator() failed. It needs more else if's (#1)" << std::endl; + std::cerr << "dynamic type of the Object : " << lo.approx().type().name() << std::endl; + + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + ET eto = ec(CGAL::exact(l1)); + return make_lazy(eto); + } + return Object(); + } + + template + result_type + operator()(const L1& l1, const L2& l2) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + Lazy_object lo(new Lazy_rep_2(ac, ec, l1, l2)); + + if(lo.approx().is_empty()) + return Object(); + +#define CGAL_Kernel_obj(X) \ + if (object_cast(& (lo.approx()))) { \ + typedef Lazy_rep_1, Object_cast, E2A, Lazy_object> Lcr; \ + Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ + return make_object(typename LK::X(lcr)); \ + } + +#include + + std::cerr << "object_cast inside Lazy_construction_rep::operator() failed. It needs more else if's (#1)" << std::endl; + std::cerr << "dynamic type of the Object : " << lo.approx().type().name() << std::endl; + + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + ET eto = ec(CGAL::exact(l1), CGAL::exact(l2)); + return make_lazy(eto); + } + return Object(); + } + +}; + + + +//____________________________________________________________ +// The magic functor that has Lazy as result type + +template +struct Lazy_construction +{ + static const bool Protection = true; + + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename EK::FT EFT; + typedef typename Default::Get::type E2A; + typedef typename AC::result_type AT; + typedef typename EC::result_type ET; + typedef Lazy Handle; + //typedef typename Type_mapper::type result_type; + typedef Handle result_type; + + AC ac; + EC ec; + +public: + + result_type + operator()() const + { + return result_type( Handle(new Lazy_rep_0()) ); + } + + template + result_type + operator()(const L1& l1) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_1(ac, ec, l1)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1)))) ); + } + } + + template + result_type + operator()(const L1& l1, const L2& l2) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_2(ac, ec, l1, l2)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2)))) ); + } + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_3(ac, ec, l1, l2, l3)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3)))) ); + } + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_4(ac, ec, l1, l2, l3, l4)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4)))) ); + } + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_5(ac, ec, l1, l2, l3, l4, l5)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5)))) ); + } + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_6(ac, ec, l1, l2, l3, l4, l5, l6)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5), CGAL::exact(l6)))) ); + } + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_7(ac, ec, l1, l2, l3, l4, l5, l6, l7)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5), CGAL::exact(l6), CGAL::exact(l7)))) ); + } + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7, const L8& l8) const + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return result_type( Handle(new Lazy_rep_8(ac, ec, l1, l2, l3, l4, l5, l6, l7, l8)) ); + } catch (Uncertain_conversion_exception) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5), CGAL::exact(l6), CGAL::exact(l7), CGAL::exact(l8)))) ); + } + } + +}; + +} //namespace CGAL + +#endif // CGAL_LAZY_H diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index b12db5ff1ae..1425c78b892 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -124,6 +124,11 @@ namespace CGAL { } }; +#ifdef CGAL_CXX0X + using std::decay; +#else + template struct decay : boost::remove_cv::type> {}; +#endif } #endif diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 3ef9d72421c..92cdaa2533c 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -3,11 +3,11 @@ all: normal cxx0x CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include normal: - g++ test.cpp -O2 -g -lCGAL -frounding-math -Wall -I. -lgmp -I../../include -I/usr/include/eigen2 -DCGAL_USE_EIGEN ${CGAL_INC} + g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include -I/opt/eigen -DCGAL_USE_EIGEN ${CGAL_INC} ./a.out cxx0x: - /usr/lib/gcc-snapshot/bin/g++ -std=c++0x -O2 -g test.cpp -lCGAL -frounding-math -Wall -I. -lgmp -DCGAL_CXX0X -I../../include -I/usr/include/eigen2 -DCGAL_USE_EIGEN ${CGAL_INC} + /usr/lib/gcc-snapshot/bin/g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include -I/opt/eigen -DCGAL_USE_EIGEN ${CGAL_INC} ./a.out #-DBOOST_RESULT_OF_USE_DECLTYPE From b92124727e5f4c8ae72a3fa9a3bd39448ec9460b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 10:12:31 +0000 Subject: [PATCH 010/210] blabla --- NewKernel_d/include/CGAL/LA_eigen/LA.h | 15 ++++- NewKernel_d/include/CGAL/Lazy.h | 76 ++++++++++++++++++++++---- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/NewKernel_d/include/CGAL/LA_eigen/LA.h b/NewKernel_d/include/CGAL/LA_eigen/LA.h index f88f0c7da88..87f72dfadd1 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/LA_eigen/LA.h @@ -13,6 +13,7 @@ namespace CGAL { +//FIXME: where could we use Matrix_base instead of Matrix? template struct LA_eigen { typedef NT_ NT; // Dim_ real dimension @@ -20,20 +21,30 @@ template struct LA_eigen { template struct Vector { typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> type; typedef Construct_eigen Constructor; - //typedef NT const* const_iterator; - //FIXME: use Matrix_base instead in the iterator? +#if (EIGEN_WORLD_VERSION>=3) + typedef NT const* const_iterator; +#else typedef Iterator_from_indices const_iterator; +#endif templatestatic const_iterator vector_begin(Vec_ const&a){ +#if (EIGEN_WORLD_VERSION>=3) + return &a[0]; +#else return const_iterator(a,0); +#endif } templatestatic const_iterator vector_end(Vec_ const&a){ +#if (EIGEN_WORLD_VERSION>=3) + return &a[0]+a.size(); +#else return const_iterator(a,a.size()); +#endif } }; diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index fa73986e13c..9f2b9d73a8b 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -32,13 +32,20 @@ #include #include #include +#include #include +#include #ifdef CGAL_HAS_THREADS # include #endif namespace CGAL { +namespace internal { + BOOST_MPL_HAS_XXX_TRAIT_DEF(AT) + BOOST_MPL_HAS_XXX_TRAIT_DEF(ET) +} + template class Lazy; @@ -81,10 +88,11 @@ depth(const Lazy& l) } +/* #define CGAL_LAZY_FORWARD(T) \ - inline const T & approx(const T& d) { return d; } \ - inline const T & exact (const T& d) { return d; } \ - inline unsigned depth (const T& ) { return 0; } + inline T const & approx(T const& d) { return d; } \ + inline T const & exact (T const& d) { return d; } \ + inline unsigned depth (T const& ) { return 0; } CGAL_LAZY_FORWARD(double) @@ -97,7 +105,13 @@ CGAL_LAZY_FORWARD(Origin) CGAL_LAZY_FORWARD(Orientation) CGAL_LAZY_FORWARD(Bbox_2) CGAL_LAZY_FORWARD(Bbox_3) - +*/ +template +inline T const & approx(T const& d) { return d; }; +template +inline T const & exact (T const& d) { return d; }; +template +inline unsigned depth (T const& ) { return 0; }; #ifdef CGAL_LAZY_KERNEL_DEBUG @@ -407,11 +421,11 @@ public: template class Lazy_rep_3 - : public Lazy_rep + : public Lazy_rep::type, typename decay::type, E2A> , private EC { - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; + typedef typename decay::type AT; + typedef typename decay::type ET; typedef Lazy_rep Base; mutable L1 l1_; @@ -834,16 +848,36 @@ public: template < typename K1, typename K2 > struct Approx_converter { + typedef Approx_converter Self; typedef K1 Source_kernel; typedef K2 Target_kernel; //typedef Converter Number_type_converter; + template struct result_; + template struct result_ { + typedef typename T::AT const& type; + }; + template struct result_ { + typedef transforming_iterator type; + }; + + template struct result; + template struct result : result_::value,is_iterator::value>{}; + template struct result{typedef Null_vector type;}; + template struct result{typedef Bbox_2 type;}; + template struct result{typedef Bbox_3 type;}; + template < typename T > const typename T::AT& operator()(const T&t) const { return t.approx(); } - //TODO: a transforming_iterator version + template + transforming_iterator,It>::type> + operator()(const It& i) const + { + return make_transforming_iterator(i,*this); + } const Null_vector& operator()(const Null_vector& n) const @@ -861,15 +895,37 @@ struct Approx_converter template < typename K1, typename K2 > struct Exact_converter { + typedef Exact_converter Self; typedef K1 Source_kernel; typedef K2 Target_kernel; //typedef Converter Number_type_converter; + template struct result_; + template struct result_ { + typedef typename T::ET const& type; + }; + template struct result_ { + typedef transforming_iterator type; + }; + + template struct result; + template struct result : result_::value,is_iterator::value>{}; + template struct result{typedef Null_vector type;}; + template struct result{typedef Bbox_2 type;}; + template struct result{typedef Bbox_3 type;}; + template < typename T > const typename T::ET& operator()(const T&t) const { return t.exact(); } + template + transforming_iterator,It>::type> + operator()(const It& i) const + { + return make_transforming_iterator(i,*this); + } + const Null_vector& operator()(const Null_vector& n) const { return n; } @@ -1720,8 +1776,8 @@ struct Lazy_construction typedef typename LK::Exact_kernel EK; typedef typename EK::FT EFT; typedef typename Default::Get::type E2A; - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; + typedef typename decay::type AT; + typedef typename decay::type ET; typedef Lazy Handle; //typedef typename Type_mapper::type result_type; typedef Handle result_type; From 76c16e45eec61d21c3707b66032f91ff4886b0e8 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 12:47:30 +0000 Subject: [PATCH 011/210] a --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h | 2 ++ NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) 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 518d9957514..4455c832dbb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -55,6 +55,7 @@ struct Cartesian_LA_base_d : public Dimension_base typedef LA_vector Point; typedef LA_vector Vector; +#if 0 // old way typedef CartesianDVectorBase::Construct_LA_vector Construct_point; typedef CartesianDVectorBase::Construct_LA_vector Construct_vector; @@ -65,6 +66,7 @@ struct Cartesian_LA_base_d : public Dimension_base typedef CartesianDVectorBase::Construct_midpoint Construct_midpoint; typedef CartesianDVectorBase::Compute_cartesian_coordinate Compute_cartesian_coordinate; +#endif // new way template struct Construct { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index 875fe3f6c51..a965e6564a1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -1,13 +1,14 @@ #ifndef CGAL_KERNELD_SEGMENTD_H #define CGAL_KERNELD_SEGMENTD_H #include +#include #define Segmentd SegmentCd namespace CGAL { template class Segmentd { typedef typename R_::FT FT_; typedef typename R_::Point Point_; typedef typename R_::Vector Vector_; - typedef typename R_::Construct_vector Cv_; + typedef typename R_::template Construct::type Cv_; // typedef typename R_::Compute_squared_distance Csd_; typedef std::pair Data_; Data_ data; From 0e0374300fbda2f7fefa31a12efdd38b08dd0d73 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 13:15:40 +0000 Subject: [PATCH 012/210] b --- NewKernel_d/test/NewKernel_d/test.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 35b05255fdd..b4d101aeb7a 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -25,20 +25,21 @@ typedef K1::Segment S; //typedef K1::Construct_point CP; typedef K1::Construct::type CP; typedef K1::Construct::type CV; +typedef K1::Construct::type CS; typedef K1::Construct::type CCI; typedef K1::Predicate::type PO; typedef K1::Cartesian_const_iterator CI; typedef K1::Compute::type CC; int main(){ - CP cp; CCI ci; CC cc; PO po; + CP cp; CCI ci; CC cc; PO po; CS cs; P a=cp(3,4); P b=cp(5,6,7); int rr[]={3,5,2}; int* r=rr; P c=cp(r,r+2); P d=cp(r,r+3,CGAL::Homogeneous_tag()); - S s(c,d); + S s=cs(c,d); std::cout << cc(a,1) << std::endl; std::cout << cc(b,1) << std::endl; std::cout << cc(s[0],1) << std::endl; From 5fa563096e376a5828b060b9a3626201e131f604 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 13:23:54 +0000 Subject: [PATCH 013/210] c --- NewKernel_d/test/NewKernel_d/test.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index b4d101aeb7a..d5e29da4b65 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -26,13 +26,19 @@ typedef K1::Segment S; typedef K1::Construct::type CP; typedef K1::Construct::type CV; typedef K1::Construct::type CS; +typedef K1::Construct::type CSE; typedef K1::Construct::type CCI; typedef K1::Predicate::type PO; typedef K1::Cartesian_const_iterator CI; typedef K1::Compute::type CC; int main(){ - CP cp; CCI ci; CC cc; PO po; CS cs; + CP cp; + CCI ci; + CC cc; + PO po; + CS cs; + CSE cse; P a=cp(3,4); P b=cp(5,6,7); int rr[]={3,5,2}; @@ -42,8 +48,8 @@ int main(){ S s=cs(c,d); std::cout << cc(a,1) << std::endl; std::cout << cc(b,1) << std::endl; - std::cout << cc(s[0],1) << std::endl; - std::cout << cc(s[1],1) << std::endl; + std::cout << cc(cse(s,0),1) << std::endl; + std::cout << cc(cse(s,1),1) << std::endl; for(CI i=ci.begin(a);i!=ci.end(a);++i) std::cout << *i << ' '; std::cout << '\n'; From 3f6c9660b38b18fabc3a068f4a1a5dc18f454ee2 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 13:24:05 +0000 Subject: [PATCH 014/210] d --- .../CGAL/Kernel_d/Cartesian_converter.h | 7 ++++ NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 2 +- .../Kernel_d/function_objects_cartesian.h | 34 +++++++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 4 +++ NewKernel_d/include/CGAL/functor_tags.h | 1 + 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index 26a1013005e..749c58f185a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -61,6 +61,13 @@ template class CartesianD_converter { return cv(operator()(i.begin(p)),operator()(i.end(p))); } + typename K2::Segment operator()(typename K1::Segment const& s)const{ + //typename K1::template Construct::type i; + //FIXME: should replace source and target by a functor + typename K2::template Construct::type cs; + return cs(operator()(s.source()),operator()(s.target())); + } + Object operator()(const Object &obj) const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index a965e6564a1..8a7120aa0c2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -15,7 +15,7 @@ template class Segmentd { public: typedef Segmentd Segment; #ifdef CGAL_CXX0X - template + template::type...>,std::tuple>::value>::type> Segmentd(U&&...u):data(std::forward(u)...){} #else Segmentd(){} 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 80f158a999c..cb6d07e1df3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -167,6 +167,7 @@ template struct Less_coordinate { typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; typedef typename R::template Compute::type Cc; + // This is_exact thing should be reengineered. typedef typename CGAL::Is_exact::type Is_exact; template @@ -176,7 +177,40 @@ template struct Less_coordinate { } }; +template struct Construct_segment { + typedef R_ R; + typedef typename R_::Point Point; + typedef typename R_::Segment Segment; + typedef Segment result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return result_type(std::forward(u)...); + } +#else + result_type operator()(Point const&a, Point const&b)const{ + return result_type(a,b); + } +#endif +}; +template struct Construct_segment_extremity { + typedef R_ R; + typedef typename R_::Point Point; + typedef typename R_::Segment Segment; + typedef Point result_type; + result_type operator()(Segment const&s, int i)const{ + if(i==0) return s.source(); + CGAL_assertion(i==1); + return s.target(); + } +#ifdef CGAL_CXX0X + result_type operator()(Segment &&s, int i)const{ + if(i==0) return std::move(s).source(); + CGAL_assertion(i==1); + return std::move(s).target(); + } +#endif +}; } } diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 81dcd4c2b00..c96121ece06 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -50,6 +50,10 @@ CGAL_Kernel_cons2(Construct_opposite_vector, construct_opposite_vector_object) CGAL_Kernel_cons2(Construct_midpoint, construct_midpoint_object) +CGAL_Kernel_cons2(Construct_segment, + construct_segment_object) +CGAL_Kernel_cons2(Construct_segment_extremity, + construct_segment_extremity_object) CGAL_Kernel_comp1(Compute_cartesian_coordinate, compute_cartesian_coordinate_object) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index c9ca87e58a9..52c5682a748 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -19,6 +19,7 @@ namespace CGAL { struct Construct_ray_tag {}; struct Construct_cartesian_const_iterator_tag {}; struct Construct_midpoint_tag {}; + struct Construct_segment_extremity_tag {}; struct Construct_sum_of_vectors_tag {}; struct Construct_difference_of_vectors_tag {}; struct Construct_opposite_vector_tag {}; From 55190f70690ad9eab6779152b1017b6a4b28e96d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 16:15:17 +0000 Subject: [PATCH 015/210] don't share Cartesian_const_iterator between point and vector --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 8 +++-- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 3 +- .../CGAL/Kernel_d/Cartesian_change_FT.h | 19 +++++++---- .../CGAL/Kernel_d/Cartesian_converter.h | 8 ++--- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 34 ++++++++++++++----- .../Kernel_d/function_objects_cartesian.h | 12 +++---- .../include/CGAL/Kernel_d/interface_macros.h | 6 ++-- NewKernel_d/include/CGAL/functor_tags.h | 4 ++- .../include/CGAL/iterator_from_indices.h | 15 ++++++-- 9 files changed, 77 insertions(+), 32 deletions(-) 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 4455c832dbb..dfc2700ff7d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -49,7 +49,8 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typename LA::template Vector LA_vector_selector; typedef typename LA_vector_selector::type LA_vector; typedef typename LA_vector_selector::Constructor Constructor; - typedef typename LA_vector_selector::const_iterator Cartesian_const_iterator; + typedef typename LA_vector_selector::const_iterator Point_cartesian_const_iterator; + typedef typename LA_vector_selector::const_iterator Vector_cartesian_const_iterator; // convert types to the new way? painful to use... typedef LA_vector Point; @@ -78,7 +79,10 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Construct { typedef CartesianDVectorBase::Construct_LA_vector type; }; - template struct Construct { + template struct Construct { + typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; + }; + template struct Construct { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; template struct Construct { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 84f0f045b1e..4f9fe056a79 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -121,7 +121,8 @@ template struct Construct_cartesian_const_iterator { typedef R_ R; typedef typename R::LA_vector argument_type; typedef typename R::LA_vector_selector S_; - typedef typename R::Cartesian_const_iterator result_type; + typedef typename R::Point_cartesian_const_iterator result_type; + // same as Vector result_type begin(argument_type const& v)const{ return S_::vector_begin(v); 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 21883e6c454..25a2b11a86c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -36,13 +36,15 @@ struct Cartesian_change_FT_base : public Angle; typedef NT_converter FT_converter; - typedef transforming_iterator Cartesian_const_iterator; + typedef transforming_iterator Point_cartesian_const_iterator; + typedef transforming_iterator Vector_cartesian_const_iterator; //FIXME: what if the functor's constructor takes a kernel as argument? - struct Construct_cartesian_const_iterator { - typedef typename Kernel_base::template Construct::type Functor_base; + template + struct Construct_cartesian_const_iterator_ { + typedef typename Kernel_base::template Construct::type Functor_base; Functor_base f; - typedef Cartesian_const_iterator result_type; + typedef Type result_type; template result_type begin(T const& v)const{ return make_transforming_iterator(f.begin(v),FT_converter()); @@ -52,6 +54,8 @@ struct Cartesian_change_FT_base : public return make_transforming_iterator(f.end(v),FT_converter()); } }; + typedef Construct_cartesian_const_iterator_ Construct_point_cartesian_const_iterator; + typedef Construct_cartesian_const_iterator_ Construct_vector_cartesian_const_iterator; struct Compute_cartesian_coordinate { typedef typename Kernel_base::template Compute::type Functor_base; @@ -70,8 +74,11 @@ struct Cartesian_change_FT_base : public template struct Predicate { typedef Null_functor type; }; template struct Construct : Kernel_base::template Construct { }; - template struct Construct { - typedef Construct_cartesian_const_iterator type; + template struct Construct { + typedef Construct_point_cartesian_const_iterator type; + }; + template struct Construct { + typedef Construct_vector_cartesian_const_iterator type; }; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index 749c58f185a..31e4e7f4d50 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -50,22 +50,22 @@ template class CartesianD_converter { } typename K2::Point operator()(typename K1::Point const& p)const{ - typename K1::template Construct::type i; + typename K1::template Construct::type i; typename K2::template Construct::type cp; return cp(operator()(i.begin(p)),operator()(i.end(p))); } typename K2::Vector operator()(typename First_if_different::Type const& p)const{ - typename K1::template Construct::type i; + typename K1::template Construct::type i; typename K2::template Construct::type cv; return cv(operator()(i.begin(p)),operator()(i.end(p))); } typename K2::Segment operator()(typename K1::Segment const& s)const{ - //typename K1::template Construct::type i; + typename K1::template Construct::type f; //FIXME: should replace source and target by a functor typename K2::template Construct::type cs; - return cs(operator()(s.source()),operator()(s.target())); + return cs(operator()(f(s,0)),operator()(f(s,1))); } Object diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index fb6b2660ab3..4a7974eb326 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -4,15 +4,18 @@ #include #include #include +#include namespace CGAL { template -struct Lazy_cartesian +struct Lazy_cartesian : Dimension_base { //CGAL_CONSTEXPR Lazy_cartesian(){} //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} + //TODO: store an AK and an EK + typedef Lazy_cartesian Self; typedef AK_ Approximate_kernel; typedef EK_ Exact_kernel; typedef E2A_ E2A; @@ -23,6 +26,8 @@ struct Lazy_cartesian typedef typename Exact_kernel::Rep_tag Rep_tag; typedef typename Exact_kernel::Kernel_tag Kernel_tag; + typedef typename Exact_kernel::Default_ambient_dimension Default_ambient_dimension; + typedef typename Exact_kernel::Max_ambient_dimension Max_ambient_dimension; typedef typename Same_uncertainty_nt::type Boolean; @@ -60,16 +65,29 @@ struct Lazy_cartesian typedef Lazy_construction type; }; + typedef Iterator_from_indices::type> Point_cartesian_const_iterator; + typedef Iterator_from_indices::type> Vector_cartesian_const_iterator; //TODO: //typedef ????????? Cartesian_const_iterator; //typedef ????????? Construct_cartesian_const_iterator -// -// template struct Compute { -// typedef Compute_cartesian_coordinate type; -// }; -// template struct Construct { -// typedef Construct_cartesian_const_iterator type; -// }; + template + struct Construct_iter { + typedef U result_type; + template + result_type begin(T const& t)const{ + return result_type(t,0); + } + template + result_type end(T const& t)const{ + return result_type(t,Self().dimension()); + } + }; + template struct Construct { + typedef Construct_iter type; + }; + template struct Construct { + typedef Construct_iter type; + }; }; 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 cb6d07e1df3..93d2f16d3cb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -65,7 +65,7 @@ template struct Construct_opposite_vector { typedef typename R_::FT FT; typedef typename R::Vector Vector; typedef typename R::template Construct::type CV; - typedef typename R::template Construct::type CI; + typedef typename R::template Construct::type CI; typedef Vector result_type; typedef Vector argument_type; result_type operator()(Vector const&v)const{ @@ -79,7 +79,7 @@ template struct Construct_sum_of_vectors { typedef typename R_::FT FT; typedef typename R::Vector Vector; typedef typename R::template Construct::type CV; - typedef typename R::template Construct::type CI; + typedef typename R::template Construct::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -94,7 +94,7 @@ template struct Construct_difference_of_vectors { typedef typename R_::FT FT; typedef typename R::Vector Vector; typedef typename R::template Construct::type CV; - typedef typename R::template Construct::type CI; + typedef typename R::template Construct::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -109,7 +109,7 @@ template struct Construct_midpoint { typedef typename R_::FT FT; typedef typename R::Point Point; typedef typename R::template Construct::type CP; - typedef typename R::template Construct::type CI; + typedef typename R::template Construct::type CI; typedef Point result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -130,7 +130,7 @@ template struct Compute_squared_length { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Construct::type CI; + typedef typename R::template Construct::type CI; typedef FT result_type; typedef Vector argument_type; result_type operator()(Vector const&a)const{ @@ -145,7 +145,7 @@ template struct Compute_squared_distance { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; - typedef typename R::template Construct::type CI; + typedef typename R::template Construct::type CI; typedef FT result_type; typedef Point first_argument_type; typedef Point second_argument_type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index c96121ece06..3da99fa182b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -40,8 +40,10 @@ CGAL_Kernel_cons1(Construct_vector, construct_vector_object) CGAL_Kernel_cons1(Construct_point, construct_point_object) -CGAL_Kernel_cons1(Construct_cartesian_const_iterator, - construct_cartesian_const_iterator_object) +CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, + construct_point_cartesian_const_iterator_object) +CGAL_Kernel_cons1(Construct_vector_cartesian_const_iterator, + construct_vector_cartesian_const_iterator_object) CGAL_Kernel_cons2(Construct_sum_of_vectors, construct_sum_of_vectors_object) CGAL_Kernel_cons2(Construct_difference_of_vectors, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 52c5682a748..e5aa4221714 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -17,7 +17,9 @@ namespace CGAL { struct Construct_line_tag {}; struct Construct_direction_tag {}; struct Construct_ray_tag {}; - struct Construct_cartesian_const_iterator_tag {}; + //struct Construct_cartesian_const_iterator_tag {}; + struct Construct_point_cartesian_const_iterator_tag {}; + struct Construct_vector_cartesian_const_iterator_tag {}; struct Construct_midpoint_tag {}; struct Construct_segment_extremity_tag {}; struct Construct_sum_of_vectors_tag {}; diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index bdea272a71b..258d50b4aff 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -2,6 +2,14 @@ #define CGAL_ITERATOR_FROM_INDICES_H #include namespace CGAL { +template +struct Default_coordinate_access { + typedef Ref_ result_type; + template Ref_ operator()(T const& t, int i)const{ + return t[i]; + } +}; + //TODO: default type for Value_: typename same_cv::type::value_type>::type template > class Iterator_from_indices -: public boost::iterator_facade, +: public boost::iterator_facade, Value_, std::bidirectional_iterator_tag, Ref_> { friend class boost::iterator_core_access; @@ -31,7 +40,9 @@ class Iterator_from_indices return index==other.index; } Ref_ dereference()const{ - return cont[index]; + //FIXME: use the functor properly + Coord_access ca; + return ca(cont,index); } public: Iterator_from_indices(Container_& cont_,std::size_t n) From cb55b147eb5b0999235a917e4462d65a2ccfe128 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 16:15:26 +0000 Subject: [PATCH 016/210] d --- NewKernel_d/test/NewKernel_d/test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index d5e29da4b65..f2f20279977 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -14,7 +14,7 @@ typedef CGAL::Cartesian_base_d > KE; typedef K0 K1; #elif 0 typedef CGAL::Cartesian_filter_NT K1; -#elif 1 +#elif 0 typedef CGAL::Cartesian_filter_K K1; #elif 1 struct K1: CGAL::Lazy_cartesian,K1>{}; @@ -27,9 +27,9 @@ typedef K1::Construct::type CP; typedef K1::Construct::type CV; typedef K1::Construct::type CS; typedef K1::Construct::type CSE; -typedef K1::Construct::type CCI; +typedef K1::Construct::type CCI; typedef K1::Predicate::type PO; -typedef K1::Cartesian_const_iterator CI; +typedef K1::Point_cartesian_const_iterator CI; typedef K1::Compute::type CC; int main(){ From 9ec30b773c703a7e7b1efabf40193def0a475865 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 May 2011 19:41:03 +0000 Subject: [PATCH 017/210] Vector wrapper --- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 247 ++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h new file mode 100644 index 00000000000..0324dcf9f88 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -0,0 +1,247 @@ +#ifndef CGAL_WRAPPER_VECTOR_D_H +#define CGAL_WRAPPER_VECTOR_D_H + +#include +#include +#include +#include +#include +#include +#include +#ifndef CGAL_CXX0X +#include +#endif +#include + +namespace CGAL { + +template +class Vector_d : public R_::Kernel_base::Vector +{ + typedef typename R_::RT RT_; + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename R_::Point Point_; + typedef typename Kbase::template Construct::type CVBase; + typedef typename Kbase::template Compute::type CCBase; + + typedef Vector_d Self; + BOOST_STATIC_ASSERT((boost::is_same::value)); + +public: + + 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 Kbase::Vector Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX0X + template::type...>,std::tuple >::value>::type> explicit Vector_d(U&&...u) + : Rep(CVBase()(std::forward(u)...)){} + +// // called from Construct_vector_d +// template explicit Vector_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward(u)...){} + template explicit Vector_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward(f)(std::forward(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(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 CODE(Z,N,_) template \ + explicit Vector_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CVBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template \ + 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 \ +// 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,CODE,_) +#undef CODE + + // this one should be implicit + Vector_d(Null_vector const& v) + : Rep(CVBase()(v)) {} + +#endif + + typename boost::result_of::type cartesian(int i)const{ + return CCBase()(rep(),i); + } + + Vector_d operator-() const + { + return typename R::template Construct::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::Type & c) const + { + return R().construct_divided_vector_d_object()(*this,c); + } + + typename Qualified_result_of::type + x() const + { + return R().compute_x_3_object()(*this); + } + + typename Qualified_result_of::type + y() const + { + return R().compute_y_3_object()(*this); + } + + typename Qualified_result_of::type + z() const + { + return R().compute_z_3_object()(*this); + } + + typename Qualified_result_of::type + hx() const + { + return R().compute_hx_3_object()(*this); + } + + typename Qualified_result_of::type + hy() const + { + return R().compute_hy_3_object()(*this); + } + + typename Qualified_result_of::type + hz() const + { + return R().compute_hz_3_object()(*this); + } + + typename Qualified_result_of::type + hw() const + { + return R().compute_hw_3_object()(*this); + } + + typename Qualified_result_of::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::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 Qualified_result_of::type + operator[](int i) const + { + return cartesian(i); + } + + Cartesian_const_iterator cartesian_begin() const + { + return typename R::Construct_cartesian_const_iterator_3()(*this); + } + + Cartesian_const_iterator cartesian_end() const + { + return typename R::Construct_cartesian_const_iterator_3()(*this,3); + } + + typename Qualified_result_of::type + squared_length() const + { + return R().compute_squared_length_3_object()(*this); + } +*/ +}; +#if 0 +template Vector_d::Vector_d(Vector_d &)=default; +#endif + +//TODO: IO + +template +Vector_d operator+(const Vector_d& v,const Vector_d& w) const +{ + return typename R::template Construct::type()(v,w); +} + +template +Vector_d operator-(const Vector_d& v,const Vector_d& w) const +{ + return typename R::template Construct::type()(v,w); +} + +} //namespace CGAL + +#endif // CGAL_WRAPPER_VECTOR_D_H From a873c260993f2e689e134d012d2990f8efe81173 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 13 May 2011 16:05:15 +0000 Subject: [PATCH 018/210] Continue with Wrapper --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 6 +- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 9 +- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 54 ++++ .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 245 ++++++++++++++++++ .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 111 ++++++++ .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 16 +- NewKernel_d/include/CGAL/functor_tags.h | 46 ++-- NewKernel_d/test/NewKernel_d/test.cpp | 16 +- 8 files changed, 468 insertions(+), 35 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h 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 dfc2700ff7d..fc8f1d25c57 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -2,6 +2,7 @@ #define CGAL_KERNEL_D_CARTESIAN_LA_BASE_H #include +#include #include #include @@ -20,6 +21,7 @@ template < typename FT_, typename Dim_> struct Cartesian_LA_base_d : public Dimension_base { typedef FT_ FT; + typedef FT_ RT; typedef Cartesian_LA_base_d Self; typedef Cartesian_tag Rep_tag; typedef Cartesian_tag Kernel_tag; @@ -74,10 +76,10 @@ struct Cartesian_LA_base_d : public Dimension_base typedef Null_functor type; }; template struct Construct { - typedef CartesianDVectorBase::Construct_LA_vector type; + typedef CartesianDVectorBase::Construct_LA_vector type; }; template struct Construct { - typedef CartesianDVectorBase::Construct_LA_vector type; + typedef CartesianDVectorBase::Construct_LA_vector type; }; template struct Construct { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 4f9fe056a79..32b85d44fcd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -30,7 +30,7 @@ BOOST_PP_REPEAT_FROM_TO(2, 11, CODE, _ ) } #endif -template struct Construct_LA_vector +template struct Construct_LA_vector #ifndef CGAL_CXX0X : internal::Construct_LA_vector_ #endif @@ -48,6 +48,9 @@ template struct Construct_LA_vector result_type operator()()const{ return typename Constructor::Dimension()(dim); } + result_type operator()(Zero_ const&)const{ + return typename Constructor::Dimension()(dim); + } result_type operator()(result_type const& v)const{ return v; } @@ -109,7 +112,9 @@ template struct Compute_cartesian_coordinate { #ifdef CGAL_CXX0X typedef decltype(std::declval()[0]) result_type; #else - typedef FT result_type; // FT const& doesn't work with some LA + typedef FT const& result_type; + // FT const& doesn't work with some LA (Eigen2 for instance) so we + // should use plain FT or find a way to detect this. #endif result_type operator()(first_argument_type const& v,int i)const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h new file mode 100644 index 00000000000..87e61d58ae8 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -0,0 +1,54 @@ +#ifndef CGAL_KERNEL_D_CARTESIAN_WRAP_H +#define CGAL_KERNEL_D_CARTESIAN_WRAP_H + +#include +#include +#include +#include + +namespace CGAL { + +template < typename Base_ > +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; + + template struct map_type; +#define CGAL_Kernel_obj(X) typedef X##_d X; \ + template struct map_type { typedef X type; }; +#include + + //TODO: adapt all functors + //TODO: safely apply .rep() to the arguments (and transforming_iterator) + template struct Construct { + typedef typename Kernel_base::template Construct::type B; + struct type { + typedef typename map_result_tag::type result_tag; + typedef typename map_kernel_obj::type result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return result_type(Eval_functor(),B(),std::forward(u)...); + } +#else +#define CODE(Z,N,_) template result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return result_type(Eval_functor(),B(),BOOST_PP_ENUM_PARAMS(N,u)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#endif + }; + }; + template struct Construct { + typedef typename Kernel_base::template Construct::type type; + }; + template struct Construct { + typedef typename Kernel_base::template Construct::type type; + }; +}; + +} //namespace CGAL + +#endif // CGAL_KERNEL_D_CARTESIAN_WRAP_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h new file mode 100644 index 00000000000..ca3f0a30526 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -0,0 +1,245 @@ +#ifndef CGAL_WRAPPER_POINT_D_H +#define CGAL_WRAPPER_POINT_D_H + +#include +#include +#include +#include +#include +#include +#include +#ifndef CGAL_CXX0X +#include +#endif +#include + +namespace CGAL { + +template +class Point_d : public R_::Kernel_base::Point +{ + typedef typename R_::RT RT_; + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename R_::Vector Vector_; + typedef typename Kbase::template Construct::type CPBase; + typedef typename Kbase::template Compute::type CCBase; + + typedef Point_d Self; + BOOST_STATIC_ASSERT((boost::is_same::value)); + +public: + + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef Dimension_tag<0> Feature_dimension; + + typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; + typedef typename Kbase::Point Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX0X + template::type...>,std::tuple >::value>::type> explicit Point_d(U&&...u) + : Rep(CPBase()(std::forward(u)...)){} + +// // called from Construct_point_d +// template explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward(u)...){} + template explicit Point_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward(f)(std::forward(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(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 CODE(Z,N,_) template \ + explicit Point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CPBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template \ + 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 \ + 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,CODE,_) +#undef CODE + + // this one should be implicit + Point_d(Null_vector const& v) + : Rep(CPBase()(v)) {} + +#endif + + typename boost::result_of::type cartesian(int i)const{ + return CCBase()(rep(),i); + } + + + /* + 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::Type & c) const + { + return R().construct_divided_vector_d_object()(*this,c); + } + + typename Qualified_result_of::type + x() const + { + return R().compute_x_3_object()(*this); + } + + typename Qualified_result_of::type + y() const + { + return R().compute_y_3_object()(*this); + } + + typename Qualified_result_of::type + z() const + { + return R().compute_z_3_object()(*this); + } + + typename Qualified_result_of::type + hx() const + { + return R().compute_hx_3_object()(*this); + } + + typename Qualified_result_of::type + hy() const + { + return R().compute_hy_3_object()(*this); + } + + typename Qualified_result_of::type + hz() const + { + return R().compute_hz_3_object()(*this); + } + + typename Qualified_result_of::type + hw() const + { + return R().compute_hw_3_object()(*this); + } + + typename Qualified_result_of::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::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 Qualified_result_of::type + operator[](int i) const + { + return cartesian(i); + } + + Cartesian_const_iterator cartesian_begin() const + { + return typename R::Construct_cartesian_const_iterator_3()(*this); + } + + Cartesian_const_iterator cartesian_end() const + { + return typename R::Construct_cartesian_const_iterator_3()(*this,3); + } + + typename Qualified_result_of::type + squared_length() const + { + return R().compute_squared_length_3_object()(*this); + } +*/ +}; +#if 0 +template Point_d::Point_d(Point_d &)=default; +#endif + +//TODO: IO + +//template +//Vector_d operator+(const Vector_d& v,const Vector_d& w) const +//{ +// return typename R::template Construct::type()(v,w); +//} +// +//template +//Vector_d operator-(const Vector_d& v,const Vector_d& w) const +//{ +// return typename R::template Construct::type()(v,w); +//} + +} //namespace CGAL + +#endif // CGAL_WRAPPER_POINT_D_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h new file mode 100644 index 00000000000..ca779f9fa5f --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -0,0 +1,111 @@ +#ifndef CGAL_WRAPPER_SEGMENT_D_H +#define CGAL_WRAPPER_SEGMENT_D_H + +#include +#include +#include +#include +#include +#include +#include +#ifndef CGAL_CXX0X +#include +#endif +#include + +namespace CGAL { + +template +class Segment_d : public R_::Kernel_base::Segment +{ + typedef typename R_::RT RT_; + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename R_::Point Point_; + typedef typename Kbase::template Construct::type CPBase; + typedef typename Kbase::template Construct::type CSBase; + typedef typename Kbase::template Construct::type CSEBase; + + typedef Segment_d Self; + BOOST_STATIC_ASSERT((boost::is_same::value)); + +public: + + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef Dimension_tag<1> Feature_dimension; + + typedef typename Kbase::Segment Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX0X + template::type...>,std::tuple >::value>::type> explicit Segment_d(U&&...u) + : Rep(CSBase()(std::forward(u)...)){} + +// // called from Construct_point_d +// template explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward(u)...){} + template explicit Segment_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward(f)(std::forward(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(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 CODE(Z,N,_) template \ + explicit Segment_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CSBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template \ + 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 \ + 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,CODE,_) +#undef 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 CGAL + +#endif // CGAL_WRAPPER_SEGMENT_D_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 0324dcf9f88..021360dd477 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -92,9 +92,11 @@ public: template \ 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 \ -// Vector_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ -// : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} + /* + template \ + 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,CODE,_) #undef CODE @@ -231,15 +233,15 @@ template Vector_d::Vector_d(Vector_d &)=default; //TODO: IO template -Vector_d operator+(const Vector_d& v,const Vector_d& w) const +Vector_d operator+(const Vector_d& v,const Vector_d& w) { - return typename R::template Construct::type()(v,w); + return typename R_::template Construct::type()(v,w); } template -Vector_d operator-(const Vector_d& v,const Vector_d& w) const +Vector_d operator-(const Vector_d& v,const Vector_d& w) { - return typename R::template Construct::type()(v,w); + return typename R_::template Construct::type()(v,w); } } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index e5aa4221714..19893cf33ad 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -3,28 +3,36 @@ namespace CGAL { class Null_type {~Null_type();}; // no such object should be created - struct Vector_tag {}; - struct Point_tag {}; - struct Segment_tag {}; - struct Line_tag {}; - struct Direction_tag {}; - struct Ray_tag {}; - struct Bbox_tag {}; + templatestruct map_kernel_obj{typedef Null_type type;}; +#define DECL_OBJ(X) struct X##_tag {}; \ + templatestruct map_kernel_obj{typedef typename K::X type;} + DECL_OBJ(Vector); + DECL_OBJ(Point); + DECL_OBJ(Segment); + DECL_OBJ(Line); + DECL_OBJ(Direction); + DECL_OBJ(Ray); + DECL_OBJ(Bbox); +#undef DECL_OBJ - struct Construct_vector_tag {}; - struct Construct_point_tag {}; - struct Construct_segment_tag {}; - struct Construct_line_tag {}; - struct Construct_direction_tag {}; - struct Construct_ray_tag {}; - //struct Construct_cartesian_const_iterator_tag {}; struct Construct_point_cartesian_const_iterator_tag {}; struct Construct_vector_cartesian_const_iterator_tag {}; - struct Construct_midpoint_tag {}; - struct Construct_segment_extremity_tag {}; - struct Construct_sum_of_vectors_tag {}; - struct Construct_difference_of_vectors_tag {}; - struct Construct_opposite_vector_tag {}; + + templatestruct map_result_tag{typedef Null_type type;}; +#define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ + template<>struct map_result_tag{typedef Y##_tag type;} + DECL_CONSTRUCT(Construct_vector,Vector); + DECL_CONSTRUCT(Construct_point,Point); + DECL_CONSTRUCT(Construct_segment,Segment); + DECL_CONSTRUCT(Construct_line,Line); + DECL_CONSTRUCT(Construct_direction,Direction); + DECL_CONSTRUCT(Construct_ray,Ray); + DECL_CONSTRUCT(Construct_midpoint,Point); + DECL_CONSTRUCT(Construct_segment_extremity,Point); + DECL_CONSTRUCT(Construct_sum_of_vectors,Vector); + DECL_CONSTRUCT(Construct_difference_of_vectors,Vector); + DECL_CONSTRUCT(Construct_opposite_vector,Vector); +#undef DECL_CONSTRUCT struct Compute_cartesian_coordinate_tag {}; struct Compute_homogeneous_coordinate_tag {}; diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index f2f20279977..2a002d6a020 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -11,13 +12,18 @@ typedef CGAL::Cartesian_base_d > K0; typedef CGAL::Cartesian_base_d > KA; typedef CGAL::Cartesian_base_d > KE; #if 0 -typedef K0 K1; +typedef K0 K2; #elif 0 -typedef CGAL::Cartesian_filter_NT K1; -#elif 0 -typedef CGAL::Cartesian_filter_K K1; +typedef CGAL::Cartesian_filter_NT K2; #elif 1 -struct K1: CGAL::Lazy_cartesian,K1>{}; +typedef CGAL::Cartesian_filter_K K2; +#elif 1 +struct K2: CGAL::Lazy_cartesian,K2>{}; +#endif +#if 1 +typedef K2 K1; +#elif 1 +typedef CGAL::Cartesian_wrap K1; #endif typedef K1::Point P; typedef K1::Vector V; From 7a58fd43b4ad5035be60f0c697d3f0e29a960c5d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 13 May 2011 20:23:19 +0000 Subject: [PATCH 019/210] More wrapper ugliness --- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 110 +++++++++++++++++- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 1 + .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 1 + .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 1 + NewKernel_d/include/CGAL/marcutils.h | 13 +++ NewKernel_d/test/NewKernel_d/test.cpp | 4 +- 6 files changed, 124 insertions(+), 6 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 87e61d58ae8..c2d80b9dfdb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -2,11 +2,67 @@ #define CGAL_KERNEL_D_CARTESIAN_WRAP_H #include +#include #include #include #include +#include namespace CGAL { +namespace internal { +BOOST_MPL_HAS_XXX_TRAIT_DEF(Is_wrapper) +template::value> struct Is_wrapper { + enum { value=false }; + typedef Tag_false type; +}; +template struct Is_wrapper { + typedef typename T::Is_wrapper type; + enum { value=type::value }; +}; + +template::value> struct Is_wrapper_iterator { + enum { value=false }; + typedef Tag_false type; +}; +template struct Is_wrapper_iterator : + Is_wrapper::value_type> +{ }; + +struct Forward_rep { +//TODO: make a good C++0X version with perfect forwarding +//#ifdef CGAL_CXX0X +//template ::type>::value&&!Is_wrapper_iterator::type>::value>::type> +//T&& operator()(typename std::remove_reference::type&& t) const {return static_cast(t);}; +//template ::type>::value&&!Is_wrapper_iterator::type>::value>::type> +//T&& operator()(typename std::remove_reference::type& t) const {return static_cast(t);}; +// +//template ::type>::value>::type> +//typename Type_copy_cvref::type::Rep>::type&& +//operator()(T&& t) const { +// return static_cast::type::Rep>::type&&>(t.rep()); +//}; +// +//template ::type>::value>::type> +//transforming_iterator::type> +//operator()(T&& t) const { +// return make_transforming_iterator(std::forward(t),Forward_rep()); +//}; +//#else +template ::value,bool=Is_wrapper_iterator::value> struct result_; +template struct result_{typedef T type;}; +template struct result_{typedef typename decay::type::Rep type;}; +template struct result_{typedef transforming_iterator::type> type;}; +template struct result; +template struct result : result_ {}; + +template typename boost::disable_if,Is_wrapper_iterator >,T>::type const& operator()(T const& t) const {return t;} + +template typename boost::enable_if,T>::type::Rep const& operator()(T const& t) const {return t.rep();} + +template transforming_iterator,T>::type> operator()(T const& t) const {return make_transforming_iterator(t,Forward_rep());} +//#endif +}; +} template < typename Base_ > struct Cartesian_wrap : public Base_ @@ -21,8 +77,6 @@ struct Cartesian_wrap : public Base_ template struct map_type { typedef X type; }; #include - //TODO: adapt all functors - //TODO: safely apply .rep() to the arguments (and transforming_iterator) template struct Construct { typedef typename Kernel_base::template Construct::type B; struct type { @@ -30,23 +84,71 @@ struct Cartesian_wrap : public Base_ typedef typename map_kernel_obj::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ - return result_type(Eval_functor(),B(),std::forward(u)...); + return result_type(Eval_functor(),B(),internal::Forward_rep()(u)...); } #else +#define VAR(Z,N,_) internal::Forward_rep()(u##N) #define CODE(Z,N,_) template result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return result_type(Eval_functor(),B(),BOOST_PP_ENUM_PARAMS(N,u)); \ + return result_type(Eval_functor(),B(),BOOST_PP_ENUM(N,VAR,)); \ } BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#undef VAR #endif }; }; + + //TODO: adapt all functors + //TODO: safely apply .rep() to the arguments (and transforming_iterator) + //FIXME: looks like only those 2 are missing template struct Construct { typedef typename Kernel_base::template Construct::type type; }; template struct Construct { typedef typename Kernel_base::template Construct::type type; }; + + template struct Predicate { + typedef typename Kernel_base::template Predicate::type B; + struct type { + typedef typename B::result_type result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return B()(internal::Forward_rep()(u)...); + } +#else +#define VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CODE(Z,N,_) template result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return B()(BOOST_PP_ENUM(N,VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#undef VAR +#endif + }; + }; + template struct Compute { + typedef typename Kernel_base::template Compute::type B; + struct type { + typedef typename B::result_type result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return B()(internal::Forward_rep()(u)...); + } +#else +#define VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CODE(Z,N,_) template result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return B()(BOOST_PP_ENUM(N,VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#undef VAR +#endif + }; + }; }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index ca3f0a30526..c3d9b48f54d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -30,6 +30,7 @@ class Point_d : public R_::Kernel_base::Point public: + typedef Tag_true Is_wrapper; typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<0> Feature_dimension; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index ca779f9fa5f..38528f878db 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -31,6 +31,7 @@ class Segment_d : public R_::Kernel_base::Segment public: + typedef Tag_true Is_wrapper; typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<1> Feature_dimension; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 021360dd477..dc318909c77 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -30,6 +30,7 @@ class Vector_d : public R_::Kernel_base::Vector public: + typedef Tag_true Is_wrapper; typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<0> Feature_dimension; diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 1425c78b892..844b97a2933 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -129,6 +129,19 @@ namespace CGAL { #else template struct decay : boost::remove_cv::type> {}; #endif + + template struct Type_copy_ref { typedef U type; }; + template struct Type_copy_ref { typedef U& type; }; +#ifdef CGAL_CXX0X + template struct Type_copy_ref { typedef U&& type; }; +#endif + template struct Type_copy_cv { typedef U type; }; + template struct Type_copy_cv { typedef U const type; }; + template struct Type_copy_cv { typedef U volatile type; }; + template struct Type_copy_cv { typedef U const volatile type; }; + + template struct Type_copy_cvref : + Type_copy_ref::type,U>::type> {}; } #endif diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 2a002d6a020..9d131a9e8f6 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -15,12 +15,12 @@ typedef CGAL::Cartesian_base_d > KE; typedef K0 K2; #elif 0 typedef CGAL::Cartesian_filter_NT K2; -#elif 1 +#elif 0 typedef CGAL::Cartesian_filter_K K2; #elif 1 struct K2: CGAL::Lazy_cartesian,K2>{}; #endif -#if 1 +#if 0 typedef K2 K1; #elif 1 typedef CGAL::Cartesian_wrap K1; From 8d0384fb9e212fd1ea122647356acbc753f4cc40 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 14 May 2011 10:30:38 +0000 Subject: [PATCH 020/210] Start on a reference counting wrapper to point --- NewKernel_d/include/CGAL/Handle_for.h | 316 ++++++++++++++++++ .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 1 + .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 245 ++++++++++++++ 3 files changed, 562 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Handle_for.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h diff --git a/NewKernel_d/include/CGAL/Handle_for.h b/NewKernel_d/include/CGAL/Handle_for.h new file mode 100644 index 00000000000..d647e0d427d --- /dev/null +++ b/NewKernel_d/include/CGAL/Handle_for.h @@ -0,0 +1,316 @@ +// Copyright (c) 1999,2001,2003 Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), +// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg +// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), +// and Tel-Aviv University (Israel). All rights reserved. +// +// 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; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// 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) : Stefan Schirra, Sylvain Pion + +#ifndef CGAL_HANDLE_FOR_H +#define CGAL_HANDLE_FOR_H + +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable:4345) // Avoid warning http://msdn.microsoft.com/en-us/library/wewb47ee(VS.80).aspx +#endif +namespace CGAL { + +template +class Handle_for +{ + // Wrapper that adds the reference counter. + struct RefCounted { + T t; + unsigned int count; + }; + + typedef typename Alloc::template rebind::other Allocator; + typedef typename Allocator::pointer pointer; + + static Allocator allocator; + pointer ptr_; + +public: + + typedef T element_type; + + typedef std::ptrdiff_t Id_type ; + + Handle_for() + : ptr_(allocator.allocate(1)) + { + new (&(ptr_->t)) element_type(); // we get the warning here + ptr_->count = 1; + } + + Handle_for(const element_type& t) + : ptr_(allocator.allocate(1)) + { + new (&(ptr_->t)) element_type(t); + ptr_->count = 1; + } + +#ifndef CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE + Handle_for(element_type && t) + : ptr_(allocator.allocate(1)) + { + new (&(ptr_->t)) element_type(std::move(t)); + ptr_->count = 1; + } +#endif + +/* I comment this one for now, since it's preventing the automatic conversions + to take place. We'll see if it's a problem later. + template < typename T1 > + Handle_for(const T1& t1) + : ptr_(allocator.allocate(1)) + { + new (&(ptr_->t)) T(t1); + ptr_->count = 1; + } +*/ + +#if !defined CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES && !defined CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE + template < typename T1, typename T2, typename... Args > + Handle_for(T1 && t1, T2 && t2, Args && ... args) + : ptr_(allocator.allocate(1)) + { + new (&(ptr_->t)) element_type(std::forward(t1), std::forward(t2), std::forward(args)...); + ptr_->count = 1; + } + + template < typename F, typename... Args > + Handle_for(Eval_functor &&, F && f, Args && ... args) + : ptr_(allocator.allocate(1)) + { + new (&(ptr_->t)) element_type(std::forward(f)(std::forward(args)...)); + ptr_->count = 1; + } +#else +#define CODE(Z,N,_) template \ + Handle_for(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : ptr_(allocator.allocate(1)) \ + { \ + new (&(ptr_->t)) element_type(BOOST_PP_ENUM_PARAMS(N,t)); \ + ptr_->count = 1; \ + } + BOOST_PP_REPEAT_FROM_TO(2,11,CODE,_) +#undef CODE +#define CODE(Z,N,_) template \ + Handle_for(Eval_functor,F const&f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : ptr_(allocator.allocate(1)) \ + { \ + new (&(ptr_->t)) element_type(f(BOOST_PP_ENUM_PARAMS(N,t))); \ + ptr_->count = 1; \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + + Handle_for(const Handle_for& h) + : ptr_(h.ptr_) + { + ++(ptr_->count); + } + + Handle_for& + operator=(const Handle_for& h) + { + Handle_for tmp = h; + swap(tmp); + return *this; + } + + Handle_for& + operator=(const element_type &t) + { + if (is_shared()) + *this = Handle_for(t); + else + ptr_->t = t; + + return *this; + } + +#ifndef CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE + // Note : I don't see a way to make a useful move constructor, apart + // from e.g. using NULL as a ptr value, but this is drastic. + + Handle_for& + operator=(Handle_for && h) + { + swap(h); + return *this; + } + + Handle_for& + operator=(element_type && t) + { + if (is_shared()) + *this = Handle_for(std::move(t)); + else + ptr_->t = std::move(t); + + return *this; + } +#endif + + ~Handle_for() + { + if (! is_shared() ) { + allocator.destroy( ptr_); + allocator.deallocate( ptr_, 1); + } + else + --(ptr_->count); + } + + void + initialize_with(const element_type& t) + { + // kept for backward compatibility. Use operator=(t) instead. + *this = t; + } + + Id_type id() const { return Ptr() - static_cast(0); } + + bool identical(const Handle_for& h) const { return Ptr() == h.Ptr(); } + + + // Ptr() is the "public" access to the pointer to the object. + // The non-const version asserts that the instance is not shared. + const element_type * + Ptr() const + { + return &(ptr_->t); + } + + /* + // The assertion triggers in a couple of places, so I comment it for now. + T * + Ptr() + { + CGAL_assertion(!is_shared()); + return &(ptr_->t); + } + */ + + bool + is_shared() const + { + return ptr_->count > 1; + } + + bool + unique() const + { + return !is_shared(); + } + + long + use_count() const + { + return ptr_->count; + } + + void + swap(Handle_for& h) + { + std::swap(ptr_, h.ptr_); + } + +protected: + + void + copy_on_write() + { + if ( is_shared() ) + { + pointer tmp_ptr = allocator.allocate(1); + new (&(tmp_ptr->t)) element_type(ptr_->t); + tmp_ptr->count = 1; + --(ptr_->count); + ptr_ = tmp_ptr; + } + } + + // ptr() is the protected access to the pointer. Both const and non-const. + // Redundant with Ptr(). + element_type * + ptr() + { return &(ptr_->t); } + + const element_type * + ptr() const + { return &(ptr_->t); } +}; + + +template +typename Handle_for::Allocator +Handle_for::allocator; + +template +inline +void +swap(Handle_for &h1, Handle_for &h2) +{ + h1.swap(h2); +} + +template +inline +bool +identical(const Handle_for &h1, + const Handle_for &h2) +{ + return h1.identical(h2); +} + +template inline bool identical(const T &t1, const T &t2) { return &t1 == &t2; } + +template +inline +const T& +get(const Handle_for &h) +{ + return *(h.Ptr()); +} + +template +inline +const T& +get(const T &t) +{ + return t; +} + +} //namespace CGAL + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +#endif // CGAL_HANDLE_FOR_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index c2d80b9dfdb..42ff052eab4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -129,6 +129,7 @@ struct Cartesian_wrap : public Base_ #endif }; }; + //TODO: if B is Null_functor, let type be the same template struct Compute { typedef typename Kernel_base::template Compute::type B; struct type { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h new file mode 100644 index 00000000000..57ef8f5e719 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -0,0 +1,245 @@ +#ifndef CGAL_WRAPPER_POINT_RC_D_H +#define CGAL_WRAPPER_POINT_RC_D_H + +#include +#include +#include +#include +#include +#include +#include +#ifndef CGAL_CXX0X +#include +#endif +#include + +namespace CGAL { + +template +class Point_rc_d +{ + typedef typename R_::RT RT_; + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename R_::Vector Vector_; + typedef typename Kbase::template Construct::type CPBase; + typedef typename Kbase::template Compute::type CCBase; + + typedef Point_rc_d Self; + BOOST_STATIC_ASSERT((boost::is_same::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef Dimension_tag<0> Feature_dimension; + + typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; + typedef typename Kbase::Point Rep; + typedef Handle_for Data; + +private: + Data data; +public: + + const Rep& rep() const + { + return CGAL::get(data); + } + + typedef R_ R; + +#ifdef CGAL_CXX0X + template::type...>,std::tuple >::value>::type> explicit Point_rc_d(U&&...u) + : Rep(Eval_functor(),CPBase(),std::forward(u)...){} + +// // called from Construct_point_d +// template explicit Point_rc_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward(u)...){} + template explicit Point_rc_d(Eval_functor&&,F&&f,U&&...u) + : Rep(Eval_functor(),std::forward(f),std::forward(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_rc_d(Rep const& v) : data(v) {} + Point_rc_d(Rep& v) : data(static_cast(v)) {} + Point_rc_d(Rep&& v) : data(std::move(v)) {} + + // this one should be implicit + Point_rc_d(Origin const& v) + : data(Eval_functor(),CPBase(),v) {} + Point_rc_d(Origin& v) + : data(Eval_functor(),CPBase(),v) {} + Point_rc_d(Origin&& v) + : data(Eval_functor(),CPBase(),std::move(v)) {} + +#else + + Point_rc_d() : data(CPBase()()) {} + + Point_rc_d(Rep const& v) : data(v) {} // try not to use it + +#define CODE(Z,N,_) template \ + explicit Point_rc_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : data(Eval_functor(),CPBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ + \ + template \ + Point_rc_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : data(Eval_functor(),f,BOOST_PP_ENUM_PARAMS(N,t)) {} + /* + template \ + 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,CODE,_) +#undef CODE + + // this one should be implicit + Point_rc_d(Null_vector const& v) + : data(Eval_functor(),CPBase(),v) {} + +#endif + + typename boost::result_of::type cartesian(int i)const{ + return CCBase()(rep(),i); + } + + + /* + 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::Type & c) const + { + return R().construct_divided_vector_d_object()(*this,c); + } + + typename Qualified_result_of::type + x() const + { + return R().compute_x_3_object()(*this); + } + + typename Qualified_result_of::type + y() const + { + return R().compute_y_3_object()(*this); + } + + typename Qualified_result_of::type + z() const + { + return R().compute_z_3_object()(*this); + } + + typename Qualified_result_of::type + hx() const + { + return R().compute_hx_3_object()(*this); + } + + typename Qualified_result_of::type + hy() const + { + return R().compute_hy_3_object()(*this); + } + + typename Qualified_result_of::type + hz() const + { + return R().compute_hz_3_object()(*this); + } + + typename Qualified_result_of::type + hw() const + { + return R().compute_hw_3_object()(*this); + } + + typename Qualified_result_of::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::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 Qualified_result_of::type + operator[](int i) const + { + return cartesian(i); + } + + Cartesian_const_iterator cartesian_begin() const + { + return typename R::Construct_cartesian_const_iterator_3()(*this); + } + + Cartesian_const_iterator cartesian_end() const + { + return typename R::Construct_cartesian_const_iterator_3()(*this,3); + } + + typename Qualified_result_of::type + squared_length() const + { + return R().compute_squared_length_3_object()(*this); + } +*/ +}; +#if 0 +template Point_d::Point_d(Point_d &)=default; +#endif + +//TODO: IO + +//template +//Vector_d operator+(const Vector_d& v,const Vector_d& w) const +//{ +// return typename R::template Construct::type()(v,w); +//} +// +//template +//Vector_d operator-(const Vector_d& v,const Vector_d& w) const +//{ +// return typename R::template Construct::type()(v,w); +//} + +} //namespace CGAL + +#endif // CGAL_WRAPPER_POINT_RC_D_H From 372dae50098d6a453d5a04f173fdbf518b9c87b3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 14 May 2011 13:37:19 +0000 Subject: [PATCH 021/210] continue refcount --- NewKernel_d/include/CGAL/Handle_for.h | 7 + .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 4 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 161 +----------------- .../Kernel_d/function_objects_cartesian.h | 5 +- .../include/CGAL/Kernel_d/interface_macros.h | 2 + NewKernel_d/include/CGAL/functor_tags.h | 22 ++- 6 files changed, 34 insertions(+), 167 deletions(-) diff --git a/NewKernel_d/include/CGAL/Handle_for.h b/NewKernel_d/include/CGAL/Handle_for.h index d647e0d427d..047a6657fab 100644 --- a/NewKernel_d/include/CGAL/Handle_for.h +++ b/NewKernel_d/include/CGAL/Handle_for.h @@ -127,6 +127,13 @@ public: } BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) #undef CODE + template + Handle_for(Eval_functor,F const&f) + : ptr_(allocator.allocate(1)) + { + new (&(ptr_->t)) element_type(f()); + ptr_->count = 1; + } #endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES Handle_for(const Handle_for& h) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index c3d9b48f54d..e7f85a512f8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -103,8 +103,8 @@ public: #undef CODE // this one should be implicit - Point_d(Null_vector const& v) - : Rep(CPBase()(v)) {} + Point_d(Origin const& o) + : Rep(CPBase()(o)) {} #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index 57ef8f5e719..b9fbedc8366 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -13,15 +13,15 @@ #endif #include +// no need for a fancy interface here, people can use the Point_d wrapper on +// top. + namespace CGAL { template class Point_rc_d { - typedef typename R_::RT RT_; - typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::Vector Vector_; typedef typename Kbase::template Construct::type CPBase; typedef typename Kbase::template Compute::type CCBase; @@ -29,6 +29,7 @@ class Point_rc_d BOOST_STATIC_ASSERT((boost::is_same::value)); public: + typedef R_ R; typedef Tag_true Is_wrapper; typedef typename R_::Default_ambient_dimension Ambient_dimension; @@ -47,25 +48,13 @@ public: return CGAL::get(data); } - typedef R_ R; - #ifdef CGAL_CXX0X template::type...>,std::tuple >::value>::type> explicit Point_rc_d(U&&...u) : Rep(Eval_functor(),CPBase(),std::forward(u)...){} -// // called from Construct_point_d -// template explicit Point_rc_d(Eval_functor&&,U&&...u) -// : Rep(Eval_functor(), std::forward(u)...){} template explicit Point_rc_d(Eval_functor&&,F&&f,U&&...u) : Rep(Eval_functor(),std::forward(f),std::forward(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_rc_d(Rep const& v) : data(v) {} Point_rc_d(Rep& v) : data(static_cast(v)) {} @@ -81,7 +70,7 @@ public: #else - Point_rc_d() : data(CPBase()()) {} + Point_rc_d() : data(Eval_functor(),CPBase()) {} Point_rc_d(Rep const& v) : data(v) {} // try not to use it @@ -92,153 +81,17 @@ public: template \ Point_rc_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ : data(Eval_functor(),f,BOOST_PP_ENUM_PARAMS(N,t)) {} - /* - template \ - 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,CODE,_) #undef CODE // this one should be implicit - Point_rc_d(Null_vector const& v) - : data(Eval_functor(),CPBase(),v) {} + Point_rc_d(Origin const& o) + : data(Eval_functor(),CPBase(),o) {} #endif - typename boost::result_of::type cartesian(int i)const{ - return CCBase()(rep(),i); - } - - - /* - 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::Type & c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - typename Qualified_result_of::type - x() const - { - return R().compute_x_3_object()(*this); - } - - typename Qualified_result_of::type - y() const - { - return R().compute_y_3_object()(*this); - } - - typename Qualified_result_of::type - z() const - { - return R().compute_z_3_object()(*this); - } - - typename Qualified_result_of::type - hx() const - { - return R().compute_hx_3_object()(*this); - } - - typename Qualified_result_of::type - hy() const - { - return R().compute_hy_3_object()(*this); - } - - typename Qualified_result_of::type - hz() const - { - return R().compute_hz_3_object()(*this); - } - - typename Qualified_result_of::type - hw() const - { - return R().compute_hw_3_object()(*this); - } - - typename Qualified_result_of::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::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 Qualified_result_of::type - operator[](int i) const - { - return cartesian(i); - } - - Cartesian_const_iterator cartesian_begin() const - { - return typename R::Construct_cartesian_const_iterator_3()(*this); - } - - Cartesian_const_iterator cartesian_end() const - { - return typename R::Construct_cartesian_const_iterator_3()(*this,3); - } - - typename Qualified_result_of::type - squared_length() const - { - return R().compute_squared_length_3_object()(*this); - } -*/ }; -#if 0 -template Point_d::Point_d(Point_d &)=default; -#endif - -//TODO: IO - -//template -//Vector_d operator+(const Vector_d& v,const Vector_d& w) const -//{ -// return typename R::template Construct::type()(v,w); -//} -// -//template -//Vector_d operator-(const Vector_d& v,const Vector_d& w) const -//{ -// return typename R::template Construct::type()(v,w); -//} } //namespace CGAL 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 93d2f16d3cb..a689de321ee 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -162,12 +162,13 @@ template struct Compute_squared_distance { } }; -template struct Less_coordinate { +template struct Less_cartesian_coordinate { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; typedef typename R::template Compute::type Cc; - // This is_exact thing should be reengineered. + // 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; template diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 3da99fa182b..af5d45f04f6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -62,6 +62,8 @@ CGAL_Kernel_comp1(Compute_cartesian_coordinate, CGAL_Kernel_pred(Orientation, orientation_object) +CGAL_Kernel_pred(Less_cartesian_coordinate, + less_cartesian_coordinate_object) #undef CGAL_Kernel_pred #undef CGAL_Kernel_comp diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 19893cf33ad..53d2c663f49 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -15,6 +15,7 @@ namespace CGAL { DECL_OBJ(Bbox); #undef DECL_OBJ + //TODO: split into _begin and _end ? struct Construct_point_cartesian_const_iterator_tag {}; struct Construct_vector_cartesian_const_iterator_tag {}; @@ -34,15 +35,18 @@ namespace CGAL { DECL_CONSTRUCT(Construct_opposite_vector,Vector); #undef DECL_CONSTRUCT - struct Compute_cartesian_coordinate_tag {}; - struct Compute_homogeneous_coordinate_tag {}; - struct Compute_squared_distance_tag {}; - struct Compute_squared_length_tag {}; +#define DECL_COMPUTE(X) struct X##_tag {} + DECL_COMPUTE(Compute_cartesian_coordinate); + DECL_COMPUTE(Compute_homogeneous_coordinate); + DECL_COMPUTE(Compute_squared_distance); + DECL_COMPUTE(Compute_squared_length); +#undef DECL_COMPUTE - struct Predicate_less_cartesian_coordinate_tag {}; - //FIXME: choose a convention - struct Predicate_orientation_tag {}; - struct Orientation_tag {}; - struct Predicate_in_sphere_tag {}; + //FIXME: choose a convention: prefix with Predicate_ ? +#define DECL_PREDICATE(X) struct X##_tag {} + DECL_PREDICATE(Less_cartesian_coordinate); + DECL_PREDICATE(Orientation); + DECL_PREDICATE(In_sphere); +#undef DECL_PREDICATE } #endif // CGAL_FUNCTOR_TAGS_H From c17a1b2f6d369743440a06452ca0589bf8368c0a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 14 May 2011 13:38:01 +0000 Subject: [PATCH 022/210] forgot to svn add --- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h new file mode 100644 index 00000000000..d8aa326ef08 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -0,0 +1,98 @@ +#ifndef CGAL_WRAPPER_VECTOR_RC_D_H +#define CGAL_WRAPPER_VECTOR_RC_D_H + +#include +#include +#include +#include +#include +#include +#include +#ifndef CGAL_CXX0X +#include +#endif +#include + +// no need for a fancy interface here, people can use the Vector_d wrapper on +// top. + +namespace CGAL { + +template +class Vector_rc_d +{ + typedef typename R_::Kernel_base Kbase; + typedef typename Kbase::template Construct::type CPBase; + typedef typename Kbase::template Compute::type CCBase; + + typedef Vector_rc_d Self; + BOOST_STATIC_ASSERT((boost::is_same::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 R_::Vector_cartesian_const_iterator Cartesian_const_iterator; + typedef typename Kbase::Vector Rep; + typedef Handle_for Data; + +private: + Data data; +public: + + const Rep& rep() const + { + return CGAL::get(data); + } + +#ifdef CGAL_CXX0X + template::type...>,std::tuple >::value>::type> explicit Vector_rc_d(U&&...u) + : Rep(Eval_functor(),CPBase(),std::forward(u)...){} + + template explicit Vector_rc_d(Eval_functor&&,F&&f,U&&...u) + : Rep(Eval_functor(),std::forward(f),std::forward(u)...){} + + // try not to use these + Vector_rc_d(Rep const& v) : data(v) {} + Vector_rc_d(Rep& v) : data(static_cast(v)) {} + Vector_rc_d(Rep&& v) : data(std::move(v)) {} + + // this one should be implicit + Vector_rc_d(Null_vector const& v) + : data(Eval_functor(),CPBase(),v) {} + Vector_rc_d(Null_vector& v) + : data(Eval_functor(),CPBase(),v) {} + Vector_rc_d(Null_vector&& v) + : data(Eval_functor(),CPBase(),std::move(v)) {} + +#else + + Vector_rc_d() : data(Eval_functor(),CPBase()) {} + + Vector_rc_d(Rep const& v) : data(v) {} // try not to use it + +#define CODE(Z,N,_) template \ + explicit Vector_rc_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : data(Eval_functor(),CPBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ + \ + template \ + Vector_rc_d(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,CODE,_) +#undef CODE + + // this one should be implicit + Vector_rc_d(Null_vector const& v) + : data(Eval_functor(),CPBase(),v) {} + +#endif + +}; + +} //namespace CGAL + +#endif // CGAL_WRAPPER_VECTOR_RC_D_H From 369007296479a0dd88f2ecc461feb7687b2bb847 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 17 May 2011 15:21:49 +0000 Subject: [PATCH 023/210] Use a single Functor template regrouping Predicate, Construct and Compute, and a map to know the category of a functor. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 28 ++---- .../CGAL/Kernel_d/Cartesian_change_FT.h | 20 ++-- .../CGAL/Kernel_d/Cartesian_complete.h | 98 +++++++------------ .../CGAL/Kernel_d/Cartesian_converter.h | 12 +-- .../CGAL/Kernel_d/Cartesian_filter_K.h | 13 ++- .../CGAL/Kernel_d/Cartesian_filter_NT.h | 9 +- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 36 ++++--- NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 2 +- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 75 ++++++-------- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 4 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 4 +- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 6 +- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 10 +- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 4 +- .../Kernel_d/function_objects_cartesian.h | 26 ++--- NewKernel_d/include/CGAL/functor_tags.h | 27 +++-- NewKernel_d/test/NewKernel_d/test.cpp | 14 +-- 17 files changed, 182 insertions(+), 206 deletions(-) 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 fc8f1d25c57..ae02192b38e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -72,45 +72,37 @@ struct Cartesian_LA_base_d : public Dimension_base #endif // new way - template struct Construct { + template struct Functor { typedef Null_functor type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_LA_vector type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_LA_vector type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_sum_of_vectors type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_difference_of_vectors type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_opposite_vector type; }; - template struct Construct { + template struct Functor { typedef CartesianDVectorBase::Construct_midpoint type; }; - - template struct Compute { - typedef Null_functor type; - }; - template struct Compute { + template struct Functor { typedef CartesianDVectorBase::Compute_cartesian_coordinate type; }; - template struct Predicate { - typedef Null_functor type; - }; - CGAL_CONSTEXPR Cartesian_LA_base_d(){} CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} }; 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 25a2b11a86c..dbe3780d0e1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -42,7 +42,7 @@ struct Cartesian_change_FT_base : public //FIXME: what if the functor's constructor takes a kernel as argument? template struct Construct_cartesian_const_iterator_ { - typedef typename Kernel_base::template Construct::type Functor_base; + typedef typename Kernel_base::template Functor::type Functor_base; Functor_base f; typedef Type result_type; template @@ -58,7 +58,7 @@ struct Cartesian_change_FT_base : public typedef Construct_cartesian_const_iterator_ Construct_vector_cartesian_const_iterator; struct Compute_cartesian_coordinate { - typedef typename Kernel_base::template Compute::type Functor_base; + typedef typename Kernel_base::template Functor::type Functor_base; Functor_base f; typedef FT result_type; template @@ -67,17 +67,19 @@ struct Cartesian_change_FT_base : public } }; - template struct Compute { typedef Null_functor type; }; - template struct Compute { + template::type> struct Functor : + Kernel_base::template Functor { }; + template struct Functor + { typedef Null_functor type; }; + template struct Functor + { typedef Null_functor type; }; + template struct Functor { typedef Compute_cartesian_coordinate type; }; - template struct Predicate { typedef Null_functor type; }; - template struct Construct : - Kernel_base::template Construct { }; - template struct Construct { + template struct Functor { typedef Construct_point_cartesian_const_iterator type; }; - template struct Construct { + template struct Functor { typedef Construct_vector_cartesian_const_iterator type; }; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 683931c6174..78518826e9e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -16,6 +16,25 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(Direction) BOOST_MPL_HAS_XXX_TRAIT_DEF(Line) } +template struct Cartesian_define_all_functors +: public R_ +{ + typedef R_ Kernel_base; + template struct Functor + : Kernel_base::template Functor + { }; +#define CGAL_Kernel_cons2(F,f) \ + template struct Functor { \ + typedef CartesianDKernelFunctors::F type; \ + }; + //type f() const { return type(); } +#define CGAL_Kernel_pred(F,f) CGAL_Kernel_cons2(F,f) +#define CGAL_Kernel_comp2(F,f) CGAL_Kernel_cons2(F,f) + +#include + +}; + template struct Cartesian_complete_types : public R_ { @@ -29,90 +48,47 @@ template struct Cartesian_complete : public R_ { typedef R_ Kernel_base; - template struct Construct { - typedef typename Kernel_base::template Construct::type Base_functor; - typedef typename boost::mpl::if_, - typename Cartesian_complete_constructors::template Construct::type, + template::type> struct Functor : + R_::template Functor {}; + template struct Functor { + typedef typename Kernel_base::template Functor::type Base_functor; + typedef typename boost::mpl::if_c::value, + typename Cartesian_define_all_functors::template Functor::type, Base_functor>::type type; }; }; -template struct Cartesian_complete_constructors -: public R_ -{ - typedef R_ Kernel_base; - template struct Construct - : Kernel_base::template Construct - { }; -#define CGAL_Kernel_cons2(F,f) \ - template struct Construct { \ - typedef CartesianDKernelFunctors::F type; \ - type f() const { return type(); } \ - }; -#include - -}; - - template struct Cartesian_complete_predicates : public R_ { typedef R_ Kernel_base; - template struct Predicate { - typedef typename Kernel_base::template Predicate::type Base_functor; - typedef typename boost::mpl::if_, - typename Cartesian_complete_predicates::template Predicate::type, + template::type> struct Functor : + R_::template Functor {}; + template struct Functor { + typedef typename Kernel_base::template Functor::type Base_functor; + typedef typename boost::mpl::if_c::value, + typename Cartesian_define_all_functors::template Functor::type, Base_functor>::type type; }; }; -template struct Cartesian_complete_predicates -: public R_ -{ - typedef R_ Kernel_base; - template struct Predicate - : Kernel_base::template Predicate - { }; -#define CGAL_Kernel_pred(F,f) \ - template struct Predicate { \ - typedef CartesianDKernelFunctors::F type; \ - type f() const { return type(); } \ - }; -#include - -}; - - template struct Cartesian_complete_computes : public R_ { typedef R_ Kernel_base; - template struct Compute { - typedef typename Kernel_base::template Compute::type Base_functor; - typedef typename boost::mpl::if_, - typename Cartesian_complete_computes::template Compute::type, + template::type> struct Functor : + R_::template Functor {}; + template struct Functor { + typedef typename Kernel_base::template Functor::type Base_functor; + typedef typename boost::mpl::if_c::value, + typename Cartesian_define_all_functors::template Functor::type, Base_functor>::type type; }; }; -template struct Cartesian_complete_computes -: public R_ -{ - typedef R_ Kernel_base; - template struct Compute - : Kernel_base::template Compute - { }; -#define CGAL_Kernel_comp2(F,f) \ - template struct Compute { \ - typedef CartesianDKernelFunctors::F type; \ - type f() const { return type(); } \ - }; -#include - -}; } #endif // CGAL_KERNEL_D_CARTESIAN_COMPLETE_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index 31e4e7f4d50..c39e53e9062 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -50,21 +50,21 @@ template class CartesianD_converter { } typename K2::Point operator()(typename K1::Point const& p)const{ - typename K1::template Construct::type i; - typename K2::template Construct::type cp; + typename K1::template Functor::type i; + typename K2::template Functor::type cp; return cp(operator()(i.begin(p)),operator()(i.end(p))); } typename K2::Vector operator()(typename First_if_different::Type const& p)const{ - typename K1::template Construct::type i; - typename K2::template Construct::type cv; + typename K1::template Functor::type i; + typename K2::template Functor::type cv; return cv(operator()(i.begin(p)),operator()(i.end(p))); } typename K2::Segment operator()(typename K1::Segment const& s)const{ - typename K1::template Construct::type f; + typename K1::template Functor::type f; //FIXME: should replace source and target by a functor - typename K2::template Construct::type cs; + typename K2::template Functor::type cs; return cs(operator()(f(s,0)),operator()(f(s,1))); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index 343c1eac928..bd7e0ad3973 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -18,11 +18,18 @@ struct Cartesian_filter_K : public Base_ typedef CartesianD_converter C2A; typedef CartesianD_converter C2E; - template struct Predicate { - typedef typename AK::template Predicate::type AP; - typedef typename EK::template Predicate::type EP; + template::type> struct Functor : + Kernel_base::template Functor {}; + template struct Functor { + typedef typename AK::template Functor::type AP; + typedef typename EK::template Functor::type EP; typedef Filtered_predicate type; }; +// TODO: +// template struct Functor : +// Kernel_base::template Functor {}; +// TODO: +// detect when Less_cartesian_coordinate doesn't need filtering }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h index 29c70024ce6..01f94f5c484 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -17,11 +17,13 @@ struct Cartesian_filter_NT : public Base_ typedef typename internal::Exact_type_selector::Type Exact_nt; typedef Cartesian_change_FT K2; - template struct Predicate { + template::type> struct Functor : + Kernel_base::template Functor {}; + template struct Functor { struct type { //TODO: use compression (derive from a compressed_pair?) - typedef typename K1::template Predicate::type P1; P1 p1; - typedef typename K2::template Predicate::type P2; P2 p2; + typedef typename K1::template Functor::type P1; P1 p1; + typedef typename K2::template Functor::type P2; P2 p2; typedef typename P2::result_type result_type; //FIXME: if predicate's constructor takes a kernel as argument, how do we translate that? @@ -43,7 +45,6 @@ struct Cartesian_filter_NT : public Base_ return p2(std::forward(u)...); } #else - //FIXME: usual boost preprocessor magic result_type operator()()const{ // does it make sense to have 0 argument? { Protect_FPU_rounding p; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 4a7974eb326..8ee8ff36500 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -8,6 +8,7 @@ namespace CGAL { + //TODO: ? use Lazy_cartesian instead of Kernel ? template struct Lazy_cartesian : Dimension_base { @@ -49,27 +50,29 @@ struct Lazy_cartesian : Dimension_base #include - template struct Predicate { - typedef typename Approximate_kernel::template Predicate::type FA; - typedef typename Exact_kernel::template Predicate::type FE; + template::type> struct Functor { + typedef Null_functor type; + }; + //FIXME: what do we do with D here? + template struct Functor { + typedef typename Approximate_kernel::template Functor::type FA; + typedef typename Exact_kernel::template Functor::type FE; typedef Filtered_predicate type; }; - template struct Compute { - typedef typename Approximate_kernel::template Compute::type FA; - typedef typename Exact_kernel::template Compute::type FE; + template struct Functor { + typedef typename Approximate_kernel::template Functor::type FA; + typedef typename Exact_kernel::template Functor::type FE; typedef Lazy_construction_nt type; }; - template struct Construct { - typedef typename Approximate_kernel::template Construct::type FA; - typedef typename Exact_kernel::template Construct::type FE; + template struct Functor { + typedef typename Approximate_kernel::template Functor::type FA; + typedef typename Exact_kernel::template Functor::type FE; typedef Lazy_construction type; }; - typedef Iterator_from_indices::type> Point_cartesian_const_iterator; - typedef Iterator_from_indices::type> Vector_cartesian_const_iterator; - //TODO: - //typedef ????????? Cartesian_const_iterator; - //typedef ????????? Construct_cartesian_const_iterator + typedef Iterator_from_indices::type> Point_cartesian_const_iterator; + typedef Iterator_from_indices::type> Vector_cartesian_const_iterator; + template struct Construct_iter { typedef U result_type; @@ -82,12 +85,13 @@ struct Lazy_cartesian : Dimension_base return result_type(t,Self().dimension()); } }; - template struct Construct { + template struct Functor { typedef Construct_iter type; }; - template struct Construct { + template struct Functor { typedef Construct_iter type; }; + //TODO: what about other functors of the Misc category? }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index 8a7120aa0c2..829a8f1d8e7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -8,7 +8,7 @@ template class Segmentd { typedef typename R_::FT FT_; typedef typename R_::Point Point_; typedef typename R_::Vector Vector_; - typedef typename R_::template Construct::type Cv_; + typedef typename R_::template Functor::type Cv_; // typedef typename R_::Compute_squared_distance Csd_; typedef std::pair Data_; Data_ data; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 42ff052eab4..029acb49bc5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -77,8 +77,30 @@ struct Cartesian_wrap : public Base_ template struct map_type { typedef X type; }; #include - template struct Construct { - typedef typename Kernel_base::template Construct::type B; + //TODO:FIXME: if B is Null_functor, let type be the same + template::type> struct Functor { + typedef typename Kernel_base::template Functor::type B; + struct type { + typedef typename B::result_type result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return B()(internal::Forward_rep()(u)...); + } +#else +#define VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CODE(Z,N,_) template result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return B()(BOOST_PP_ENUM(N,VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#undef VAR +#endif + }; + }; + + template struct Functor { + typedef typename Kernel_base::template Functor::type B; struct type { typedef typename map_result_tag::type result_tag; typedef typename map_kernel_obj::type result_type; @@ -102,54 +124,13 @@ struct Cartesian_wrap : public Base_ //TODO: adapt all functors //TODO: safely apply .rep() to the arguments (and transforming_iterator) //FIXME: looks like only those 2 are missing - template struct Construct { - typedef typename Kernel_base::template Construct::type type; + template struct Functor { + typedef typename Kernel_base::template Functor::type type; }; - template struct Construct { - typedef typename Kernel_base::template Construct::type type; + template struct Functor { + typedef typename Kernel_base::template Functor::type type; }; - template struct Predicate { - typedef typename Kernel_base::template Predicate::type B; - struct type { - typedef typename B::result_type result_type; -#ifdef CGAL_CXX0X - template result_type operator()(U&&...u)const{ - return B()(internal::Forward_rep()(u)...); - } -#else -#define VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return B()(BOOST_PP_ENUM(N,VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) -#undef CODE -#undef VAR -#endif - }; - }; - //TODO: if B is Null_functor, let type be the same - template struct Compute { - typedef typename Kernel_base::template Compute::type B; - struct type { - typedef typename B::result_type result_type; -#ifdef CGAL_CXX0X - template result_type operator()(U&&...u)const{ - return B()(internal::Forward_rep()(u)...); - } -#else -#define VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return B()(BOOST_PP_ENUM(N,VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) -#undef CODE -#undef VAR -#endif - }; - }; }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index e7f85a512f8..0fd4c183df9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -22,8 +22,8 @@ class Point_d : public R_::Kernel_base::Point typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Vector Vector_; - typedef typename Kbase::template Construct::type CPBase; - typedef typename Kbase::template Compute::type CCBase; + typedef typename Kbase::template Functor::type CPBase; + typedef typename Kbase::template Functor::type CCBase; typedef Point_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index b9fbedc8366..be95b3a349d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -22,8 +22,8 @@ template class Point_rc_d { typedef typename R_::Kernel_base Kbase; - typedef typename Kbase::template Construct::type CPBase; - typedef typename Kbase::template Compute::type CCBase; + typedef typename Kbase::template Functor::type CPBase; + typedef typename Kbase::template Functor::type CCBase; typedef Point_rc_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 38528f878db..734d7c67537 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -22,9 +22,9 @@ class Segment_d : public R_::Kernel_base::Segment typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Point Point_; - typedef typename Kbase::template Construct::type CPBase; - typedef typename Kbase::template Construct::type CSBase; - typedef typename Kbase::template Construct::type CSEBase; + typedef typename Kbase::template Functor::type CPBase; + typedef typename Kbase::template Functor::type CSBase; + typedef typename Kbase::template Functor::type CSEBase; typedef Segment_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index dc318909c77..46801f72fda 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -22,8 +22,8 @@ class Vector_d : public R_::Kernel_base::Vector typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Point Point_; - typedef typename Kbase::template Construct::type CVBase; - typedef typename Kbase::template Compute::type CCBase; + typedef typename Kbase::template Functor::type CVBase; + typedef typename Kbase::template Functor::type CCBase; typedef Vector_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); @@ -114,7 +114,7 @@ public: Vector_d operator-() const { - return typename R::template Construct::type()(*this); + return typename R::template Functor::type()(*this); } /* @@ -236,13 +236,13 @@ template Vector_d::Vector_d(Vector_d &)=default; template Vector_d operator+(const Vector_d& v,const Vector_d& w) { - return typename R_::template Construct::type()(v,w); + return typename R_::template Functor::type()(v,w); } template Vector_d operator-(const Vector_d& v,const Vector_d& w) { - return typename R_::template Construct::type()(v,w); + return typename R_::template Functor::type()(v,w); } } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index d8aa326ef08..541ce185a2f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -22,8 +22,8 @@ template class Vector_rc_d { typedef typename R_::Kernel_base Kbase; - typedef typename Kbase::template Construct::type CPBase; - typedef typename Kbase::template Compute::type CCBase; + typedef typename Kbase::template Functor::type CPBase; + typedef typename Kbase::template Functor::type CCBase; typedef Vector_rc_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); 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 a689de321ee..4a4253db468 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -24,7 +24,7 @@ template struct Orientation { template result_type operator()(Iter f, Iter const& e, Vector_tag)const{ - typename R::template Compute::type c; + typename R::template Functor::type c; Matrix m(R().dimension(),R().dimension()); for(int i=0;f!=e;++f,++i) { for(int j=0;j struct Orientation { } template result_type operator()(Iter f, Iter const& e, Point_tag)const{ - typename R::template Compute::type c; + typename R::template Functor::type c; Matrix m(R().dimension(),R().dimension()); Point const& p0=*f++; for(int i=0;f!=e;++f,++i) { @@ -64,8 +64,8 @@ template struct Construct_opposite_vector { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Construct::type CV; - typedef typename R::template Construct::type CI; + typedef typename R::template Functor::type CV; + typedef typename R::template Functor::type CI; typedef Vector result_type; typedef Vector argument_type; result_type operator()(Vector const&v)const{ @@ -78,8 +78,8 @@ template struct Construct_sum_of_vectors { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Construct::type CV; - typedef typename R::template Construct::type CI; + typedef typename R::template Functor::type CV; + typedef typename R::template Functor::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -93,8 +93,8 @@ template struct Construct_difference_of_vectors { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Construct::type CV; - typedef typename R::template Construct::type CI; + typedef typename R::template Functor::type CV; + typedef typename R::template Functor::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -108,8 +108,8 @@ template struct Construct_midpoint { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; - typedef typename R::template Construct::type CP; - typedef typename R::template Construct::type CI; + typedef typename R::template Functor::type CP; + typedef typename R::template Functor::type CI; typedef Point result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -130,7 +130,7 @@ template struct Compute_squared_length { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Construct::type CI; + typedef typename R::template Functor::type CI; typedef FT result_type; typedef Vector argument_type; result_type operator()(Vector const&a)const{ @@ -145,7 +145,7 @@ template struct Compute_squared_distance { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; - typedef typename R::template Construct::type CI; + typedef typename R::template Functor::type CI; typedef FT result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -166,7 +166,7 @@ template struct Less_cartesian_coordinate { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; - typedef typename R::template Compute::type Cc; + typedef typename R::template Functor::type Cc; // 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 53d2c663f49..d41cd05c941 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -3,6 +3,13 @@ namespace CGAL { class Null_type {~Null_type();}; // no such object should be created + struct Predicate_tag {}; + struct Construct_tag {}; + struct Compute_tag {}; + struct Misc_tag {}; + + templatestruct map_functor_type{typedef Misc_tag type;}; + templatestruct map_kernel_obj{typedef Null_type type;}; #define DECL_OBJ(X) struct X##_tag {}; \ templatestruct map_kernel_obj{typedef typename K::X type;} @@ -15,13 +22,10 @@ namespace CGAL { DECL_OBJ(Bbox); #undef DECL_OBJ - //TODO: split into _begin and _end ? - struct Construct_point_cartesian_const_iterator_tag {}; - struct Construct_vector_cartesian_const_iterator_tag {}; - templatestruct map_result_tag{typedef Null_type type;}; #define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ - template<>struct map_result_tag{typedef Y##_tag type;} + template<>struct map_result_tag{typedef Y##_tag type;}; \ + template<>struct map_functor_type{typedef Construct_tag type;} DECL_CONSTRUCT(Construct_vector,Vector); DECL_CONSTRUCT(Construct_point,Point); DECL_CONSTRUCT(Construct_segment,Segment); @@ -35,7 +39,8 @@ namespace CGAL { DECL_CONSTRUCT(Construct_opposite_vector,Vector); #undef DECL_CONSTRUCT -#define DECL_COMPUTE(X) struct X##_tag {} +#define DECL_COMPUTE(X) struct X##_tag {}; \ + template<>struct map_functor_type{typedef Compute_tag type;} DECL_COMPUTE(Compute_cartesian_coordinate); DECL_COMPUTE(Compute_homogeneous_coordinate); DECL_COMPUTE(Compute_squared_distance); @@ -43,10 +48,18 @@ namespace CGAL { #undef DECL_COMPUTE //FIXME: choose a convention: prefix with Predicate_ ? -#define DECL_PREDICATE(X) struct X##_tag {} +#define DECL_PREDICATE(X) struct X##_tag {}; \ + template<>struct map_functor_type{typedef Predicate_tag type;} DECL_PREDICATE(Less_cartesian_coordinate); DECL_PREDICATE(Orientation); DECL_PREDICATE(In_sphere); #undef DECL_PREDICATE + +#define DECL_MISC(X) struct X##_tag {}; \ + template<>struct map_functor_type{typedef Misc_tag type;} + //TODO: split into _begin and _end ? + DECL_MISC(Construct_point_cartesian_const_iterator); + DECL_MISC(Construct_vector_cartesian_const_iterator); +#undef DECL_MISC } #endif // CGAL_FUNCTOR_TAGS_H diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 5de518a65cd..008755eed79 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -29,14 +29,14 @@ typedef K1::Point P; typedef K1::Vector V; typedef K1::Segment S; //typedef K1::Construct_point CP; -typedef K1::Construct::type CP; -typedef K1::Construct::type CV; -typedef K1::Construct::type CS; -typedef K1::Construct::type CSE; -typedef K1::Construct::type CCI; -typedef K1::Predicate::type PO; +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 PO; typedef K1::Point_cartesian_const_iterator CI; -typedef K1::Compute::type CC; +typedef K1::Functor::type CC; int main(){ CP cp; From b75920fff5f6fcd6b375b6738779409b3d58d944 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 17 May 2011 16:40:30 +0000 Subject: [PATCH 024/210] make Construct_*_cartesian_const_iterator a true functor --- .../include/CGAL/Kernel_d/Cartesian_LA_functors.h | 4 ++-- .../include/CGAL/Kernel_d/Cartesian_converter.h | 4 ++-- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 4 ++-- .../include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 12 ++++++------ .../CGAL/Kernel_d/function_objects_cartesian.h | 12 ++++++------ NewKernel_d/include/CGAL/functor_tags.h | 3 +++ NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 32b85d44fcd..3721b07332d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -129,10 +129,10 @@ template struct Construct_cartesian_const_iterator { typedef typename R::Point_cartesian_const_iterator result_type; // same as Vector - result_type begin(argument_type const& v)const{ + result_type operator()(argument_type const& v,Begin_tag)const{ return S_::vector_begin(v); } - result_type end(argument_type const& v)const{ + result_type operator()(argument_type const& v,End_tag)const{ return S_::vector_end(v); } }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index c39e53e9062..6e10af13ed5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -52,13 +52,13 @@ template class CartesianD_converter { typename K2::Point operator()(typename K1::Point const& p)const{ typename K1::template Functor::type i; typename K2::template Functor::type cp; - return cp(operator()(i.begin(p)),operator()(i.end(p))); + return cp(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } typename K2::Vector operator()(typename First_if_different::Type const& p)const{ typename K1::template Functor::type i; typename K2::template Functor::type cv; - return cv(operator()(i.begin(p)),operator()(i.end(p))); + return cv(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } typename K2::Segment operator()(typename K1::Segment const& s)const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 8ee8ff36500..378165fa1bc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -77,11 +77,11 @@ struct Lazy_cartesian : Dimension_base struct Construct_iter { typedef U result_type; template - result_type begin(T const& t)const{ + result_type operator()(T const& t,Begin_tag)const{ return result_type(t,0); } template - result_type end(T const& t)const{ + result_type operator()(T const& t,End_tag)const{ return result_type(t,Self().dimension()); } }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 029acb49bc5..349d21c56db 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -124,12 +124,12 @@ struct Cartesian_wrap : public Base_ //TODO: adapt all functors //TODO: safely apply .rep() to the arguments (and transforming_iterator) //FIXME: looks like only those 2 are missing - template struct Functor { - typedef typename Kernel_base::template Functor::type type; - }; - template struct Functor { - typedef typename Kernel_base::template Functor::type type; - }; + //template struct Functor { + // typedef typename Kernel_base::template Functor::type type; + //}; + //template struct Functor { + // typedef typename Kernel_base::template Functor::type type; + //}; }; 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 4a4253db468..f46a3e2d43f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -70,7 +70,7 @@ template struct Construct_opposite_vector { typedef Vector argument_type; result_type operator()(Vector const&v)const{ CI ci; - return CV()(make_transforming_iterator(ci.begin(v),std::negate()),make_transforming_iterator(ci.end(v),std::negate())); + return CV()(make_transforming_iterator(ci(v,Begin_tag()),std::negate()),make_transforming_iterator(ci(v,End_tag()),std::negate())); } }; @@ -85,7 +85,7 @@ template struct Construct_sum_of_vectors { typedef Vector second_argument_type; result_type operator()(Vector const&a, Vector const&b)const{ CI ci; - return CV()(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::plus()),make_transforming_pair_iterator(ci.end(a),ci.end(b),std::plus())); + return CV()(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::plus())); } }; @@ -100,7 +100,7 @@ template struct Construct_difference_of_vectors { typedef Vector second_argument_type; result_type operator()(Vector const&a, Vector const&b)const{ CI ci; - return CV()(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::minus()),make_transforming_pair_iterator(ci.end(a),ci.end(b),std::minus())); + return CV()(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); } }; @@ -122,7 +122,7 @@ template struct Construct_midpoint { CI ci; //Divide half(2); //return CP()(make_transforming_iterator(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::plus()),half),make_transforming_iterator(make_transforming_pair_iterator(ci.end(a),ci.end(b),std::plus()),half)); - return CP()(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),Average()),make_transforming_pair_iterator(ci.end(a),ci.end(b),Average())); + return CP()(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),Average()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),Average())); } }; @@ -137,7 +137,7 @@ template struct Compute_squared_length { CI ci; typename Algebraic_structure_traits::Square f; // TODO: avoid this FT(0)+... - return std::accumulate(make_transforming_iterator(ci.begin(a),f),make_transforming_iterator(ci.end(a),f),FT(0)); + return std::accumulate(make_transforming_iterator(ci(a,Begin_tag()),f),make_transforming_iterator(ci(a,End_tag()),f),FT(0)); } }; @@ -158,7 +158,7 @@ template struct Compute_squared_distance { CI ci; Sq_diff f; // TODO: avoid this FT(0)+... - return std::accumulate(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),f),make_transforming_pair_iterator(ci.end(a),ci.end(b),f),FT(0)); + return std::accumulate(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),f),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),f),FT(0)); } }; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index d41cd05c941..02f20b83a49 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -3,6 +3,9 @@ namespace CGAL { class Null_type {~Null_type();}; // no such object should be created + struct Begin_tag {}; + struct End_tag {}; + struct Predicate_tag {}; struct Construct_tag {}; struct Compute_tag {}; diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 008755eed79..850c3e99f29 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -56,7 +56,7 @@ int main(){ std::cout << cc(b,1) << std::endl; std::cout << cc(cse(s,0),1) << std::endl; std::cout << cc(cse(s,1),1) << std::endl; - for(CI i=ci.begin(a);i!=ci.end(a);++i) + for(CI i=ci(a,CGAL::Begin_tag());i!=ci(a,CGAL::End_tag());++i) std::cout << *i << ' '; std::cout << '\n'; P tab[]={a,b,c}; From 8aaf9c465a32770c7949613c704ab52b914cd0ba Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 17 May 2011 17:30:33 +0000 Subject: [PATCH 025/210] Wrap(Null_functor)==Null_functor --- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 21 +++++++------------ NewKernel_d/test/NewKernel_d/test.cpp | 5 ++++- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 349d21c56db..61ff85db5d6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -77,8 +77,8 @@ struct Cartesian_wrap : public Base_ template struct map_type { typedef X type; }; #include - //TODO:FIXME: if B is Null_functor, let type be the same - template::type> struct Functor { + //Translate the arguments + template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { typedef typename B::result_type result_type; @@ -99,7 +99,12 @@ struct Cartesian_wrap : public Base_ }; }; - template struct Functor { + //Translate both the arguments and the result + template struct Functor { + typedef Null_functor type; + }; + + template struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { typedef typename map_result_tag::type result_tag; @@ -121,16 +126,6 @@ struct Cartesian_wrap : public Base_ }; }; - //TODO: adapt all functors - //TODO: safely apply .rep() to the arguments (and transforming_iterator) - //FIXME: looks like only those 2 are missing - //template struct Functor { - // typedef typename Kernel_base::template Functor::type type; - //}; - //template struct Functor { - // typedef typename Kernel_base::template Functor::type type; - //}; - }; } //namespace CGAL diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 850c3e99f29..5e574cc71ab 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -22,8 +22,11 @@ struct K2: CGAL::Lazy_cartesian,K2>{}; #endif #if 0 typedef K2 K1; -#elif 1 +#elif 0 typedef CGAL::Cartesian_wrap K1; +#elif 1 +typedef CGAL::Cartesian_wrap K3; +typedef CGAL::Cartesian_wrap K1; #endif typedef K1::Point P; typedef K1::Vector V; From 363b57cbd9f21589bba230309633a892d0003d96 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 17 May 2011 20:02:04 +0000 Subject: [PATCH 026/210] finish refcounting wrapper --- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 79 +++++++++++++++++++ .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 4 +- NewKernel_d/test/NewKernel_d/test.cpp | 27 ++++++- 3 files changed, 105 insertions(+), 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 61ff85db5d6..99156c7617e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -3,9 +3,14 @@ #include #include + #include #include #include + +#include +#include + #include namespace CGAL { @@ -128,6 +133,80 @@ struct Cartesian_wrap : public Base_ }; +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; + + template struct map_type; +#define CGAL_Kernel_obj(X) typedef X##_rc_d X; \ + template struct map_type { typedef X type; }; + CGAL_Kernel_obj(Point) + CGAL_Kernel_obj(Vector) + + template struct Dispatch { + //typedef typename map_functor_type::type f_t; + typedef typename map_result_tag::type r_t; + enum { + is_nul = boost::is_same::type,Null_functor>::value, + ret_rcobj = boost::is_same::value || boost::is_same::value + }; + }; + + //Translate the arguments + template::is_nul,bool=Dispatch::ret_rcobj> struct Functor { + typedef typename Kernel_base::template Functor::type B; + struct type { + typedef typename B::result_type result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return B()(internal::Forward_rep()(u)...); + } +#else +#define VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CODE(Z,N,_) template result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return B()(BOOST_PP_ENUM(N,VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#undef VAR +#endif + }; + }; + + //Translate both the arguments and the result + template struct Functor { + typedef Null_functor type; + }; + + template struct Functor { + typedef typename Kernel_base::template Functor::type B; + struct type { + typedef typename map_result_tag::type result_tag; + typedef typename map_kernel_obj::type result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return result_type(Eval_functor(),B(),internal::Forward_rep()(u)...); + } +#else +#define VAR(Z,N,_) internal::Forward_rep()(u##N) +#define CODE(Z,N,_) template result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return result_type(Eval_functor(),B(),BOOST_PP_ENUM(N,VAR,)); \ + } + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#undef VAR +#endif + }; + }; + +}; + } //namespace CGAL #endif // CGAL_KERNEL_D_CARTESIAN_WRAP_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index be95b3a349d..3897b871e74 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -50,10 +50,10 @@ public: #ifdef CGAL_CXX0X template::type...>,std::tuple >::value>::type> explicit Point_rc_d(U&&...u) - : Rep(Eval_functor(),CPBase(),std::forward(u)...){} + : data(Eval_functor(),CPBase(),std::forward(u)...){} template explicit Point_rc_d(Eval_functor&&,F&&f,U&&...u) - : Rep(Eval_functor(),std::forward(f),std::forward(u)...){} + : data(Eval_functor(),std::forward(f),std::forward(u)...){} // try not to use these Point_rc_d(Rep const& v) : data(v) {} diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 5e574cc71ab..332117e6b53 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -8,21 +8,42 @@ #include #include #include -typedef CGAL::Cartesian_base_d > K0; +//typedef CGAL::Cartesian_base_d > K0; typedef CGAL::Cartesian_base_d > KA; typedef CGAL::Cartesian_base_d > KE; + +struct RC: public +CGAL::Cartesian_complete_predicates< +CGAL::Cartesian_complete_constructors< +CGAL::Cartesian_complete_computes< +CGAL::Cartesian_complete_types< +CGAL::Cartesian_refcount< +CGAL::Cartesian_LA_base_d > +> +>, false, RC +>, false, RC +>, false, RC +> +{ + RC(){} + RC(int){} +}; + +typedef RC K0; + + #if 0 typedef K0 K2; #elif 0 typedef CGAL::Cartesian_filter_NT K2; -#elif 1 +#elif 0 typedef CGAL::Cartesian_filter_K K2; #elif 1 struct K2: CGAL::Lazy_cartesian,K2>{}; #endif #if 0 typedef K2 K1; -#elif 0 +#elif 1 typedef CGAL::Cartesian_wrap K1; #elif 1 typedef CGAL::Cartesian_wrap K3; From b92b4d87f08aa29b5a6c438e9981950b0337e8ee Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 17 May 2011 20:08:57 +0000 Subject: [PATCH 027/210] =?UTF-8?q?Aux=20armes,=20citoyens=20Formez=20vos?= =?UTF-8?q?=20bataillons=20Marchez,=20marchez=C2=A0!=20Qu'un=20sang=20impu?= =?UTF-8?q?r=20Abreuve=20nos=20sillons=C2=A0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index 541ce185a2f..4d07fb6b432 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -50,10 +50,10 @@ public: #ifdef CGAL_CXX0X template::type...>,std::tuple >::value>::type> explicit Vector_rc_d(U&&...u) - : Rep(Eval_functor(),CPBase(),std::forward(u)...){} + : data(Eval_functor(),CPBase(),std::forward(u)...){} template explicit Vector_rc_d(Eval_functor&&,F&&f,U&&...u) - : Rep(Eval_functor(),std::forward(f),std::forward(u)...){} + : data(Eval_functor(),std::forward(f),std::forward(u)...){} // try not to use these Vector_rc_d(Rep const& v) : data(v) {} From 895c891cd2a84a8a4c0e0324dcf0e088bccc1f1c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 18 May 2011 16:47:24 +0000 Subject: [PATCH 028/210] Small start on stateful kernels --- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 9 +++ .../CGAL/Kernel_d/Cartesian_change_FT.h | 14 +++-- .../CGAL/Kernel_d/Cartesian_converter.h | 23 ++++--- .../CGAL/Kernel_d/Cartesian_filter_K.h | 8 ++- .../Kernel_d/function_objects_cartesian.h | 57 ++++++++++------- NewKernel_d/include/CGAL/store_kernel.h | 63 +++++++++++++++++++ 6 files changed, 137 insertions(+), 37 deletions(-) create mode 100644 NewKernel_d/include/CGAL/store_kernel.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 3721b07332d..a09c7eb950d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace CGAL { namespace CartesianDVectorBase { @@ -35,6 +36,7 @@ template struct Construct_LA_vector : internal::Construct_LA_vector_ #endif { + CGAL_FUNCTOR_INIT_IGNORE(Construct_LA_vector) typedef R_ R; typedef typename R::Constructor Constructor; typedef typename R::FT FT; @@ -104,6 +106,7 @@ template struct Construct_LA_vector }; template struct Compute_cartesian_coordinate { + CGAL_FUNCTOR_INIT_IGNORE(Compute_cartesian_coordinate) typedef R_ R; typedef typename R_::FT FT; typedef typename R::LA_vector first_argument_type; @@ -123,6 +126,7 @@ template struct Compute_cartesian_coordinate { }; template struct Construct_cartesian_const_iterator { + CGAL_FUNCTOR_INIT_IGNORE(Construct_cartesian_const_iterator) typedef R_ R; typedef typename R::LA_vector argument_type; typedef typename R::LA_vector_selector S_; @@ -138,6 +142,7 @@ template struct Construct_cartesian_const_iterator { }; template struct Construct_midpoint { + CGAL_FUNCTOR_INIT_IGNORE(Construct_midpoint) typedef R_ R; typedef typename R::Point first_argument_type; typedef typename R::Point second_argument_type; @@ -149,6 +154,7 @@ template struct Construct_midpoint { }; template struct Construct_sum_of_vectors { + CGAL_FUNCTOR_INIT_IGNORE(Construct_sum_of_vectors) typedef R_ R; typedef typename R::Vector first_argument_type; typedef typename R::Vector second_argument_type; @@ -160,6 +166,7 @@ template struct Construct_sum_of_vectors { }; template struct Construct_difference_of_vectors { + CGAL_FUNCTOR_INIT_IGNORE(Construct_difference_of_vectors) typedef R_ R; typedef typename R::Vector first_argument_type; typedef typename R::Vector second_argument_type; @@ -171,6 +178,7 @@ template struct Construct_difference_of_vectors { }; template struct Construct_opposite_vector { + CGAL_FUNCTOR_INIT_IGNORE(Construct_opposite_vector) typedef R_ R; typedef typename R::Vector result_type; typedef typename R::Vector argument_type; @@ -181,6 +189,7 @@ template struct Construct_opposite_vector { }; template struct Compute_scalar_product { + CGAL_FUNCTOR_INIT_IGNORE(Compute_scalar_product) typedef R_ R; typedef typename R::LA LA; typedef typename R::FT result_type; 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 dbe3780d0e1..40196a9350b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -15,6 +15,7 @@ struct Cartesian_change_FT_base : public CGAL_CONSTEXPR Cartesian_change_FT_base(){} CGAL_CONSTEXPR Cartesian_change_FT_base(int d):Base_(d){} + typedef Cartesian_change_FT_base Self; typedef Base_ Kernel_base; typedef FT_ RT; typedef FT_ FT; @@ -39,19 +40,20 @@ struct Cartesian_change_FT_base : public typedef transforming_iterator Point_cartesian_const_iterator; typedef transforming_iterator Vector_cartesian_const_iterator; - //FIXME: what if the functor's constructor takes a kernel as argument? template struct Construct_cartesian_const_iterator_ { typedef typename Kernel_base::template Functor::type Functor_base; + Construct_cartesian_const_iterator_(){} + Construct_cartesian_const_iterator_(Self const&r):f(r){} Functor_base f; typedef Type result_type; template - result_type begin(T const& v)const{ - return make_transforming_iterator(f.begin(v),FT_converter()); + result_type operator()(T const& v, Begin_tag)const{ + return make_transforming_iterator(f(v,Begin_tag()),FT_converter()); } template - result_type end(T const& v)const{ - return make_transforming_iterator(f.end(v),FT_converter()); + result_type operator()(T const& v, End_tag)const{ + return make_transforming_iterator(f(v,End_tag()),FT_converter()); } }; typedef Construct_cartesian_const_iterator_ Construct_point_cartesian_const_iterator; @@ -59,6 +61,8 @@ struct Cartesian_change_FT_base : public struct Compute_cartesian_coordinate { typedef typename Kernel_base::template Functor::type Functor_base; + Compute_cartesian_coordinate(){} + Compute_cartesian_coordinate(Self const&r):f(r){} Functor_base f; typedef FT result_type; template diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index 6e10af13ed5..d5054ded14a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -9,16 +9,22 @@ #include #include #include +#include namespace CGAL { -template class CartesianD_converter { + //TODO: special case when K1==K2 (or they are very close?) +template class CartesianD_converter + : private Store_kernel, private Store_kernel2 +{ typedef CartesianD_converter Self; typedef typename K1::FT FT1; typedef typename K2::FT FT2; typedef NT_converter NTc; NTc c; - // TODO: store a K1 and a K2 and have a suitable constructor public: + CartesianD_converter(){} + CartesianD_converter(K1 const&a,K2 const&b):Store_kernel(a),Store_kernel2(b){} + // For boost::result_of, used in transforming_iterator template struct result; template struct result{ @@ -50,21 +56,20 @@ template class CartesianD_converter { } typename K2::Point operator()(typename K1::Point const& p)const{ - typename K1::template Functor::type i; - typename K2::template Functor::type cp; + typename K1::template Functor::type i(this->kernel()); + typename K2::template Functor::type cp(this->kernel2()); return cp(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } typename K2::Vector operator()(typename First_if_different::Type const& p)const{ - typename K1::template Functor::type i; - typename K2::template Functor::type cv; + typename K1::template Functor::type i(this->kernel()); + typename K2::template Functor::type cv(this->kernel2()); return cv(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } typename K2::Segment operator()(typename K1::Segment const& s)const{ - typename K1::template Functor::type f; - //FIXME: should replace source and target by a functor - typename K2::template Functor::type cs; + typename K1::template Functor::type f(this->kernel()); + typename K2::template Functor::type cs(this->kernel2()); return cs(operator()(f(s,0)),operator()(f(s,1))); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index bd7e0ad3973..c0bf7bd7b19 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -8,13 +8,19 @@ namespace CGAL { template < typename Base_, typename AK_, typename EK_ > -struct Cartesian_filter_K : public Base_ +struct Cartesian_filter_K : public Base_, + private Store_kernel, private Store_kernel2 { CGAL_CONSTEXPR Cartesian_filter_K(){} CGAL_CONSTEXPR Cartesian_filter_K(int d):Base_(d){} + //FIXME: or do we want an instance of AK and EK belonging to this kernel, + //instead of a reference to external ones? + CGAL_CONSTEXPR Cartesian_filter_K(AK_ const&a,EK_ const&b):Base_(),Store_kernel(a),Store_kernel2(b){} + CGAL_CONSTEXPR Cartesian_filter_K(int d,AK_ const&a,EK_ const&b):Base_(d),Store_kernel(a),Store_kernel2(b){} typedef Base_ Kernel_base; typedef AK_ AK; typedef EK_ EK; + //TODO: C2A/C2E should be able to convert *this into this->kernel() or this->kernel2(). typedef CartesianD_converter C2A; typedef CartesianD_converter C2E; 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 f46a3e2d43f..b95a8304997 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -2,6 +2,7 @@ #define CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H #include +#include #include #include #include @@ -14,7 +15,8 @@ namespace CGAL { namespace CartesianDKernelFunctors { -template struct Orientation { +template struct Orientation : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; @@ -24,7 +26,7 @@ template struct Orientation { template result_type operator()(Iter f, Iter const& e, Vector_tag)const{ - typename R::template Functor::type c; + typename R::template Functor::type c(this->kernel()); Matrix m(R().dimension(),R().dimension()); for(int i=0;f!=e;++f,++i) { for(int j=0;j struct Orientation { } template result_type operator()(Iter f, Iter const& e, Point_tag)const{ - typename R::template Functor::type c; + typename R::template Functor::type c(this->kernel()); Matrix m(R().dimension(),R().dimension()); Point const& p0=*f++; for(int i=0;f!=e;++f,++i) { @@ -60,7 +62,8 @@ template struct Orientation { }; -template struct Construct_opposite_vector { +template struct Construct_opposite_vector : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_opposite_vector) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; @@ -69,12 +72,13 @@ template struct Construct_opposite_vector { typedef Vector result_type; typedef Vector argument_type; result_type operator()(Vector const&v)const{ - CI ci; - return CV()(make_transforming_iterator(ci(v,Begin_tag()),std::negate()),make_transforming_iterator(ci(v,End_tag()),std::negate())); + CI ci(this->kernel()); + return CV(this->kernel())(make_transforming_iterator(ci(v,Begin_tag()),std::negate()),make_transforming_iterator(ci(v,End_tag()),std::negate())); } }; -template struct Construct_sum_of_vectors { +template struct Construct_sum_of_vectors : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_sum_of_vectors) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; @@ -84,12 +88,13 @@ template struct Construct_sum_of_vectors { typedef Vector first_argument_type; typedef Vector second_argument_type; result_type operator()(Vector const&a, Vector const&b)const{ - CI ci; - return CV()(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::plus())); + CI ci(this->kernel()); + return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::plus())); } }; -template struct Construct_difference_of_vectors { +template struct Construct_difference_of_vectors : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_difference_of_vectors) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; @@ -99,12 +104,13 @@ template struct Construct_difference_of_vectors { typedef Vector first_argument_type; typedef Vector second_argument_type; result_type operator()(Vector const&a, Vector const&b)const{ - CI ci; - return CV()(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); + CI ci(this->kernel()); + return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); } }; -template struct Construct_midpoint { +template struct Construct_midpoint : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_midpoint) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; @@ -119,14 +125,15 @@ template struct Construct_midpoint { } }; result_type operator()(Point const&a, Point const&b)const{ - CI ci; + CI ci(this->kernel()); //Divide half(2); - //return CP()(make_transforming_iterator(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::plus()),half),make_transforming_iterator(make_transforming_pair_iterator(ci.end(a),ci.end(b),std::plus()),half)); - return CP()(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),Average()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),Average())); + //return CP(this->kernel())(make_transforming_iterator(make_transforming_pair_iterator(ci.begin(a),ci.begin(b),std::plus()),half),make_transforming_iterator(make_transforming_pair_iterator(ci.end(a),ci.end(b),std::plus()),half)); + return CP(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),Average()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),Average())); } }; -template struct Compute_squared_length { +template struct Compute_squared_length : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Compute_squared_length) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; @@ -134,14 +141,15 @@ template struct Compute_squared_length { typedef FT result_type; typedef Vector argument_type; result_type operator()(Vector const&a)const{ - CI ci; + CI ci(this->kernel()); typename Algebraic_structure_traits::Square f; // TODO: avoid this FT(0)+... return std::accumulate(make_transforming_iterator(ci(a,Begin_tag()),f),make_transforming_iterator(ci(a,End_tag()),f),FT(0)); } }; -template struct Compute_squared_distance { +template struct Compute_squared_distance : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Compute_squared_distance) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; @@ -155,14 +163,15 @@ template struct Compute_squared_distance { } }; result_type operator()(Point const&a, Point const&b)const{ - CI ci; + CI ci(this->kernel()); Sq_diff f; // TODO: avoid this FT(0)+... return std::accumulate(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),f),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),f),FT(0)); } }; -template struct Less_cartesian_coordinate { +template struct Less_cartesian_coordinate : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Less_cartesian_coordinate) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; @@ -173,18 +182,20 @@ template struct Less_cartesian_coordinate { template result_type operator()(V const&a, V const&b, I i)const{ - Cc c; + Cc c(this->kernel()); return c(a,i) struct Construct_segment { + CGAL_FUNCTOR_INIT_IGNORE(Construct_segment) typedef R_ R; typedef typename R_::Point Point; typedef typename R_::Segment Segment; typedef Segment result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ + // should use Construct_point ? return result_type(std::forward(u)...); } #else @@ -194,7 +205,9 @@ template struct Construct_segment { #endif }; +// This should be part of Construct_point, according to Kernel_23 conventions template struct Construct_segment_extremity { + CGAL_FUNCTOR_INIT_IGNORE(Construct_segment_extremity) typedef R_ R; typedef typename R_::Point Point; typedef typename R_::Segment Segment; diff --git a/NewKernel_d/include/CGAL/store_kernel.h b/NewKernel_d/include/CGAL/store_kernel.h new file mode 100644 index 00000000000..05bb230e96a --- /dev/null +++ b/NewKernel_d/include/CGAL/store_kernel.h @@ -0,0 +1,63 @@ +#ifndef CGAL_STORE_KERNEL_H +#define CGAL_STORE_KERNEL_H + +#include +#include + +namespace CGAL { +namespace internal { +BOOST_MPL_HAS_XXX_TRAIT_DEF(Do_not_store_kernel) +template::value> struct Do_not_store_kernel { + enum { value=false }; + typedef Tag_false type; +}; +template struct Do_not_store_kernel { + typedef typename T::Do_not_store_kernel type; + enum { value=type::value }; +}; +} + +template::value||internal::Do_not_store_kernel::value> +struct Store_kernel { + Store_kernel(){} + Store_kernel(R_ const&){} + enum { kernel_is_stored = false }; + R_ kernel()const{return R_();} +}; +template +struct Store_kernel { + Store_kernel(){ CGAL_warning_msg(true,"I should know my kernel"); } + Store_kernel(R_ const& r):rp(&r){} + enum { kernel_is_stored = true }; + R_ const& kernel()const{return *rp;} + private: + R_ const* rp; +}; + +//For a second kernel. TODO: find something more elegant +template::value||internal::Do_not_store_kernel::value> +struct Store_kernel2 { + Store_kernel2(){} + Store_kernel2(R_ const&){} + enum { kernel2_is_stored = false }; + R_ kernel2()const{return R_();} +}; +template +struct Store_kernel2 { + Store_kernel2(){ CGAL_warning_msg(true,"I should know my kernel"); } + Store_kernel2(R_ const& r):rp(&r){} + enum { kernel2_is_stored = true }; + R_ const& kernel2()const{return *rp;} + private: + R_ const* rp; +}; +} +#define CGAL_BASE_INIT(X,Y) \ + X():Y(){} \ + X(R_ const&r):Y(r){} +#define CGAL_FUNCTOR_INIT_STORE(X) CGAL_BASE_INIT(X,Store_kernel) +#define CGAL_FUNCTOR_INIT_IGNORE(X) \ + X(){} \ + X(R_ const&){} + +#endif // CGAL_STORE_KERNEL_H From 447777d15603b031568a48f0d0afd1828223d1f9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 19 May 2011 14:17:17 +0000 Subject: [PATCH 029/210] e --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h | 4 +++- NewKernel_d/include/CGAL/LA_eigen/constructors.h | 1 + NewKernel_d/include/CGAL/store_kernel.h | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index d5054ded14a..c2798996739 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -16,7 +16,7 @@ namespace CGAL { template class CartesianD_converter : private Store_kernel, private Store_kernel2 { - typedef CartesianD_converter Self; + typedef CartesianD_converter Self; typedef typename K1::FT FT1; typedef typename K2::FT FT2; typedef NT_converter NTc; @@ -35,6 +35,7 @@ template class CartesianD_converter #endif typedef transforming_iterator type; }; + template struct result{typedef K2 type;}; template struct result{typedef int type;}; template struct result{typedef Origin type;}; template struct result{typedef Null_vector type;}; @@ -43,6 +44,7 @@ template class CartesianD_converter template struct result{typedef typename K2::Point type;}; template struct result::Type),i>{typedef typename K2::Vector type;}; + typename Store_kernel2::reference2_type operator()(K1 const&)const{return this->kernel2();} int operator()(int i)const{return i;} Origin operator()(Origin const&o)const{return o;} Null_vector operator()(Null_vector const&v)const{return v;} diff --git a/NewKernel_d/include/CGAL/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/LA_eigen/constructors.h index d30a3637ddf..ee44a1e4513 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/LA_eigen/constructors.h @@ -20,6 +20,7 @@ template struct Construct_eigen { template result_type operator()(int d,Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)); + //FIXME: the std::min is useless? it causes problems for intel/clang CGAL_assertion(d<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); result_type a(d); // TODO: check the right way to do this diff --git a/NewKernel_d/include/CGAL/store_kernel.h b/NewKernel_d/include/CGAL/store_kernel.h index 05bb230e96a..34bab819ac6 100644 --- a/NewKernel_d/include/CGAL/store_kernel.h +++ b/NewKernel_d/include/CGAL/store_kernel.h @@ -23,6 +23,7 @@ struct Store_kernel { Store_kernel(R_ const&){} enum { kernel_is_stored = false }; R_ kernel()const{return R_();} + typedef R_ reference_type; }; template struct Store_kernel { @@ -30,6 +31,7 @@ struct Store_kernel { Store_kernel(R_ const& r):rp(&r){} enum { kernel_is_stored = true }; R_ const& kernel()const{return *rp;} + typedef R_ const& reference_type; private: R_ const* rp; }; @@ -41,6 +43,7 @@ struct Store_kernel2 { Store_kernel2(R_ const&){} enum { kernel2_is_stored = false }; R_ kernel2()const{return R_();} + typedef R_ reference2_type; }; template struct Store_kernel2 { @@ -48,6 +51,7 @@ struct Store_kernel2 { Store_kernel2(R_ const& r):rp(&r){} enum { kernel2_is_stored = true }; R_ const& kernel2()const{return *rp;} + typedef R_ const& reference2_type; private: R_ const* rp; }; From ef27c36545a4dceb9a5725cf4dc0afb730481e70 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 19 May 2011 15:19:03 +0000 Subject: [PATCH 030/210] f --- NewKernel_d/include/CGAL/store_kernel.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/include/CGAL/store_kernel.h b/NewKernel_d/include/CGAL/store_kernel.h index 34bab819ac6..38aac7bb2ed 100644 --- a/NewKernel_d/include/CGAL/store_kernel.h +++ b/NewKernel_d/include/CGAL/store_kernel.h @@ -24,14 +24,23 @@ struct Store_kernel { enum { kernel_is_stored = false }; R_ kernel()const{return R_();} typedef R_ reference_type; + void set_kernel(R_ const&){} }; template struct Store_kernel { - Store_kernel(){ CGAL_warning_msg(true,"I should know my kernel"); } + Store_kernel():rp(0){ + //CGAL_warning_msg(true,"I should know my kernel"); + //Can't do the check here, Filtered_predicate doesn't let you + //initialize c2a/c2e. + } Store_kernel(R_ const& r):rp(&r){} enum { kernel_is_stored = true }; - R_ const& kernel()const{return *rp;} + R_ const& kernel()const{ + CGAL_warning_msg(rp==0,"I should know my kernel"); } + return *rp; + } typedef R_ const& reference_type; + void set_kernel(R_ const&r){rp=&r;} private: R_ const* rp; }; @@ -44,14 +53,18 @@ struct Store_kernel2 { enum { kernel2_is_stored = false }; R_ kernel2()const{return R_();} typedef R_ reference2_type; + void set_kernel2(R_ const&){} }; template struct Store_kernel2 { - Store_kernel2(){ CGAL_warning_msg(true,"I should know my kernel"); } + Store_kernel2(){ + //CGAL_warning_msg(true,"I should know my kernel"); + } Store_kernel2(R_ const& r):rp(&r){} enum { kernel2_is_stored = true }; R_ const& kernel2()const{return *rp;} typedef R_ const& reference2_type; + void set_kernel2(R_ const&r){rp=&r;} private: R_ const* rp; }; From 32fecea31f56368d42e4251a490b23e6c1a28e31 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 20 May 2011 15:58:28 +0000 Subject: [PATCH 031/210] Lazy_cartesian is an independent layer --- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 8 +++++--- NewKernel_d/include/CGAL/store_kernel.h | 7 +++++-- NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 378165fa1bc..ad6b6f14031 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -3,20 +3,22 @@ #include #include +#include #include #include namespace CGAL { - //TODO: ? use Lazy_cartesian instead of Kernel ? -template +template struct Lazy_cartesian : Dimension_base { //CGAL_CONSTEXPR Lazy_cartesian(){} //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} //TODO: store an AK and an EK - typedef Lazy_cartesian Self; + typedef Lazy_cartesian Self; + //typedef typename Default::Get::type Kernel; + typedef Self Kernel; typedef AK_ Approximate_kernel; typedef EK_ Exact_kernel; typedef E2A_ E2A; diff --git a/NewKernel_d/include/CGAL/store_kernel.h b/NewKernel_d/include/CGAL/store_kernel.h index 38aac7bb2ed..7a96bde1c73 100644 --- a/NewKernel_d/include/CGAL/store_kernel.h +++ b/NewKernel_d/include/CGAL/store_kernel.h @@ -36,7 +36,7 @@ struct Store_kernel { Store_kernel(R_ const& r):rp(&r){} enum { kernel_is_stored = true }; R_ const& kernel()const{ - CGAL_warning_msg(rp==0,"I should know my kernel"); } + CGAL_warning_msg(rp==0,"I should know my kernel"); return *rp; } typedef R_ const& reference_type; @@ -62,7 +62,10 @@ struct Store_kernel2 { } Store_kernel2(R_ const& r):rp(&r){} enum { kernel2_is_stored = true }; - R_ const& kernel2()const{return *rp;} + R_ const& kernel2()const{ + CGAL_warning_msg(rp==0,"I should know my kernel"); + return *rp; + } typedef R_ const& reference2_type; void set_kernel2(R_ const&r){rp=&r;} private: diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 332117e6b53..4c03fcb8168 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -39,7 +39,7 @@ typedef CGAL::Cartesian_filter_NT K2; #elif 0 typedef CGAL::Cartesian_filter_K K2; #elif 1 -struct K2: CGAL::Lazy_cartesian,K2>{}; +typedef CGAL::Lazy_cartesian > K2; #endif #if 0 typedef K2 K1; From 5f0f7fb19d2c1152e16b9ef9f04ff42fa3e9f1e7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 May 2011 15:58:00 +0000 Subject: [PATCH 032/210] couple more places for stateful kernels --- NewKernel_d/include/CGAL/Filtered_predicate.h | 420 ++++++++++++++++++ .../CGAL/Kernel_d/Cartesian_filter_K.h | 8 +- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 7 +- NewKernel_d/include/CGAL/Lazy.h | 7 + 4 files changed, 440 insertions(+), 2 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Filtered_predicate.h diff --git a/NewKernel_d/include/CGAL/Filtered_predicate.h b/NewKernel_d/include/CGAL/Filtered_predicate.h new file mode 100644 index 00000000000..c4608c2d3cf --- /dev/null +++ b/NewKernel_d/include/CGAL/Filtered_predicate.h @@ -0,0 +1,420 @@ +// Copyright (c) 2001-2005 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// 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; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// 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) : Sylvain Pion + +#ifndef CGAL_FILTERED_PREDICATE_H +#define CGAL_FILTERED_PREDICATE_H + +#include +#include +#include +#include +#include + +namespace CGAL { + +// This template class is a wrapper that implements the filtering for any +// predicate (dynamic filters with IA). + +// TODO : +// - each predicate in the default kernel should define a tag that says if it +// wants to be filtered or not (=> all homogeneous predicate define this +// tag). We could even test-suite that automatically. It makes a strong +// new requirement on the kernel though... +// Could be done with a traits mechanism ? +// A default template could use the current IA, but other tags or whatever +// could specify no filtering at all, or static filtering... +// - same thing for constructions => virtual operator() ? +// - similarly, constructions should have a tag saying if they can throw or +// not, or we let all this up to the compiler optimizer to figure out ? +// - Some caching could be done at the Point_2 level. + + +template +class Filtered_predicate +{ +//TODO: pack (at least use a tuple) +//FIXME: is it better to store those, or just store enough to recreate them +//(i.e. possibly references to the kernels)? + EP ep; + AP ap; + C2E c2e; + C2A c2a; + + typedef typename AP::result_type Ares; + +public: + + typedef AP Approximate_predicate; + typedef EP Exact_predicate; + typedef C2E To_exact_converter; + typedef C2A To_approximate_converter; + + typedef typename EP::result_type result_type; + // AP::result_type must be convertible to EP::result_type. + + Filtered_predicate() + {} + + template + Filtered_predicate(const K& k) + : ep(k.exact_kernel()), ap(k.approximate_kernel()), c2e(k,k.exact_kernel()), c2a(k,k.approximate_kernel()) + {} + + template + Filtered_predicate(const K& k,const EK& ek,const AK& ak) + : ep(ek), ap(ak), c2e(k,ek), c2a(k,ak) + {} + + +#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + template + result_type + operator()(const Args&... args) const; +#else + + template + result_type + operator()(const A1 &a1) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, + const A9 &a9) const; + + template + result_type + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, + const A9 &a9, const A10 &a10) const; + + // Idem for more than 10 arguments. Do it on demand. + +#endif +}; + +#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const Args&... args) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(args)...); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(args)...); +} + +#else + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + + Ares res = ap(c2a(a1)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), + c2a(a7)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), + c2a(a7), c2a(a8)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7), + c2e(a8)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, + const A9 &a9) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), + c2a(a7), c2a(a8), c2a(a9)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7), + c2e(a8), c2e(a9)); +} + +template + template +typename Filtered_predicate::result_type +Filtered_predicate:: + operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, + const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, + const A9 &a9, const A10 &a10) const +{ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + { + Protect_FPU_rounding p; + try + { + Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), + c2a(a7), c2a(a8), c2a(a9), c2a(a10)); + if (is_certain(res)) + return get_certain(res); + } + catch (Uncertain_conversion_exception) {} + } + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding p(CGAL_FE_TONEAREST); + return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7), + c2e(a8), c2e(a9), c2e(a10)); +} + +#endif + +} //namespace CGAL + +#endif // CGAL_FILTERED_PREDICATE_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index c0bf7bd7b19..328106b6c9c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -4,6 +4,7 @@ #include #include #include +#include namespace CGAL { @@ -20,7 +21,12 @@ struct Cartesian_filter_K : public Base_, typedef Base_ Kernel_base; typedef AK_ AK; typedef EK_ EK; - //TODO: C2A/C2E should be able to convert *this into this->kernel() or this->kernel2(). + typedef typename Store_kernel::reference_type AK_rt; + AK_rt approximate_kernel()const{return this->kernel();} + typedef typename Store_kernel2::reference2_type EK_rt; + EK_rt exact_kernel()const{return this->kernel2();} + + //TODO: C2A/C2E could be able to convert *this into this->kernel() or this->kernel2(). typedef CartesianD_converter C2A; typedef CartesianD_converter C2E; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index ad6b6f14031..56b9e6d2da3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -15,7 +15,12 @@ struct Lazy_cartesian : Dimension_base //CGAL_CONSTEXPR Lazy_cartesian(){} //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} - //TODO: store an AK and an EK + //TODO: Do we want to store an AK and an EK? Or just references? + //FIXME: references would be better I guess. + AK_ ak; EK_ ek; + AK_ const& approximate_kernel()const{return ak;} + EK_ const& exact_kernel()const{return ek;} + typedef Lazy_cartesian Self; //typedef typename Default::Get::type Kernel; typedef Self Kernel; diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index 9f2b9d73a8b..2f2a490c577 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -852,6 +852,9 @@ struct Approx_converter typedef K1 Source_kernel; typedef K2 Target_kernel; //typedef Converter Number_type_converter; + Approx_converter(){} + Approx_converter(K1 const&,K2 const&){} + //TODO: check that it is normal that we never need k1 or k2 here template struct result_; template struct result_ { @@ -899,6 +902,9 @@ struct Exact_converter typedef K1 Source_kernel; typedef K2 Target_kernel; //typedef Converter Number_type_converter; + Exact_converter(){} + Exact_converter(K1 const&,K2 const&){} + //TODO: check that it is normal that we never need k1 or k2 here template struct result_; template struct result_ { @@ -1784,6 +1790,7 @@ struct Lazy_construction AC ac; EC ec; + //TODO: need a constructor to initialize ac and ec properly public: From 9c655afded3955829efce86a78e67bb239e2eebf Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 24 May 2011 15:28:27 +0000 Subject: [PATCH 033/210] More stateful kernels. --- .../CGAL/Kernel_d/Cartesian_filter_NT.h | 10 ++----- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 11 ++++++-- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 28 +++++++++++++------ .../Kernel_d/function_objects_cartesian.h | 3 ++ NewKernel_d/include/CGAL/Lazy.h | 5 +++- .../include/CGAL/iterator_from_indices.h | 5 +++- NewKernel_d/include/CGAL/store_kernel.h | 6 ++-- NewKernel_d/test/NewKernel_d/test.cpp | 28 ++++++++++++------- 8 files changed, 62 insertions(+), 34 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h index 01f94f5c484..5f0bc94c963 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -25,13 +25,9 @@ struct Cartesian_filter_NT : public Base_ typedef typename K1::template Functor::type P1; P1 p1; typedef typename K2::template Functor::type P2; P2 p2; typedef typename P2::result_type result_type; - - //FIXME: if predicate's constructor takes a kernel as argument, how do we translate that? -#ifdef CGAL_CXX0X - template type(U&&...u):p1(std::forward(u)...),p2(std::forward(u)...){} -#else - //FIXME: usual boost preprocessor magic -#endif + type(){} + type(Cartesian_filter_NT const&k):p1(reinterpret_cast(k)),p2(reinterpret_cast(k)){} + //FIXME: if predicate's constructor takes a kernel as argument, how do we translate that? reinterpret_cast is really ugly and possibly unsafe. #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 56b9e6d2da3..0ce144f8ebb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -17,6 +17,8 @@ struct Lazy_cartesian : Dimension_base //TODO: Do we want to store an AK and an EK? Or just references? //FIXME: references would be better I guess. + //TODO: In any case, make sure that we don't end up storing this kernel for + //nothing (it is not empty but references empty kernels or something) AK_ ak; EK_ ek; AK_ const& approximate_kernel()const{return ak;} EK_ const& exact_kernel()const{return ek;} @@ -81,15 +83,18 @@ struct Lazy_cartesian : Dimension_base typedef Iterator_from_indices::type> Vector_cartesian_const_iterator; template - struct Construct_iter { + struct Construct_iter : private Store_kernel { + Construct_iter(){} + Construct_iter(Kernel const&k):Store_kernel(k){} + //FIXME: pass the kernel to the functor in the iterator typedef U result_type; template result_type operator()(T const& t,Begin_tag)const{ - return result_type(t,0); + return result_type(t,0,this->kernel()); } template result_type operator()(T const& t,End_tag)const{ - return result_type(t,Self().dimension()); + return result_type(t,Self().dimension(),this->kernel()); } }; template struct Functor { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 99156c7617e..f39ed3de488 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -86,16 +86,19 @@ struct Cartesian_wrap : public Base_ template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { + B b; + type(){} + type(Self const&k):b(k){} typedef typename B::result_type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ - return B()(internal::Forward_rep()(u)...); + return b(internal::Forward_rep()(u)...); } #else #define VAR(Z,N,_) internal::Forward_rep()(u##N) #define CODE(Z,N,_) template result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return B()(BOOST_PP_ENUM(N,VAR,)); \ + return b(BOOST_PP_ENUM(N,VAR,)); \ } BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) #undef CODE @@ -112,17 +115,20 @@ struct Cartesian_wrap : public Base_ template struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { + B b; + type(){} + type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; typedef typename map_kernel_obj::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ - return result_type(Eval_functor(),B(),internal::Forward_rep()(u)...); + return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); } #else #define VAR(Z,N,_) internal::Forward_rep()(u##N) #define CODE(Z,N,_) template result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return result_type(Eval_functor(),B(),BOOST_PP_ENUM(N,VAR,)); \ + return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,VAR,)); \ } BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) #undef CODE @@ -160,16 +166,19 @@ struct Cartesian_refcount : public Base_ template::is_nul,bool=Dispatch::ret_rcobj> struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { + B b; + type(){} + type(Self const&k):b(k){} typedef typename B::result_type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ - return B()(internal::Forward_rep()(u)...); + return b(internal::Forward_rep()(u)...); } #else #define VAR(Z,N,_) internal::Forward_rep()(u##N) #define CODE(Z,N,_) template result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return B()(BOOST_PP_ENUM(N,VAR,)); \ + return b(BOOST_PP_ENUM(N,VAR,)); \ } BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) #undef CODE @@ -186,17 +195,20 @@ struct Cartesian_refcount : public Base_ template struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { + B b; + type(){} + type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; typedef typename map_kernel_obj::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ - return result_type(Eval_functor(),B(),internal::Forward_rep()(u)...); + return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); } #else #define VAR(Z,N,_) internal::Forward_rep()(u##N) #define CODE(Z,N,_) template result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return result_type(Eval_functor(),B(),BOOST_PP_ENUM(N,VAR,)); \ + return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,VAR,)); \ } BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) #undef CODE 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 b95a8304997..bd6fd6b94f3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -49,6 +49,9 @@ template struct Orientation : private Store_kernel { } return R::LA::sign_of_determinant(CGAL_MOVE(m)); } + //FIXME!!! + //when Point and Vector are distinct types, the dispatch should be made + //in a way that doesn't instantiate a conversion from Point to Vector template result_type operator()(Iter const&f, Iter const& e)const{ typename std::iterator_traits::difference_type d=std::distance(f,e); diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index 2f2a490c577..68ce0adb9f0 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -1295,6 +1295,8 @@ struct Lazy_construction_nt { AC ac; EC ec; + Lazy_construction_nt(){} + Lazy_construction_nt(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} template result_type operator()(const L1& l1) const @@ -1790,7 +1792,8 @@ struct Lazy_construction AC ac; EC ec; - //TODO: need a constructor to initialize ac and ec properly + Lazy_construction(){} + Lazy_construction(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} public: diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index 258d50b4aff..ad7edef0d23 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -29,6 +29,7 @@ class Iterator_from_indices typedef std::size_t index_t; Container_& cont; index_t index; + Coord_access ca; void increment(){ ++index; } void decrement(){ --index; } void advance(std::ptrdiff_t n){ index+=n; } @@ -41,12 +42,14 @@ class Iterator_from_indices } Ref_ dereference()const{ //FIXME: use the functor properly - Coord_access ca; return ca(cont,index); } public: Iterator_from_indices(Container_& cont_,std::size_t n) : cont(cont_), index(n) {} + template + Iterator_from_indices(Container_& cont_,std::size_t n,T const&t) + : cont(cont_), index(n), ca(t) {} }; } #endif // CGAL_ITERATOR_FROM_INDICES_H diff --git a/NewKernel_d/include/CGAL/store_kernel.h b/NewKernel_d/include/CGAL/store_kernel.h index 7a96bde1c73..669bcb56ce6 100644 --- a/NewKernel_d/include/CGAL/store_kernel.h +++ b/NewKernel_d/include/CGAL/store_kernel.h @@ -29,14 +29,12 @@ struct Store_kernel { template struct Store_kernel { Store_kernel():rp(0){ - //CGAL_warning_msg(true,"I should know my kernel"); - //Can't do the check here, Filtered_predicate doesn't let you - //initialize c2a/c2e. + CGAL_warning_msg(true,"I should know my kernel"); } Store_kernel(R_ const& r):rp(&r){} enum { kernel_is_stored = true }; R_ const& kernel()const{ - CGAL_warning_msg(rp==0,"I should know my kernel"); + CGAL_warning_msg(rp!=0,"I should know my kernel"); return *rp; } typedef R_ const& reference_type; diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 4c03fcb8168..39723779577 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -17,9 +17,9 @@ CGAL::Cartesian_complete_predicates< CGAL::Cartesian_complete_constructors< CGAL::Cartesian_complete_computes< CGAL::Cartesian_complete_types< -CGAL::Cartesian_refcount< +//CGAL::Cartesian_refcount< CGAL::Cartesian_LA_base_d > -> +//> >, false, RC >, false, RC >, false, RC @@ -34,13 +34,14 @@ typedef RC K0; #if 0 typedef K0 K2; -#elif 0 +#elif 1 typedef CGAL::Cartesian_filter_NT K2; -#elif 0 +#elif 1 typedef CGAL::Cartesian_filter_K K2; #elif 1 typedef CGAL::Lazy_cartesian > K2; #endif + #if 0 typedef K2 K1; #elif 1 @@ -62,13 +63,20 @@ typedef K1::Functor::type PO; typedef K1::Point_cartesian_const_iterator CI; typedef K1::Functor::type CC; +#if 1 +#define Kinit (k) +#else +#define Kinit +#endif + int main(){ - CP cp; - CCI ci; - CC cc; - PO po; - CS cs; - CSE cse; + K1 k; + CP cp Kinit; + CCI ci Kinit; + CC cc Kinit; + PO po Kinit; + CS cs Kinit; + CSE cse Kinit; P a=cp(3,4); P b=cp(5,6,7); int rr[]={3,5,2}; From 1347e068cdb4a9bd05ef4abc11758133e09f7a60 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 25 May 2011 09:06:05 +0000 Subject: [PATCH 034/210] Fix Orientation when Point!=Vector. I don't think there is much point having a single functor for both. --- .../Kernel_d/function_objects_cartesian.h | 86 +++++++++++++++---- .../include/CGAL/Kernel_d/interface_macros.h | 4 + NewKernel_d/include/CGAL/functor_tags.h | 2 + NewKernel_d/include/CGAL/is_iterator.h | 67 +++++++++++++++ NewKernel_d/test/NewKernel_d/test.cpp | 6 +- 5 files changed, 144 insertions(+), 21 deletions(-) create mode 100644 NewKernel_d/include/CGAL/is_iterator.h 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 bd6fd6b94f3..85f15702a75 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -15,29 +15,16 @@ namespace CGAL { namespace CartesianDKernelFunctors { -template struct Orientation : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Orientation) +template struct Orientation_of_points : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Vector Vector; typedef typename R::Point Point; typedef typename R::Orientation result_type; typedef typename R::LA::template Matrix::type Matrix; template - result_type operator()(Iter f, Iter const& e, Vector_tag)const{ - typename R::template Functor::type c(this->kernel()); - Matrix m(R().dimension(),R().dimension()); - for(int i=0;f!=e;++f,++i) { - for(int j=0;j - result_type operator()(Iter f, Iter const& e, Point_tag)const{ + result_type operator()(Iter f, Iter const& e)const{ typename R::template Functor::type c(this->kernel()); Matrix m(R().dimension(),R().dimension()); Point const& p0=*f++; @@ -49,6 +36,43 @@ template struct Orientation : private Store_kernel { } return R::LA::sign_of_determinant(CGAL_MOVE(m)); } + //TODO: version that takes objects directly instead of iterators +}; + +template struct Orientation_of_vectors : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::Orientation result_type; + typedef typename R::LA::template Matrix::type Matrix; + + template + result_type operator()(Iter f, Iter const& e)const{ + typename R::template Functor::type c(this->kernel()); + Matrix m(R().dimension(),R().dimension()); + for(int i=0;f!=e;++f,++i) { + for(int j=0;j::value> struct Orientation : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::Point Point; + typedef typename R::Orientation result_type; + typedef typename R::template Functor::type OP; + typedef typename R::template Functor::type OV; + typedef typename R::LA::template Matrix::type Matrix; + //FIXME!!! //when Point and Vector are distinct types, the dispatch should be made //in a way that doesn't instantiate a conversion from Point to Vector @@ -56,11 +80,37 @@ template struct Orientation : private Store_kernel { result_type operator()(Iter const&f, Iter const& e)const{ typename std::iterator_traits::difference_type d=std::distance(f,e); int dim=R().dimension(); - if(d==dim) return operator()(f,e,Vector_tag()); + if(d==dim) return OV(this->kernel())(f,e); CGAL_assertion(d==dim+1); - return operator()(f,e,Point_tag()); + return OP(this->kernel())(f,e); } + //TODO: version that takes objects directly instead of iterators +}; +template struct Orientation : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::Point Point; + typedef typename R::Orientation result_type; + typedef typename R::template Functor::type OP; + typedef typename R::template Functor::type OV; + typedef typename R::LA::template Matrix::type Matrix; + + //FIXME!!! + //when Point and Vector are distinct types, the dispatch should be made + //in a way that doesn't instantiate a conversion from Point to Vector + template + typename boost::enable_if,result_type>::type + operator()(Iter const&f, Iter const& e)const{ + return OP(this->kernel())(f,e); + } + template + typename boost::enable_if,result_type>::type + operator()(Iter const&f, Iter const& e)const{ + return OV(this->kernel())(f,e); + } //TODO: version that takes objects directly instead of iterators }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index af5d45f04f6..dc7d79eca72 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -62,6 +62,10 @@ CGAL_Kernel_comp1(Compute_cartesian_coordinate, CGAL_Kernel_pred(Orientation, orientation_object) +CGAL_Kernel_pred(Orientation_of_points, + orientation_of_points_object) +CGAL_Kernel_pred(Orientation_of_vectors, + orientation_of_vectors_object) CGAL_Kernel_pred(Less_cartesian_coordinate, less_cartesian_coordinate_object) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 02f20b83a49..69e6a3e2be9 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -55,6 +55,8 @@ namespace CGAL { template<>struct map_functor_type{typedef Predicate_tag type;} DECL_PREDICATE(Less_cartesian_coordinate); DECL_PREDICATE(Orientation); + DECL_PREDICATE(Orientation_of_points); + DECL_PREDICATE(Orientation_of_vectors); DECL_PREDICATE(In_sphere); #undef DECL_PREDICATE diff --git a/NewKernel_d/include/CGAL/is_iterator.h b/NewKernel_d/include/CGAL/is_iterator.h new file mode 100644 index 00000000000..21711845808 --- /dev/null +++ b/NewKernel_d/include/CGAL/is_iterator.h @@ -0,0 +1,67 @@ +// Copyright (c) 2011 INRIA Saclay Ile-de-France (France). +// All rights reserved. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// 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; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// 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_IS_ITERATOR_H +#define CGAL_IS_ITERATOR_H + +#include +#include +#include + +namespace CGAL { +namespace internal { +BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) +template struct is_iterator_ { + enum { value = has_iterator_category::value + || boost::is_pointer::value }; +}; +template ::value> +struct is_iterator_type_ { + enum { value=false }; +}; +template struct is_iterator_type_ : + //boost::is_base_of::iterator_category> + boost::is_convertible::iterator_category,U> + {}; + +template struct decay_array { typedef T type; }; +template struct decay_array { typedef T* type; }; +template struct decay_array { typedef T* type; }; +} + +// NOTE: we don't want the real std::decay or functions are included +template struct is_iterator : + internal::is_iterator_::type>::type>::type> {}; + +template struct is_iterator_type : + internal::is_iterator_type_::type>::type>::type,Tag> {}; + +template ::value> struct is_iterator_to { + enum { value=false }; +}; +template struct is_iterator_to : + boost::is_convertible::value_type,U> +{ }; + + +} + +#endif // CGAL_IS_ITERATOR_H diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 39723779577..b5bb18e64f3 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -17,9 +17,9 @@ CGAL::Cartesian_complete_predicates< CGAL::Cartesian_complete_constructors< CGAL::Cartesian_complete_computes< CGAL::Cartesian_complete_types< -//CGAL::Cartesian_refcount< +CGAL::Cartesian_refcount< CGAL::Cartesian_LA_base_d > -//> +> >, false, RC >, false, RC >, false, RC @@ -34,7 +34,7 @@ typedef RC K0; #if 0 typedef K0 K2; -#elif 1 +#elif 0 typedef CGAL::Cartesian_filter_NT K2; #elif 1 typedef CGAL::Cartesian_filter_K K2; From 5717606849c93529acd3ebbd914b88fdb02461aa Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 26 May 2011 17:08:24 +0000 Subject: [PATCH 035/210] cleanup use of dimension a bit --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 6 +++++ .../CGAL/Kernel_d/Cartesian_LA_functors.h | 17 ++++++++++++- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 2 ++ .../Kernel_d/function_objects_cartesian.h | 25 +++++++++++++------ .../include/CGAL/Kernel_d/interface_macros.h | 2 ++ NewKernel_d/include/CGAL/LA_eigen/LA.h | 4 +++ NewKernel_d/include/CGAL/functor_tags.h | 2 ++ 7 files changed, 49 insertions(+), 9 deletions(-) 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 ae02192b38e..6974cc8afe7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -102,6 +102,12 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Functor { typedef CartesianDVectorBase::Compute_cartesian_coordinate type; }; + template struct Functor { + typedef CartesianDVectorBase::PV_dimension type; + }; + template struct Functor { + typedef CartesianDVectorBase::PV_dimension type; + }; CGAL_CONSTEXPR Cartesian_LA_base_d(){} CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index a09c7eb950d..3403c380a34 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -12,7 +12,10 @@ namespace CGAL { namespace CartesianDVectorBase { #ifndef CGAL_CXX0X namespace internal { -template struct Construct_LA_vector_; +template struct Construct_LA_vector_ { + struct Never_use {}; + void operator()(Never_use)const; +}; #define CODE(Z,N,_) template struct Construct_LA_vector_ { \ typedef typename R::Constructor Constructor; \ typedef typename R::FT FT; \ @@ -201,6 +204,18 @@ template struct Compute_scalar_product { } }; +template struct PV_dimension { + CGAL_FUNCTOR_INIT_IGNORE(PV_dimension) + typedef R_ R; + typedef typename R::LA_vector argument_type; + typedef int result_type; + + // take a template argument instead? + result_type operator()(argument_type const& v)const{ + return R::LA::size_of_vector(v); + } +}; + } } // namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index f39ed3de488..823b82ea46b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -13,6 +13,8 @@ #include +//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) 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 85f15702a75..3fbbf976682 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -26,11 +26,13 @@ template struct Orientation_of_points : private Store_kernel { template result_type operator()(Iter f, Iter const& e)const{ typename R::template Functor::type c(this->kernel()); - Matrix m(R().dimension(),R().dimension()); + typename R::template Functor::type pd(this->kernel()); Point const& p0=*f++; + int d=pd(p0); + Matrix m(d,d); for(int i=0;f!=e;++f,++i) { - for(int j=0;j struct Orientation_of_vectors : private Store_kernel { template result_type operator()(Iter f, Iter const& e)const{ typename R::template Functor::type c(this->kernel()); - Matrix m(R().dimension(),R().dimension()); - for(int i=0;f!=e;++f,++i) { - for(int j=0;j::type vd(this->kernel()); + Vector const& v0=*f; + int d=vd(v0); + Matrix m(d,d); + for(int j=0;j struct Orientation_of_vectors : private Store_kernel { //TODO: version that takes objects directly instead of iterators }; +#if 0 template::value> struct Orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation) typedef R_ R; @@ -71,15 +80,15 @@ template::v typedef typename R::Orientation result_type; typedef typename R::template Functor::type OP; typedef typename R::template Functor::type OV; - typedef typename R::LA::template Matrix::type Matrix; //FIXME!!! //when Point and Vector are distinct types, the dispatch should be made //in a way that doesn't instantiate a conversion from Point to Vector template result_type operator()(Iter const&f, Iter const& e)const{ + typename R::template Functor::type pd(this->kernel()); typename std::iterator_traits::difference_type d=std::distance(f,e); - int dim=R().dimension(); + int dim=pd(*f); // BAD if(d==dim) return OV(this->kernel())(f,e); CGAL_assertion(d==dim+1); return OP(this->kernel())(f,e); @@ -113,7 +122,7 @@ template struct Orientation : private Store_kernel { } //TODO: version that takes objects directly instead of iterators }; - +#endif template struct Construct_opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_opposite_vector) diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index dc7d79eca72..00e91eae7f9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -60,8 +60,10 @@ CGAL_Kernel_cons2(Construct_segment_extremity, CGAL_Kernel_comp1(Compute_cartesian_coordinate, compute_cartesian_coordinate_object) +#if 0 CGAL_Kernel_pred(Orientation, orientation_object) +#endif CGAL_Kernel_pred(Orientation_of_points, orientation_of_points_object) CGAL_Kernel_pred(Orientation_of_vectors, diff --git a/NewKernel_d/include/CGAL/LA_eigen/LA.h b/NewKernel_d/include/CGAL/LA_eigen/LA.h index 87f72dfadd1..4e40b9b2930 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/LA_eigen/LA.h @@ -63,6 +63,10 @@ template struct LA_eigen { }; public: + templatestatic int size_of_vector(Vec_ const&v){ + return v.size(); + } + templatestatic NT dot_product(Vec_ const&a,Vec_ const&b){ return a.dot(b); } diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 69e6a3e2be9..9472a60c522 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -65,6 +65,8 @@ namespace CGAL { //TODO: split into _begin and _end ? DECL_MISC(Construct_point_cartesian_const_iterator); DECL_MISC(Construct_vector_cartesian_const_iterator); + DECL_MISC(Point_dimension); + DECL_MISC(Vector_dimension); #undef DECL_MISC } #endif // CGAL_FUNCTOR_TAGS_H From 3369e6120cb05b87bea5cea2f1220ff500e127ed Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 30 May 2011 10:08:31 +0000 Subject: [PATCH 036/210] rename Orientation --- NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index b5bb18e64f3..6229fecdc1a 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -59,7 +59,7 @@ typedef K1::Functor::type CV; typedef K1::Functor::type CS; typedef K1::Functor::type CSE; typedef K1::Functor::type CCI; -typedef K1::Functor::type PO; +typedef K1::Functor::type PO; typedef K1::Point_cartesian_const_iterator CI; typedef K1::Functor::type CC; From 9374416840ffbd55041007b1f786dc41d95bd443 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 31 May 2011 17:58:38 +0000 Subject: [PATCH 037/210] Same change as in next. --- NewKernel_d/include/CGAL/is_iterator.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/is_iterator.h b/NewKernel_d/include/CGAL/is_iterator.h index 21711845808..02cf09b0d14 100644 --- a/NewKernel_d/include/CGAL/is_iterator.h +++ b/NewKernel_d/include/CGAL/is_iterator.h @@ -42,17 +42,14 @@ template struct is_iterator_type_ : boost::is_convertible::iterator_category,U> {}; -template struct decay_array { typedef T type; }; -template struct decay_array { typedef T* type; }; -template struct decay_array { typedef T* type; }; } // NOTE: we don't want the real std::decay or functions are included template struct is_iterator : - internal::is_iterator_::type>::type>::type> {}; + internal::is_iterator_::type>::type> {}; template struct is_iterator_type : - internal::is_iterator_type_::type>::type>::type,Tag> {}; + internal::is_iterator_type_::type>::type,Tag> {}; template ::value> struct is_iterator_to { enum { value=false }; From 43d50228f27591fd2dbd4da0e4239cc9039213f4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 20 Jun 2011 13:58:26 +0000 Subject: [PATCH 038/210] Side_of_oriented_sphere --- .../Kernel_d/function_objects_cartesian.h | 36 +++++++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 2 ++ NewKernel_d/include/CGAL/functor_tags.h | 2 +- NewKernel_d/test/NewKernel_d/Makefile | 4 +-- NewKernel_d/test/NewKernel_d/test.cpp | 7 ++-- 5 files changed, 46 insertions(+), 5 deletions(-) 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 3fbbf976682..d3b345870a9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -2,6 +2,7 @@ #define CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H #include +#include #include #include #include @@ -124,6 +125,41 @@ template struct Orientation : private Store_kernel { }; #endif +template struct Side_of_oriented_sphere : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Point Point; + typedef typename R::Oriented_side result_type; + typedef typename Increment_dimension::type D1; + typedef typename Increment_dimension::type D2; + typedef typename R::LA::template Matrix::type Matrix; + + template + result_type operator()(Iter f, Iter const& e)const{ + typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type pd(this->kernel()); + Point const& p0=*f++; + int d=pd(p0); + FT sq=0; + for(int j=0;j struct Construct_opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_opposite_vector) typedef R_ R; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 00e91eae7f9..bf343c15512 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -68,6 +68,8 @@ CGAL_Kernel_pred(Orientation_of_points, orientation_of_points_object) CGAL_Kernel_pred(Orientation_of_vectors, orientation_of_vectors_object) +CGAL_Kernel_pred(Side_of_oriented_sphere, + side_of_oriented_sphere_object) CGAL_Kernel_pred(Less_cartesian_coordinate, less_cartesian_coordinate_object) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 9472a60c522..314242f32f4 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -57,7 +57,7 @@ namespace CGAL { DECL_PREDICATE(Orientation); DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_vectors); - DECL_PREDICATE(In_sphere); + DECL_PREDICATE(Side_of_oriented_sphere); #undef DECL_PREDICATE #define DECL_MISC(X) struct X##_tag {}; \ diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 92cdaa2533c..c80353008f9 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -3,11 +3,11 @@ all: normal cxx0x CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include normal: - g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include -I/opt/eigen -DCGAL_USE_EIGEN ${CGAL_INC} + g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} ./a.out cxx0x: - /usr/lib/gcc-snapshot/bin/g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include -I/opt/eigen -DCGAL_USE_EIGEN ${CGAL_INC} + /usr/lib/gcc-snapshot/bin/g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} ./a.out #-DBOOST_RESULT_OF_USE_DECLTYPE diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 6229fecdc1a..5029dda9462 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -60,6 +60,7 @@ typedef K1::Functor::type CS; typedef K1::Functor::type CSE; typedef K1::Functor::type CCI; typedef K1::Functor::type PO; +typedef K1::Functor::type SOS; typedef K1::Point_cartesian_const_iterator CI; typedef K1::Functor::type CC; @@ -77,6 +78,7 @@ int main(){ PO po Kinit; CS cs Kinit; CSE cse Kinit; + SOS sos Kinit; P a=cp(3,4); P b=cp(5,6,7); int rr[]={3,5,2}; @@ -91,6 +93,7 @@ int main(){ for(CI i=ci(a,CGAL::Begin_tag());i!=ci(a,CGAL::End_tag());++i) std::cout << *i << ' '; std::cout << '\n'; - P tab[]={a,b,c}; - std::cout << po(&tab[0],tab+3) << std::endl; + P tab[]={a,b,c,d}; + std::cout << po (&tab[0],tab+3) << std::endl; + std::cout << sos(&tab[0],tab+4) << std::endl; } From 852c317f5688f970e8790b2c6b65b9d4bab44202 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 12 Oct 2011 15:40:20 +0000 Subject: [PATCH 039/210] Take vector from Vector, not LA. Hush signed/unsigned comparison. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 26 +++++++++---------- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 12 ++++----- NewKernel_d/include/CGAL/Vector/array.h | 15 ++++++----- 3 files changed, 27 insertions(+), 26 deletions(-) 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 6974cc8afe7..f3a60b979fd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef CGAL_USE_EIGEN #include #else @@ -17,7 +18,7 @@ namespace CGAL { -template < typename FT_, typename Dim_> +template < typename FT_, typename Dim_, typename Vec_=Array_vector, typename LA_=LA_eigen > struct Cartesian_LA_base_d : public Dimension_base { typedef FT_ FT; @@ -27,11 +28,7 @@ struct Cartesian_LA_base_d : public Dimension_base typedef Cartesian_tag Kernel_tag; typedef Dim_ Default_ambient_dimension; typedef Dim_ Max_ambient_dimension; -#ifdef CGAL_USE_EIGEN - typedef CGAL::LA_eigen LA; -#else - typedef CGAL::LA_default LA; -#endif + typedef LA_ LA; typedef typename Same_uncertainty_nt::type Boolean; @@ -48,15 +45,15 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typename Same_uncertainty_nt::type Angle; - typedef typename LA::template Vector LA_vector_selector; - typedef typename LA_vector_selector::type LA_vector; - typedef typename LA_vector_selector::Constructor Constructor; - typedef typename LA_vector_selector::const_iterator Point_cartesian_const_iterator; - typedef typename LA_vector_selector::const_iterator Vector_cartesian_const_iterator; + typedef Vec_ Vector_selector; + typedef typename Vector_selector::type Vector_; + typedef typename Vector_selector::Constructor Constructor; + typedef typename Vector_selector::const_iterator Point_cartesian_const_iterator; + typedef typename Vector_selector::const_iterator Vector_cartesian_const_iterator; // convert types to the new way? painful to use... - typedef LA_vector Point; - typedef LA_vector Vector; + typedef Vector_ Point; + typedef Vector_ Vector; #if 0 // old way @@ -87,6 +84,8 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Functor { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; +#if 0 + // Doesn't seem worth the trouble. template struct Functor { typedef CartesianDVectorBase::Construct_sum_of_vectors type; }; @@ -99,6 +98,7 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Functor { typedef CartesianDVectorBase::Construct_midpoint type; }; +#endif template struct Functor { typedef CartesianDVectorBase::Compute_cartesian_coordinate type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 509e9430461..dcece0c4592 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -19,7 +19,7 @@ template struct Construct_LA_vector_ { #define CODE(Z,N,_) template struct Construct_LA_vector_ { \ typedef typename R::Constructor Constructor; \ typedef typename R::FT FT; \ - typedef typename R::LA_vector result_type; \ + typedef typename R::Vector_ result_type; \ result_type operator() \ (BOOST_PP_ENUM_PARAMS(N,FT const& t)) const { \ return typename Constructor::Values()(BOOST_PP_ENUM_PARAMS(N,t)); \ @@ -43,7 +43,7 @@ template struct Construct_LA_vector typedef R_ R; typedef typename R::Constructor Constructor; typedef typename R::FT FT; - typedef typename R::LA_vector result_type; + typedef typename R::Vector_ result_type; typedef typename R_::Default_ambient_dimension Dimension; static const int dim=Dimension::value; result_type operator()(int d)const{ @@ -112,7 +112,7 @@ template struct Compute_cartesian_coordinate { CGAL_FUNCTOR_INIT_IGNORE(Compute_cartesian_coordinate) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::LA_vector first_argument_type; + typedef typename R::Vector_ first_argument_type; typedef int second_argument_type; typedef Tag_true Is_exact; #ifdef CGAL_CXX0X @@ -131,8 +131,8 @@ template struct Compute_cartesian_coordinate { template struct Construct_cartesian_const_iterator { CGAL_FUNCTOR_INIT_IGNORE(Construct_cartesian_const_iterator) typedef R_ R; - typedef typename R::LA_vector argument_type; - typedef typename R::LA_vector_selector S_; + typedef typename R::Vector_ argument_type; + typedef typename R::Vector_selector S_; typedef typename R::Point_cartesian_const_iterator result_type; // same as Vector @@ -207,7 +207,7 @@ template struct Compute_scalar_product { template struct PV_dimension { CGAL_FUNCTOR_INIT_IGNORE(PV_dimension) typedef R_ R; - typedef typename R::LA_vector argument_type; + typedef typename R::Vector_ argument_type; typedef int result_type; // take a template argument instead? diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 9410025a502..43594e59835 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -9,15 +9,16 @@ #include namespace CGAL { -// May not be safe to use with dim!=max_dim +// May not be safe to use with dim!=max_dim. +// In that case, we should store the real dim next to the array. template struct Array_vector { typedef NT_ NT; - static const int d_=Max_dim_::value; + static const unsigned d_=Max_dim_::value; typedef cpp0x::array type; struct Constructor { struct Dimension { // Initialize with NaN if possible? - type operator()(int d) const { + type operator()(unsigned d) const { CGAL_assertion(d<=d_); return type(); } @@ -25,7 +26,7 @@ template struct Array_vector { struct Iterator { template - type operator()(int d,Iter const& f,Iter const& e) const { + type operator()(unsigned d,Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)); CGAL_assertion(d<=d_); //TODO: optimize for forward iterators @@ -38,7 +39,7 @@ template struct Array_vector { #if 0 struct Iterator_add_one { template - type operator()(int d,Iter const& f,Iter const& e) const { + type operator()(unsigned d,Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)+1); CGAL_assertion(d<=d_); //TODO: optimize @@ -52,7 +53,7 @@ template struct Array_vector { struct Iterator_and_last { template - type operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + type operator()(unsigned d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { CGAL_assertion(d==std::distance(f,e)+1); CGAL_assertion(d<=d_); //TODO: optimize for forward iterators @@ -116,7 +117,7 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) static const_iterator vector_end(type const&a){ return &a[0]+d_; // Don't know the real size } - static int size_of_vector(type const&a){ + static unsigned size_of_vector(type const&a){ return d_; // Don't know the real size } From 21228b30e65d2c890340e5f4291f317d6aaaeff3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 12 Oct 2011 19:48:23 +0000 Subject: [PATCH 040/210] Continue removing LA. Start obfuscating^Wusing an indirection for object types. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 26 +++++++------------ .../CGAL/Kernel_d/Cartesian_LA_functors.h | 2 ++ .../CGAL/Kernel_d/Cartesian_complete.h | 6 ++++- .../CGAL/Kernel_d/Cartesian_converter.h | 8 +++--- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 2 +- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 8 +++--- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 2 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 2 +- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 4 +-- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 2 +- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 2 +- .../Kernel_d/function_objects_cartesian.h | 8 +++--- .../include/CGAL/Kernel_d/interface_macros.h | 12 ++++----- NewKernel_d/include/CGAL/functor_tags.h | 5 +++- NewKernel_d/test/NewKernel_d/test.cpp | 6 ++--- 16 files changed, 50 insertions(+), 47 deletions(-) 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 f3a60b979fd..d65c47468fd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -51,31 +51,25 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typename Vector_selector::const_iterator Point_cartesian_const_iterator; typedef typename Vector_selector::const_iterator Vector_cartesian_const_iterator; - // convert types to the new way? painful to use... + // TODO: remove typedef Vector_ Point; typedef Vector_ Vector; -#if 0 - // old way - typedef CartesianDVectorBase::Construct_LA_vector Construct_point; - typedef CartesianDVectorBase::Construct_LA_vector Construct_vector; - typedef CartesianDVectorBase::Construct_cartesian_const_iterator Construct_cartesian_const_iterator; - typedef CartesianDVectorBase::Construct_sum_of_vectors Construct_sum_of_vectors; - typedef CartesianDVectorBase::Construct_difference_of_vectors Construct_difference_of_vectors; - typedef CartesianDVectorBase::Construct_opposite_vector Construct_opposite_vector; - typedef CartesianDVectorBase::Construct_midpoint Construct_midpoint; + template struct Type {}; + template struct Type { + typedef Vector_ type; + }; + template struct Type { + typedef Vector_ type; + }; - typedef CartesianDVectorBase::Compute_cartesian_coordinate Compute_cartesian_coordinate; -#endif - - // new way template struct Functor { typedef Null_functor type; }; - template struct Functor { + template struct Functor,D> { typedef CartesianDVectorBase::Construct_LA_vector type; }; - template struct Functor { + template struct Functor,D> { typedef CartesianDVectorBase::Construct_LA_vector type; }; template struct Functor { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index dcece0c4592..61f80041a2e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -144,6 +144,7 @@ template struct Construct_cartesian_const_iterator { } }; +#if 0 template struct Construct_midpoint { CGAL_FUNCTOR_INIT_IGNORE(Construct_midpoint) typedef R_ R; @@ -203,6 +204,7 @@ template struct Compute_scalar_product { return LA::dot_product(a,b); } }; +#endif template struct PV_dimension { CGAL_FUNCTOR_INIT_IGNORE(PV_dimension) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 78518826e9e..83a69a0877a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -28,6 +28,10 @@ template struct Cartesian_define_all_functors typedef CartesianDKernelFunctors::F type; \ }; //type f() const { return type(); } +#define CGAL_Kernel_obj2(X,Y) \ + template struct Functor ,D> { \ + typedef CartesianDKernelFunctors::Construct_##Y type; \ + }; #define CGAL_Kernel_pred(F,f) CGAL_Kernel_cons2(F,f) #define CGAL_Kernel_comp2(F,f) CGAL_Kernel_cons2(F,f) @@ -39,7 +43,7 @@ template struct Cartesian_complete_types : public R_ { typedef R_ Kernel_base; -#define CGAL_Kernel_obj2(X) typedef typename boost::mpl::if_c::value,X##Cd,R_>::type::X X; +#define CGAL_Kernel_obj2(X,Y) typedef typename boost::mpl::if_c::value,X##Cd,R_>::type::X X; #include }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index c2798996739..3d28df1d9fe 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -59,26 +59,26 @@ template class CartesianD_converter typename K2::Point operator()(typename K1::Point const& p)const{ typename K1::template Functor::type i(this->kernel()); - typename K2::template Functor::type cp(this->kernel2()); + typename K2::template Functor >::type cp(this->kernel2()); return cp(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } typename K2::Vector operator()(typename First_if_different::Type const& p)const{ typename K1::template Functor::type i(this->kernel()); - typename K2::template Functor::type cv(this->kernel2()); + typename K2::template Functor >::type cv(this->kernel2()); return cv(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } typename K2::Segment operator()(typename K1::Segment const& s)const{ typename K1::template Functor::type f(this->kernel()); - typename K2::template Functor::type cs(this->kernel2()); + typename K2::template Functor >::type cs(this->kernel2()); return cs(operator()(f(s,0)),operator()(f(s,1))); } Object operator()(const Object &obj) const { -#define CGAL_Kernel_obj(X) \ +#define CGAL_Kernel_obj(X,Y) \ if (const typename K1::X * ptr = object_cast(&obj)) \ return make_object(operator()(*ptr)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 0ce144f8ebb..2ab3145d4c9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -54,7 +54,7 @@ struct Lazy_cartesian : Dimension_base typedef typename Same_uncertainty_nt::type Angle; -#define CGAL_Kernel_obj(X) \ +#define CGAL_Kernel_obj(X,Y) \ typedef Lazy X; #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index 829a8f1d8e7..19ec9f44ca0 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -8,7 +8,7 @@ template class Segmentd { typedef typename R_::FT FT_; typedef typename R_::Point Point_; typedef typename R_::Vector Vector_; - typedef typename R_::template Functor::type Cv_; + typedef typename R_::template Functor >::type Cv_; // typedef typename R_::Compute_squared_distance Csd_; typedef std::pair Data_; Data_ data; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 823b82ea46b..e2867e86162 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -80,7 +80,7 @@ struct Cartesian_wrap : public Base_ typedef Cartesian_wrap Self; template struct map_type; -#define CGAL_Kernel_obj(X) typedef X##_d X; \ +#define CGAL_Kernel_obj(X,Y) typedef X##_d X; \ template struct map_type { typedef X type; }; #include @@ -150,10 +150,10 @@ struct Cartesian_refcount : public Base_ typedef Cartesian_refcount Self; template struct map_type; -#define CGAL_Kernel_obj(X) typedef X##_rc_d X; \ +#define CGAL_Kernel_obj(X,Y) typedef X##_rc_d X; \ template struct map_type { typedef X type; }; - CGAL_Kernel_obj(Point) - CGAL_Kernel_obj(Vector) + CGAL_Kernel_obj(Point,point) + CGAL_Kernel_obj(Vector,vector) template struct Dispatch { //typedef typename map_functor_type::type f_t; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 0fd4c183df9..440731c7531 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -22,7 +22,7 @@ class Point_d : public R_::Kernel_base::Point typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Vector Vector_; - typedef typename Kbase::template Functor::type CPBase; + typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor::type CCBase; typedef Point_d Self; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index 3897b871e74..7ce96bbc6d9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -22,7 +22,7 @@ template class Point_rc_d { typedef typename R_::Kernel_base Kbase; - typedef typename Kbase::template Functor::type CPBase; + typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor::type CCBase; typedef Point_rc_d Self; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 734d7c67537..6376b66b390 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -22,8 +22,8 @@ class Segment_d : public R_::Kernel_base::Segment typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Point Point_; - typedef typename Kbase::template Functor::type CPBase; - typedef typename Kbase::template Functor::type CSBase; + typedef typename Kbase::template Functor >::type CPBase; + typedef typename Kbase::template Functor >::type CSBase; typedef typename Kbase::template Functor::type CSEBase; typedef Segment_d Self; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 46801f72fda..3b8897259e9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -22,7 +22,7 @@ class Vector_d : public R_::Kernel_base::Vector typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Point Point_; - typedef typename Kbase::template Functor::type CVBase; + typedef typename Kbase::template Functor >::type CVBase; typedef typename Kbase::template Functor::type CCBase; typedef Vector_d Self; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index 4d07fb6b432..85b9f567e8a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -22,7 +22,7 @@ template class Vector_rc_d { typedef typename R_::Kernel_base Kbase; - typedef typename Kbase::template Functor::type CPBase; + typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor::type CCBase; typedef Vector_rc_d Self; 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 7a69eb600a5..ac873b12bc2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -165,7 +165,7 @@ template struct Construct_opposite_vector : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Functor::type CV; + typedef typename R::template Functor >::type CV; typedef typename R::template Functor::type CI; typedef Vector result_type; typedef Vector argument_type; @@ -180,7 +180,7 @@ template struct Construct_sum_of_vectors : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Functor::type CV; + typedef typename R::template Functor >::type CV; typedef typename R::template Functor::type CI; typedef Vector result_type; typedef Vector first_argument_type; @@ -196,7 +196,7 @@ template struct Construct_difference_of_vectors : private Store_kernel typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Functor::type CV; + typedef typename R::template Functor >::type CV; typedef typename R::template Functor::type CI; typedef Vector result_type; typedef Vector first_argument_type; @@ -212,7 +212,7 @@ template struct Construct_midpoint : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; - typedef typename R::template Functor::type CP; + typedef typename R::template Functor >::type CP; typedef typename R::template Functor::type CI; typedef Point result_type; typedef Point first_argument_type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index bf343c15512..784cda3294a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -23,18 +23,18 @@ #endif #ifndef CGAL_Kernel_obj -# define CGAL_Kernel_obj(X) +# define CGAL_Kernel_obj(X,Y) #endif #ifndef CGAL_Kernel_obj1 -# define CGAL_Kernel_obj1(X) CGAL_Kernel_obj(X) +# define CGAL_Kernel_obj1(X,Y) CGAL_Kernel_obj(X,Y) #endif #ifndef CGAL_Kernel_obj2 -# define CGAL_Kernel_obj2(X) CGAL_Kernel_obj(X) +# define CGAL_Kernel_obj2(X,Y) CGAL_Kernel_obj(X,Y) #endif -CGAL_Kernel_obj1(Vector) -CGAL_Kernel_obj1(Point) -CGAL_Kernel_obj2(Segment) +CGAL_Kernel_obj1(Vector,vector) +CGAL_Kernel_obj1(Point,point) +CGAL_Kernel_obj2(Segment,segment) CGAL_Kernel_cons1(Construct_vector, construct_vector_object) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 314242f32f4..0589b0a4539 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -25,7 +25,10 @@ namespace CGAL { DECL_OBJ(Bbox); #undef DECL_OBJ - templatestruct map_result_tag{typedef Null_type type;}; + templatestruct Construct_ttag {}; + templatestruct map_result_tag{typedef Null_type type;}; + templatestruct map_result_tag >{typedef T type;}; + templatestruct map_functor_type >{typedef Construct_tag type;}; #define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ template<>struct map_result_tag{typedef Y##_tag type;}; \ template<>struct map_functor_type{typedef Construct_tag type;} diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 5029dda9462..07eb01b7043 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -54,9 +54,9 @@ typedef K1::Point P; typedef K1::Vector V; typedef K1::Segment S; //typedef K1::Construct_point CP; -typedef K1::Functor::type CP; -typedef K1::Functor::type CV; -typedef K1::Functor::type CS; +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 PO; From 15fddb1e2f6149cb9b492d3f7a711acf10572a91 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 14 Oct 2011 20:48:31 +0000 Subject: [PATCH 041/210] continue move to Type<*_tag> --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h | 4 ++-- NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h | 8 +++++++- NewKernel_d/include/CGAL/marcutils.h | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) 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 40196a9350b..bd334219e9d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -8,7 +8,7 @@ namespace CGAL { -template < typename Base_, typename FT_> +template < typename Base_, typename FT_, typename LA_=CGAL::LA_eigen > struct Cartesian_change_FT_base : public Base_ { @@ -19,7 +19,7 @@ struct Cartesian_change_FT_base : public typedef Base_ Kernel_base; typedef FT_ RT; typedef FT_ FT; - typedef CGAL::LA_eigen LA; + typedef LA_ LA; typedef typename Same_uncertainty_nt::type Boolean; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 83a69a0877a..b1aaf342078 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -43,7 +43,13 @@ template struct Cartesian_complete_types : public R_ { typedef R_ Kernel_base; -#define CGAL_Kernel_obj2(X,Y) typedef typename boost::mpl::if_c::value,X##Cd,R_>::type::X X; + template struct Type : Kernel_base::template Type {}; +#define CGAL_Kernel_obj2(X,Y) \ + typedef typename boost::mpl::if_c::value,X##Cd,R_>::type::X X; \ + template struct Type { \ + typedef typename Kernel_base::template Type B_; \ + typedef typename boost::mpl::if_c::value,Wrap_type >,B_>::type::type type; \ + }; #include }; diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 844b97a2933..8d898070e7e 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -20,6 +20,12 @@ namespace CGAL { +namespace internal { + BOOST_MPL_HAS_XXX_TRAIT_DEF(type) +} + + template struct Wrap_type { typedef T type; }; + // tell a function f(a,b,c) that its real argument is a(b,c) struct Eval_functor {}; From c358e2ed56ffffbf9934acb561d0f2390777c42f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 16 Oct 2011 08:38:38 +0000 Subject: [PATCH 042/210] Continue with Type<*_tag> --- .../CGAL/Kernel_d/Cartesian_converter.h | 23 +++++++++------- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 10 ++++--- NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 4 +-- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 6 +++++ .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 8 +++--- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 4 +-- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 8 +++--- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 8 +++--- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 4 +-- .../Kernel_d/function_objects_cartesian.h | 26 +++++++++---------- 10 files changed, 58 insertions(+), 43 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index 3d28df1d9fe..f6b498f48c9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -21,6 +21,13 @@ template class CartesianD_converter typedef typename K2::FT FT2; typedef NT_converter NTc; NTc c; + + typedef typename K1::template Type::type K1_Point; + typedef typename K2::template Type::type K2_Point; + typedef typename K1::template Type::type K1_Vector; + typedef typename K2::template Type::type K2_Vector; + typedef typename K1::template Type::type K1_Segment; + typedef typename K2::template Type::type K2_Segment; public: CartesianD_converter(){} CartesianD_converter(K1 const&a,K2 const&b):Store_kernel(a),Store_kernel2(b){} @@ -30,9 +37,7 @@ template class CartesianD_converter template struct result{ //assert that T is an iterator, or better yet make sure //we don't get here otherwise -#ifdef CGAL_CXX0X - static_assert(is_iterator::value,"OUIN!"); -#endif + CGAL_static_assertion(is_iterator::value); typedef transforming_iterator type; }; template struct result{typedef K2 type;}; @@ -41,8 +46,8 @@ template class CartesianD_converter template struct result{typedef Null_vector type;}; template struct result{typedef Object type;}; template struct result{typedef FT2 type;}; - template struct result{typedef typename K2::Point type;}; - template struct result::Type),i>{typedef typename K2::Vector type;}; + template struct result{typedef K2_Point type;}; + template struct result::Type),i>{typedef K2_Vector type;}; typename Store_kernel2::reference2_type operator()(K1 const&)const{return this->kernel2();} int operator()(int i)const{return i;} @@ -57,19 +62,19 @@ template class CartesianD_converter return make_transforming_iterator(it,*this); } - typename K2::Point operator()(typename K1::Point const& p)const{ + K2_Point operator()(K1_Point const& p)const{ typename K1::template Functor::type i(this->kernel()); typename K2::template Functor >::type cp(this->kernel2()); return cp(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } - typename K2::Vector operator()(typename First_if_different::Type const& p)const{ + K2_Vector operator()(typename First_if_different::Type const& p)const{ typename K1::template Functor::type i(this->kernel()); typename K2::template Functor >::type cv(this->kernel2()); return cv(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); } - typename K2::Segment operator()(typename K1::Segment const& s)const{ + K2_Segment operator()(K1_Segment const& s)const{ typename K1::template Functor::type f(this->kernel()); typename K2::template Functor >::type cs(this->kernel2()); return cs(operator()(f(s,0)),operator()(f(s,1))); @@ -79,7 +84,7 @@ template class CartesianD_converter operator()(const Object &obj) const { #define CGAL_Kernel_obj(X,Y) \ - if (const typename K1::X * ptr = object_cast(&obj)) \ + if (const typename K1::template Type::type * ptr = object_cast::type>(&obj)) \ return make_object(operator()(*ptr)); #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 2ab3145d4c9..c19e3f98a60 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -54,8 +54,12 @@ struct Lazy_cartesian : Dimension_base typedef typename Same_uncertainty_nt::type Angle; + template struct Type {}; #define CGAL_Kernel_obj(X,Y) \ - typedef Lazy X; + typedef Lazy::type, typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> X; \ + template struct Type { \ + typedef Lazy::type, typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> type; \ + }; #include @@ -79,8 +83,8 @@ struct Lazy_cartesian : Dimension_base typedef Lazy_construction type; }; - typedef Iterator_from_indices::type> Point_cartesian_const_iterator; - typedef Iterator_from_indices::type> Vector_cartesian_const_iterator; + typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Point_cartesian_const_iterator; + typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Vector_cartesian_const_iterator; template struct Construct_iter : private Store_kernel { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index 19ec9f44ca0..385d3278886 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -6,8 +6,8 @@ namespace CGAL { template class Segmentd { typedef typename R_::FT FT_; - typedef typename R_::Point Point_; - typedef typename R_::Vector Vector_; + typedef typename R_::template Type::type Point_; + typedef typename R_::template Type::type Vector_; typedef typename R_::template Functor >::type Cv_; // typedef typename R_::Compute_squared_distance Csd_; typedef std::pair Data_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index e2867e86162..75e55ff8766 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -79,8 +79,12 @@ struct Cartesian_wrap : public Base_ typedef Base_ Kernel_base; typedef Cartesian_wrap Self; + templatestruct Type : Kernel_base::template Type {}; + + // What is map_type for? It is not currently used and seems redundant with map_kernel_obj. template struct map_type; #define CGAL_Kernel_obj(X,Y) typedef X##_d X; \ + templatestruct Type { typedef X##_d type; };\ template struct map_type { typedef X type; }; #include @@ -149,8 +153,10 @@ struct Cartesian_refcount : public Base_ typedef Base_ Kernel_base; typedef Cartesian_refcount Self; + templatestruct Type : Kernel_base::template Type {}; template struct map_type; #define CGAL_Kernel_obj(X,Y) typedef X##_rc_d X; \ + templatestruct Type { typedef X##_rc_d type; };\ template struct map_type { typedef X type; }; CGAL_Kernel_obj(Point,point) CGAL_Kernel_obj(Vector,vector) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 440731c7531..aa9ed6526c3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -16,17 +16,17 @@ namespace CGAL { template -class Point_d : public R_::Kernel_base::Point +class Point_d : public R_::Kernel_base::template Type::type { typedef typename R_::RT RT_; typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::Vector Vector_; + typedef typename R_::template Type::type Vector_; typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor::type CCBase; typedef Point_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: @@ -35,7 +35,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Point Rep; + typedef typename Kbase::template Type::type Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index 7ce96bbc6d9..966b8069044 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -26,7 +26,7 @@ class Point_rc_d typedef typename Kbase::template Functor::type CCBase; typedef Point_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: typedef R_ R; @@ -36,7 +36,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Point Rep; + typedef typename Kbase::template Type::type Rep; typedef Handle_for Data; private: diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 6376b66b390..1a9accc7313 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -16,18 +16,18 @@ namespace CGAL { template -class Segment_d : public R_::Kernel_base::Segment +class Segment_d : public R_::Kernel_base::template Type::type { typedef typename R_::RT RT_; typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::Point Point_; + typedef typename R_::template Type::type Point_; typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor >::type CSBase; typedef typename Kbase::template Functor::type CSEBase; typedef Segment_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: @@ -35,7 +35,7 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<1> Feature_dimension; - typedef typename Kbase::Segment Rep; + typedef typename Kbase::template Type::type Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 3b8897259e9..c86250b1181 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -16,17 +16,17 @@ namespace CGAL { template -class Vector_d : public R_::Kernel_base::Vector +class Vector_d : public R_::Kernel_base::template Type::type { typedef typename R_::RT RT_; typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::Point Point_; + typedef typename R_::template Type::type Point_; typedef typename Kbase::template Functor >::type CVBase; typedef typename Kbase::template Functor::type CCBase; typedef Vector_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: @@ -35,7 +35,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Vector_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Vector Rep; + typedef typename Kbase::template Type::type Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index 85b9f567e8a..419e4039a1d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -26,7 +26,7 @@ class Vector_rc_d typedef typename Kbase::template Functor::type CCBase; typedef Vector_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: typedef R_ R; @@ -36,7 +36,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Vector_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Vector Rep; + typedef typename Kbase::template Type::type Rep; typedef Handle_for Data; private: 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 ac873b12bc2..c10b32332f2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -20,7 +20,7 @@ template struct Orientation_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename R::template Type::type Point; typedef typename R::Orientation result_type; typedef typename R::LA::template Matrix::type Matrix; @@ -46,7 +46,7 @@ template struct Orientation_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Vector Vector; + typedef typename R::template Type::type Vector; typedef typename R::Orientation result_type; typedef typename R::LA::template Matrix::type Matrix; @@ -129,7 +129,7 @@ template struct Side_of_oriented_sphere : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename R::template Type::type Point; typedef typename R::Oriented_side result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; @@ -164,7 +164,7 @@ template struct Construct_opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_opposite_vector) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Vector Vector; + typedef typename R::template Type::type Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor::type CI; typedef Vector result_type; @@ -179,7 +179,7 @@ template struct Construct_sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_sum_of_vectors) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Vector Vector; + typedef typename R::template Type::type Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor::type CI; typedef Vector result_type; @@ -195,7 +195,7 @@ template struct Construct_difference_of_vectors : private Store_kernel CGAL_FUNCTOR_INIT_STORE(Construct_difference_of_vectors) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Vector Vector; + typedef typename R::template Type::type Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor::type CI; typedef Vector result_type; @@ -211,7 +211,7 @@ template struct Construct_midpoint : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_midpoint) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename R::template Type::type Point; typedef typename R::template Functor >::type CP; typedef typename R::template Functor::type CI; typedef Point result_type; @@ -234,7 +234,7 @@ template struct Compute_squared_length : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compute_squared_length) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Vector Vector; + typedef typename R::template Type::type Vector; typedef typename R::template Functor::type CI; typedef FT result_type; typedef Vector argument_type; @@ -250,7 +250,7 @@ template struct Compute_squared_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compute_squared_distance) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename R::template Type::type Point; typedef typename R::template Functor::type CI; typedef FT result_type; typedef Point first_argument_type; @@ -288,8 +288,8 @@ template struct Less_cartesian_coordinate : private Store_kernel { template struct Construct_segment { CGAL_FUNCTOR_INIT_IGNORE(Construct_segment) typedef R_ R; - typedef typename R_::Point Point; - typedef typename R_::Segment Segment; + typedef typename R_::template Type::type Point; + typedef typename R_::template Type::type Segment; typedef Segment result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ @@ -307,8 +307,8 @@ template struct Construct_segment { template struct Construct_segment_extremity { CGAL_FUNCTOR_INIT_IGNORE(Construct_segment_extremity) typedef R_ R; - typedef typename R_::Point Point; - typedef typename R_::Segment Segment; + typedef typename R_::template Type::type Point; + typedef typename R_::template Type::type Segment; typedef Point result_type; result_type operator()(Segment const&s, int i)const{ if(i==0) return s.source(); From 3fd4068328b2c3b66fc4b3490cd17249d4eece5f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 17 Oct 2011 11:34:11 +0000 Subject: [PATCH 043/210] Remove non-Type stuff --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 4 ---- .../include/CGAL/Kernel_d/Cartesian_complete.h | 1 - .../include/CGAL/Kernel_d/Lazy_cartesian.h | 1 - .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 18 +++++++----------- NewKernel_d/include/CGAL/functor_tags.h | 4 +--- NewKernel_d/test/NewKernel_d/test.cpp | 6 +++--- 6 files changed, 11 insertions(+), 23 deletions(-) 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 d65c47468fd..699570077f5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -51,10 +51,6 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typename Vector_selector::const_iterator Point_cartesian_const_iterator; typedef typename Vector_selector::const_iterator Vector_cartesian_const_iterator; - // TODO: remove - typedef Vector_ Point; - typedef Vector_ Vector; - template struct Type {}; template struct Type { typedef Vector_ type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index b1aaf342078..50258a506cc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -45,7 +45,6 @@ template struct Cartesian_complete_types typedef R_ Kernel_base; template struct Type : Kernel_base::template Type {}; #define CGAL_Kernel_obj2(X,Y) \ - typedef typename boost::mpl::if_c::value,X##Cd,R_>::type::X X; \ template struct Type { \ typedef typename Kernel_base::template Type B_; \ typedef typename boost::mpl::if_c::value,Wrap_type >,B_>::type::type type; \ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index c19e3f98a60..24411d72e01 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -56,7 +56,6 @@ struct Lazy_cartesian : Dimension_base template struct Type {}; #define CGAL_Kernel_obj(X,Y) \ - typedef Lazy::type, typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> X; \ template struct Type { \ typedef Lazy::type, typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> type; \ }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 75e55ff8766..bf8c76ad3a2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -81,11 +81,8 @@ struct Cartesian_wrap : public Base_ templatestruct Type : Kernel_base::template Type {}; - // What is map_type for? It is not currently used and seems redundant with map_kernel_obj. - template struct map_type; -#define CGAL_Kernel_obj(X,Y) typedef X##_d X; \ - templatestruct Type { typedef X##_d type; };\ - template struct map_type { typedef X type; }; +#define CGAL_Kernel_obj(X,Y) \ + templatestruct Type { typedef X##_d type; }; #include //Translate the arguments @@ -125,7 +122,7 @@ struct Cartesian_wrap : public Base_ type(){} type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; - typedef typename map_kernel_obj::type result_type; + typedef typename Self::template Type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); @@ -154,12 +151,11 @@ struct Cartesian_refcount : public Base_ typedef Cartesian_refcount Self; templatestruct Type : Kernel_base::template Type {}; - template struct map_type; -#define CGAL_Kernel_obj(X,Y) typedef X##_rc_d X; \ - templatestruct Type { typedef X##_rc_d type; };\ - template struct map_type { typedef X type; }; +#define CGAL_Kernel_obj(X,Y) \ + templatestruct Type { typedef X##_rc_d type; }; CGAL_Kernel_obj(Point,point) CGAL_Kernel_obj(Vector,vector) +#undef CGAL_Kernel_obj template struct Dispatch { //typedef typename map_functor_type::type f_t; @@ -207,7 +203,7 @@ struct Cartesian_refcount : public Base_ type(){} type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; - typedef typename map_kernel_obj::type result_type; + typedef typename Self::template Type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 0589b0a4539..4fd7a35d729 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -13,9 +13,7 @@ namespace CGAL { templatestruct map_functor_type{typedef Misc_tag type;}; - templatestruct map_kernel_obj{typedef Null_type type;}; -#define DECL_OBJ(X) struct X##_tag {}; \ - templatestruct map_kernel_obj{typedef typename K::X type;} +#define DECL_OBJ(X) struct X##_tag {}; DECL_OBJ(Vector); DECL_OBJ(Point); DECL_OBJ(Segment); diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 07eb01b7043..b9674c3c26b 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -50,9 +50,9 @@ typedef CGAL::Cartesian_wrap K1; typedef CGAL::Cartesian_wrap K3; typedef CGAL::Cartesian_wrap K1; #endif -typedef K1::Point P; -typedef K1::Vector V; -typedef K1::Segment S; +typedef K1::Type::type P; +typedef K1::Type::type V; +typedef K1::Type::type S; //typedef K1::Construct_point CP; typedef K1::Functor >::type CP; typedef K1::Functor >::type CV; From 1d9e7b9858d0b72917153b69457afafcd92fa1af Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 25 Oct 2011 11:57:11 +0000 Subject: [PATCH 044/210] try and make the converter more flexible --- .../CGAL/Kernel_d/Cartesian_converter.h | 110 +++++++++++------- .../CGAL/Kernel_d/Kernel_object_converter.h | 46 ++++++++ NewKernel_d/test/NewKernel_d/Makefile | 2 +- 3 files changed, 115 insertions(+), 43 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index f6b498f48c9..110848eaf78 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -2,6 +2,7 @@ #define CGAL_KERNEL_D_CARTESIAN_CONVERTER_H #include +#include #include #include #include @@ -10,45 +11,85 @@ #include #include #include +#include namespace CGAL { //TODO: special case when K1==K2 (or they are very close?) -template class CartesianD_converter - : private Store_kernel, private Store_kernel2 +template class CartesianD_converter_; +template class CartesianD_converter_ > { + public: + struct Do_not_use{}; + void operator()(Do_not_use)const{} + template struct result; + Final_& myself(){return *static_cast(this);} + Final_ const& myself()const{return *static_cast(this);} +}; +#ifdef CGAL_CXX0X +template class CartesianD_converter_ > +: public CartesianD_converter_ > +{ + typedef CartesianD_converter_ > Base; + typedef KO_converter KOC; + typedef typename KOC::argument_type K1_Obj; + typedef typename KOC::result_type K2_Obj; + public: + using Base::operator(); // don't use directly, just make it accessible to the next level + K2_Obj operator()(K1_Obj const& o)const{ + return KOC()(this->myself().kernel(),this->myself().kernel2(),this->myself(),o); + } + template struct result:Base::template result{}; + template struct result {typedef K2_Obj type;}; +}; +#else +#define CODE(Z,N,_) \ +template class CartesianD_converter_ > \ +: public CartesianD_converter_ > \ +{ \ + typedef CartesianD_converter_ > Base; \ + typedef KO_converter KOC; \ + typedef typename KOC::argument_type K1_Obj; \ + typedef typename KOC::result_type K2_Obj; \ + public: \ + using Base::operator(); \ + K2_Obj operator()(K1_Obj const& o)const{ \ + return KOC()(this->myself().kernel(),this->myself().kernel2(),this->myself(),o); \ + } \ + template struct result:Base::template result{}; \ + template struct result {typedef K2_Obj type;}; \ +}; +BOOST_PP_REPEAT_FROM_TO(0, 8, CODE, _ ) +#undef CODE +#endif +template > class CartesianD_converter + : public Store_kernel, public Store_kernel2, + public CartesianD_converter_,K1,K2,List_> { typedef CartesianD_converter Self; + typedef Self Final_; + typedef CartesianD_converter_ Base; typedef typename K1::FT FT1; typedef typename K2::FT FT2; typedef NT_converter NTc; - NTc c; + NTc c; // TODO: compressed storage as this is likely empty and the converter gets passed around (and stored in iterators) - typedef typename K1::template Type::type K1_Point; - typedef typename K2::template Type::type K2_Point; - typedef typename K1::template Type::type K1_Vector; - typedef typename K2::template Type::type K2_Vector; - typedef typename K1::template Type::type K1_Segment; - typedef typename K2::template Type::type K2_Segment; public: CartesianD_converter(){} CartesianD_converter(K1 const&a,K2 const&b):Store_kernel(a),Store_kernel2(b){} // For boost::result_of, used in transforming_iterator - template struct result; - template struct result{ - //assert that T is an iterator, or better yet make sure - //we don't get here otherwise - CGAL_static_assertion(is_iterator::value); - typedef transforming_iterator type; + template::value?42:0> struct result:Base::template result{}; + template struct result { + typedef transforming_iterator type; }; - template struct result{typedef K2 type;}; - template struct result{typedef int type;}; - template struct result{typedef Origin type;}; - template struct result{typedef Null_vector type;}; - template struct result{typedef Object type;}; - template struct result{typedef FT2 type;}; - template struct result{typedef K2_Point type;}; - template struct result::Type),i>{typedef K2_Vector type;}; + template struct result{typedef K2 type;}; + template struct result{typedef int type;}; + // Ideally the next 2 would come with Point_tag and Vector_tag, but that's hard... + template struct result{typedef Origin type;}; + template struct result{typedef Null_vector type;}; + template struct result{typedef Object type;}; + template struct result{typedef FT2 type;}; + using Base::operator(); typename Store_kernel2::reference2_type operator()(K1 const&)const{return this->kernel2();} int operator()(int i)const{return i;} Origin operator()(Origin const&o)const{return o;} @@ -57,32 +98,15 @@ template class CartesianD_converter //RT2 operator()(typename First_if_different::Type const&x)const{return cr(x);} template - transforming_iterator,It>::type> + transforming_iterator,It>::type> operator()(It const& it)const { return make_transforming_iterator(it,*this); } - K2_Point operator()(K1_Point const& p)const{ - typename K1::template Functor::type i(this->kernel()); - typename K2::template Functor >::type cp(this->kernel2()); - return cp(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); - } - - K2_Vector operator()(typename First_if_different::Type const& p)const{ - typename K1::template Functor::type i(this->kernel()); - typename K2::template Functor >::type cv(this->kernel2()); - return cv(operator()(i(p,Begin_tag())),operator()(i(p,End_tag()))); - } - - K2_Segment operator()(K1_Segment const& s)const{ - typename K1::template Functor::type f(this->kernel()); - typename K2::template Functor >::type cs(this->kernel2()); - return cs(operator()(f(s,0)),operator()(f(s,1))); - } - Object operator()(const Object &obj) const { + //TODO: use the tags from List_ instead #define CGAL_Kernel_obj(X,Y) \ if (const typename K1::template Type::type * ptr = object_cast::type>(&obj)) \ return make_object(operator()(*ptr)); @@ -101,6 +125,8 @@ template class CartesianD_converter return Object(); } + //TODO: convert boost::variant + }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h new file mode 100644 index 00000000000..bedbb5340bb --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -0,0 +1,46 @@ +#ifndef CGAL_KD_KO_CONVERTER_H +#define CGAL_KD_KO_CONVERTER_H +#include +#include // First_if_different +namespace CGAL { +template struct KO_converter; +//TODO: It would probably be better if this was a Misc Functor in K1. + +template struct KO_converter{ + typedef typename K1::template Type::type argument_type; + 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 K2::template Functor >::type cp(k2); + return cp(conv(i(p,Begin_tag())),conv(i(p,End_tag()))); + } +}; + +template struct KO_converter{ + typedef typename K1::template Type::type K1_Vector; + typedef typename K1::template Type< Point_tag>::type K1_Point; + // can't use vector without at least a placeholder point because of this + typedef typename First_if_different::Type argument_type; + 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 K2::template Functor >::type cp(k2); + return cp(conv(i(v,Begin_tag())),conv(i(v,End_tag()))); + } +}; + +template struct KO_converter{ + typedef typename K1::template Type::type argument_type; + typedef typename K2::template Type::type result_type; + template + result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { + typename K1::template Functor::type f(k1); + typename K2::template Functor >::type cs(k2); + return conv(operator()(f(s,0)),operator()(f(s,1))); + } +}; + +} +#endif diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index c80353008f9..72bf20ae1c0 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -7,7 +7,7 @@ normal: ./a.out cxx0x: - /usr/lib/gcc-snapshot/bin/g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} + g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} ./a.out #-DBOOST_RESULT_OF_USE_DECLTYPE From 58ebdbac5136e43d87cc3dba11f99236ec4bdb1a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 28 Oct 2011 14:17:58 +0000 Subject: [PATCH 045/210] just a comment --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h | 1 + 1 file changed, 1 insertion(+) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index 328106b6c9c..8b8e5f6c50a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -27,6 +27,7 @@ struct Cartesian_filter_K : public Base_, EK_rt exact_kernel()const{return this->kernel2();} //TODO: C2A/C2E could be able to convert *this into this->kernel() or this->kernel2(). + //TODO: give CartesianD_converter the list of objects it needs to be able to convert (tuple for instance), so Cartesian_filter_K needs to know that list (take an extra template parameter? Read it from Kernel_base?) typedef CartesianD_converter C2A; typedef CartesianD_converter C2E; From 38f2c13c86ce4b699f85c3dffdca14bd095b8d2d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 28 Oct 2011 15:11:17 +0000 Subject: [PATCH 046/210] Let us override default predicates for specific dimensions. --- .../include/CGAL/Kernel_d/Cartesian_2.h | 29 +++++++++++++++++++ .../CGAL/Kernel_d/Cartesian_complete.h | 6 +++- .../CGAL/Kernel_d/Cartesian_per_dimension.h | 29 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h new file mode 100644 index 00000000000..d2c8b136f44 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h @@ -0,0 +1,29 @@ +#ifndef CGAL_KD_CARTESIAN_2_H +#define CGAL_KD_CARTESIAN_2_H +#include +#include + +namespace CGAL { +namespace CartesianDKernelFunctors { +template +struct Orientation_of_points_2 : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); + typedef typename R_::template Type::type Point; + typedef typename R_::Orientation result_type; + typedef typename R_::FT FT; + template + result_type operator()(Iter f, Iter e)const{ + typename R_::template Functor::type c(this->kernel()); + Point const&A=*f; + FT const& ax=c(A,0); + FT const& ay=c(A,1); + Point const&B=*++f; + Point const&C=*++f; + CGAL_assertion(++f==e); + return sign_of_determinant(c(B,0)-ax,c(B,1)-ay,c(C,0)-ax,c(C,1)-ay); + } +}; +} +} + +#endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 50258a506cc..4510e453930 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -16,7 +17,7 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(Direction) BOOST_MPL_HAS_XXX_TRAIT_DEF(Line) } -template struct Cartesian_define_all_functors +template struct Cartesian_define_all_functors_ : public R_ { typedef R_ Kernel_base; @@ -39,6 +40,9 @@ template struct Cartesian_define_all_functors }; +template struct Cartesian_define_all_functors +: public Cartesian_per_dimension,Derived_> {}; + template struct Cartesian_complete_types : public R_ { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h new file mode 100644 index 00000000000..5f237284929 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h @@ -0,0 +1,29 @@ +#ifndef CGAL_KD_CARTESIAN_PER_DIM_H +#define CGAL_KD_CARTESIAN_PER_DIM_H +#include +#include +#include +#include + +namespace CGAL { +template +struct Cartesian_per_dimension : public R_ {}; + +// TODO: we want to put the actual functors in some other file. Maybe name the +// classes Orientation_2 to make it easy to typedef them all. +template +struct Cartesian_per_dimension,R_,Derived_> : public R_ { + typedef R_ Kernel_base; + template struct Functor + : Kernel_base::template Functor + { }; + +#define CGAL_override_in_dim2(X) \ + template struct Functor { \ + typedef CartesianDKernelFunctors::X##_2 type; \ + } + CGAL_override_in_dim2(Orientation_of_points); +}; +} + +#endif From e12e4f0705ed85867a07693ef8170e34e4436901 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 28 Oct 2011 17:38:26 +0000 Subject: [PATCH 047/210] Reuse existing static filter --- .../CGAL/Kernel_d/Cartesian_static_filters.h | 60 +++++++++++++++++++ NewKernel_d/test/NewKernel_d/test.cpp | 3 + 2 files changed, 63 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h new file mode 100644 index 00000000000..fac83a43be0 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -0,0 +1,60 @@ +#ifndef CGAL_KD_CARTESIAN_STATIC_FILTERS_H +#define CGAL_KD_CARTESIAN_STATIC_FILTERS_H +#include +#include +#include // bug, should be included by the next one +#include + +namespace CGAL { +namespace SFA { // static filter adapter +// Note that this would be quite a bit simpler without stateful kernels +template struct Orientation_of_points_2 : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); + typedef typename R_::template Type::type Point; + typedef typename R_::Orientation result_type; + typedef typename R_::FT FT; + typedef typename R_::template Functor::type CC; + typedef typename R_::template Functor::type Orientation_base; + // TODO: Move this out for easy reuse + struct Adapter { + struct Point_2 { + R_ const&r; CC const&c; Point const& p; + Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){} + FT x()const{return c(p,0);} + FT y()const{return c(p,1);} + }; + struct Vector_2 {}; + struct Circle_2 {}; + struct Orientation_2 { + typedef Orientation_of_points_2::result_type result_type; // really? + template result_type operator()(Point_2 const&A, Point_2 const&B, Point_2 const&C)const{ + Point_2 t[3]={&A.p,&B.p,&C.p}; + return Orientation_base(A.r)(t+0,t+3); + } + }; + }; + template result_type operator()(Iter f, Iter e)const{ + CC c(this->kernel()); + Point const& A=*f; + Point const& B=*++f; + Point const& C=*++f; + CGAL_assertion(++f==e); + typedef typename Adapter::Point_2 P; + return typename internal::Static_filters_predicates::Orientation_2()(P(*this,c,A),P(*this,c,B),P(*this,c,C)); + } +}; +} + +template struct Cartesian_static_filters : public R_ {}; + +template struct Cartesian_static_filters, R_, Derived_> : public R_ { + //TODO: Functor<*,No_filter_tag> + template struct Functor : R_::template Functor {}; + template struct Functor { + typedef SFA::Orientation_of_points_2 type; + }; +}; + +} + +#endif diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index b9674c3c26b..b1cfa392581 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -13,6 +14,7 @@ typedef CGAL::Cartesian_base_d typedef CGAL::Cartesian_base_d > KE; struct RC: public +CGAL::Cartesian_static_filters, // Yes, it is silly to put it there. CGAL::Cartesian_complete_predicates< CGAL::Cartesian_complete_constructors< CGAL::Cartesian_complete_computes< @@ -23,6 +25,7 @@ CGAL::Cartesian_LA_base_d > >, false, RC >, false, RC >, false, RC +>, RC > { RC(){} From 333f59470a691b463c4add9953c4f5882bb6fa9f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 4 Nov 2011 09:02:57 +0000 Subject: [PATCH 048/210] Fix static filter, which hadn't been properly tested. --- .../include/CGAL/Kernel_d/Cartesian_static_filters.h | 10 +++++----- NewKernel_d/include/CGAL/marcutils.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index fac83a43be0..daceaf446bf 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -26,10 +26,10 @@ template struct Orientation_of_points_2 : private Store_kernel { struct Vector_2 {}; struct Circle_2 {}; struct Orientation_2 { - typedef Orientation_of_points_2::result_type result_type; // really? - template result_type operator()(Point_2 const&A, Point_2 const&B, Point_2 const&C)const{ - Point_2 t[3]={&A.p,&B.p,&C.p}; - return Orientation_base(A.r)(t+0,t+3); + typedef Orientation_of_points_2::result_type result_type; + result_type operator()(Point_2 const&A, Point_2 const&B, Point_2 const&C)const{ + Point const* t[3]={&A.p,&B.p,&C.p}; + return Orientation_base(A.r)(make_transforming_iterator(t+0),make_transforming_iterator(t+3)); } }; }; @@ -40,7 +40,7 @@ template struct Orientation_of_points_2 : private Store_kernel { Point const& C=*++f; CGAL_assertion(++f==e); typedef typename Adapter::Point_2 P; - return typename internal::Static_filters_predicates::Orientation_2()(P(*this,c,A),P(*this,c,B),P(*this,c,C)); + return typename internal::Static_filters_predicates::Orientation_2()(P(this->kernel(),c,A),P(this->kernel(),c,B),P(this->kernel(),c,C)); } }; } diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 8d898070e7e..b2ed2770303 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -148,6 +148,17 @@ namespace internal { template struct Type_copy_cvref : Type_copy_ref::type,U>::type> {}; + + struct Dereference_functor { + template struct result{}; + template struct result { + typedef typename std::iterator_traits::reference type; + }; + template typename result::type + operator()(It const&i)const{ + return *i; + } + }; } #endif From d90d515da4b1235d60d6296ca722369538728193 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Nov 2011 14:33:54 +0000 Subject: [PATCH 049/210] Fix untested code. Add more CRTP. Work around too much CRTP... --- .../include/CGAL/Kernel_d/Cartesian_base.h | 12 ++++++----- .../CGAL/Kernel_d/Cartesian_complete.h | 20 +++++++++++-------- .../CGAL/Kernel_d/Cartesian_static_filters.h | 10 +++++++--- .../CGAL/Kernel_d/Kernel_object_converter.h | 2 +- NewKernel_d/include/CGAL/functor_tags.h | 2 ++ NewKernel_d/test/NewKernel_d/Makefile | 2 +- NewKernel_d/test/NewKernel_d/test.cpp | 5 +++-- 7 files changed, 33 insertions(+), 20 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h index c86cc88a8f3..8060a39222b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h @@ -7,16 +7,18 @@ namespace CGAL { -template < typename FT_, typename Dim_> +template < typename FT_, typename Dim_, typename Derived_=Default> struct Cartesian_base_d : public Cartesian_complete_predicates< Cartesian_complete_constructors< Cartesian_complete_computes< Cartesian_complete_types< - Cartesian_LA_base_d ->, false, Cartesian_base_d ->, false, Cartesian_base_d ->, false, Cartesian_base_d +Cartesian_LA_base_d< + FT_, Dim_ +>, false, typename Default::Get >::type +>, false, typename Default::Get >::type +>, false, typename Default::Get >::type +>, false, typename Default::Get >::type > { CGAL_CONSTEXPR Cartesian_base_d(){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 4510e453930..8f684ab613a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -43,60 +43,64 @@ template struct Cartesian_define_all_functors_ template struct Cartesian_define_all_functors : public Cartesian_per_dimension,Derived_> {}; -template struct Cartesian_complete_types +template struct Cartesian_complete_types : public R_ { typedef R_ Kernel_base; + typedef typename Default::Get::type Derived; template struct Type : Kernel_base::template Type {}; #define CGAL_Kernel_obj2(X,Y) \ template struct Type { \ typedef typename Kernel_base::template Type B_; \ - typedef typename boost::mpl::if_c::value,Wrap_type >,B_>::type::type type; \ + typedef typename boost::mpl::if_c::value,Wrap_type >,B_>::type::type type; \ }; #include }; -template struct Cartesian_complete_constructors +template struct Cartesian_complete_constructors : public R_ { typedef R_ Kernel_base; + typedef typename Default::Get::type Derived; template::type> struct Functor : R_::template Functor {}; template struct Functor { typedef typename Kernel_base::template Functor::type Base_functor; typedef typename boost::mpl::if_c::value, - typename Cartesian_define_all_functors::template Functor::type, + typename Cartesian_define_all_functors::template Functor::type, Base_functor>::type type; }; }; -template struct Cartesian_complete_predicates +template struct Cartesian_complete_predicates : public R_ { typedef R_ Kernel_base; + typedef typename Default::Get::type Derived; template::type> struct Functor : R_::template Functor {}; template struct Functor { typedef typename Kernel_base::template Functor::type Base_functor; typedef typename boost::mpl::if_c::value, - typename Cartesian_define_all_functors::template Functor::type, + typename Cartesian_define_all_functors::template Functor::type, Base_functor>::type type; }; }; -template struct Cartesian_complete_computes +template struct Cartesian_complete_computes : public R_ { typedef R_ Kernel_base; + typedef typename Default::Get::type Derived; template::type> struct Functor : R_::template Functor {}; template struct Functor { typedef typename Kernel_base::template Functor::type Base_functor; typedef typename boost::mpl::if_c::value, - typename Cartesian_define_all_functors::template Functor::type, + typename Cartesian_define_all_functors::template Functor::type, Base_functor>::type type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index daceaf446bf..9a58b2d5c1f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -4,6 +4,7 @@ #include #include // bug, should be included by the next one #include +#include namespace CGAL { namespace SFA { // static filter adapter @@ -14,7 +15,7 @@ template struct Orientation_of_points_2 : private Store_kernel { typedef typename R_::Orientation result_type; typedef typename R_::FT FT; typedef typename R_::template Functor::type CC; - typedef typename R_::template Functor::type Orientation_base; + typedef typename R_::template Functor::type Orientation_base; // TODO: Move this out for easy reuse struct Adapter { struct Point_2 { @@ -48,10 +49,13 @@ template struct Orientation_of_points_2 : private Store_kernel { template struct Cartesian_static_filters : public R_ {}; template struct Cartesian_static_filters, R_, Derived_> : public R_ { - //TODO: Functor<*,No_filter_tag> template struct Functor : R_::template Functor {}; template struct Functor { - typedef SFA::Orientation_of_points_2 type; + typedef typename boost::conditional< + boost::is_same::value, + typename R_::template Functor::type, + SFA::Orientation_of_points_2 + >::type 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 bedbb5340bb..e8b5a1a29bf 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -38,7 +38,7 @@ template struct KO_converter{ result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { typename K1::template Functor::type f(k1); typename K2::template Functor >::type cs(k2); - return conv(operator()(f(s,0)),operator()(f(s,1))); + return cs(conv(f(s,0)),conv(f(s,1))); } }; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 4fd7a35d729..c33473bf3fa 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -11,6 +11,8 @@ namespace CGAL { struct Compute_tag {}; struct Misc_tag {}; + struct No_filter_tag {}; + templatestruct map_functor_type{typedef Misc_tag type;}; #define DECL_OBJ(X) struct X##_tag {}; diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 72bf20ae1c0..c28e4efdd39 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -1,6 +1,6 @@ all: normal cxx0x -CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include +CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK normal: g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index b1cfa392581..5608180a7c8 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -10,7 +10,8 @@ #include #include //typedef CGAL::Cartesian_base_d > K0; -typedef CGAL::Cartesian_base_d > KA; +//typedef CGAL::Cartesian_base_d > KA; +struct KA : CGAL::Cartesian_static_filters, CGAL::Cartesian_base_d,KA >, KA> {}; typedef CGAL::Cartesian_base_d > KE; struct RC: public @@ -39,7 +40,7 @@ typedef RC K0; typedef K0 K2; #elif 0 typedef CGAL::Cartesian_filter_NT K2; -#elif 1 +#elif 0 typedef CGAL::Cartesian_filter_K K2; #elif 1 typedef CGAL::Lazy_cartesian > K2; From e8f9c73c04b26743175fbb036c0886e598916dae Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Nov 2011 15:17:48 +0000 Subject: [PATCH 050/210] the CRTP problem in the previous patch could be solved more easily (for now). --- .../CGAL/Kernel_d/Cartesian_static_filters.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 9a58b2d5c1f..a7a02cbffbb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -9,13 +9,13 @@ namespace CGAL { namespace SFA { // static filter adapter // Note that this would be quite a bit simpler without stateful kernels -template struct Orientation_of_points_2 : private Store_kernel { +template struct Orientation_of_points_2 : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); typedef typename R_::template Type::type Point; typedef typename R_::Orientation result_type; typedef typename R_::FT FT; typedef typename R_::template Functor::type CC; - typedef typename R_::template Functor::type Orientation_base; + typedef typename Base_::template Functor::type Orientation_base; // TODO: Move this out for easy reuse struct Adapter { struct Point_2 { @@ -46,16 +46,18 @@ template struct Orientation_of_points_2 : private Store_kernel { }; } -template struct Cartesian_static_filters : public R_ {}; +template struct Cartesian_static_filters : public R_ {}; template struct Cartesian_static_filters, R_, Derived_> : public R_ { template struct Functor : R_::template Functor {}; template struct Functor { - typedef typename boost::conditional< - boost::is_same::value, - typename R_::template Functor::type, - SFA::Orientation_of_points_2 - >::type type; + typedef + //typename boost::conditional< + //boost::is_same::value, + //typename R_::template Functor::type, + SFA::Orientation_of_points_2 + // >::type + type; }; }; From 2956679f016c174e4a1c580324a37fd809c99867 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Nov 2011 17:39:38 +0000 Subject: [PATCH 051/210] Wrapper to make it look like DelaunayTriangulationTraits_2 (not tested yet). --- .../CGAL/Kernel_d/Kernel_2_interface.h | 73 +++++++++++++++++++ .../Kernel_d/function_objects_cartesian.h | 40 +++++++++- .../include/CGAL/Kernel_d/interface_macros.h | 4 + NewKernel_d/include/CGAL/functor_tags.h | 2 + 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h new file mode 100644 index 00000000000..5088160629b --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -0,0 +1,73 @@ +#ifndef CGAL_KD_KERNEL_2_INTERFACE_H +#define CGAL_KD_KERNEL_2_INTERFACE_H + +#include +#include +#include + +namespace CGAL { +template struct Kernel_2_interface : public Base_ { + typedef Base_ Base; + typedef Kernel_2_interface Kernel; + typedef typename Base::template Type::type Point_2; + typedef typename Base::template Type::type Vector_2; + typedef typename Base::template Type::type Segment_2; + template struct Help_2p_i { + typedef typename Base::template Functor::type LT; + typedef LT::result_type result_type; + LT lt; + Help_2p_i(Kernel const&k):lt(k){} + result_type operator()(Point_2 const&a, Point_2 const&b) { + return lt(a,b,i); + } + }; + typedef Help_2p_i Less_x_2; + typedef Help_2p_i Less_y_2; + typedef Help_2p_i Compare_x_2; + typedef Help_2p_i Compare_y_2; + struct Compare_distance_2 { + typedef typename Base::template Functor::type CD; + typedef CD::result_type result_type; + CD cd; + Compare_distance_2(Kernel const&k):cd(k){} + result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c) { + return cd(a,b,c); + } + result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c, Point_2 const&d) { + return cd(a,b,c,d); + } + }; + struct Orientation_2 { + typedef typename Base::template Functor::type O; + typedef O::result_type result_type; + O o; + Orientation_2(Kernel const&k):o(k){} + result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c) { + //return o(a,b,c); + Point_2 const* t[3]={&a,&b,&c}; + return o(make_transforming_iterator(t+0),make_transforming_iterator(t+3)); + + } + }; + struct Side_of_oriented_sphere_2 { + typedef typename Base::template Functor::type SOS; + typedef SOS::result_type result_type; + SOS sos; + Side_of_oriented_sphere_2(Kernel const&k):sos(k){} + result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c, Point_2 const&d) { + //return sos(a,b,c,d); + Point_2 const* t[4]={&a,&b,&c,&d}; + return sos(make_transforming_iterator(t+0),make_transforming_iterator(t+4)); + } + }; + Less_x_2 less_x_2_object()const{ return Less_x_2(*this); } + Less_y_2 less_y_2_object()const{ return Less_y_2(*this); } + Compare_x_2 compare_x_2_object()const{ return Compare_x_2(*this); } + Compare_y_2 compare_y_2_object()const{ return Compare_y_2(*this); } + Compare_distance_2 compare_distance_2_object()const{ return Compare_distance_2(*this); } + Orientation_2 orientation_2_object()const{ return Orientation_2(*this); } + Side_of_oriented_sphere_2 side_of_oriented_sphere_2_object()const{ return Side_of_oriented_sphere_2(*this); } +}; +} + +#endif 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 c10b32332f2..e06706b084f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -268,10 +268,48 @@ template struct Compute_squared_distance : private Store_kernel { } }; +template struct Compare_distance : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Compare_distance) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::template Type::type Point; + typedef typename R::template Functor::type CSD; + typedef typename R_::Comparison_result result_type; + typedef Point first_argument_type; + typedef Point second_argument_type; + typedef Point third_argument_type; // why am I doing this already? + typedef Point fourth_argument_type; + result_type operator()(Point const&a, Point const&b, Point const&c)const{ + CSD csd(this->kernel()); + return CGAL_NTS compare(csd(a,b),csd(a,c)); + } + result_type operator()(Point const&a, Point const&b, Point const&c, Point const&d)const{ + CSD csd(this->kernel()); + return CGAL_NTS compare(csd(a,b),csd(c,d)); + } +}; + template struct Less_cartesian_coordinate : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_cartesian_coordinate) typedef R_ R; typedef typename R_::FT FT; + typedef typename R::Boolean result_type; + typedef typename R::template Functor::type Cc; + // 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; + + template + result_type operator()(V const&a, V const&b, I i)const{ + Cc c(this->kernel()); + return c(a,i) struct Compare_cartesian_coordinate : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Compare_cartesian_coordinate) + typedef R_ R; + typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; typedef typename R::template Functor::type Cc; // TODO: This is_exact thing should be reengineered. @@ -281,7 +319,7 @@ template struct Less_cartesian_coordinate : private Store_kernel { template result_type operator()(V const&a, V const&b, I i)const{ Cc c(this->kernel()); - return c(a,i)struct map_functor_type{typedef Predicate_tag type;} DECL_PREDICATE(Less_cartesian_coordinate); + DECL_PREDICATE(Compare_cartesian_coordinate); + DECL_PREDICATE(Compare_distance); DECL_PREDICATE(Orientation); DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_vectors); From 90c0cca81eaebccc53c00f6179d0f9e340c165c7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Nov 2011 21:23:31 +0000 Subject: [PATCH 052/210] minor fixes --- .../include/CGAL/Kernel_d/Kernel_2_interface.h | 11 +++++++---- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h | 1 + .../CGAL/Kernel_d/function_objects_cartesian.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h index 5088160629b..1d2df381a22 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -4,6 +4,8 @@ #include #include #include +#include + namespace CGAL { template struct Kernel_2_interface : public Base_ { @@ -12,9 +14,10 @@ template struct Kernel_2_interface : public Base_ { typedef typename Base::template Type::type Point_2; typedef typename Base::template Type::type Vector_2; typedef typename Base::template Type::type Segment_2; + typedef cpp0x::tuple Triangle_2; // triangulation insists... template struct Help_2p_i { typedef typename Base::template Functor::type LT; - typedef LT::result_type result_type; + typedef typename LT::result_type result_type; LT lt; Help_2p_i(Kernel const&k):lt(k){} result_type operator()(Point_2 const&a, Point_2 const&b) { @@ -27,7 +30,7 @@ template struct Kernel_2_interface : public Base_ { typedef Help_2p_i Compare_y_2; struct Compare_distance_2 { typedef typename Base::template Functor::type CD; - typedef CD::result_type result_type; + typedef typename CD::result_type result_type; CD cd; Compare_distance_2(Kernel const&k):cd(k){} result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c) { @@ -39,7 +42,7 @@ template struct Kernel_2_interface : public Base_ { }; struct Orientation_2 { typedef typename Base::template Functor::type O; - typedef O::result_type result_type; + typedef typename O::result_type result_type; O o; Orientation_2(Kernel const&k):o(k){} result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c) { @@ -51,7 +54,7 @@ template struct Kernel_2_interface : public Base_ { }; struct Side_of_oriented_sphere_2 { typedef typename Base::template Functor::type SOS; - typedef SOS::result_type result_type; + typedef typename SOS::result_type result_type; SOS sos; Side_of_oriented_sphere_2(Kernel const&k):sos(k){} result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c, Point_2 const&d) { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index aa9ed6526c3..2f9477cc76d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -17,6 +17,7 @@ namespace CGAL { template class Point_d : public R_::Kernel_base::template Type::type + // Deriving won't work if the point is just a __m256d. { typedef typename R_::RT RT_; typedef typename R_::FT FT_; 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 e06706b084f..4e5595271d7 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 Less_cartesian_coordinate : private Store_kernel { typedef typename CGAL::Is_exact::type Is_exact; template - result_type operator()(V const&a, V const&b, I i)const{ + result_type operator()(V const&a, W const&b, I i)const{ Cc c(this->kernel()); return c(a,i) struct Compare_cartesian_coordinate : private Store_kernel::type Is_exact; template - result_type operator()(V const&a, V const&b, I i)const{ + result_type operator()(V const&a, W const&b, I i)const{ Cc c(this->kernel()); return CGAL_NTS compare(c(a,i),c(b,i)); } From e9b21c303514f6e1f21036ba14286adaf2ffd05f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Nov 2011 21:46:45 +0000 Subject: [PATCH 053/210] Hard to count from 0. --- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 6 ++++++ NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index bf8c76ad3a2..a50c29e80d1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -179,6 +179,9 @@ struct Cartesian_refcount : public Base_ return b(internal::Forward_rep()(u)...); } #else + result_type operator()()const{ + return b(); + } #define VAR(Z,N,_) internal::Forward_rep()(u##N) #define CODE(Z,N,_) template result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ @@ -209,6 +212,9 @@ struct Cartesian_refcount : public Base_ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); } #else + result_type operator()()const{ + return result_type(Eval_functor(),b); + } #define VAR(Z,N,_) internal::Forward_rep()(u##N) #define CODE(Z,N,_) template result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index 966b8069044..b5644bce86d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -16,6 +16,8 @@ // no need for a fancy interface here, people can use the Point_d wrapper on // top. +// I don't remember why this type even exists, why it isn't just Handle_for (or something similar because of limitations in the interface of Handle_for) + namespace CGAL { template @@ -84,6 +86,9 @@ public: BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) #undef CODE + template + Point_rc_d(Eval_functor,F const& f) + : data(Eval_functor(),f) {} // this one should be implicit Point_rc_d(Origin const& o) From 8bb065ba559f3d764fa5bb7be28ef169faa83eb2 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 6 Nov 2011 11:20:03 +0000 Subject: [PATCH 054/210] Wrapper to make it look like DelaunayTriangulationTraits_3 (not tested yet). Missing the coplanar predicates. Missing the things that shouldn't be needed for a basic use: tetrahedron, construct_segment, etc. --- .../CGAL/Kernel_d/Kernel_3_interface.h | 74 +++++++++++++++++++ .../Kernel_d/function_objects_cartesian.h | 29 ++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 2 + NewKernel_d/include/CGAL/functor_tags.h | 1 + 4 files changed, 106 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h new file mode 100644 index 00000000000..2fb2ad8e081 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h @@ -0,0 +1,74 @@ +#ifndef CGAL_KD_KERNEL_3_INTERFACE_H +#define CGAL_KD_KERNEL_3_INTERFACE_H + +#include +#include +#include +#include + + +namespace CGAL { +template struct Kernel_3_interface : public Base_ { + typedef Base_ Base; + typedef Kernel_3_interface Kernel; + typedef typename Base::template Type::type Point_3; + typedef typename Base::template Type::type Vector_3; + typedef typename Base::template Type::type Segment_3; + typedef cpp0x::tuple Triangle_3; // placeholder + typedef cpp0x::tuple Tetrahedron_3; // placeholder + struct Compare_xyz_3 { + typedef typename Base::template Functor::type CL; + typedef typename CL::result_type result_type; + CL cl; + Compare_xyz_3(Kernel const&k):cl(k){} + result_type operator()(Point_3 const&a, Point_3 const&b) { + return cl(a,b); + } + }; + struct Compare_distance_3 { + typedef typename Base::template Functor::type CD; + typedef typename CD::result_type result_type; + CD cd; + Compare_distance_3(Kernel const&k):cd(k){} + result_type operator()(Point_3 const&a, Point_3 const&b, Point_3 const&c) { + return cd(a,b,c); + } + result_type operator()(Point_3 const&a, Point_3 const&b, Point_3 const&c, Point_3 const&d) { + return cd(a,b,c,d); + } + }; + struct Orientation_3 { + typedef typename Base::template Functor::type O; + typedef typename O::result_type result_type; + O o; + Orientation_3(Kernel const&k):o(k){} + result_type operator()(Point_3 const&a, Point_3 const&b, Point_3 const&c, Point_3 const&d) { + //return o(a,b,c,d); + Point_3 const* t[4]={&a,&b,&c,&d}; + return o(make_transforming_iterator(t+0),make_transforming_iterator(t+4)); + + } + }; + struct Side_of_oriented_sphere_3 { + typedef typename Base::template Functor::type SOS; + typedef typename SOS::result_type result_type; + SOS sos; + Side_of_oriented_sphere_3(Kernel const&k):sos(k){} + result_type operator()(Point_3 const&a, Point_3 const&b, Point_3 const&c, Point_3 const&d, Point_3 const&e) { + //return sos(a,b,c,d); + Point_3 const* t[5]={&a,&b,&c,&d,&e}; + return sos(make_transforming_iterator(t+0),make_transforming_iterator(t+5)); + } + }; + + // I don't have the Coplanar predicates (yet) + + + Compare_xyz_3 compare_xyz_3_object()const{ return Compare_xyz_3(*this); } + Compare_distance_3 compare_distance_3_object()const{ return Compare_distance_3(*this); } + Orientation_3 orientation_3_object()const{ return Orientation_3(*this); } + Side_of_oriented_sphere_3 side_of_oriented_sphere_3_object()const{ return Side_of_oriented_sphere_3(*this); } +}; +} + +#endif 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 4e5595271d7..d56952ffd06 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -323,6 +323,35 @@ template struct Compare_cartesian_coordinate : private Store_kernel struct Compare_lexicographically : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Compare_lexicographically) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Comparison_result result_type; + 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; + + template + result_type operator()(V const&a, W const&b)const{ + CI c(this->kernel()); +#ifdef CGAL_CXX0X + auto +#else + typename CI::result_type +#endif + a_begin=c(a,Begin_tag()), + b_begin=c(b,Begin_tag()), + a_end=c(a,End_tag()); + result_type res=CGAL_NTS compare(*a_begin++,*b_begin++); + // can't we do slightly better for Uncertain<*> ? + while(a_begin!=a_end && res==EQUAL) + res=CGAL_NTS compare(*a_begin++,*b_begin++); + return res; + } +}; + template struct Construct_segment { CGAL_FUNCTOR_INIT_IGNORE(Construct_segment) typedef R_ R; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 73a17b55390..75f31e1b2c8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -76,6 +76,8 @@ CGAL_Kernel_pred(Compare_cartesian_coordinate, compare_cartesian_coordinate_object) CGAL_Kernel_pred(Compare_distance, compare_distance_object) +CGAL_Kernel_pred(Compare_lexicographically, + compare_lexicographically_object) #undef CGAL_Kernel_pred #undef CGAL_Kernel_comp diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index c9f381d40dc..2c39a90e17d 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -59,6 +59,7 @@ namespace CGAL { DECL_PREDICATE(Less_cartesian_coordinate); DECL_PREDICATE(Compare_cartesian_coordinate); DECL_PREDICATE(Compare_distance); + DECL_PREDICATE(Compare_lexicographically); DECL_PREDICATE(Orientation); DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_vectors); From 6fc68e95f0908ef8a5f0933a5e546519322a7549 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 6 Nov 2011 19:04:55 +0000 Subject: [PATCH 055/210] converter on Object and vector --- .../CGAL/Kernel_d/Cartesian_converter.h | 87 +++++++++++++++---- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index 110848eaf78..73fc731db51 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -14,6 +14,61 @@ #include namespace CGAL { +namespace internal { +template struct Map_tuple_tags_to_tuple_types; +#ifdef CGAL_CXX0X +template struct Map_tuple_tags_to_tuple_types > { + typedef cpp0x::tuple::type...> type; +}; +#else +template struct Map_tuple_tags_to_tuple_types > { + typedef cpp0x::tuple<> type; +}; +#define CODE(Z,N,_) template \ + struct Map_tuple_tags_to_tuple_types > { \ + typedef cpp0x::tuple::type BOOST_PP_INTERCEPT)> type; \ + }; + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#endif +} +template > struct Object_converter { + typedef Object result_type; + template + result_type operator()(Object const&,F const&)const { + CGAL_error_msg("Cartesiand_converter is unable to determine what is wrapped in the Object"); + return Object(); + } +}; +#ifdef CGAL_CXX0X +template struct Object_converter > { + typedef Object result_type; + template + result_type operator()(Object const& o, F const& f) const { + if (const T * ptr = object_cast(&o)) + return make_object(f(*ptr)); + else + return Object_converter >()(o,f); + } +}; +#else +#define CODE(Z,N,_) template \ + struct Object_converter > { \ + typedef Object result_type; \ + template \ + result_type operator()(Object const& o, F const& f) const { \ + if (const T0 * ptr = object_cast(&o)) \ + return make_object(f(*ptr)); \ + else \ + return Object_converter >()(o,f); \ + } \ + }; + + BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) +#undef CODE +#endif + //TODO: special case when K1==K2 (or they are very close?) template class CartesianD_converter_; template class CartesianD_converter_ > { @@ -99,35 +154,29 @@ template transforming_iterator,It>::type> - operator()(It const& it)const { + operator()(It const& it) const { return make_transforming_iterator(it,*this); } + template + //TODO: use decltype in C++11 instead of result + std::vector::type> + operator()(const std::vector& v) const { + return std::vector::type>(operator()(v.begin()),operator()(v.begin())); + } + + //TODO: convert std::list and other containers? + Object operator()(const Object &obj) const { - //TODO: use the tags from List_ instead -#define CGAL_Kernel_obj(X,Y) \ - if (const typename K1::template Type::type * ptr = object_cast::type>(&obj)) \ - return make_object(operator()(*ptr)); - -#include - /* - if (const std::vector * ptr = object_cast >(&obj)) { - std::vector res ( - operator()(ptr->begin()), - operator()(ptr->end()) ); - return make_object(res); - } - */ - - CGAL_error_msg("Cartesiand_converter is unable to determine what is wrapped in the Object"); - return Object(); + typedef typename internal::Map_tuple_tags_to_tuple_types::type Possibilities; + //TODO: add Empty, vector, etc to the list. + return Object_converter()(obj,*this); } //TODO: convert boost::variant - }; } //namespace CGAL From 2e88bc0dafed9179aa40923b4c188b85fb2dc3c1 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 8 Nov 2011 11:53:21 +0000 Subject: [PATCH 056/210] Move Segment to a module that can be included. Segmentd.h should disappear, the functionality should be in Wrapper/Segment_d.h. --- .../CGAL/Kernel_d/Cartesian_complete.h | 1 - .../include/CGAL/Kernel_d/Define_segment.h | 70 +++++++++++++++++++ .../include/CGAL/Kernel_d/Lazy_cartesian.h | 2 + .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 5 ++ .../Kernel_d/function_objects_cartesian.h | 38 ---------- .../include/CGAL/Kernel_d/interface_macros.h | 10 +-- NewKernel_d/test/NewKernel_d/test.cpp | 9 +-- 7 files changed, 87 insertions(+), 48 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Define_segment.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 8f684ab613a..4f676effff5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -2,7 +2,6 @@ #define CGAL_KERNEL_D_CARTESIAN_COMPLETE_H #include -#include #include #include #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h new file mode 100644 index 00000000000..a5c64a9bb27 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -0,0 +1,70 @@ +#ifndef CGAL_KD_DEFINE_SEGMENT_H +#define CGAL_KD_DEFINE_SEGMENT_H +#include +#include + +namespace CGAL { +namespace CartesianDKernelFunctors { + +template struct Construct_segment { + CGAL_FUNCTOR_INIT_IGNORE(Construct_segment) + typedef R_ R; + typedef typename R_::template Type::type Point; + typedef typename R_::template Type::type Segment; + typedef Segment result_type; +//#ifdef CGAL_CXX0X +// template result_type operator()(U&&...u)const{ +// // should use Construct_point ? +// return result_type(std::forward(u)...); +// } +//#else + result_type operator()(Point const&a, Point const&b)const{ + return result_type(a,b); + } +//#endif +}; + +// This should be part of Construct_point, according to Kernel_23 conventions +template struct Construct_segment_extremity { + CGAL_FUNCTOR_INIT_IGNORE(Construct_segment_extremity) + typedef R_ R; + typedef typename R_::template Type::type Point; + typedef typename R_::template Type::type Segment; + typedef Point result_type; + result_type operator()(Segment const&s, int i)const{ + if(i==0) return s.first; + CGAL_assertion(i==1); + return s.second; + } +#ifdef CGAL_CXX0X + result_type operator()(Segment &&s, int i)const{ + if(i==0) return std::move(s.first); + CGAL_assertion(i==1); + return std::move(s.second); + } +#endif +}; +} // CartesianDKernelFunctors + +template +struct Define_segment : public Base_ { + typedef Base_ Base; + typedef Define_segment Self; + typedef typename Default::Get::type Derived; + template struct Type : Base_::template Type {}; + template struct Type { + typedef typename Derived::template Type::type Point; + typedef std::pair type; + }; + // TODO: forward the second Functor argument (like fast, no_filter) + template struct Functor : Base_::template Functor {}; + + template struct Functor,D> { + typedef CartesianDKernelFunctors::Construct_segment type; + }; + template struct Functor { + typedef CartesianDKernelFunctors::Construct_segment_extremity type; + }; +}; +} +#endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 24411d72e01..e452cdc1f99 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -60,6 +60,8 @@ struct Lazy_cartesian : Dimension_base typedef Lazy::type, typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> type; \ }; + CGAL_Kernel_obj(Segment,segment) +// TODO: avoid using interface_macros here, pass the kernel a list of tags. #include template::type> struct Functor { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index a50c29e80d1..496361fa99b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -71,6 +71,9 @@ template transforming_iterator struct Cartesian_wrap : public Base_ { @@ -83,6 +86,8 @@ struct Cartesian_wrap : public Base_ #define CGAL_Kernel_obj(X,Y) \ templatestruct Type { typedef X##_d type; }; + CGAL_Kernel_obj(Segment,segment) + //TODO: give a list to Cartesian_wrap #include //Translate the arguments 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 d56952ffd06..bbff4d354be 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -352,44 +352,6 @@ template struct Compare_lexicographically : private Store_kernel { } }; -template struct Construct_segment { - CGAL_FUNCTOR_INIT_IGNORE(Construct_segment) - typedef R_ R; - typedef typename R_::template Type::type Point; - typedef typename R_::template Type::type Segment; - typedef Segment result_type; -#ifdef CGAL_CXX0X - template result_type operator()(U&&...u)const{ - // should use Construct_point ? - return result_type(std::forward(u)...); - } -#else - result_type operator()(Point const&a, Point const&b)const{ - return result_type(a,b); - } -#endif -}; - -// This should be part of Construct_point, according to Kernel_23 conventions -template struct Construct_segment_extremity { - CGAL_FUNCTOR_INIT_IGNORE(Construct_segment_extremity) - typedef R_ R; - typedef typename R_::template Type::type Point; - typedef typename R_::template Type::type Segment; - typedef Point result_type; - result_type operator()(Segment const&s, int i)const{ - if(i==0) return s.source(); - CGAL_assertion(i==1); - return s.target(); - } -#ifdef CGAL_CXX0X - result_type operator()(Segment &&s, int i)const{ - if(i==0) return std::move(s).source(); - CGAL_assertion(i==1); - return std::move(s).target(); - } -#endif -}; } } diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 75f31e1b2c8..286648bb016 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -34,7 +34,7 @@ CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) -CGAL_Kernel_obj2(Segment,segment) +//CGAL_Kernel_obj2(Segment,segment) CGAL_Kernel_cons1(Construct_vector, construct_vector_object) @@ -52,10 +52,10 @@ CGAL_Kernel_cons2(Construct_opposite_vector, construct_opposite_vector_object) CGAL_Kernel_cons2(Construct_midpoint, construct_midpoint_object) -CGAL_Kernel_cons2(Construct_segment, - construct_segment_object) -CGAL_Kernel_cons2(Construct_segment_extremity, - construct_segment_extremity_object) +//CGAL_Kernel_cons2(Construct_segment, +// construct_segment_object) +//CGAL_Kernel_cons2(Construct_segment_extremity, +// construct_segment_extremity_object) CGAL_Kernel_comp1(Compute_cartesian_coordinate, compute_cartesian_coordinate_object) diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 5608180a7c8..b259a3f8222 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -5,14 +5,15 @@ #include #include #include +#include #include #include #include #include //typedef CGAL::Cartesian_base_d > K0; //typedef CGAL::Cartesian_base_d > KA; -struct KA : CGAL::Cartesian_static_filters, CGAL::Cartesian_base_d,KA >, KA> {}; -typedef CGAL::Cartesian_base_d > KE; +struct KA : CGAL::Cartesian_static_filters, CGAL::Define_segment,KA>, KA>, KA> {}; +typedef CGAL::Define_segment > > KE; struct RC: public CGAL::Cartesian_static_filters, // Yes, it is silly to put it there. @@ -33,14 +34,14 @@ CGAL::Cartesian_LA_base_d > RC(int){} }; -typedef RC K0; +typedef CGAL::Define_segment K0; #if 0 typedef K0 K2; #elif 0 typedef CGAL::Cartesian_filter_NT K2; -#elif 0 +#elif 1 typedef CGAL::Cartesian_filter_K K2; #elif 1 typedef CGAL::Lazy_cartesian > K2; From e6978d91895b4a59a0b34ea64551301f679a155c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 8 Nov 2011 13:26:23 +0000 Subject: [PATCH 057/210] piecewise construction of segment --- .../include/CGAL/Kernel_d/Define_segment.h | 18 +++++---- NewKernel_d/include/CGAL/marcutils.h | 40 ++++++++++++++++++- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index a5c64a9bb27..92313614c84 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -1,6 +1,7 @@ #ifndef CGAL_KD_DEFINE_SEGMENT_H #define CGAL_KD_DEFINE_SEGMENT_H #include +#include #include namespace CGAL { @@ -11,17 +12,20 @@ template struct Construct_segment { typedef R_ R; typedef typename R_::template Type::type Point; typedef typename R_::template Type::type Segment; + typedef typename R_::template Functor >::type CP; typedef Segment result_type; -//#ifdef CGAL_CXX0X -// template result_type operator()(U&&...u)const{ -// // should use Construct_point ? -// return result_type(std::forward(u)...); -// } -//#else result_type operator()(Point const&a, Point const&b)const{ return result_type(a,b); } -//#endif + // T should only be std::piecewise_construct_t, but we shouldn't fail if it doesn't exist. + template + result_type operator()(CGAL_FORWARDABLE(T),CGAL_FORWARDABLE(U) u,CGAL_FORWARDABLE(V) v)const{ + CP cp(this->kernel()); + result_type r = { + call_on_tuple_elements(cp, CGAL_FORWARD(U,u)), + call_on_tuple_elements(cp, CGAL_FORWARD(V,v)) }; + return r; + } }; // This should be part of Construct_point, according to Kernel_23 conventions diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index b2ed2770303..36b3037a3a9 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -16,7 +16,9 @@ #endif #include #include +#include #include +#include namespace CGAL { @@ -38,11 +40,11 @@ namespace internal { // like std::forward, except for basic types where it does a cast, to // avoid issues with narrowing conversions #ifdef CGAL_CXX0X - template + template inline typename std::conditional::value&&std::is_arithmetic::type>::value,T,U&&>::type forward_safe(V&& u) { return std::forward(u); } #else - template U const& forward_safe(U const& u) { + template inline U const& forward_safe(U const& u) { return u; } #endif @@ -159,6 +161,40 @@ namespace internal { return *i; } }; + +#ifdef CGAL_CXX0X + template struct Indices{}; + template struct Next_increasing_indices; + template struct Next_increasing_indices > { + typedef Indices type; + }; + template struct N_increasing_indices { + typedef typename Next_increasing_indices::type>::type type; + }; + template<> struct N_increasing_indices<0> { typedef Indices<> type; }; + namespace internal { + template inline typename std::result_of::type + do_call_on_tuple_elements(F&&f, std::tuple&&t, Indices&&) { + return f(std::get(std::move(t))...); + } + } // internal + template + inline typename std::result_of::type + call_on_tuple_elements(F&&f, std::tuple&&t) { + return internal::do_call_on_tuple_elements(std::forward(f),std::move(t), + typename N_increasing_indices::type()); + } +#else +#define VAR(Z,N,_) cpp0x::get(t) +#define CODE(Z,N,_) template \ + inline Res call_on_tuple_elements(F const&f, \ + cpp0x::tuple const&t) { \ + return f(BOOST_PP_ENUM(N,VAR,)); \ + } +BOOST_PP_REPEAT_FROM_TO(0, 8, CODE, _ ) +#undef CODE +#undef VAR +#endif } #endif From b57b61b13bf1c8da05eda73bea918a3235e28383 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 8 Nov 2011 23:42:21 +0000 Subject: [PATCH 058/210] Make everything lazy by default --- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index e452cdc1f99..bbd22b93efc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -54,16 +54,14 @@ struct Lazy_cartesian : Dimension_base typedef typename Same_uncertainty_nt::type Angle; - template struct Type {}; -#define CGAL_Kernel_obj(X,Y) \ - template struct Type { \ - typedef Lazy::type, typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> type; \ + // Doesn't look like we need an explicit list. + template struct Type { + typedef Lazy< + typename Approximate_kernel::template Type::type, + typename Exact_kernel::template Type::type, + typename Exact_kernel::FT, E2A> type; }; - CGAL_Kernel_obj(Segment,segment) -// TODO: avoid using interface_macros here, pass the kernel a list of tags. -#include - template::type> struct Functor { typedef Null_functor type; }; From 9b54173f8b2f72c6bd5ada425f195e837b4047fb Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 9 Nov 2011 12:07:58 +0000 Subject: [PATCH 059/210] Orientation taking points directly instead of iterators --- .../include/CGAL/Kernel_d/Cartesian_small.h | 51 +++++++++++++ .../Kernel_d/function_objects_cartesian.h | 71 +++++++++++++++++-- 2 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h new file mode 100644 index 00000000000..4bd466f95ec --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h @@ -0,0 +1,51 @@ +#ifndef CGAL_KD_CARTESIAN_SMALL_H +#define CGAL_KD_CARTESIAN_SMALL_H +#include +#include + +// WARNING: not written yet, I just wanted to stick the BOOST stuff somewhere not to lose it. + +namespace CGAL { +namespace CartesianDKernelFunctors { +template +struct Orientation_of_points_small : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_small); + typedef typename R_::template Type::type Point; + typedef typename R_::Orientation result_type; + typedef typename R_::FT FT; +#if 0 + template + result_type operator()(Iter f, Iter e)const{ + typename R_::template Functor::type c(this->kernel()); + Point const&A=*f; + FT const& ax=c(A,0); + FT const& ay=c(A,1); + Point const&B=*++f; + Point const&C=*++f; + CGAL_assertion(++f==e); + return sign_of_determinant(c(B,0)-ax,c(B,1)-ay,c(C,0)-ax,c(C,1)-ay); + } +#endif + +// TODO: iterate outside the class to have a single declaration of the right dimension. +#define VAR(Z,J,I) m(I,J)=c(p##I,J)-c(x,J); +#define VAR2(Z,I,N) BOOST_PP_ENUM(N,VAR,I) +#define CODE(Z,N,_) \ + result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ + typename R::template Functor::type c(this->kernel()); \ + Matrix m(N,N); \ + BOOST_PP_REPEAT(N,VAR2,N) \ + return sign_of_determinant(BOOST_PP_ENUM(N,VAR2,N)); \ + } + +BOOST_PP_REPEAT_FROM_TO(2, 10, CODE, _ ) +#undef CODE +#undef VAR2 +#undef VAR +#endif + +}; +} +} + +#endif 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 bbff4d354be..6f1c3debe77 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace CGAL { namespace CartesianDKernelFunctors { @@ -35,11 +36,42 @@ template struct Orientation_of_points : private Store_kernel { Point const& p=*f; for(int j=0;j,typename R::Default_ambient_dimension>::value>::type> + template =3)>::type> + result_type operator()(U&&...u) const { + return operator()({std::forward(u)...}); + } + + template + result_type operator()(std::initializer_list

l) const { + return operator()(l.begin(),l.end()); + } +#else + //should we make it template to avoid instantiation for wrong dim? + //or iterate outside the class? +#define VAR(Z,J,I) m(I,J)=c(p##I,J)-c(x,J); +#define VAR2(Z,I,N) BOOST_PP_REPEAT(N,VAR,I) +#define CODE(Z,N,_) \ + result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ + typename R::template Functor::type c(this->kernel()); \ + Matrix m(N,N); \ + BOOST_PP_REPEAT(N,VAR2,N) \ + return R::LA::sign_of_determinant(CGAL_MOVE(m)); \ + } + +BOOST_PP_REPEAT_FROM_TO(2, 10, CODE, _ ) +#undef CODE +#undef VAR2 +#undef VAR +#endif }; template struct Orientation_of_vectors : private Store_kernel { @@ -68,7 +100,20 @@ template struct Orientation_of_vectors : private Store_kernel { } return R::LA::sign_of_determinant(CGAL_MOVE(m)); } - //TODO: version that takes objects directly instead of iterators + +#ifdef CGAL_CXX0X + template =3)>::type> + result_type operator()(U&&...u) const { + return operator()({std::forward(u)...}); + } + + template + result_type operator()(std::initializer_list l) const { + return operator()(l.begin(),l.end()); + } +#else + //TODO +#endif }; #if 0 @@ -157,7 +202,20 @@ template struct Side_of_oriented_sphere : private Store_kernel { } return R::LA::sign_of_determinant(CGAL_MOVE(m)); } - //TODO: version that takes objects directly instead of iterators + +#ifdef CGAL_CXX0X + template =4)>::type> + result_type operator()(U&&...u) const { + return operator()({std::forward(u)...}); + } + + template + result_type operator()(std::initializer_list

l) const { + return operator()(l.begin(),l.end()); + } +#else + //TODO +#endif }; template struct Construct_opposite_vector : private Store_kernel { @@ -344,10 +402,11 @@ template struct Compare_lexicographically : private Store_kernel { a_begin=c(a,Begin_tag()), b_begin=c(b,Begin_tag()), a_end=c(a,End_tag()); - result_type res=CGAL_NTS compare(*a_begin++,*b_begin++); + result_type res; // can't we do slightly better for Uncertain<*> ? - while(a_begin!=a_end && res==EQUAL) - res=CGAL_NTS compare(*a_begin++,*b_begin++); + // after res=...; if(is_uncertain(res))return indeterminate(); + do res=CGAL_NTS compare(*a_begin++,*b_begin++); + while(a_begin!=a_end && res==EQUAL); return res; } }; From 075fcc76d4cf7534e144c228b53fdbf5aa61e599 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 9 Nov 2011 14:26:05 +0000 Subject: [PATCH 060/210] Add some whitespace ;-) --- .../include/CGAL/Kernel_d/Cartesian_2.h | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h index d2c8b136f44..df812244ac3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h @@ -11,16 +11,18 @@ struct Orientation_of_points_2 : private Store_kernel { typedef typename R_::template Type::type Point; typedef typename R_::Orientation result_type; typedef typename R_::FT FT; - template - result_type operator()(Iter f, Iter e)const{ + template + result_type operator() (Iter f, Iter e) const { typename R_::template Functor::type c(this->kernel()); - Point const&A=*f; - FT const& ax=c(A,0); - FT const& ay=c(A,1); - Point const&B=*++f; - Point const&C=*++f; - CGAL_assertion(++f==e); - return sign_of_determinant(c(B,0)-ax,c(B,1)-ay,c(C,0)-ax,c(C,1)-ay); + Point const& A = *f; + FT const& ax = c(A, 0); + FT const& ay = c(A, 1); + Point const& B = *++f; + Point const& C = *++f; + CGAL_assertion(++f == e); + return sign_of_determinant( + c(B, 0) - ax, c(B, 1) - ay, + c(C, 0) - ax, c(C, 1) - ay); } }; } From ba6c34279d32ae8fe136b69394853fa7cd6f05a4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 26 Nov 2011 12:14:08 +0000 Subject: [PATCH 061/210] Orientation bypasses LA for small dimensions (filling a matrix is expensive) and can take points directly instead of iterators. --- .../include/CGAL/Kernel_d/Cartesian_2.h | 31 -------- .../CGAL/Kernel_d/Cartesian_per_dimension.h | 19 +---- .../include/CGAL/Kernel_d/Cartesian_small.h | 51 ------------ .../Kernel_d/function_objects_cartesian.h | 78 ++++++++++++++++++- 4 files changed, 78 insertions(+), 101 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h delete mode 100644 NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h deleted file mode 100644 index df812244ac3..00000000000 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_2.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CGAL_KD_CARTESIAN_2_H -#define CGAL_KD_CARTESIAN_2_H -#include -#include - -namespace CGAL { -namespace CartesianDKernelFunctors { -template -struct Orientation_of_points_2 : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); - typedef typename R_::template Type::type Point; - typedef typename R_::Orientation result_type; - typedef typename R_::FT FT; - template - result_type operator() (Iter f, Iter e) const { - typename R_::template Functor::type c(this->kernel()); - Point const& A = *f; - FT const& ax = c(A, 0); - FT const& ay = c(A, 1); - Point const& B = *++f; - Point const& C = *++f; - CGAL_assertion(++f == e); - return sign_of_determinant( - c(B, 0) - ax, c(B, 1) - ay, - c(C, 0) - ax, c(C, 1) - ay); - } -}; -} -} - -#endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h index 5f237284929..b67e680350e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_per_dimension.h @@ -3,27 +3,12 @@ #include #include #include -#include + +// Should probably disappear. namespace CGAL { template struct Cartesian_per_dimension : public R_ {}; - -// TODO: we want to put the actual functors in some other file. Maybe name the -// classes Orientation_2 to make it easy to typedef them all. -template -struct Cartesian_per_dimension,R_,Derived_> : public R_ { - typedef R_ Kernel_base; - template struct Functor - : Kernel_base::template Functor - { }; - -#define CGAL_override_in_dim2(X) \ - template struct Functor { \ - typedef CartesianDKernelFunctors::X##_2 type; \ - } - CGAL_override_in_dim2(Orientation_of_points); -}; } #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h deleted file mode 100644 index 4bd466f95ec..00000000000 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_small.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef CGAL_KD_CARTESIAN_SMALL_H -#define CGAL_KD_CARTESIAN_SMALL_H -#include -#include - -// WARNING: not written yet, I just wanted to stick the BOOST stuff somewhere not to lose it. - -namespace CGAL { -namespace CartesianDKernelFunctors { -template -struct Orientation_of_points_small : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_small); - typedef typename R_::template Type::type Point; - typedef typename R_::Orientation result_type; - typedef typename R_::FT FT; -#if 0 - template - result_type operator()(Iter f, Iter e)const{ - typename R_::template Functor::type c(this->kernel()); - Point const&A=*f; - FT const& ax=c(A,0); - FT const& ay=c(A,1); - Point const&B=*++f; - Point const&C=*++f; - CGAL_assertion(++f==e); - return sign_of_determinant(c(B,0)-ax,c(B,1)-ay,c(C,0)-ax,c(C,1)-ay); - } -#endif - -// TODO: iterate outside the class to have a single declaration of the right dimension. -#define VAR(Z,J,I) m(I,J)=c(p##I,J)-c(x,J); -#define VAR2(Z,I,N) BOOST_PP_ENUM(N,VAR,I) -#define CODE(Z,N,_) \ - result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ - typename R::template Functor::type c(this->kernel()); \ - Matrix m(N,N); \ - BOOST_PP_REPEAT(N,VAR2,N) \ - return sign_of_determinant(BOOST_PP_ENUM(N,VAR2,N)); \ - } - -BOOST_PP_REPEAT_FROM_TO(2, 10, CODE, _ ) -#undef CODE -#undef VAR2 -#undef VAR -#endif - -}; -} -} - -#endif 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 6f1c3debe77..4bd54a70444 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -16,8 +16,14 @@ namespace CGAL { namespace CartesianDKernelFunctors { +namespace internal { +template struct Dimension_at_most { enum { value = false }; }; +template struct Dimension_at_most,b> { + enum { value = (a <= b) }; +}; +} -template struct Orientation_of_points : private Store_kernel { +template::value> struct Orientation_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; typedef typename R_::FT FT; @@ -67,13 +73,81 @@ template struct Orientation_of_points : private Store_kernel { return R::LA::sign_of_determinant(CGAL_MOVE(m)); \ } -BOOST_PP_REPEAT_FROM_TO(2, 10, CODE, _ ) +BOOST_PP_REPEAT_FROM_TO(7, 10, CODE, _ ) + // No need to do it for <=6, since that uses a different code path #undef CODE #undef VAR2 #undef VAR #endif }; +#ifdef CGAL_CXX0X +template struct Orientation_of_points,true> : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::template Type::type Point; + typedef typename R::Orientation result_type; + templatestruct Help; + templatestruct Help > { + template result_type operator()(C const&c,P const&x,T&&t)const{ + return sign_of_determinant(c(std::get(t),I%d)-c(x,I%d)...); + } + }; + template result_type operator()(P0 const&x,P&&...p)const{ + static_assert(d==sizeof...(P),"Wrong number of arguments"); + typename R::template Functor::type c(this->kernel()); + return Help::type>()(c,x,std::forward_as_tuple(std::forward

(p)...)); + } + + + template result_type help2(Dimension_tag, Iter f, Iter const&e, U&&...u)const{ + auto const&p=*f; + return help2(Dimension_tag(),++f,e,std::forward(u)...,p); + } + template result_type help2(Dimension_tag<0>, Iter f, Iter const&e, U&&...u)const{ + CGAL_assertion(f==e); + return operator()(std::forward(u)...); + } + template + result_type operator()(Iter f, Iter e)const{ + return help2(Dimension_tag(),f,e); + } +}; +#else +#define VAR(Z,J,I) c(p##I,J)-x##J +#define VAR2(Z,I,N) BOOST_PP_ENUM(N,VAR,I) +#define VAR3(Z,N,_) Point const&p##N=*++f; +#define VAR4(Z,N,_) FT const&x##N=c(x,N); +#define CODE(Z,N,_) \ +template struct Orientation_of_points,true> : private Store_kernel { \ + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) \ + typedef R_ R; \ + typedef typename R_::FT FT; \ + typedef typename R::template Type::type Point; \ + typedef typename R::Orientation result_type; \ + result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ + typename R::template Functor::type c(this->kernel()); \ + BOOST_PP_REPEAT(N,VAR4,) \ + return sign_of_determinant(BOOST_PP_ENUM(N,VAR2,N)); \ + } \ + template \ + result_type operator()(Iter f, Iter e)const{ \ + Point const&x=*f; \ + BOOST_PP_REPEAT(N,VAR3,) \ + return operator()(x,BOOST_PP_ENUM_PARAMS(N,p)); \ + } \ +}; + + BOOST_PP_REPEAT_FROM_TO(2, 7, CODE, _ ) +#undef CODE +#undef VAR2 +#undef VAR + +#endif + + + template struct Orientation_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) typedef R_ R; From 4d0c67612e6293b3f747d415f9af3f2217befc4b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 26 Nov 2011 16:08:43 +0000 Subject: [PATCH 062/210] sizeof... always needs parentheses --- NewKernel_d/include/CGAL/Vector/eigen.h | 4 ++-- NewKernel_d/include/CGAL/marcutils.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/include/CGAL/Vector/eigen.h b/NewKernel_d/include/CGAL/Vector/eigen.h index 233b3a94820..2830b5afc2f 100644 --- a/NewKernel_d/include/CGAL/Vector/eigen.h +++ b/NewKernel_d/include/CGAL/Vector/eigen.h @@ -92,7 +92,7 @@ template struct Eigen_vector { // TODO avoid going through Initializer_list which may cause extra copies. Possibly use forward_as_tuple. template type operator()(U&&...u) const { - check_dim(sizeof...U); // use static_assert + check_dim(sizeof...(U)); // use static_assert return Initializer_list()({forward_safe(u)...}); } #else @@ -113,7 +113,7 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) #ifdef CGAL_CXX0X template type operator()(H const&h,U&&...u) const { - check_dim(sizeof...U); // use static_assert + check_dim(sizeof...(U)); // use static_assert return Initializer_list()({Rational_traits().make_rational(std::forward(u),h)...}); } #else diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 36b3037a3a9..c6c2764cacd 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -166,7 +166,7 @@ namespace internal { template struct Indices{}; template struct Next_increasing_indices; template struct Next_increasing_indices > { - typedef Indices type; + typedef Indices type; }; template struct N_increasing_indices { typedef typename Next_increasing_indices::type>::type type; From cfce80eb0bba35397b376a28297b768644e9ed00 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 26 Nov 2011 18:56:40 +0000 Subject: [PATCH 063/210] Don't include in C++03. --- NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h | 2 ++ 1 file changed, 2 insertions(+) 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 4bd54a70444..c6ecf2a7752 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -12,7 +12,9 @@ #include #include #include +#ifdef CGAL_CXX0X #include +#endif namespace CGAL { namespace CartesianDKernelFunctors { From 5f5fe324309c1fd43ed767c958ba6a6c8fe6d54b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 26 Nov 2011 18:57:31 +0000 Subject: [PATCH 064/210] Default value for Derived parameter. --- .../include/CGAL/Kernel_d/Cartesian_static_filters.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index a7a02cbffbb..97122213806 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -46,16 +46,18 @@ template struct Orientation_of_points_2 : private Store_k }; } -template struct Cartesian_static_filters : public R_ {}; +template struct Cartesian_static_filters : public R_ {}; template struct Cartesian_static_filters, R_, Derived_> : public R_ { + typedef Cartesian_static_filters, R_, Derived_> Self; + typedef typename Default::Get::type Derived; template struct Functor : R_::template Functor {}; template struct Functor { typedef //typename boost::conditional< //boost::is_same::value, //typename R_::template Functor::type, - SFA::Orientation_of_points_2 + SFA::Orientation_of_points_2 // >::type type; }; From 843e3ab1bba4afb9f2a3b44d745971d137f22142 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 27 Nov 2011 12:13:01 +0000 Subject: [PATCH 065/210] Avoid some unnecessary copying. --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h | 5 +++-- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 97122213806..f8307f2b35d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -21,8 +21,9 @@ template struct Orientation_of_points_2 : private Store_k struct Point_2 { R_ const&r; CC const&c; Point const& p; Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){} - FT x()const{return c(p,0);} - FT y()const{return c(p,1);} + // use result_of instead? + typename CC::result_type x()const{return c(p,0);} + typename CC::result_type y()const{return c(p,1);} }; struct Vector_2 {}; struct Circle_2 {}; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 496361fa99b..2b25b2a8c00 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -56,8 +56,8 @@ struct Forward_rep { //}; //#else template ::value,bool=Is_wrapper_iterator::value> struct result_; -template struct result_{typedef T type;}; -template struct result_{typedef typename decay::type::Rep type;}; +template struct result_{typedef T const& type;}; +template struct result_{typedef typename decay::type::Rep const& type;}; template struct result_{typedef transforming_iterator::type> type;}; template struct result; template struct result : result_ {}; From 24d09207ff0f15b1e90e29a924fa7b0dd91046ca Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 30 Nov 2011 19:50:08 +0000 Subject: [PATCH 066/210] Missing inline. Adding a file that's nonsense currently, but I'll be at the office tomorrow. --- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 68 +++++++++++++++++++ .../include/CGAL/transforming_iterator.h | 2 +- .../include/CGAL/transforming_pair_iterator.h | 2 +- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Coaffine.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h new file mode 100644 index 00000000000..2a95a7fb304 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -0,0 +1,68 @@ +#ifndef CGAL_KD_COAFFINE_H +#define CGAL_KD_COAFFINE_H +#include +// DRAFT, DOESN'T WORK YET +namespace CGAL { +struct Orientation_in_subspace { + std::vector indices; + // use indices.size() to know if the origin is added + // an index of i means add the vector (0,...,1,...,0) with the 1 in i-th position + // *OR* it means *don't* add this one... +}; + +template struct Construct_orientation_in_subspace : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_orientation_in_subspace) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::template Type::type Point; + typedef typename R::template Functor::type CCC; + typedef typename R::LA LA; + typedef typename LA::template Matrix::type Matrix; + typedef typename R::template Functor::type PD; + typedef Orientation_in_subspace result_type; + + // This implementation is going to suck. Maybe we should push the + // functionality into LA. + template + result_type operator()(Iter f, Iter e)const{ + PD pd (this->kernel()); + CCC ccc (this->kernel()); + int dim = pd(*f); + Matrix coord (dim, dim); + int col = 0; + std::vector proj; + std::vector rest; rest.reserve(dim); + for(int i=0; i::iterator it=rest.begin();it!=rest.end();++it) { + for(int i=0; i }; -template +template inline transforming_iterator make_transforming_iterator(Iter i, F const&f=F()) { return transforming_iterator(i,f); } diff --git a/NewKernel_d/include/CGAL/transforming_pair_iterator.h b/NewKernel_d/include/CGAL/transforming_pair_iterator.h index 72e6f6ac170..9df4b61c4e9 100644 --- a/NewKernel_d/include/CGAL/transforming_pair_iterator.h +++ b/NewKernel_d/include/CGAL/transforming_pair_iterator.h @@ -97,7 +97,7 @@ private internal::Functor_as_base }; -template +template inline transforming_pair_iterator make_transforming_pair_iterator(It1 i1, It2 i2, F const&f=F()) { return transforming_pair_iterator(i1,i2,f); } From 13c3f90e33ddf7beb9d8db4edbe9f09904fddac0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 5 Dec 2011 21:08:32 +0000 Subject: [PATCH 067/210] I'd really like for it to compile soon... --- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 194 ++++++++++++++++--- NewKernel_d/include/CGAL/functor_tags.h | 4 + 2 files changed, 172 insertions(+), 26 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 2a95a7fb304..c0f1918dd6f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -1,25 +1,28 @@ #ifndef CGAL_KD_COAFFINE_H #define CGAL_KD_COAFFINE_H #include -// DRAFT, DOESN'T WORK YET +#include +#include +#include + namespace CGAL { -struct Orientation_in_subspace { - std::vector indices; - // use indices.size() to know if the origin is added - // an index of i means add the vector (0,...,1,...,0) with the 1 in i-th position - // *OR* it means *don't* add this one... +namespace CartesianDKernelFunctors { +struct Flat_orientation { + std::vector proj; + std::vector rest; }; -template struct Construct_orientation_in_subspace : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Construct_orientation_in_subspace) +template struct Construct_flat_orientation : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_flat_orientation) typedef R_ R; typedef typename R_::FT FT; typedef typename R::template Type::type Point; typedef typename R::template Functor::type CCC; typedef typename R::LA LA; - typedef typename LA::template Matrix::type Matrix; + typedef typename Increment_dimension::type Dplusone; + typedef typename LA::template Matrix::type Matrix; typedef typename R::template Functor::type PD; - typedef Orientation_in_subspace result_type; + typedef Flat_orientation result_type; // This implementation is going to suck. Maybe we should push the // functionality into LA. @@ -28,14 +31,17 @@ template struct Construct_orientation_in_subspace : private Store_kern PD pd (this->kernel()); CCC ccc (this->kernel()); int dim = pd(*f); - Matrix coord (dim, dim); + Matrix coord (dim+1, dim+1); // use distance(f,e)? int col = 0; - std::vector proj; - std::vector rest; rest.reserve(dim); - for(int i=0; i& proj=o.proj; + std::vector& rest=o.rest; rest.reserve(dim+1); + for(int i=0; i struct Construct_orientation_in_subspace : private Store_kern // TODO: iterate on rest by the end, or use a (forward_)list. for(std::vector::iterator it=rest.begin();it!=rest.end();++it) { for(int i=0; i struct Contained_in_affine_hull : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Contained_in_affine_hull) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::template Type::type Point; + typedef typename R::Orientation result_type; + typedef typename R::template Functor::type CCC; + typedef typename R::template Functor::type PD; + typedef typename Increment_dimension::type D1; + typedef typename Increment_dimension::type D2; + typedef typename R::LA::template Matrix::type Matrix; + + // mostly copied from Construct_flat_orientation. TODO: dedup this code. + template + result_type operator()(Iter f, Iter e, Point const&x) const { + PD pd (this->kernel()); + CCC ccc (this->kernel()); + int dim=pd(*f); + Matrix coord (dim+1, dim+1); // use distance + int col = 0; + std::vector proj; + std::vector rest; rest.reserve(dim+1); + for(int i=0; i::iterator it=rest.begin();it!=rest.end();++it) { + for(int i=0; i::iterator it=rest.begin();it!=rest.end();++it) { + for(int i=0; i struct In_flat_orientation : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(In_flat_orientation) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::template Type::type Point; + typedef typename R::Orientation result_type; + typedef typename Increment_dimension::type D1; + typedef typename Increment_dimension::type D2; + typedef typename R::LA::template Matrix::type Matrix; + + template + result_type operator()(Flat_orientation const&o, Iter f, Iter e) const { + // TODO: work in the projection instead of the ambient space. + typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type pd(this->kernel()); + int d=pd(*f); + Matrix m(d+1,d+1); + int i=0; + for(;f!=e;++f,++i) { + Point const& p=*f; + m(i,0)=1; + for(int j=0;j::const_iterator it = o.rest.begin(); it != o.rest.end() /* i struct In_flat_side_of_oriented_sphere : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(In_flat_side_of_oriented_sphere) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::template Type::type Point; + typedef typename R::Orientation result_type; + typedef typename Increment_dimension::type D1; + typedef typename Increment_dimension::type D2; + typedef typename R::LA::template Matrix::type Matrix; + + template + result_type operator()(Flat_orientation const&o, Iter f, Iter e, Point const&x) const { + // TODO: can't work in the projection, but we should at least remove the row of 1s. + typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type pd(this->kernel()); + int d=pd(*f); + Matrix m(d+2,d+2); + int i=0; + for(;f!=e;++f,++i) { + Point const& p=*f; + m(i,0)=1; + m(i,d+1)=0; + for(int j=0;j::const_iterator it = o.rest.begin(); it != o.rest.end() /* i Date: Wed, 7 Dec 2011 11:04:28 +0000 Subject: [PATCH 068/210] Kernel_d-like interface --- .../CGAL/Kernel_d/Cartesian_complete.h | 3 ++ NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 8 ++-- .../CGAL/Kernel_d/Kernel_d_interface.h | 37 +++++++++++++++++++ .../Kernel_d/function_objects_cartesian.h | 1 + .../include/CGAL/Kernel_d/interface_macros.h | 8 ++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 4f676effff5..25ff38b6ef9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -76,6 +76,9 @@ template struct Cartesian_com template struct Cartesian_complete_predicates : public R_ { + // TODO: this doesn't look like the right place for this typedef... + typedef CartesianDKernelFunctors::Flat_orientation Flat_orientation; + typedef R_ Kernel_base; typedef typename Default::Get::type Derived; template::type> struct Functor : diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index c0f1918dd6f..b7da88507c0 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -3,6 +3,7 @@ #include #include #include +#include #include namespace CGAL { @@ -20,7 +21,7 @@ template struct Construct_flat_orientation : private Store_kernel typedef typename R::template Functor::type CCC; typedef typename R::LA LA; typedef typename Increment_dimension::type Dplusone; - typedef typename LA::template Matrix::type Matrix; + typedef typename LA::template Matrix::type Matrix; typedef typename R::template Functor::type PD; typedef Flat_orientation result_type; @@ -60,7 +61,7 @@ template struct Construct_flat_orientation : private Store_kernel } //CGAL_assertion(it!=rest.end()); } - std::sort(proj.begin(),proj.last()); + std::sort(proj.begin(),proj.end()); return o; } }; @@ -69,13 +70,14 @@ template struct Contained_in_affine_hull : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Contained_in_affine_hull) typedef R_ R; typedef typename R_::FT FT; + typedef typename R::LA LA; typedef typename R::template Type::type Point; typedef typename R::Orientation result_type; typedef typename R::template Functor::type CCC; typedef typename R::template Functor::type PD; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; - typedef typename R::LA::template Matrix::type Matrix; + typedef typename LA::template Matrix::type Matrix; // mostly copied from Construct_flat_orientation. TODO: dedup this code. template diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h new file mode 100644 index 00000000000..2466a0a3558 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -0,0 +1,37 @@ +#ifndef CGAL_KD_KERNEL_3_INTERFACE_H +#define CGAL_KD_KERNEL_3_INTERFACE_H + +#include +#include +#include +#include + + +namespace CGAL { +template struct Kernel_d_interface : public Base_ { + typedef Base_ Base; + typedef Kernel_d_interface Kernel; + typedef typename Base::Flat_orientation Flat_orientation_d; + typedef typename Base::template Type::type Point_d; + typedef typename Base::template Type::type Vector_d; + //typedef typename Base::template Type::type Segment_d; + typedef typename Base::template Functor::type Compare_lexicographically_d; + typedef typename Base::template Functor::type Orientation_d; + typedef typename Base::template Functor::type Side_of_oriented_sphere_d; + typedef typename Base::template Functor::type Contained_in_affine_hull_d; + typedef typename Base::template Functor::type Construct_flat_orientation_d; + typedef typename Base::template Functor::type In_flat_orientation_d; + typedef typename Base::template Functor::type In_flat_side_of_oriented_sphere_d; + + + Compare_lexicographically_d compare_lexicographically_d_object()const{ return Compare_lexicographically_d(*this); } + Orientation_d orientation_d_object()const{ return Orientation_d(*this); } + Side_of_oriented_sphere_d side_of_oriented_sphere_d_object()const{ return Side_of_oriented_sphere_d(*this); } + Contained_in_affine_hull_d contained_in_affine_hull_d_object()const{ return Contained_in_affine_hull_d(*this); } + Construct_flat_orientation_d construct_flat_orientation_d_object()const{ return Construct_flat_orientation_d(*this); } + In_flat_orientation_d in_flat_orientation_d_object()const{ return In_flat_orientation_d(*this); } + In_flat_side_of_oriented_sphere_d in_flat_side_of_oriented_sphere_d_object()const{ return In_flat_side_of_oriented_sphere_d(*this); } +}; +} + +#endif 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 c6ecf2a7752..7579ae208c0 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -490,4 +490,5 @@ template struct Compare_lexicographically : private Store_kernel { } } +#include #endif // CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 286648bb016..98a089183cb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -78,6 +78,14 @@ CGAL_Kernel_pred(Compare_distance, compare_distance_object) CGAL_Kernel_pred(Compare_lexicographically, compare_lexicographically_object) +CGAL_Kernel_pred(Contained_in_affine_hull, + contained_in_affine_hull_object) +CGAL_Kernel_pred(In_flat_orientation, + in_flat_orientation_object) +CGAL_Kernel_pred(In_flat_side_of_oriented_sphere, + in_flat_side_of_oriented_sphere_object) +CGAL_Kernel_pred(Construct_flat_orientation, + construct_flat_orientation_object) #undef CGAL_Kernel_pred #undef CGAL_Kernel_comp From 212ca488ea26929e1b233792694ae29380f04bf6 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 7 Dec 2011 11:21:00 +0000 Subject: [PATCH 069/210] CGAL_CFG macros --- NewKernel_d/test/NewKernel_d/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index c28e4efdd39..e20954641ee 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -3,7 +3,7 @@ all: normal cxx0x CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK normal: - g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} + g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV ./a.out cxx0x: From 92e92d730d6494b0df273148f82b5a295cd81dd5 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 17 Dec 2011 09:51:53 +0000 Subject: [PATCH 070/210] missing inline. convert points without iterators. --- NewKernel_d/include/CGAL/Dimension.h | 2 +- .../CGAL/Kernel_d/Kernel_object_converter.h | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/Dimension.h b/NewKernel_d/include/CGAL/Dimension.h index 66609cf95c3..06be888abb4 100644 --- a/NewKernel_d/include/CGAL/Dimension.h +++ b/NewKernel_d/include/CGAL/Dimension.h @@ -35,7 +35,7 @@ const int UNKNOWN_DIMENSION=Eigen::Dynamic; const int UNKNOWN_DIMENSION=std::numeric_limits::max(); #endif -bool check_dimension(int d1, int d2){ +inline bool check_dimension(int d1, int d2){ //return (d2==UNKNOWN_DIMENSION)||(d1<=d2); return d1<=d2; } 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 e8b5a1a29bf..3cbb816aac6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -1,12 +1,17 @@ #ifndef CGAL_KD_KO_CONVERTER_H #define CGAL_KD_KO_CONVERTER_H +#include #include #include // First_if_different namespace CGAL { template struct KO_converter; //TODO: It would probably be better if this was a Misc Functor in K1. +// This way K1 could chose how it wants to present its points (sparse +// iterator?) and derived classes would inherit it. -template struct KO_converter{ +namespace internal { +template +struct Point_converter_help { typedef typename K1::template Type::type argument_type; typedef typename K2::template Type::type result_type; template @@ -16,6 +21,29 @@ template struct KO_converter{ return cp(conv(i(p,Begin_tag())),conv(i(p,End_tag()))); } }; +#ifdef CGAL_CXX0X +// This doesn't seem so useful, the compiler should be able to handle +// the iterators just as efficiently. +template +struct Point_converter_help,K1,K2> { + typedef typename K1::template Type::type argument_type; + typedef typename K2::template Type::type result_type; + template + result_type help(Indices, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { + typename K1::template Functor::type cc(k1); + typename K2::template Functor >::type cp(k2); + return cp(conv(cc(p,I))...); + } + template + result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { + return help(typename N_increasing_indices::type(),k1,k2,conv,p); + } +}; +#endif +} +template struct KO_converter +: internal::Point_converter_help +{}; template struct KO_converter{ typedef typename K1::template Type::type K1_Vector; From 11c5bc353f67ad1f13c7ee858e3680f5be98f2b0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 28 Feb 2012 08:51:14 +0000 Subject: [PATCH 071/210] Basic typeset. Not sure I'll use it yet.\nSome tex file (no content) so I can try the manual tools. --- .../doc_tex/NewKernel_d_ref/Kernel.tex | 48 +++++++++++++++++++ .../CGAL/Kernel_d/Cartesian_LA_functors.h | 2 + NewKernel_d/include/CGAL/typeset.h | 35 ++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex create mode 100644 NewKernel_d/include/CGAL/typeset.h diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex new file mode 100644 index 00000000000..26638e95042 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex @@ -0,0 +1,48 @@ +\begin{ccRefConcept}{Kernel} +The concept of a {\em kernel} is defined by a set of requirements on +the provision of certain types. The types are function object classes to be +used within the algorithms and data structures of \cgal. + +A kernel provides types, construction objects, and generalized predicates. +The former replace constructors of the kernel classes and constructive +procedures in the kernel. There are also function objects replacing operators, +especially for equality testing. + +Types and functors are identified by tags, which may be any type (like \ccc{CGAL::Segment_tag}). As a special case, the construction functor of a type identified by \ccc{Some_tag} is identified by the tag \ccc{Construct_ttag}, and the conversion functor by \ccc{Convert_ttag}. + +Functors have a constructor that takes a \ccc{Kernel} as argument. If the kernel is stateless (as tested with \ccc{boost::is_empty}), functors may (must???) also have a default constructor. Functors follow the \ccc{result_of}-protocol. + +\ccTypes + +\ccNestedType{FT}{a model of \ccc{FieldNumberType}} +\ccGlue +\ccNestedType{RT}{a model of \ccc{RingNumberType}} + +The following types describe the return types of predicates. They typically +map to \ccc{bool} and \cgal\ kernel enum types, except when an interval arithmetic +number type is used such as within the filtering kernels, in which case it is +\ccc{Uncertain} or similar. + +\ccNestedType{Boolean}{\ccc{bool} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Sign}{\ccc{CGAL::Sign} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Comparison_result}{\ccc{CGAL::Comparison_result} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Orientation}{\ccc{CGAL::Orientation} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Oriented_side}{\ccc{CGAL::Oriented_side} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Bounded_side}{\ccc{CGAL::Bounded_side} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Angle}{\ccc{CGAL::Angle} or \ccc{Uncertain}} + +\ccHeading{Geometric Objects} + +\ccNestedType{template struct Type}{This nested template class defines an object type \ccc{type}. For instance, \ccc{Type::type} is the type of points.} + +\ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate.} + + +\end{ccRefConcept} + diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 61f80041a2e..5c5272abb1c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -135,6 +135,7 @@ template struct Construct_cartesian_const_iterator { typedef typename R::Vector_selector S_; typedef typename R::Point_cartesian_const_iterator result_type; // same as Vector + typedef Tag_true Is_exact; result_type operator()(argument_type const& v,Begin_tag)const{ return S_::vector_begin(v); @@ -211,6 +212,7 @@ template struct PV_dimension { typedef R_ R; typedef typename R::Vector_ argument_type; typedef int result_type; + typedef Tag_true Is_exact; // take a template argument instead? result_type operator()(argument_type const& v)const{ diff --git a/NewKernel_d/include/CGAL/typeset.h b/NewKernel_d/include/CGAL/typeset.h new file mode 100644 index 00000000000..94ae331a13b --- /dev/null +++ b/NewKernel_d/include/CGAL/typeset.h @@ -0,0 +1,35 @@ +#ifndef CGAL_TYPESET_H +#define CGAL_TYPESET_H +#ifdef CGAL_CXX0X +#include +#else +#include +#endif + +// Sometimes using tuple just to list types is overkill (takes forever to +// instantiate). + +namespace CGAL { +#ifdef CGAL_CXX0X + template struct typeset; + template struct typeset { + typedef T head; + typedef typeset tail; + template struct contains { + enum { value = std::conditional::value,std::true_type,tail::contains>::type::value }; + }; + template struct add { + typedef std::conditional::value,typeset,typeset>::type type; + }; + }; + template<> struct typeset<> { + template struct contains : boost::false_type {}; + template struct add { + typedef typeset type; + }; + }; +#else + // ??? +#endif +} +#endif From 1d02e5a32c6e2d234b48cf902feb47adcaeb745d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 28 Feb 2012 15:11:00 +0000 Subject: [PATCH 072/210] beginning of a doc, seems to compile, although PkgDescription may be ignored... --- .../doc_tex/NewKernel_d_ref/Kernel.tex | 4 ---- .../NewKernel_d_ref/Kernel_functor.tex | 19 +++++++++++++++++++ .../NewKernel_d_ref/PkgDescription.tex | 8 ++++++++ NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 11 +++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/PkgDescription.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/main.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex index 26638e95042..ee357ec68ca 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex @@ -10,8 +10,6 @@ especially for equality testing. Types and functors are identified by tags, which may be any type (like \ccc{CGAL::Segment_tag}). As a special case, the construction functor of a type identified by \ccc{Some_tag} is identified by the tag \ccc{Construct_ttag}, and the conversion functor by \ccc{Convert_ttag}. -Functors have a constructor that takes a \ccc{Kernel} as argument. If the kernel is stateless (as tested with \ccc{boost::is_empty}), functors may (must???) also have a default constructor. Functors follow the \ccc{result_of}-protocol. - \ccTypes \ccNestedType{FT}{a model of \ccc{FieldNumberType}} @@ -37,8 +35,6 @@ number type is used such as within the filtering kernels, in which case it is \ccGlue \ccNestedType{Angle}{\ccc{CGAL::Angle} or \ccc{Uncertain}} -\ccHeading{Geometric Objects} - \ccNestedType{template struct Type}{This nested template class defines an object type \ccc{type}. For instance, \ccc{Type::type} is the type of points.} \ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate.} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex new file mode 100644 index 00000000000..f6cb6137079 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex @@ -0,0 +1,19 @@ +\begin{ccRefConcept}{Kernel::Functor} +Functors have a constructor that takes a \ccc{Kernel} as argument. If the kernel is stateless (as tested with \ccc{boost::is_empty}), functors may (must???) also have a default constructor. Functors follow the \ccc{result_of}-protocol. + +Member functions provided by each functor are described in their concept. Some special cases are: +\begin{itemize} + \item A constructor is a functor represented by a tag \ccc{Construct_ttag}. It contains member functions \ccc{Kernel::Type::type operator()(Args...) const}. + \item A converter is a functor represented by a tag \ccc{Convert_ttag}. It contains a member function \ccc{template K2::Type::type operator()(Kernel::Type::type, K2::Functor>::type, Converter???) const}. As an example, a segment converter could first extract its extremities with \ccc{Kernel::Functor}, then convert them to \ccc{K2::Type} using \ccc{Converter} and finally build a \ccc{K2::Type} with \ccc{K2::Functor}. + %TODO: clarify this Converter business +\end{itemize} + +\ccc{Option} is used to specify a specific version of the functor. For instance, for a predicate, you might ask for a fast inexact version with \ccc{Fast_tag}. + +For each functor tag \ccc{Tag}, \ccc{map_functor_type::type} shall be +\ccc{Predicate_tag}, \ccc{Construct_tag}, \ccc{Compute_tag} or \ccc{Misc_tag} +depending on the kind of functor it is. Predicates output a discrete value, for instance \ccc{Kernel::Boolean}. Computations output a number of type \ccc{Kernel::FT} or \ccc{Kernel::RT}. Constructions output an object of type \ccc{Kernel::Type::type>::type} where \ccc{map_result_tag} is specialized to specify the tag of the result. All others are miscellaneous. + + +\end{ccRefConcept} + diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/PkgDescription.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/PkgDescription.tex new file mode 100644 index 00000000000..369d0eff79f --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/PkgDescription.tex @@ -0,0 +1,8 @@ +\begin{ccPkgDescription}{dD Kernel} +\ccPkgSummary{ +A new d-dimensional kernel. +} +\ccPkgIntroducedInCGAL{42.0} +\ccPkgLicense{\ccLicenseLGPL} +\end{ccPkgDescription} + diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex new file mode 100644 index 00000000000..38af43fc57f --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -0,0 +1,11 @@ +\ccUserChapter{dD NewKernel\label{uddk}} +\label{ddk} +\ccChapterAuthor{Marc Glisse} + +\input{NewKernel_d_ref/PkgDescription} + +\minitoc + +\input{NewKernel_d_ref/Kernel} +\input{NewKernel_d_ref/Kernel_functor} + From d75fff953ef1b26acfc9b176152f27e660836351 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 16 Mar 2012 17:12:44 +0000 Subject: [PATCH 073/210] Minor doc changes I forgot to commit from the office. --- NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex | 12 ++++++++++++ .../doc_tex/NewKernel_d_ref/Kernel_functor.tex | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex index ee357ec68ca..6cdaff12803 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex @@ -10,12 +10,22 @@ especially for equality testing. Types and functors are identified by tags, which may be any type (like \ccc{CGAL::Segment_tag}). As a special case, the construction functor of a type identified by \ccc{Some_tag} is identified by the tag \ccc{Construct_ttag}, and the conversion functor by \ccc{Convert_ttag}. +Depending on \ccc{Default_ambient_dimension}, a kernel has 2 constructors, a default constructor and a constructor that takes as argument an \ccc{int} for the dimension. + \ccTypes +\ccNestedType{Default_ambient_dimension}{\ccc{Dimension_tag} where \ccc{d} is the ambient dimension or \ccc{Dynamic_dimension_tag} if the dimension is unknown.} +\ccGlue +\ccNestedType{Max_ambient_dimension}{\ccc{Dimension_tag} where \ccc{d} is an upper bound on the ambient dimension or \ccc{Dynamic_dimension_tag}.} + +% Replace with Type::type? \ccNestedType{FT}{a model of \ccc{FieldNumberType}} \ccGlue \ccNestedType{RT}{a model of \ccc{RingNumberType}} +% Not documented in the first version +\ccNestedType{LA}{a model of \ccc{LinearAlgebraSomething} using \ccc{RT}} + The following types describe the return types of predicates. They typically map to \ccc{bool} and \cgal\ kernel enum types, except when an interval arithmetic number type is used such as within the filtering kernels, in which case it is @@ -39,6 +49,8 @@ number type is used such as within the filtering kernels, in which case it is \ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate.} +% Shouldn't be tuple but some special typelist class instead. +\ccNestedType{Object_list}{A typedef for \ccc{tuple} with the list of tags that can be passed to the \ccc{Type} template.} \end{ccRefConcept} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex index f6cb6137079..3e2e278947e 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex @@ -1,4 +1,4 @@ -\begin{ccRefConcept}{Kernel::Functor} +\begin{ccRefConcept}[Kernel::]{Functor} Functors have a constructor that takes a \ccc{Kernel} as argument. If the kernel is stateless (as tested with \ccc{boost::is_empty}), functors may (must???) also have a default constructor. Functors follow the \ccc{result_of}-protocol. Member functions provided by each functor are described in their concept. Some special cases are: From e9c244217603f07f71cb87791f8c640ac3f4d83f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 16 Mar 2012 17:20:56 +0000 Subject: [PATCH 074/210] typo --- NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex index 3e2e278947e..512018dcce9 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex @@ -4,7 +4,7 @@ Functors have a constructor that takes a \ccc{Kernel} as argument. If the kernel Member functions provided by each functor are described in their concept. Some special cases are: \begin{itemize} \item A constructor is a functor represented by a tag \ccc{Construct_ttag}. It contains member functions \ccc{Kernel::Type::type operator()(Args...) const}. - \item A converter is a functor represented by a tag \ccc{Convert_ttag}. It contains a member function \ccc{template K2::Type::type operator()(Kernel::Type::type, K2::Functor>::type, Converter???) const}. As an example, a segment converter could first extract its extremities with \ccc{Kernel::Functor}, then convert them to \ccc{K2::Type} using \ccc{Converter} and finally build a \ccc{K2::Type} with \ccc{K2::Functor}. + \item A converter is a functor represented by a tag \ccc{Convert_ttag}. It contains a member function \ccc{template K2::Type::type operator()(Kernel::Type::type, K2::Functor>::type, Converter???) const}. As an example, a segment converter could first extract its extremities with \ccc{Kernel::Functor}, then convert them to \ccc{K2::Type} using \ccc{Converter} and finally build a \ccc{K2::Type} with \ccc{K2::Functor}. %TODO: clarify this Converter business \end{itemize} From 821dc0a543cb16bdc3e29f9ecfe9761c36575374 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 16 Mar 2012 18:05:14 +0000 Subject: [PATCH 075/210] doc for Point --- NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex | 24 +++++++++++++++++++ NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 1 + 2 files changed, 25 insertions(+) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex new file mode 100644 index 00000000000..dd05de01f7a --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex @@ -0,0 +1,24 @@ +\begin{ccRefConcept}{Point} +The concept of a {\em Point} is defined by a set of requirements on +the provision of certain types in a \ccc{Kernel}. + +\ccNestedType{Object_list}{shall contain at least \ccc{Point_tag} and \ccc{Point_cartesian_const_iterator_tag}.} + +\ccNestedType{Type::type}{shall be CopyConstructible.} +\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}{} +\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:\\ + \ccc{Type::type operator()(int dim)const} which constructs a point at the origin;\\ + \ccc{Type::type operator()()const} the same, when \ccc{Default_ambient_dimension} is known;\\ + \ccc{Type::type operator()(Type::type)const} which copies (???);\\ + \ccc{Type::type operator()(Iter, Iter, Cartesian_tag)const} which reads the Cartesian coordinates from the iterators;\\ + \ccc{Type::type operator()(Iter, Iter)const} same as above;\\ + \ccc{Type::type operator()(FT...)const} which reads the Cartesian coordinates from the arguments, when \ccc{Default_ambient_dimension} is known. +} + +\end{ccRefConcept} + diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex index 38af43fc57f..c63d1b402d1 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -8,4 +8,5 @@ \input{NewKernel_d_ref/Kernel} \input{NewKernel_d_ref/Kernel_functor} +\input{NewKernel_d_ref/Point} From 5a20d469620f962764644bd1270137718b6305ac Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 17 Mar 2012 15:52:22 +0000 Subject: [PATCH 076/210] basic doc for filtered kernel and kernel converter --- .../NewKernel_d_ref/Cartesian_filter_K.tex | 24 +++++++++++++++++++ .../NewKernel_d_ref/KernelD_converter.tex | 10 ++++++++ 2 files changed, 34 insertions(+) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex new file mode 100644 index 00000000000..f30281c79ba --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex @@ -0,0 +1,24 @@ +\begin{ccRefClass}{Cartesian_filter_K} +\include{CGAL/NewKernel_d/Cartesian_filter_K.h} +\ccDefinition +A model for \ccc{Kernel} that derives from \ccc{Base} (already a +\ccc{Kernel}) and redefines the predicates as filtered predicates +using \ccc{AK} as the approximate kernel and \ccc{EK} as the exact +kernel. + +\ccIsModel +\ccRefConceptPage{Kernel} + +Constructors??? + +NOTYET: +\begin{itemize} +\item If Base::Functor::Is_exact::value is true, don't filter. +\item Functor::type is taken from Base. +\end{itemize} + +\ccImplementation +The implementation uses \ccc{CGAL::Filtered_predicate} and +\ccc{CGAL::KernelD_converter}. + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex new file mode 100644 index 00000000000..a36626c2893 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex @@ -0,0 +1,10 @@ +\begin{ccRefClass}{KernelD_converter} +\include{CGAL/NewKernel_d/KernelD_converter.h} +\ccDefinition +A function object that converts objects from kernel \ccc{K1} to kernel \ccc{K2}. By default, it uses identity on \ccc{int}, \ccc{Origin} and \ccc{Null_vector}. It uses \ccc{NT_converter} for \ccc{RT} and \ccc{FT}. It uses \ccc{K1::Functor::type} for \ccc{K1::Type::type} (the list of possible \ccc{Tag} is taken from \ccc{List}). It can recursively convert iterators and \ccc{std::vector} of objects it already knows how to convert. It also unwraps a \ccc{CGAL::Object}, converts the content and rewraps it. + +\ccFunction{KernelD_converter::KernelD_converter(K1 const&,K2 const&)}{main constructor} +\ccFunction{KernelD_converter::KernelD_converter()}{default constructor, only if \ccc{K1} and \ccc{K2} are stateless.} +\ccFunction{K2::SomeThing operator()(K1::SomeThing)const}{returns a converted object.} + +\end{ccRefClass} From ba79a013d0f812bd2c355ad7da4bc89c1c861b48 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 19 Mar 2012 11:25:20 +0000 Subject: [PATCH 077/210] more doc stubs --- .../NewKernel_d_ref/Cartesian_complete.tex | 24 +++++++++++++++++++ .../NewKernel_d_ref/Cartesian_mini_d.tex | 15 ++++++++++++ .../NewKernel_d_ref/Kernel_d_interface.tex | 18 ++++++++++++++ NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 6 ++++- 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex new file mode 100644 index 00000000000..d1264e05686 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex @@ -0,0 +1,24 @@ +\begin{ccRefClass}{Cartesian_complete} +\include{CGAL/NewKernel_d/Cartesian_complete.h} +\ccDefinition +A model for \ccc{Kernel}, that takes a \ccc{Kernel} model \ccc{Base} +which provides at least \ccc{Point} and extends it by defining a number +of classical types and functors. The \ccc{force} parameter says whether +the class should override existing objects from \ccc{Base}. +\ccc{Derived} is the name of the ``final'' class for CRTP patterns, +which by default is \ccc{Cartesian_complete} itself. + +This is in particular expected to be enough for the \ccc{Triangulation} +package. + +\ccIsModel +\ccRefConceptPage{Kernel} + +\ccImplementation +This is split in classes \ccc{Cartesian_complete_predicates}, +\ccc{Cartesian_complete_computations}, +\ccc{Cartesian_complete_constructions}, +\ccc{Cartesian_complete_functors} (a reunion of the previous three), +\ccc{Cartesian_complete_types}, all with the same parameters. + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex new file mode 100644 index 00000000000..13dc0a4ef4d --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex @@ -0,0 +1,15 @@ +\begin{ccRefClass}{Cartesian_mini_d} +\include{CGAL/NewKernel_d/Cartesian_mini_d.h} +\ccDefinition +A minimal model for \ccc{Kernel} where \ccc{FT} and +\ccc{Default_ambient_dimension} are provided as template arguments. +This kernel provides the \ccc{Point} concept and not much more. + +The class takes several other template parameters (in particular to +specify \ccc{LA}) that are undocumented for now. + +\ccIsModel +\ccRefConceptPage{Kernel} +\ccRefConceptPage{Point} + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex new file mode 100644 index 00000000000..5f9d6b75bf5 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex @@ -0,0 +1,18 @@ +\begin{ccRefClass}{Kernel_d_interface} +\include{CGAL/NewKernel_d/Kernel_d_interface.h} +\ccDefinition +This class derives from a \ccc{Kernel} \ccc{Base} and defines a number +of typedefs and functions to give it an interface close to that of the +classical \ccc{Kernel_d}. As an example, it contains: + +\ccc{typedef Type::type Point_d}\\ +\ccc{typedef Functor::type Compare_lexicographically_d}\\ +\ccc{Compare_lexicographically_d compare_lexicographically_d_object()const{ return Compare_lexicographically_d(*this); }} + +Assuming that \ccc{Base} provides everything required, this provides +an interface suitable for the \ccc{Triangulation} package. + +\ccIsModel +\ccRefConceptPage{Triangulation_traits} + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex index c63d1b402d1..b2fe3c8c2c5 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -9,4 +9,8 @@ \input{NewKernel_d_ref/Kernel} \input{NewKernel_d_ref/Kernel_functor} \input{NewKernel_d_ref/Point} - +\input{NewKernel_d_ref/Cartesian_filter_K.tex} +\input{NewKernel_d_ref/Cartesian_mini_d.tex} +\input{NewKernel_d_ref/Cartesian_complete.tex} +\input{NewKernel_d_ref/KernelD_converter.tex} +\input{NewKernel_d_ref/Kernel_d_interface} From 99b0bf96045a432f97346b2a0efbb1b22688f30b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 19 Mar 2012 11:31:51 +0000 Subject: [PATCH 078/210] more doc... --- .../NewKernel_d_ref/Kernel_2_interface.tex | 15 +++++++++++++++ .../NewKernel_d_ref/Kernel_3_interface.tex | 15 +++++++++++++++ NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 2 ++ 3 files changed, 32 insertions(+) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex new file mode 100644 index 00000000000..9653d79fa68 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex @@ -0,0 +1,15 @@ +\begin{ccRefClass}{Kernel_2_interface} +\include{CGAL/NewKernel_d/Kernel_2_interface.h} +\ccDefinition +This class derives from a \ccc{Kernel} \ccc{Base} and defines a number +of typedefs and functions to give it an interface close to that of the +classical \ccc{Kernel_23}, restricted to 2D. As an example, it contains: + +\ccc{typedef Type::type Point_2}\\ +\ccc{struct Less_x_2}\\ +\ccc{Less_x_2 less_x_2_object()const} + +Assuming that \ccc{Base} provides everything required, this provides +an interface suitable for the \ccc{Triangulation_2} package. + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex new file mode 100644 index 00000000000..db5ebe2d5da --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex @@ -0,0 +1,15 @@ +\begin{ccRefClass}{Kernel_3_interface} +\include{CGAL/NewKernel_d/Kernel_3_interface.h} +\ccDefinition +This class derives from a \ccc{Kernel} \ccc{Base} and defines a number +of typedefs and functions to give it an interface close to that of the +classical \ccc{Kernel_23}, restricted to 3D. As an example, it contains: + +\ccc{typedef Type::type Point_3}\\ +\ccc{struct Side_of_oriented_sphere_3}\\ +\ccc{Side_of_oriented_sphere_3 side_of_oriented_sphere_3_object()const} + +Assuming that \ccc{Base} provides everything required, this provides +an interface suitable for the \ccc{Triangulation_2} package. + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex index b2fe3c8c2c5..1786ec2a021 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -13,4 +13,6 @@ \input{NewKernel_d_ref/Cartesian_mini_d.tex} \input{NewKernel_d_ref/Cartesian_complete.tex} \input{NewKernel_d_ref/KernelD_converter.tex} +\input{NewKernel_d_ref/Kernel_2_interface} +\input{NewKernel_d_ref/Kernel_3_interface} \input{NewKernel_d_ref/Kernel_d_interface} From 4c60e9f669e390766de44d56f8225e903b490ebf Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 19 Mar 2012 12:16:21 +0000 Subject: [PATCH 079/210] let doc compile --- .../doc_tex/NewKernel_d_ref/Cartesian_complete.tex | 2 +- .../doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex | 6 +++--- NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex | 2 +- NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex | 8 ++++---- .../doc_tex/NewKernel_d_ref/Kernel_2_interface.tex | 2 +- .../doc_tex/NewKernel_d_ref/Kernel_3_interface.tex | 2 +- .../doc_tex/NewKernel_d_ref/Kernel_d_interface.tex | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex index d1264e05686..ec12e1fdecd 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex @@ -1,5 +1,5 @@ \begin{ccRefClass}{Cartesian_complete} -\include{CGAL/NewKernel_d/Cartesian_complete.h} +\ccInclude{CGAL/NewKernel_d/Cartesian_complete.h} \ccDefinition A model for \ccc{Kernel}, that takes a \ccc{Kernel} model \ccc{Base} which provides at least \ccc{Point} and extends it by defining a number diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex index f30281c79ba..3fa320cc7ed 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex @@ -1,5 +1,5 @@ \begin{ccRefClass}{Cartesian_filter_K} -\include{CGAL/NewKernel_d/Cartesian_filter_K.h} +\ccInclude{CGAL/NewKernel_d/Cartesian_filter_K.h} \ccDefinition A model for \ccc{Kernel} that derives from \ccc{Base} (already a \ccc{Kernel}) and redefines the predicates as filtered predicates @@ -13,8 +13,8 @@ Constructors??? NOTYET: \begin{itemize} -\item If Base::Functor::Is_exact::value is true, don't filter. -\item Functor::type is taken from Base. + \item If \ccc{Base::Functor::Is_exact::value} is true, don't filter. + \item \ccc{Functor::type} is taken from Base. \end{itemize} \ccImplementation diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex index 13dc0a4ef4d..aa86d29bf28 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex @@ -1,5 +1,5 @@ \begin{ccRefClass}{Cartesian_mini_d} -\include{CGAL/NewKernel_d/Cartesian_mini_d.h} +\ccInclude{CGAL/NewKernel_d/Cartesian_mini_d.h} \ccDefinition A minimal model for \ccc{Kernel} where \ccc{FT} and \ccc{Default_ambient_dimension} are provided as template arguments. diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex index a36626c2893..3869f61fe93 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex @@ -1,10 +1,10 @@ \begin{ccRefClass}{KernelD_converter} -\include{CGAL/NewKernel_d/KernelD_converter.h} +\ccInclude{CGAL/NewKernel_d/KernelD_converter.h} \ccDefinition A function object that converts objects from kernel \ccc{K1} to kernel \ccc{K2}. By default, it uses identity on \ccc{int}, \ccc{Origin} and \ccc{Null_vector}. It uses \ccc{NT_converter} for \ccc{RT} and \ccc{FT}. It uses \ccc{K1::Functor::type} for \ccc{K1::Type::type} (the list of possible \ccc{Tag} is taken from \ccc{List}). It can recursively convert iterators and \ccc{std::vector} of objects it already knows how to convert. It also unwraps a \ccc{CGAL::Object}, converts the content and rewraps it. -\ccFunction{KernelD_converter::KernelD_converter(K1 const&,K2 const&)}{main constructor} -\ccFunction{KernelD_converter::KernelD_converter()}{default constructor, only if \ccc{K1} and \ccc{K2} are stateless.} -\ccFunction{K2::SomeThing operator()(K1::SomeThing)const}{returns a converted object.} +\ccConstructor{KernelD_converter::KernelD_converter(K1 const&,K2 const&)}{main constructor} +\ccConstructor{KernelD_converter::KernelD_converter(void)}{default constructor, only if \ccc{K1} and \ccc{K2} are stateless.} +\ccMethod{K2::SomeThing operator()(K1::SomeThing)const;}{returns a converted object.} \end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex index 9653d79fa68..109b7c9f790 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex @@ -1,5 +1,5 @@ \begin{ccRefClass}{Kernel_2_interface} -\include{CGAL/NewKernel_d/Kernel_2_interface.h} +\ccInclude{CGAL/NewKernel_d/Kernel_2_interface.h} \ccDefinition This class derives from a \ccc{Kernel} \ccc{Base} and defines a number of typedefs and functions to give it an interface close to that of the diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex index db5ebe2d5da..ffdc6a00461 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex @@ -1,5 +1,5 @@ \begin{ccRefClass}{Kernel_3_interface} -\include{CGAL/NewKernel_d/Kernel_3_interface.h} +\ccInclude{CGAL/NewKernel_d/Kernel_3_interface.h} \ccDefinition This class derives from a \ccc{Kernel} \ccc{Base} and defines a number of typedefs and functions to give it an interface close to that of the diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex index 5f9d6b75bf5..c10fa9117bc 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex @@ -1,5 +1,5 @@ \begin{ccRefClass}{Kernel_d_interface} -\include{CGAL/NewKernel_d/Kernel_d_interface.h} +\ccInclude{CGAL/NewKernel_d/Kernel_d_interface.h} \ccDefinition This class derives from a \ccc{Kernel} \ccc{Base} and defines a number of typedefs and functions to give it an interface close to that of the From 41d9a5e6315588ac1d95fa499dd6a172c474ac6e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 19 Mar 2012 15:55:49 +0000 Subject: [PATCH 080/210] doc segment --- .../NewKernel_d_ref/Define_segment.tex | 17 +++++++++++++ .../doc_tex/NewKernel_d_ref/Segment.tex | 25 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex new file mode 100644 index 00000000000..7e2cc58a9c5 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex @@ -0,0 +1,17 @@ +\begin{ccRefClass}{Define_segment} +\ccInclude{CGAL/NewKernel_d/Define_segment.h} +\ccDefinition +A model for \ccc{Kernel}, that takes a \ccc{Kernel} model \ccc{Base} +which provides at least \ccc{Point} and extends it by providing +\ccc{Segment}. +\ccc{Derived} is the name of the ``final'' class for CRTP patterns, +which by default is \ccc{Define_segment} itself. + +\ccIsModel +\ccRefConceptPage{Kernel} +\ccRefConceptPage{Segment} + +\ccImplementation +The segment type is defined as an \ccc{std::pair} of points. + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex new file mode 100644 index 00000000000..4ed32fa3b04 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex @@ -0,0 +1,25 @@ +\begin{ccRefConcept}{Segment} +The concept of a {\em Segment} is defined by a set of requirements on +the provision of certain types in a \ccc{Kernel} that already provides +the concept of a \ccc{Point}. + +\ccNestedType{Object_list}{shall contain at least \ccc{Segment_tag}.} + +\ccNestedType{Type::type}{shall be CopyConstructible.} + +\ccNestedType{Functor>::type}{} +\ccNestedType{Functor::type}{shall +provide \ccc{Type::type operator()(Type::type, +int k)const} which returns the $k$th ($0$ or $1$) extremity of the segment.} +\ccNestedType{Functor>::type}{shall provide:\\ + \ccc{Type::type + operator()(Type::type,Type::type)const} which + constructs a segment from its extremities;\\ + \ccc{Type::type operator()(piecewise_construct_t, + tuple u, tuple v)const} which calls + \ccc{Functor>::type} on the content of each + tuple to create the extremities. +} + +\end{ccRefConcept} + From c57757e24e6fa85332f4a0ab5ce07206ee20d444 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 20 Mar 2012 14:35:53 +0000 Subject: [PATCH 081/210] doc Cartesian_wrap --- .../NewKernel_d_ref/Cartesian_wrap.tex | 20 +++++++++++++++++++ NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 1 + 2 files changed, 21 insertions(+) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex new file mode 100644 index 00000000000..5e2ec067c71 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex @@ -0,0 +1,20 @@ +\begin{ccRefClass}{Cartesian_wrap} +\ccInclude{CGAL/NewKernel_d/Cartesian_wrap.h} +\ccDefinition +This class derives from a \ccc{Kernel} \ccc{Base} and replaces a number +of types (point, segment) with wrappers that have intuitive member +functions that call the corresponding functors. For instance, the +constructors forward to \ccc{Functor>::type}, +\ccc{Point::operator[]} forwards to +\ccc{Functor::type}, +\ccc{operator+(Vector,Vector)} forwards to +\ccc{Functor::type}, etc. + +\ccIsModel +\ccRefConceptPage{Kernel} + +\ccImplementation +The implementation \emph{tries} to avoid any extra copying that could be +caused by the wrapping. + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex index 1786ec2a021..cbfc5707f02 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -12,6 +12,7 @@ \input{NewKernel_d_ref/Cartesian_filter_K.tex} \input{NewKernel_d_ref/Cartesian_mini_d.tex} \input{NewKernel_d_ref/Cartesian_complete.tex} +\input{NewKernel_d_ref/Cartesian_wrap.tex} \input{NewKernel_d_ref/KernelD_converter.tex} \input{NewKernel_d_ref/Kernel_2_interface} \input{NewKernel_d_ref/Kernel_3_interface} From 83ac195e3fcc356a05ccdd73c5fd55576a194ce9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 20 Mar 2012 16:16:44 +0000 Subject: [PATCH 082/210] lazy doc --- .../doc_tex/NewKernel_d_ref/Lazy_kernel.tex | 16 ++++++++++++++++ NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 13 ++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex new file mode 100644 index 00000000000..3ba825f3ccd --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex @@ -0,0 +1,16 @@ +\begin{ccRefClass}{Lazy_kernel>} +\ccInclude{CGAL/NewKernel_d/Lazy_kernel.h} +\ccDefinition +A model for \ccc{Kernel}. +\ccc{AK} is an approximate kernel (with an interval number type) and \ccc{EK} +is an exact kernel. + +\ccIsModel +\ccRefConceptPage{Kernel} + +\ccImplementation +For each object, this kernel stores both an approximate object from +\ccc{AK} and either an exact object from \ccc{EK} or a graph that +allows it to compute such an exact object when needed. + +\end{ccRefClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex index cbfc5707f02..abc2a9a617a 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -9,11 +9,14 @@ \input{NewKernel_d_ref/Kernel} \input{NewKernel_d_ref/Kernel_functor} \input{NewKernel_d_ref/Point} -\input{NewKernel_d_ref/Cartesian_filter_K.tex} -\input{NewKernel_d_ref/Cartesian_mini_d.tex} -\input{NewKernel_d_ref/Cartesian_complete.tex} -\input{NewKernel_d_ref/Cartesian_wrap.tex} -\input{NewKernel_d_ref/KernelD_converter.tex} +\input{NewKernel_d_ref/Segment} +\input{NewKernel_d_ref/Cartesian_filter_K} +\input{NewKernel_d_ref/Cartesian_mini_d} +\input{NewKernel_d_ref/Cartesian_complete} +\input{NewKernel_d_ref/Cartesian_wrap} +\input{NewKernel_d_ref/Define_segment} +\input{NewKernel_d_ref/Lazy_kernel} +\input{NewKernel_d_ref/KernelD_converter} \input{NewKernel_d_ref/Kernel_2_interface} \input{NewKernel_d_ref/Kernel_3_interface} \input{NewKernel_d_ref/Kernel_d_interface} From 09a52dccc392772ffbf6bd5f696fb4ad760f01c7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 21 Mar 2012 12:37:52 +0000 Subject: [PATCH 083/210] note on object wrapper for stateful kernels --- NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex index 5e2ec067c71..19c5560a05e 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex @@ -10,6 +10,12 @@ constructors forward to \ccc{Functor>::type}, \ccc{operator+(Vector,Vector)} forwards to \ccc{Functor::type}, etc. +For stateful kernels, the wrappers will store a pointer to the kernel +instance. This means in particular that for such a kernel, one can't +just create a point from its coordinates (like \ccc{Point M(1,2,3);}), +they have to create it using some functor or an operation on existing +objects. + \ccIsModel \ccRefConceptPage{Kernel} From 82cec77b9eb7c848e45cd7e1f403d444f8ff5083 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 21 Mar 2012 13:07:36 +0000 Subject: [PATCH 084/210] details --- NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex | 4 ++-- NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex | 3 +++ NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex index 3869f61fe93..f42666c8554 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex @@ -1,4 +1,4 @@ -\begin{ccRefClass}{KernelD_converter} +\begin{ccRefFunctionObjectClass}{KernelD_converter} \ccInclude{CGAL/NewKernel_d/KernelD_converter.h} \ccDefinition A function object that converts objects from kernel \ccc{K1} to kernel \ccc{K2}. By default, it uses identity on \ccc{int}, \ccc{Origin} and \ccc{Null_vector}. It uses \ccc{NT_converter} for \ccc{RT} and \ccc{FT}. It uses \ccc{K1::Functor::type} for \ccc{K1::Type::type} (the list of possible \ccc{Tag} is taken from \ccc{List}). It can recursively convert iterators and \ccc{std::vector} of objects it already knows how to convert. It also unwraps a \ccc{CGAL::Object}, converts the content and rewraps it. @@ -7,4 +7,4 @@ A function object that converts objects from kernel \ccc{K1} to kernel \ccc{K2}. \ccConstructor{KernelD_converter::KernelD_converter(void)}{default constructor, only if \ccc{K1} and \ccc{K2} are stateless.} \ccMethod{K2::SomeThing operator()(K1::SomeThing)const;}{returns a converted object.} -\end{ccRefClass} +\end{ccRefFunctionObjectClass} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex index dd05de01f7a..eff45deb36e 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex @@ -2,6 +2,9 @@ The concept of a {\em Point} is defined by a set of requirements on the provision of certain types in a \ccc{Kernel}. +\ccRefines +\ccc{Kernel} + \ccNestedType{Object_list}{shall contain at least \ccc{Point_tag} and \ccc{Point_cartesian_const_iterator_tag}.} \ccNestedType{Type::type}{shall be CopyConstructible.} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex index 4ed32fa3b04..2eb8315dee8 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex @@ -3,6 +3,9 @@ The concept of a {\em Segment} is defined by a set of requirements on the provision of certain types in a \ccc{Kernel} that already provides the concept of a \ccc{Point}. +\ccRefines +\ccc{Point} + \ccNestedType{Object_list}{shall contain at least \ccc{Segment_tag}.} \ccNestedType{Type::type}{shall be CopyConstructible.} From 7dd3d86ff1eb0829a12ec2390043417bafd14bb6 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 21 Mar 2012 15:41:53 +0000 Subject: [PATCH 085/210] newline --- NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex | 1 + NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex | 1 + 10 files changed, 10 insertions(+) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex index ec12e1fdecd..02fa294a347 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_complete.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Cartesian_complete} \ccInclude{CGAL/NewKernel_d/Cartesian_complete.h} + \ccDefinition A model for \ccc{Kernel}, that takes a \ccc{Kernel} model \ccc{Base} which provides at least \ccc{Point} and extends it by defining a number diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex index 3fa320cc7ed..28c1fdc9d16 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_filter_K.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Cartesian_filter_K} \ccInclude{CGAL/NewKernel_d/Cartesian_filter_K.h} + \ccDefinition A model for \ccc{Kernel} that derives from \ccc{Base} (already a \ccc{Kernel}) and redefines the predicates as filtered predicates diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex index aa86d29bf28..806109d70c8 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_mini_d.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Cartesian_mini_d} \ccInclude{CGAL/NewKernel_d/Cartesian_mini_d.h} + \ccDefinition A minimal model for \ccc{Kernel} where \ccc{FT} and \ccc{Default_ambient_dimension} are provided as template arguments. diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex index 19c5560a05e..6d8644789af 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Cartesian_wrap.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Cartesian_wrap} \ccInclude{CGAL/NewKernel_d/Cartesian_wrap.h} + \ccDefinition This class derives from a \ccc{Kernel} \ccc{Base} and replaces a number of types (point, segment) with wrappers that have intuitive member diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex index 7e2cc58a9c5..107671ddc2a 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Define_segment.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Define_segment} \ccInclude{CGAL/NewKernel_d/Define_segment.h} + \ccDefinition A model for \ccc{Kernel}, that takes a \ccc{Kernel} model \ccc{Base} which provides at least \ccc{Point} and extends it by providing diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex index f42666c8554..1146003dd4a 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex @@ -1,5 +1,6 @@ \begin{ccRefFunctionObjectClass}{KernelD_converter} \ccInclude{CGAL/NewKernel_d/KernelD_converter.h} + \ccDefinition A function object that converts objects from kernel \ccc{K1} to kernel \ccc{K2}. By default, it uses identity on \ccc{int}, \ccc{Origin} and \ccc{Null_vector}. It uses \ccc{NT_converter} for \ccc{RT} and \ccc{FT}. It uses \ccc{K1::Functor::type} for \ccc{K1::Type::type} (the list of possible \ccc{Tag} is taken from \ccc{List}). It can recursively convert iterators and \ccc{std::vector} of objects it already knows how to convert. It also unwraps a \ccc{CGAL::Object}, converts the content and rewraps it. diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex index 109b7c9f790..f04d1ffd1f0 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_2_interface.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Kernel_2_interface} \ccInclude{CGAL/NewKernel_d/Kernel_2_interface.h} + \ccDefinition This class derives from a \ccc{Kernel} \ccc{Base} and defines a number of typedefs and functions to give it an interface close to that of the diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex index ffdc6a00461..99ccf619b17 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_3_interface.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Kernel_3_interface} \ccInclude{CGAL/NewKernel_d/Kernel_3_interface.h} + \ccDefinition This class derives from a \ccc{Kernel} \ccc{Base} and defines a number of typedefs and functions to give it an interface close to that of the diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex index c10fa9117bc..a75b6045e3e 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_d_interface.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Kernel_d_interface} \ccInclude{CGAL/NewKernel_d/Kernel_d_interface.h} + \ccDefinition This class derives from a \ccc{Kernel} \ccc{Base} and defines a number of typedefs and functions to give it an interface close to that of the diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex index 3ba825f3ccd..4b6f7c0ad64 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Lazy_kernel.tex @@ -1,5 +1,6 @@ \begin{ccRefClass}{Lazy_kernel>} \ccInclude{CGAL/NewKernel_d/Lazy_kernel.h} + \ccDefinition A model for \ccc{Kernel}. \ccc{AK} is an approximate kernel (with an interval number type) and \ccc{EK} From 2869bf0c5908374a567fa14c272bfe9318a09535 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 21 Mar 2012 18:13:38 +0000 Subject: [PATCH 086/210] make typeset functional. --- NewKernel_d/include/CGAL/typeset.h | 54 ++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/NewKernel_d/include/CGAL/typeset.h b/NewKernel_d/include/CGAL/typeset.h index 94ae331a13b..dffa8c4aeb5 100644 --- a/NewKernel_d/include/CGAL/typeset.h +++ b/NewKernel_d/include/CGAL/typeset.h @@ -3,7 +3,7 @@ #ifdef CGAL_CXX0X #include #else -#include +#include #endif // Sometimes using tuple just to list types is overkill (takes forever to @@ -12,24 +12,50 @@ namespace CGAL { #ifdef CGAL_CXX0X template struct typeset; - template struct typeset { - typedef T head; + template struct typeset { + typedef H head; typedef typeset tail; - template struct contains { - enum { value = std::conditional::value,std::true_type,tail::contains>::type::value }; - }; - template struct add { - typedef std::conditional::value,typeset,typeset>::type type; - }; + typedef typeset type; + template using contains = typename + std::conditional< + std::is_same::value, + std::true_type, + typename tail::template contains + >::type; + template using add = typename + std::conditional< + contains::value, + typeset, + typeset + >::type; }; template<> struct typeset<> { - template struct contains : boost::false_type {}; - template struct add { - typedef typeset type; - }; + typedef typeset type; + template using contains = std::false_type; + template using add = typeset; }; #else - // ??? + template struct typeset; + template, void, typeset >::type > + struct typeset { + typedef typeset type; + typedef H head; + typedef T tail; + template struct contains : + boost::mpl::if_,boost::true_type,typename tail::template contains >::type + {}; + template struct add : + //boost::mpl::if_,typeset,typeset >::type + typeset::type> + {}; + template struct add : typeset {}; + }; + template<> struct typeset<> { + typedef typeset type; + template struct contains : boost::false_type {}; + template struct add : typeset {}; + }; #endif } #endif From ac3c0d52bd9eee6661c86f6978df0409adb2c25b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 21 Mar 2012 19:43:08 +0000 Subject: [PATCH 087/210] doc for typeset --- NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex | 3 +-- NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 3 +++ NewKernel_d/doc_tex/NewKernel_d_ref/typeset.tex | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/typeset.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex index 6cdaff12803..e3aec0ee939 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex @@ -49,8 +49,7 @@ number type is used such as within the filtering kernels, in which case it is \ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate.} -% Shouldn't be tuple but some special typelist class instead. -\ccNestedType{Object_list}{A typedef for \ccc{tuple} with the list of tags that can be passed to the \ccc{Type} template.} +\ccNestedType{Object_list}{A typedef for \ccc{typeset} with the list of tags that can be passed to the \ccc{Type} template.} \end{ccRefConcept} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex index abc2a9a617a..6b2cd3eba9f 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -20,3 +20,6 @@ \input{NewKernel_d_ref/Kernel_2_interface} \input{NewKernel_d_ref/Kernel_3_interface} \input{NewKernel_d_ref/Kernel_d_interface} + +% move to another package +\input{NewKernel_d_ref/typeset} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/typeset.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/typeset.tex new file mode 100644 index 00000000000..5c07a3591de --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/typeset.tex @@ -0,0 +1,17 @@ +\begin{ccRefClass}{typeset<...>} +\ccInclude{CGAL/typeset.h} + +\ccDefinition +This class provides a set of types, where each type appears at most once. Iterating through the set should be done by looking at \ccc{head} and recursing on \ccc{tail}, testing whether a set is empty by comparing it to \ccc{typeset<>}. + +\ccNestedType{head}{One element from the list.} +\ccNestedType{tail}{A typeset of the other elements from list.} +\ccNestedType{add::type}{A typeset with \ccc{X} added to the list.} +\ccNestedType{contains::value}{A boolean that says whether \ccc{X} is in the list.} + +In C++11, \ccc{add} is already a typeset so one can omit \ccc{::type}, and \ccc{contains} derives from \ccc{true_type} or \ccc{false_type}. + +\ccImplementation +In C++11, the list looks like \ccc{typeset} whereas in C++03 it looks like \ccc{typeset > > >} (an alternative would have been \ccc{typeset}, as in \ccc{boost::tuple}). + +\end{ccRefClass} From 7a14e56b843bac7b9626f9b042373dff9afa2799 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 21 Mar 2012 20:19:56 +0000 Subject: [PATCH 088/210] still horribly mangled by Manual_tools --- .../doc_tex/NewKernel_d_ref/KernelD_converter.tex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex index 1146003dd4a..bceafc65cab 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/KernelD_converter.tex @@ -4,8 +4,11 @@ \ccDefinition A function object that converts objects from kernel \ccc{K1} to kernel \ccc{K2}. By default, it uses identity on \ccc{int}, \ccc{Origin} and \ccc{Null_vector}. It uses \ccc{NT_converter} for \ccc{RT} and \ccc{FT}. It uses \ccc{K1::Functor::type} for \ccc{K1::Type::type} (the list of possible \ccc{Tag} is taken from \ccc{List}). It can recursively convert iterators and \ccc{std::vector} of objects it already knows how to convert. It also unwraps a \ccc{CGAL::Object}, converts the content and rewraps it. -\ccConstructor{KernelD_converter::KernelD_converter(K1 const&,K2 const&)}{main constructor} -\ccConstructor{KernelD_converter::KernelD_converter(void)}{default constructor, only if \ccc{K1} and \ccc{K2} are stateless.} -\ccMethod{K2::SomeThing operator()(K1::SomeThing)const;}{returns a converted object.} +\ccCreation +\ccConstructor{KernelD_converter(K1 const&,K2 const&)}{main constructor} +\ccConstructor{KernelD_converter()}{default constructor, only if \ccc{K1} and \ccc{K2} are stateless.} + +\ccOperations +\ccMethod{K2::SomeThing operator()(K1::SomeThing) const;}{returns a converted object.} \end{ccRefFunctionObjectClass} From df87f2414935454073946ef319fc66d242d458ae Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 21 Mar 2012 20:42:34 +0000 Subject: [PATCH 089/210] introduce Object_list --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h | 2 ++ NewKernel_d/include/CGAL/Kernel_d/Define_segment.h | 1 + NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 1 + 3 files changed, 4 insertions(+) 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 699570077f5..a368a7aaa27 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type { typedef Vector_ type; }; + typedef typeset::add::type Object_list; template struct Functor { typedef Null_functor type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 92313614c84..4e9b493611c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -60,6 +60,7 @@ struct Define_segment : public Base_ { typedef typename Derived::template Type::type Point; typedef std::pair type; }; + typedef typename Base::Object_list::template add::type Object_list; // TODO: forward the second Functor argument (like fast, no_filter) template struct Functor : Base_::template Functor {}; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index bbd22b93efc..9093f763bde 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -61,6 +61,7 @@ struct Lazy_cartesian : Dimension_base typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> type; }; + typedef typename Exact_kernel::Object_list Object_list; template::type> struct Functor { typedef Null_functor type; From 98440b3bd29df9618923d560ca78bcd5ac7b686b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 22 Mar 2012 11:12:10 +0000 Subject: [PATCH 090/210] hush noisy warnings with g++47 and eigen --- NewKernel_d/test/NewKernel_d/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index e20954641ee..eea4c7d2ab0 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -2,12 +2,14 @@ all: normal cxx0x CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK +EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_USE_EIGEN + normal: - g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV + g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include ${EIGEN_INC} ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV ./a.out cxx0x: - g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include `pkg-config --cflags eigen3` -DCGAL_USE_EIGEN ${CGAL_INC} + g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include ${EIGEN_INC} ${CGAL_INC} ./a.out #-DBOOST_RESULT_OF_USE_DECLTYPE From c3e8bff39d79e6db6b07f8660353337487ace5e1 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 22 Mar 2012 14:44:13 +0000 Subject: [PATCH 091/210] typeset intersection/union. use typeset in kernel converter (unifies C++03 and C++11 code). --- .../CGAL/Kernel_d/Cartesian_converter.h | 122 ++++++------------ NewKernel_d/include/CGAL/typeset.h | 32 +++++ 2 files changed, 75 insertions(+), 79 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h index 73fc731db51..f5b76224ff6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -15,25 +16,27 @@ namespace CGAL { namespace internal { -template struct Map_tuple_tags_to_tuple_types; -#ifdef CGAL_CXX0X -template struct Map_tuple_tags_to_tuple_types > { - typedef cpp0x::tuple::type...> type; -}; -#else -template struct Map_tuple_tags_to_tuple_types > { - typedef cpp0x::tuple<> type; -}; -#define CODE(Z,N,_) template \ - struct Map_tuple_tags_to_tuple_types > { \ - typedef cpp0x::tuple::type BOOST_PP_INTERCEPT)> type; \ - }; - BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) -#undef CODE -#endif +// Reverses order, but that shouldn't matter. +template struct Map_taglist_to_typelist : + Map_taglist_to_typelist::template add::type> +{}; +template struct Map_taglist_to_typelist > : typeset<> {}; } -template > struct Object_converter { + +template > +struct Object_converter { + typedef Object result_type; + template + result_type operator()(Object const& o, F const& f) const { + typedef typename List::head H; + if (H const* ptr = object_cast(&o)) + return make_object(f(*ptr)); + else + return Object_converter()(o,f); + } +}; +template<> +struct Object_converter > { typedef Object result_type; template result_type operator()(Object const&,F const&)const { @@ -41,50 +44,15 @@ template > struct Object_converter { return Object(); } }; -#ifdef CGAL_CXX0X -template struct Object_converter > { - typedef Object result_type; - template - result_type operator()(Object const& o, F const& f) const { - if (const T * ptr = object_cast(&o)) - return make_object(f(*ptr)); - else - return Object_converter >()(o,f); - } -}; -#else -#define CODE(Z,N,_) template \ - struct Object_converter > { \ - typedef Object result_type; \ - template \ - result_type operator()(Object const& o, F const& f) const { \ - if (const T0 * ptr = object_cast(&o)) \ - return make_object(f(*ptr)); \ - else \ - return Object_converter >()(o,f); \ - } \ - }; - BOOST_PP_REPEAT_FROM_TO(1,11,CODE,_) -#undef CODE -#endif //TODO: special case when K1==K2 (or they are very close?) -template class CartesianD_converter_; -template class CartesianD_converter_ > { - public: - struct Do_not_use{}; - void operator()(Do_not_use)const{} - template struct result; - Final_& myself(){return *static_cast(this);} - Final_ const& myself()const{return *static_cast(this);} -}; -#ifdef CGAL_CXX0X -template class CartesianD_converter_ > -: public CartesianD_converter_ > +template +class CartesianD_converter_ +: public CartesianD_converter_ { - typedef CartesianD_converter_ > Base; - typedef KO_converter KOC; + typedef CartesianD_converter_ Base; + typedef KO_converter KOC; typedef typename KOC::argument_type K1_Obj; typedef typename KOC::result_type K2_Obj; public: @@ -95,27 +63,23 @@ template class CartesianD_ template struct result:Base::template result{}; template struct result {typedef K2_Obj type;}; }; -#else -#define CODE(Z,N,_) \ -template class CartesianD_converter_ > \ -: public CartesianD_converter_ > \ -{ \ - typedef CartesianD_converter_ > Base; \ - typedef KO_converter KOC; \ - typedef typename KOC::argument_type K1_Obj; \ - typedef typename KOC::result_type K2_Obj; \ - public: \ - using Base::operator(); \ - K2_Obj operator()(K1_Obj const& o)const{ \ - return KOC()(this->myself().kernel(),this->myself().kernel2(),this->myself(),o); \ - } \ - template struct result:Base::template result{}; \ - template struct result {typedef K2_Obj type;}; \ + +template +class CartesianD_converter_ > { + public: + struct Do_not_use{}; + void operator()(Do_not_use)const{} + template struct result; + Final_& myself(){return *static_cast(this);} + Final_ const& myself()const{return *static_cast(this);} }; -BOOST_PP_REPEAT_FROM_TO(0, 8, CODE, _ ) -#undef CODE -#endif -template > class CartesianD_converter + + +// TODO: use the intersection of Kn::Object_list. +template::type +//typeset::add::type/*::add::type*/ +> class CartesianD_converter : public Store_kernel, public Store_kernel2, public CartesianD_converter_,K1,K2,List_> { @@ -170,7 +134,7 @@ template::type Possibilities; + typedef typename internal::Map_taglist_to_typelist::type Possibilities; //TODO: add Empty, vector, etc to the list. return Object_converter()(obj,*this); } diff --git a/NewKernel_d/include/CGAL/typeset.h b/NewKernel_d/include/CGAL/typeset.h index dffa8c4aeb5..d9bad3c39a7 100644 --- a/NewKernel_d/include/CGAL/typeset.h +++ b/NewKernel_d/include/CGAL/typeset.h @@ -57,5 +57,37 @@ namespace CGAL { template struct add : typeset {}; }; #endif + + template struct typeset_union_ : + typeset_union_::type, typename T2::tail> + {}; + template struct typeset_union_ > : T {}; + + template + struct typeset_intersection_ { + typedef typename T1::head H; + typedef typename typeset_intersection_::type U; + typedef typename +#ifdef CGAL_CXX0X + std::conditional::value, +#else + boost::mpl::if_, +#endif + typename U::template add::type, U>::type type; + }; + template + struct typeset_intersection_,T> : typeset<> {}; + +#ifdef CGAL_CXX0X + template + using typeset_union = typename typeset_union_::type; + template + using typeset_intersection = typename typeset_intersection_::type; +#else + template + struct typeset_union : typeset_union_::type {}; + template + struct typeset_intersection : typeset_intersection_::type {}; +#endif } #endif From 2dad38bb31cc59f7cf07c5496b80c4e7a540277f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 22 Mar 2012 14:51:00 +0000 Subject: [PATCH 092/210] More Object_list. --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h | 1 - NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index 8b8e5f6c50a..328106b6c9c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -27,7 +27,6 @@ struct Cartesian_filter_K : public Base_, EK_rt exact_kernel()const{return this->kernel2();} //TODO: C2A/C2E could be able to convert *this into this->kernel() or this->kernel2(). - //TODO: give CartesianD_converter the list of objects it needs to be able to convert (tuple for instance), so Cartesian_filter_K needs to know that list (take an extra template parameter? Read it from Kernel_base?) typedef CartesianD_converter C2A; typedef CartesianD_converter C2E; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 9093f763bde..322e04e3b5d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -61,7 +61,10 @@ struct Lazy_cartesian : Dimension_base typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> type; }; - typedef typename Exact_kernel::Object_list Object_list; + typedef typename typeset_intersection< + typename Approximate_kernel::Object_list, + typename Exact_kernel::Object_list + >::type Object_list; template::type> struct Functor { typedef Null_functor type; From 5ef5dae1071fc2d878e641d865714d43f5330df9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 23 Mar 2012 17:45:51 +0000 Subject: [PATCH 093/210] make doc and impl of converter closer. --- .../doc_tex/NewKernel_d_ref/Kernel.tex | 2 +- .../NewKernel_d_ref/Kernel_functor.tex | 2 +- NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex | 2 +- .../doc_tex/NewKernel_d_ref/Segment.tex | 2 +- .../CGAL/Kernel_d/Cartesian_filter_K.h | 6 +-- ...tesian_converter.h => KernelD_converter.h} | 39 ++++++++++++------- NewKernel_d/include/CGAL/functor_tags.h | 2 + NewKernel_d/include/CGAL/marcutils.h | 5 +++ 8 files changed, 39 insertions(+), 21 deletions(-) rename NewKernel_d/include/CGAL/Kernel_d/{Cartesian_converter.h => KernelD_converter.h} (80%) diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex index e3aec0ee939..3c84e34c134 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex @@ -47,7 +47,7 @@ number type is used such as within the filtering kernels, in which case it is \ccNestedType{template struct Type}{This nested template class defines an object type \ccc{type}. For instance, \ccc{Type::type} is the type of points.} -\ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate.} +\ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate. Functors that are not provided should all be \ccc{Null_functor}.} \ccNestedType{Object_list}{A typedef for \ccc{typeset} with the list of tags that can be passed to the \ccc{Type} template.} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex index 512018dcce9..ad84ab0d69e 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel_functor.tex @@ -4,7 +4,7 @@ Functors have a constructor that takes a \ccc{Kernel} as argument. If the kernel Member functions provided by each functor are described in their concept. Some special cases are: \begin{itemize} \item A constructor is a functor represented by a tag \ccc{Construct_ttag}. It contains member functions \ccc{Kernel::Type::type operator()(Args...) const}. - \item A converter is a functor represented by a tag \ccc{Convert_ttag}. It contains a member function \ccc{template K2::Type::type operator()(Kernel::Type::type, K2::Functor>::type, Converter???) const}. As an example, a segment converter could first extract its extremities with \ccc{Kernel::Functor}, then convert them to \ccc{K2::Type} using \ccc{Converter} and finally build a \ccc{K2::Type} with \ccc{K2::Functor}. + \item A converter is a functor represented by a tag \ccc{Convert_ttag}. It contains a member function \ccc{template K2::Type::type operator()(K2 const&, Converter, Kernel::Type::type) const}. As an example, a segment converter could first extract its extremities with \ccc{Kernel::Functor}, then convert them to \ccc{K2::Type} using \ccc{Converter} and finally build a \ccc{K2::Type} with \ccc{K2::Functor}. %TODO: clarify this Converter business \end{itemize} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex index eff45deb36e..2c833f94afe 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex @@ -10,7 +10,7 @@ the provision of certain types in a \ccc{Kernel}. \ccNestedType{Type::type}{shall be CopyConstructible.} \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}{} +\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{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.} diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex index 2eb8315dee8..e6b6230582f 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/Segment.tex @@ -10,7 +10,7 @@ the concept of a \ccc{Point}. \ccNestedType{Type::type}{shall be CopyConstructible.} -\ccNestedType{Functor>::type}{} +\ccNestedType{Functor>::type}{[Optional] A default converter it available to \ccc{Kernel_converter}, but may be unsuitable if your Segment type is too original.} \ccNestedType{Functor::type}{shall provide \ccc{Type::type operator()(Type::type, int k)const} which returns the $k$th ($0$ or $1$) extremity of the segment.} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index 328106b6c9c..8c4cd4463c7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -2,7 +2,7 @@ #define CGAL_KERNEL_D_CARTESIAN_FILTER_K_H #include -#include +#include #include #include @@ -27,8 +27,8 @@ struct Cartesian_filter_K : public Base_, EK_rt exact_kernel()const{return this->kernel2();} //TODO: C2A/C2E could be able to convert *this into this->kernel() or this->kernel2(). - typedef CartesianD_converter C2A; - typedef CartesianD_converter C2E; + typedef KernelD_converter C2A; + typedef KernelD_converter C2E; template::type> struct Functor : Kernel_base::template Functor {}; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h similarity index 80% rename from NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h rename to NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index f5b76224ff6..cabe9898ec0 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -48,24 +48,35 @@ struct Object_converter > { //TODO: special case when K1==K2 (or they are very close?) template -class CartesianD_converter_ -: public CartesianD_converter_ +class KernelD_converter_ +: public KernelD_converter_ { - typedef CartesianD_converter_ Base; - typedef KO_converter KOC; - typedef typename KOC::argument_type K1_Obj; - typedef typename KOC::result_type K2_Obj; + typedef KernelD_converter_ Base; + typedef typename List::head Tag; + typedef typename K1::template Type::type K1_Obj; + typedef typename K2::template Type::type K2_Obj; + typedef typename K1::template Functor >::type K1_Conv; + typedef KO_converter KOC; + typedef BOOSTD is_same no_converter; + //typedef typename KOC::argument_type K1_Obj; + //typedef typename KOC::result_type K2_Obj; public: using Base::operator(); // don't use directly, just make it accessible to the next level - K2_Obj operator()(K1_Obj const& o)const{ + K2_Obj helper(K1_Obj const& o,BOOSTD true_type)const{ return KOC()(this->myself().kernel(),this->myself().kernel2(),this->myself(),o); } + K2_Obj helper(K1_Obj const& o,BOOSTD false_type)const{ + return K1_Conv(this->myself().kernel())(this->myself().kernel2(),this->myself(),o); + } + K2_Obj operator()(K1_Obj const& o)const{ + return helper(o,no_converter()); + } template struct result:Base::template result{}; template struct result {typedef K2_Obj type;}; }; template -class CartesianD_converter_ > { +class KernelD_converter_ > { public: struct Do_not_use{}; void operator()(Do_not_use)const{} @@ -79,21 +90,21 @@ class CartesianD_converter_ > { template::type //typeset::add::type/*::add::type*/ -> class CartesianD_converter +> class KernelD_converter : public Store_kernel, public Store_kernel2, - public CartesianD_converter_,K1,K2,List_> + public KernelD_converter_,K1,K2,List_> { - typedef CartesianD_converter Self; + typedef KernelD_converter Self; typedef Self Final_; - typedef CartesianD_converter_ Base; + typedef KernelD_converter_ Base; typedef typename K1::FT FT1; typedef typename K2::FT FT2; typedef NT_converter NTc; NTc c; // TODO: compressed storage as this is likely empty and the converter gets passed around (and stored in iterators) public: - CartesianD_converter(){} - CartesianD_converter(K1 const&a,K2 const&b):Store_kernel(a),Store_kernel2(b){} + KernelD_converter(){} + KernelD_converter(K1 const&a,K2 const&b):Store_kernel(a),Store_kernel2(b){} // For boost::result_of, used in transforming_iterator template::value?42:0> struct result:Base::template result{}; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index c196cfeb3bf..79009c9afb9 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -26,9 +26,11 @@ namespace CGAL { #undef DECL_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 >{typedef Misc_tag type;}; #define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ template<>struct map_result_tag{typedef Y##_tag type;}; \ template<>struct map_functor_type{typedef Construct_tag type;} diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index c6c2764cacd..36ac489124d 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -20,6 +20,11 @@ #include #include +#ifdef CGAL_CXX0X +#define BOOSTD std:: +#else +#define BOOSTD boost:: +#endif namespace CGAL { namespace internal { From 8b3539df88d573da167547394eff95324a2d4b46 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 24 Mar 2012 20:25:24 +0000 Subject: [PATCH 094/210] Handle duplicates. --- .../include/CGAL/Kernel_d/KernelD_converter.h | 19 +++++++++++++++---- .../CGAL/Kernel_d/Kernel_object_converter.h | 10 +++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index cabe9898ec0..e45f3fa4de2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -18,7 +18,7 @@ namespace CGAL { namespace internal { // Reverses order, but that shouldn't matter. template struct Map_taglist_to_typelist : - Map_taglist_to_typelist::template add::type> + Map_taglist_to_typelist::type::template add::type> {}; template struct Map_taglist_to_typelist > : typeset<> {}; } @@ -51,13 +51,24 @@ template class KernelD_converter_ : public KernelD_converter_ { - typedef KernelD_converter_ Base; typedef typename List::head Tag; + typedef typename List::tail Rest; + typedef KernelD_converter_ Base; typedef typename K1::template Type::type K1_Obj; typedef typename K2::template Type::type K2_Obj; typedef typename K1::template Functor >::type K1_Conv; typedef KO_converter KOC; typedef BOOSTD is_same no_converter; + typedef typename internal::Map_taglist_to_typelist::type::template contains duplicate; + + // Disable the conversion in some cases: + struct Do_not_use{}; + typedef typename BOOSTD conditional< + // If Point==Vector, keep only one conversion + duplicate::value || + // For iterator objects, the default is make_transforming_iterator + (iterator_tag_traits::is_iterator && no_converter::value), + Do_not_use,K1_Obj>::type argument_type; //typedef typename KOC::argument_type K1_Obj; //typedef typename KOC::result_type K2_Obj; public: @@ -68,11 +79,11 @@ class KernelD_converter_ K2_Obj helper(K1_Obj const& o,BOOSTD false_type)const{ return K1_Conv(this->myself().kernel())(this->myself().kernel2(),this->myself(),o); } - K2_Obj operator()(K1_Obj const& o)const{ + K2_Obj operator()(argument_type const& o)const{ return helper(o,no_converter()); } template struct result:Base::template result{}; - template struct result {typedef K2_Obj type;}; + template struct result {typedef K2_Obj type;}; }; template 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 3cbb816aac6..8a45a6fb093 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -47,9 +47,13 @@ template struct KO_converter template struct KO_converter{ typedef typename K1::template Type::type K1_Vector; - typedef typename K1::template Type< Point_tag>::type K1_Point; - // can't use vector without at least a placeholder point because of this - typedef typename First_if_different::Type argument_type; + + // Disabling is now done in KernelD_converter + // // can't use vector without at least a placeholder point because of this + // typedef typename K1::template Type< Point_tag>::type K1_Point; + // typedef typename First_if_different::Type argument_type; + + typedef K1_Vector argument_type; 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 { From f3304589c01d5b9136a5a551d6c78475b07f3738 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 24 Mar 2012 21:08:33 +0000 Subject: [PATCH 095/210] More conversion to iterators as object. Still not sure about that, they end up special cased every time so they probably should have a different category. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 12 +++++++++- .../CGAL/Kernel_d/Cartesian_change_FT.h | 6 +++++ .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 6 ++--- NewKernel_d/include/CGAL/functor_tags.h | 24 ++++++++++++++++--- NewKernel_d/test/NewKernel_d/test.cpp | 5 ++-- 5 files changed, 44 insertions(+), 9 deletions(-) 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 a368a7aaa27..b62f5c781cc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -59,7 +59,17 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type { typedef Vector_ type; }; - typedef typeset::add::type Object_list; + template struct Type { + typedef typename Vector_selector::const_iterator type; + }; + template struct Type { + typedef typename Vector_selector::const_iterator type; + }; + typedef typeset + ::add::type + ::add::type + ::add::type + Object_list; template struct Functor { typedef Null_functor type; 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 bd334219e9d..017a6f81c83 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -40,6 +40,12 @@ struct Cartesian_change_FT_base : public typedef transforming_iterator Point_cartesian_const_iterator; typedef transforming_iterator Vector_cartesian_const_iterator; + template::value_tag,FT_tag>::value> + struct Type : Kernel_base::template Type {}; + template struct Type { + typedef transforming_iterator::type> type; + }; + template struct Construct_cartesian_const_iterator_ { typedef typename Kernel_base::template Functor::type Functor_base; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 2b25b2a8c00..df75991b0d1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -91,7 +91,7 @@ struct Cartesian_wrap : public Base_ #include //Translate the arguments - template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { + template::type,bool=iterator_tag_traits::type>::is_iterator,bool=boost::is_same::type,Null_functor>::value> struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { B b; @@ -116,11 +116,11 @@ struct Cartesian_wrap : public Base_ }; //Translate both the arguments and the result - template struct Functor { + template struct Functor { typedef Null_functor type; }; - template struct Functor { + template struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { B b; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 79009c9afb9..e8299cda145 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -12,10 +12,12 @@ namespace CGAL { struct Misc_tag {}; struct No_filter_tag {}; + struct FT_tag {}; + struct RT_tag {}; templatestruct map_functor_type{typedef Misc_tag type;}; -#define DECL_OBJ(X) struct X##_tag {}; +#define DECL_OBJ(X) struct X##_tag {} DECL_OBJ(Vector); DECL_OBJ(Point); DECL_OBJ(Segment); @@ -25,6 +27,20 @@ namespace CGAL { DECL_OBJ(Bbox); #undef DECL_OBJ + template struct iterator_tag_traits { + enum { is_iterator = false }; + typedef Null_tag value_tag; + }; + +#define DECL_ITER_OBJ(X,Y) struct X##_tag {}; \ + template<>struct iterator_tag_traits { \ + enum { is_iterator = true }; \ + typedef Y##_tag value_tag; \ + } + DECL_ITER_OBJ(Vector_cartesian_const_iterator, FT); + DECL_ITER_OBJ(Point_cartesian_const_iterator, FT); +#undef DECL_ITER_OBJ + templatestruct Construct_ttag {}; templatestruct Convert_ttag {}; templatestruct map_result_tag{typedef Null_type type;}; @@ -45,6 +61,8 @@ namespace CGAL { DECL_CONSTRUCT(Construct_sum_of_vectors,Vector); DECL_CONSTRUCT(Construct_difference_of_vectors,Vector); DECL_CONSTRUCT(Construct_opposite_vector,Vector); + DECL_CONSTRUCT(Construct_point_cartesian_const_iterator,Point_cartesian_const_iterator); + DECL_CONSTRUCT(Construct_vector_cartesian_const_iterator,Vector_cartesian_const_iterator); #undef DECL_CONSTRUCT #define DECL_COMPUTE(X) struct X##_tag {}; \ @@ -75,8 +93,8 @@ namespace CGAL { #define DECL_MISC(X) struct X##_tag {}; \ template<>struct map_functor_type{typedef Misc_tag type;} //TODO: split into _begin and _end ? - DECL_MISC(Construct_point_cartesian_const_iterator); - DECL_MISC(Construct_vector_cartesian_const_iterator); + //DECL_MISC(Construct_point_cartesian_const_iterator); + //DECL_MISC(Construct_vector_cartesian_const_iterator); DECL_MISC(Point_dimension); DECL_MISC(Vector_dimension); #undef DECL_MISC diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index b259a3f8222..8119a0fc243 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -44,7 +44,7 @@ typedef CGAL::Cartesian_filter_NT K2; #elif 1 typedef CGAL::Cartesian_filter_K K2; #elif 1 -typedef CGAL::Lazy_cartesian > K2; +typedef CGAL::Lazy_cartesian > K2; #endif #if 0 @@ -56,6 +56,7 @@ typedef CGAL::Cartesian_wrap K3; typedef CGAL::Cartesian_wrap K1; #endif typedef K1::Type::type P; +typedef K1::Type::type CI; typedef K1::Type::type V; typedef K1::Type::type S; //typedef K1::Construct_point CP; @@ -66,7 +67,7 @@ typedef K1::Functor::type CSE; typedef K1::Functor::type CCI; typedef K1::Functor::type PO; typedef K1::Functor::type SOS; -typedef K1::Point_cartesian_const_iterator CI; +//typedef K1::Point_cartesian_const_iterator CI; typedef K1::Functor::type CC; #if 1 From e64fd9fc7e4dc379ee67680ebae1fd7060cf39d8 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 24 Mar 2012 21:10:19 +0000 Subject: [PATCH 096/210] Lazy iterators, doesn't compile, and even if it did, definitely a bad idea. Going to revert right after the commit, I just want to keep the code somewhere... --- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 61 ++-- NewKernel_d/include/CGAL/Lazy.h | 322 +++++++++++++++++- NewKernel_d/include/CGAL/marcutils.h | 6 + 3 files changed, 358 insertions(+), 31 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 322e04e3b5d..905eb29c655 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -66,50 +66,57 @@ struct Lazy_cartesian : Dimension_base typename Exact_kernel::Object_list >::type Object_list; - template::type> struct Functor { + template::type, + bool=iterator_tag_traits::type>::is_iterator> + struct Functor { typedef Null_functor type; }; //FIXME: what do we do with D here? - template struct Functor { + template struct Functor { typedef typename Approximate_kernel::template Functor::type FA; typedef typename Exact_kernel::template Functor::type FE; typedef Filtered_predicate type; }; - template struct Functor { + template struct Functor { typedef typename Approximate_kernel::template Functor::type FA; typedef typename Exact_kernel::template Functor::type FE; typedef Lazy_construction_nt type; }; - template struct Functor { + template struct Functor { + typedef typename Approximate_kernel::template Functor::type FA; + typedef typename Exact_kernel::template Functor::type FE; + typedef Lazy_construction_iter type; + }; + template struct Functor { typedef typename Approximate_kernel::template Functor::type FA; typedef typename Exact_kernel::template Functor::type FE; typedef Lazy_construction type; }; - typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Point_cartesian_const_iterator; - typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Vector_cartesian_const_iterator; + //typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Point_cartesian_const_iterator; + //typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Vector_cartesian_const_iterator; - template - struct Construct_iter : private Store_kernel { - Construct_iter(){} - Construct_iter(Kernel const&k):Store_kernel(k){} - //FIXME: pass the kernel to the functor in the iterator - typedef U result_type; - template - result_type operator()(T const& t,Begin_tag)const{ - return result_type(t,0,this->kernel()); - } - template - result_type operator()(T const& t,End_tag)const{ - return result_type(t,Self().dimension(),this->kernel()); - } - }; - template struct Functor { - typedef Construct_iter type; - }; - template struct Functor { - typedef Construct_iter type; - }; + //template + //struct Construct_iter : private Store_kernel { + // Construct_iter(){} + // Construct_iter(Kernel const&k):Store_kernel(k){} + // //FIXME: pass the kernel to the functor in the iterator + // typedef U result_type; + // template + // result_type operator()(T const& t,Begin_tag)const{ + // return result_type(t,0,this->kernel()); + // } + // template + // result_type operator()(T const& t,End_tag)const{ + // return result_type(t,Self().dimension(),this->kernel()); + // } + //}; + //template struct Functor { + // typedef Construct_iter type; + //}; + //template struct Functor { + // typedef Construct_iter type; + //}; //TODO: what about other functors of the Misc category? }; diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index 68ce0adb9f0..3a14f92c718 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -47,7 +47,8 @@ namespace internal { } -template class Lazy; +template ::value && is_iterator::value> class Lazy; template class Lazy_exact_nt; @@ -415,6 +416,54 @@ public: #endif }; +template +class Lazy_rep_2bis + : public Lazy_rep::type, typename decay::type, E2A> + , private EC, private AC +{ + typedef typename decay::type AT; + typedef typename decay::type ET; + typedef Lazy_rep Base; + + mutable L1 l1_; + mutable L2 l2_; + + const EC& ec() const { return *this; } + const AC& ac() const { return *this; } + +public: + + void + update_exact() const + { + this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_))); + this->at = ac()(CGAL::approx(l1_), CGAL::approx(l2_)); + // Prune lazy tree + l1_ = L1(); + l2_ = L2(); + } + + Lazy_rep_2bis(const AC& ac, const EC& /*ec*/, const L1& l1, const L2& l2) + : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2))), + l1_(l1), l2_(l2) + { + this->set_depth(max_n(CGAL::depth(l1_), CGAL::depth(l2_)) + 1); + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void + print_dag(std::ostream& os, int level) const + { + this->print_at_et(os, level); + if(this->is_lazy()){ + CGAL::msg(os, level, "DAG with two child nodes:"); + CGAL::print_dag(l1_, os, level+1); + CGAL::print_dag(l2_, os, level+1); + } + } +#endif +}; + //____________________________________________________________ @@ -876,7 +925,7 @@ struct Approx_converter { return t.approx(); } template - transforming_iterator,It>::type> + transforming_iterator::value && !internal::has_AT::value,It>::type> operator()(const It& i) const { return make_transforming_iterator(i,*this); @@ -926,7 +975,7 @@ struct Exact_converter { return t.exact(); } template - transforming_iterator,It>::type> + transforming_iterator::value && !internal::has_ET::value,It>::type> operator()(const It& i) const { return make_transforming_iterator(i,*this); @@ -1154,7 +1203,8 @@ public: //____________________________________________________________ // The handle class -template +template class Lazy : public Handle { public : @@ -1248,6 +1298,184 @@ private: Self_rep * ptr() const { return (Self_rep*) PTR; } }; +// Lazy iterator +#define VALUE_TYPE typename \ + BOOSTD conditional< \ + BOOSTD is_same::value_type, EFT>::value, \ + Lazy_exact_nt, \ + Lazy::value_type, \ + typename std::iterator_traits::value_type, \ + EFT, E2A> >::type + +template +class Lazy : public Handle, public Depth_base, + public boost::iterator_facade< + Lazy , + VALUE_TYPE, + // FIXME: use the min of the categories + typename std::iterator_traits::iterator_category, + VALUE_TYPE> + +{ +public : + //typedef typename std::iterator_traits::iterator_category iterator_category; + //typedef Lazy::value_type, + // std::iterator_traits::value_type, + // EFT, E2A> value_type; + //typedef std::ptrdiff_t difference_type; + //typedef value_type reference; + //typedef value_type* pointer; + + typedef AT_ AT; + typedef ET_ ET; + + mutable AT at; + mutable ET *et; + std::ptrdiff_t forw; + + const AT& approx() const + { + return at; + } + + AT& approx() + { + return at; + } + + const ET & exact() const + { + if (et==NULL) + update_exact(); + return *et; + } + + ET & exact() + { + if (et==NULL) + update_exact(); + return *et; + } + +#ifdef CGAL_LAZY_KERNEL_DEBUG + void print_at_et(std::ostream& os, int level) const + { + for(int i = 0; i < level; i++){ + os << " "; + } + os << "Approximation: "; + print_at(os, at); + os << std::endl; + if(! is_lazy()){ + for(int i = 0; i < level; i++){ + os << " "; + } + os << "Exact: "; + print_at(os, *et); + os << std::endl; + } + } + + virtual void print_dag(std::ostream& os, int level) const {} +#endif + + bool is_lazy() const { return et == NULL; } + + typedef Lazy Self; + typedef Lazy_rep Self_rep; + + typedef AT Approximate_type; + typedef ET Exact_type; + +/* + typedef Self Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } +*/ + + Lazy() : Handle(zero()), at(), et(0) {} + + // Before Lazy::zero() used Boost.Thread, the definition of Lazy() was: + // Lazy() + // #ifndef CGAL_HAS_THREAD + // : Handle(zero()) {} + // #else + // { + // PTR = new Lazy_rep_0(); + // } + // #endif + + Lazy(Self_rep *r) : at(r->approx()), et(0) { PTR = r; } + + //Lazy(const ET& e) : Handle(), at(E2A()(e)), et(new ET(e)) { } + + ~Lazy() { + delete et; + } + +private: + + // We have a static variable for optimizing the default constructor, + // which is in particular heavily used for pruning DAGs. + static const Self & zero() + { +#ifdef CGAL_HAS_THREADS + static boost::thread_specific_ptr z; + if (z.get() == NULL) { + z.reset(new Self(new Lazy_rep_0())); + } + return * z.get(); +#else + static const Self z = new Lazy_rep_0(); + return z; +#endif + } + + Self_rep * ptr() const { return (Self_rep*) PTR; } + + void + update_exact() const + { + if(et) return; + if(ptr()) { + ptr()->update_exact(); + this->et = new ET(ptr()->exact()); + } else + this->et = new ET(); + } + + friend class boost::iterator_core_access; + VALUE_TYPE dereference()const{ + return new Lazy_rep_1,Dereference_specific,E2A,Self>(Dereference_specific(),Dereference_specific(),*this); + } + bool equal(Self const&x)const{ return at == x.at; } + void increment(){ + ++at; + if(et) ++et; + else ++forw; + } + void decrement(){ + --at; + if(et) --et; + else --forw; + } + void advance(std::ptrdiff_t n){ + at+=n; + if(et) et+=n; + else forw+=n; + } + std::ptrdiff_t distance_to(Self const&x)const{ return x.at - at; } +}; +#undef VALUE_TYPE + @@ -1925,6 +2153,92 @@ public: }; +template +struct Lazy_construction_iter +{ + static const bool Protection = true; + + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename EK::FT EFT; + typedef typename Default::Get::type E2A; + typedef typename decay::type AT; + typedef typename decay::type ET; + typedef Lazy Handle; + //typedef typename Type_mapper::type result_type; + typedef Handle result_type; + + AC ac; + EC ec; + Lazy_construction_iter(){} + Lazy_construction_iter(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} + +public: + + result_type + operator()() const + { + return result_type( Handle(new Lazy_rep_0()) ); + } + + template + result_type + operator()(const L1& l1) const + { + return result_type( Handle(new Lazy_rep_1(ac, ec, l1)) ); + } + + template + result_type + operator()(const L1& l1, const L2& l2) const + { + return result_type( Handle(new Lazy_rep_2bis(ac, ec, l1, l2)) ); + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3) const + { + return result_type( Handle(new Lazy_rep_3(ac, ec, l1, l2, l3)) ); + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4) const + { + return result_type( Handle(new Lazy_rep_4(ac, ec, l1, l2, l3, l4)) ); + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5) const + { + return result_type( Handle(new Lazy_rep_5(ac, ec, l1, l2, l3, l4, l5)) ); + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6) const + { + return result_type( Handle(new Lazy_rep_6(ac, ec, l1, l2, l3, l4, l5, l6)) ); + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7) const + { + return result_type( Handle(new Lazy_rep_7(ac, ec, l1, l2, l3, l4, l5, l6, l7)) ); + } + + template + result_type + operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7, const L8& l8) const + { + return result_type( Handle(new Lazy_rep_8(ac, ec, l1, l2, l3, l4, l5, l6, l7, l8)) ); + } + +}; + } //namespace CGAL #endif // CGAL_LAZY_H diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 36ac489124d..fe737ee366f 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -167,6 +167,12 @@ namespace internal { } }; + template + struct Dereference_specific { + typedef typename std::iterator_traits::reference result_type; + result_type operator()(It const&i)const{ return *i; } + }; + #ifdef CGAL_CXX0X template struct Indices{}; template struct Next_increasing_indices; From c64689ba83fe6767b288d5b16472af4098f1cf3f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 24 Mar 2012 21:20:12 +0000 Subject: [PATCH 097/210] Now the revert --- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 61 ++-- NewKernel_d/include/CGAL/Lazy.h | 322 +----------------- NewKernel_d/include/CGAL/marcutils.h | 6 - 3 files changed, 31 insertions(+), 358 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 905eb29c655..322e04e3b5d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -66,57 +66,50 @@ struct Lazy_cartesian : Dimension_base typename Exact_kernel::Object_list >::type Object_list; - template::type, - bool=iterator_tag_traits::type>::is_iterator> - struct Functor { + template::type> struct Functor { typedef Null_functor type; }; //FIXME: what do we do with D here? - template struct Functor { + template struct Functor { typedef typename Approximate_kernel::template Functor::type FA; typedef typename Exact_kernel::template Functor::type FE; typedef Filtered_predicate type; }; - template struct Functor { + template struct Functor { typedef typename Approximate_kernel::template Functor::type FA; typedef typename Exact_kernel::template Functor::type FE; typedef Lazy_construction_nt type; }; - template struct Functor { - typedef typename Approximate_kernel::template Functor::type FA; - typedef typename Exact_kernel::template Functor::type FE; - typedef Lazy_construction_iter type; - }; - template struct Functor { + template struct Functor { typedef typename Approximate_kernel::template Functor::type FA; typedef typename Exact_kernel::template Functor::type FE; typedef Lazy_construction type; }; - //typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Point_cartesian_const_iterator; - //typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Vector_cartesian_const_iterator; + typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Point_cartesian_const_iterator; + typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Vector_cartesian_const_iterator; - //template - //struct Construct_iter : private Store_kernel { - // Construct_iter(){} - // Construct_iter(Kernel const&k):Store_kernel(k){} - // //FIXME: pass the kernel to the functor in the iterator - // typedef U result_type; - // template - // result_type operator()(T const& t,Begin_tag)const{ - // return result_type(t,0,this->kernel()); - // } - // template - // result_type operator()(T const& t,End_tag)const{ - // return result_type(t,Self().dimension(),this->kernel()); - // } - //}; - //template struct Functor { - // typedef Construct_iter type; - //}; - //template struct Functor { - // typedef Construct_iter type; - //}; + template + struct Construct_iter : private Store_kernel { + Construct_iter(){} + Construct_iter(Kernel const&k):Store_kernel(k){} + //FIXME: pass the kernel to the functor in the iterator + typedef U result_type; + template + result_type operator()(T const& t,Begin_tag)const{ + return result_type(t,0,this->kernel()); + } + template + result_type operator()(T const& t,End_tag)const{ + return result_type(t,Self().dimension(),this->kernel()); + } + }; + template struct Functor { + typedef Construct_iter type; + }; + template struct Functor { + typedef Construct_iter type; + }; //TODO: what about other functors of the Misc category? }; diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index 3a14f92c718..68ce0adb9f0 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -47,8 +47,7 @@ namespace internal { } -template ::value && is_iterator::value> class Lazy; +template class Lazy; template class Lazy_exact_nt; @@ -416,54 +415,6 @@ public: #endif }; -template -class Lazy_rep_2bis - : public Lazy_rep::type, typename decay::type, E2A> - , private EC, private AC -{ - typedef typename decay::type AT; - typedef typename decay::type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - - const EC& ec() const { return *this; } - const AC& ac() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_))); - this->at = ac()(CGAL::approx(l1_), CGAL::approx(l2_)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - } - - Lazy_rep_2bis(const AC& ac, const EC& /*ec*/, const L1& l1, const L2& l2) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2))), - l1_(l1), l2_(l2) - { - this->set_depth(max_n(CGAL::depth(l1_), CGAL::depth(l2_)) + 1); - } - -#ifdef CGAL_LAZY_KERNEL_DEBUG - void - print_dag(std::ostream& os, int level) const - { - this->print_at_et(os, level); - if(this->is_lazy()){ - CGAL::msg(os, level, "DAG with two child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - } - } -#endif -}; - //____________________________________________________________ @@ -925,7 +876,7 @@ struct Approx_converter { return t.approx(); } template - transforming_iterator::value && !internal::has_AT::value,It>::type> + transforming_iterator,It>::type> operator()(const It& i) const { return make_transforming_iterator(i,*this); @@ -975,7 +926,7 @@ struct Exact_converter { return t.exact(); } template - transforming_iterator::value && !internal::has_ET::value,It>::type> + transforming_iterator,It>::type> operator()(const It& i) const { return make_transforming_iterator(i,*this); @@ -1203,8 +1154,7 @@ public: //____________________________________________________________ // The handle class -template +template class Lazy : public Handle { public : @@ -1298,184 +1248,6 @@ private: Self_rep * ptr() const { return (Self_rep*) PTR; } }; -// Lazy iterator -#define VALUE_TYPE typename \ - BOOSTD conditional< \ - BOOSTD is_same::value_type, EFT>::value, \ - Lazy_exact_nt, \ - Lazy::value_type, \ - typename std::iterator_traits::value_type, \ - EFT, E2A> >::type - -template -class Lazy : public Handle, public Depth_base, - public boost::iterator_facade< - Lazy , - VALUE_TYPE, - // FIXME: use the min of the categories - typename std::iterator_traits::iterator_category, - VALUE_TYPE> - -{ -public : - //typedef typename std::iterator_traits::iterator_category iterator_category; - //typedef Lazy::value_type, - // std::iterator_traits::value_type, - // EFT, E2A> value_type; - //typedef std::ptrdiff_t difference_type; - //typedef value_type reference; - //typedef value_type* pointer; - - typedef AT_ AT; - typedef ET_ ET; - - mutable AT at; - mutable ET *et; - std::ptrdiff_t forw; - - const AT& approx() const - { - return at; - } - - AT& approx() - { - return at; - } - - const ET & exact() const - { - if (et==NULL) - update_exact(); - return *et; - } - - ET & exact() - { - if (et==NULL) - update_exact(); - return *et; - } - -#ifdef CGAL_LAZY_KERNEL_DEBUG - void print_at_et(std::ostream& os, int level) const - { - for(int i = 0; i < level; i++){ - os << " "; - } - os << "Approximation: "; - print_at(os, at); - os << std::endl; - if(! is_lazy()){ - for(int i = 0; i < level; i++){ - os << " "; - } - os << "Exact: "; - print_at(os, *et); - os << std::endl; - } - } - - virtual void print_dag(std::ostream& os, int level) const {} -#endif - - bool is_lazy() const { return et == NULL; } - - typedef Lazy Self; - typedef Lazy_rep Self_rep; - - typedef AT Approximate_type; - typedef ET Exact_type; - -/* - typedef Self Rep; - - const Rep& rep() const - { - return *this; - } - - Rep& rep() - { - return *this; - } -*/ - - Lazy() : Handle(zero()), at(), et(0) {} - - // Before Lazy::zero() used Boost.Thread, the definition of Lazy() was: - // Lazy() - // #ifndef CGAL_HAS_THREAD - // : Handle(zero()) {} - // #else - // { - // PTR = new Lazy_rep_0(); - // } - // #endif - - Lazy(Self_rep *r) : at(r->approx()), et(0) { PTR = r; } - - //Lazy(const ET& e) : Handle(), at(E2A()(e)), et(new ET(e)) { } - - ~Lazy() { - delete et; - } - -private: - - // We have a static variable for optimizing the default constructor, - // which is in particular heavily used for pruning DAGs. - static const Self & zero() - { -#ifdef CGAL_HAS_THREADS - static boost::thread_specific_ptr z; - if (z.get() == NULL) { - z.reset(new Self(new Lazy_rep_0())); - } - return * z.get(); -#else - static const Self z = new Lazy_rep_0(); - return z; -#endif - } - - Self_rep * ptr() const { return (Self_rep*) PTR; } - - void - update_exact() const - { - if(et) return; - if(ptr()) { - ptr()->update_exact(); - this->et = new ET(ptr()->exact()); - } else - this->et = new ET(); - } - - friend class boost::iterator_core_access; - VALUE_TYPE dereference()const{ - return new Lazy_rep_1,Dereference_specific,E2A,Self>(Dereference_specific(),Dereference_specific(),*this); - } - bool equal(Self const&x)const{ return at == x.at; } - void increment(){ - ++at; - if(et) ++et; - else ++forw; - } - void decrement(){ - --at; - if(et) --et; - else --forw; - } - void advance(std::ptrdiff_t n){ - at+=n; - if(et) et+=n; - else forw+=n; - } - std::ptrdiff_t distance_to(Self const&x)const{ return x.at - at; } -}; -#undef VALUE_TYPE - @@ -2153,92 +1925,6 @@ public: }; -template -struct Lazy_construction_iter -{ - static const bool Protection = true; - - typedef typename LK::Approximate_kernel AK; - typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; - typedef typename Default::Get::type E2A; - typedef typename decay::type AT; - typedef typename decay::type ET; - typedef Lazy Handle; - //typedef typename Type_mapper::type result_type; - typedef Handle result_type; - - AC ac; - EC ec; - Lazy_construction_iter(){} - Lazy_construction_iter(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} - -public: - - result_type - operator()() const - { - return result_type( Handle(new Lazy_rep_0()) ); - } - - template - result_type - operator()(const L1& l1) const - { - return result_type( Handle(new Lazy_rep_1(ac, ec, l1)) ); - } - - template - result_type - operator()(const L1& l1, const L2& l2) const - { - return result_type( Handle(new Lazy_rep_2bis(ac, ec, l1, l2)) ); - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3) const - { - return result_type( Handle(new Lazy_rep_3(ac, ec, l1, l2, l3)) ); - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4) const - { - return result_type( Handle(new Lazy_rep_4(ac, ec, l1, l2, l3, l4)) ); - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5) const - { - return result_type( Handle(new Lazy_rep_5(ac, ec, l1, l2, l3, l4, l5)) ); - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6) const - { - return result_type( Handle(new Lazy_rep_6(ac, ec, l1, l2, l3, l4, l5, l6)) ); - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7) const - { - return result_type( Handle(new Lazy_rep_7(ac, ec, l1, l2, l3, l4, l5, l6, l7)) ); - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7, const L8& l8) const - { - return result_type( Handle(new Lazy_rep_8(ac, ec, l1, l2, l3, l4, l5, l6, l7, l8)) ); - } - -}; - } //namespace CGAL #endif // CGAL_LAZY_H diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index fe737ee366f..36ac489124d 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -167,12 +167,6 @@ namespace internal { } }; - template - struct Dereference_specific { - typedef typename std::iterator_traits::reference result_type; - result_type operator()(It const&i)const{ return *i; } - }; - #ifdef CGAL_CXX0X template struct Indices{}; template struct Next_increasing_indices; From 2f6dbee262294202f547d4cc23faee5c9da3c70e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 26 Mar 2012 11:15:14 +0000 Subject: [PATCH 098/210] Small fix to lazy_cartesian now that iterators are objects (will probably change that soon, only caused trouble). Provide an easy way to have K::Point (shorter than K::Type::type...). Could do the same for functors, maybe. Now that I have an Object_list, it would be possible to use directly K::Point and get rid of that Type::type horror, which sure looks simpler (although it is actually more complicated behind), but it has some drawbacks. In particular, in a CRTP context, typedef std::pair Segment; won't work (it worked inside Type<...>), one has to use typedef MySegment Segment; instead (C++ can be a pain...). --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 6 +++-- .../CGAL/Kernel_d/Define_kernel_types.h | 24 ++++++++++++++++++ .../include/CGAL/Kernel_d/Define_segment.h | 2 ++ .../include/CGAL/Kernel_d/Lazy_cartesian.h | 11 ++++++-- NewKernel_d/include/CGAL/functor_tags.h | 25 ++++++++++++++----- NewKernel_d/test/NewKernel_d/test.cpp | 18 ++++++++++--- 6 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h 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 b62f5c781cc..5d41843f756 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -47,6 +47,8 @@ struct Cartesian_LA_base_d : public Dimension_base Angle; typedef Vec_ Vector_selector; + typedef typename Vector_selector::type Point; + typedef typename Vector_selector::type Vector; typedef typename Vector_selector::type Vector_; typedef typename Vector_selector::Constructor Constructor; typedef typename Vector_selector::const_iterator Point_cartesian_const_iterator; @@ -54,10 +56,10 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type {}; template struct Type { - typedef Vector_ type; + typedef Vector type; }; template struct Type { - typedef Vector_ type; + typedef Point type; }; template struct Type { typedef typename Vector_selector::const_iterator type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h b/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h new file mode 100644 index 00000000000..3d6cbd5325e --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h @@ -0,0 +1,24 @@ +#ifndef CGAL_DEFINE_KERNEL_TYPES_H +#define CGAL_DEFINE_KERNEL_TYPES_H +#include +#include +#ifdef CGAL_CXX0X +#include +#else +#include +#endif + +namespace CGAL { + template struct Define_kernel_types; + template + struct Define_kernel_types > : Base {}; + template + struct Define_kernel_types > {}; + template + struct Define_kernel_types : + Typedef_tag_type::type, + Define_kernel_types + > {}; +} +#endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 4e9b493611c..24fe623af6d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -55,12 +55,14 @@ struct Define_segment : public Base_ { typedef Base_ Base; typedef Define_segment Self; typedef typename Default::Get::type Derived; + template struct Type : Base_::template Type {}; template struct Type { typedef typename Derived::template Type::type Point; typedef std::pair type; }; typedef typename Base::Object_list::template add::type Object_list; + // TODO: forward the second Functor argument (like fast, no_filter) template struct Functor : Base_::template Functor {}; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 322e04e3b5d..619f0195593 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -89,6 +89,13 @@ struct Lazy_cartesian : Dimension_base typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Point_cartesian_const_iterator; typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Vector_cartesian_const_iterator; + template struct Type { + typedef Point_cartesian_const_iterator type; + }; + template struct Type { + typedef Vector_cartesian_const_iterator type; + }; + template struct Construct_iter : private Store_kernel { Construct_iter(){} @@ -104,10 +111,10 @@ struct Lazy_cartesian : Dimension_base return result_type(t,Self().dimension(),this->kernel()); } }; - template struct Functor { + template struct Functor { typedef Construct_iter type; }; - template struct Functor { + template struct Functor { typedef Construct_iter type; }; //TODO: what about other functors of the Misc category? diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index e8299cda145..faf717b37de 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -15,9 +15,17 @@ namespace CGAL { struct FT_tag {}; struct RT_tag {}; - templatestruct map_functor_type{typedef Misc_tag type;}; + template struct map_functor_type { typedef Misc_tag type; }; + template struct Typedef_tag_type; + template struct Read_tag_type; + + +#define DECL_OBJ(X) struct X##_tag {}; \ + template \ + struct Typedef_tag_type : Base { typedef Obj X; }; \ + template \ + struct Read_tag_type { typedef typename Kernel::X type; } -#define DECL_OBJ(X) struct X##_tag {} DECL_OBJ(Vector); DECL_OBJ(Point); DECL_OBJ(Segment); @@ -33,10 +41,15 @@ namespace CGAL { }; #define DECL_ITER_OBJ(X,Y) struct X##_tag {}; \ - template<>struct iterator_tag_traits { \ - enum { is_iterator = true }; \ - typedef Y##_tag value_tag; \ - } + template<>struct iterator_tag_traits { \ + enum { is_iterator = true }; \ + typedef Y##_tag value_tag; \ + }; \ + template \ + struct Typedef_tag_type : Base { typedef Obj X; }; \ + template \ + struct Read_tag_type { typedef typename Kernel::X type; } + DECL_ITER_OBJ(Vector_cartesian_const_iterator, FT); DECL_ITER_OBJ(Point_cartesian_const_iterator, FT); #undef DECL_ITER_OBJ diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 8119a0fc243..bc31b04fbd3 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -48,17 +49,28 @@ typedef CGAL::Lazy_cartesian > K2; #endif #if 0 -typedef K2 K1; +typedef K2 KK; #elif 1 -typedef CGAL::Cartesian_wrap K1; +typedef CGAL::Cartesian_wrap KK; #elif 1 typedef CGAL::Cartesian_wrap K3; -typedef CGAL::Cartesian_wrap K1; +typedef CGAL::Cartesian_wrap KK; #endif + +#if 0 +typedef KK K1; typedef K1::Type::type P; typedef K1::Type::type CI; typedef K1::Type::type V; typedef K1::Type::type S; +#elif 1 +typedef CGAL::Define_kernel_types K1; +typedef K1::Point P; +typedef K1::Point_cartesian_const_iterator CI; +typedef K1::Vector V; +typedef K1::Segment S; +#endif + //typedef K1::Construct_point CP; typedef K1::Functor >::type CP; typedef K1::Functor >::type CV; From 39ba4946b4b4355a283b0b7b730e0a3694fd772c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 27 Mar 2012 16:05:32 +0000 Subject: [PATCH 099/210] Split points and vectors some more. Might remerge them later... Iterators are not objects, handle that everywhere. Still some not-lazy-enough issues I'll have to deal with. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 17 +++++-- .../CGAL/Kernel_d/Cartesian_change_FT.h | 14 ++++-- .../CGAL/Kernel_d/Cartesian_static_filters.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 8 ++-- .../CGAL/Kernel_d/Define_kernel_types.h | 10 +++- .../CGAL/Kernel_d/Kernel_2_interface.h | 10 ++-- .../CGAL/Kernel_d/Kernel_object_converter.h | 2 +- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 46 ++++++++++++++----- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 8 ++-- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 4 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 2 +- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 4 +- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 18 ++++---- .../Kernel_d/function_objects_cartesian.h | 24 +++++----- .../include/CGAL/Kernel_d/interface_macros.h | 14 +++--- NewKernel_d/include/CGAL/functor_tags.h | 42 ++++++++++------- .../include/CGAL/iterator_from_indices.h | 9 ++-- NewKernel_d/test/NewKernel_d/test.cpp | 4 +- 18 files changed, 145 insertions(+), 93 deletions(-) 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 5d41843f756..a37c849a2db 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -61,18 +61,22 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type { typedef Point type; }; - template struct Type { + template struct Iterator {}; + template struct Iterator { typedef typename Vector_selector::const_iterator type; }; - template struct Type { + template struct Iterator { typedef typename Vector_selector::const_iterator type; }; + typedef typeset ::add::type - ::add::type - ::add::type Object_list; + typedef typeset< Point_cartesian_const_iterator_tag>::type + ::add::type + Iterator_list; + template struct Functor { typedef Null_functor type; }; @@ -103,7 +107,10 @@ struct Cartesian_LA_base_d : public Dimension_base typedef CartesianDVectorBase::Construct_midpoint type; }; #endif - template struct Functor { + template struct Functor { + typedef CartesianDVectorBase::Compute_cartesian_coordinate type; + }; + template struct Functor { typedef CartesianDVectorBase::Compute_cartesian_coordinate type; }; template struct Functor { 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 017a6f81c83..e781f63cb75 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -65,8 +65,9 @@ struct Cartesian_change_FT_base : public typedef Construct_cartesian_const_iterator_ Construct_point_cartesian_const_iterator; typedef Construct_cartesian_const_iterator_ Construct_vector_cartesian_const_iterator; + template struct Compute_cartesian_coordinate { - typedef typename Kernel_base::template Functor::type Functor_base; + typedef typename Kernel_base::template Functor::type Functor_base; Compute_cartesian_coordinate(){} Compute_cartesian_coordinate(Self const&r):f(r){} Functor_base f; @@ -83,13 +84,16 @@ struct Cartesian_change_FT_base : public { typedef Null_functor type; }; template struct Functor { typedef Null_functor type; }; - template struct Functor { - typedef Compute_cartesian_coordinate type; + template struct Functor { + typedef Compute_cartesian_coordinate type; }; - template struct Functor { + template struct Functor { + typedef Compute_cartesian_coordinate type; + }; + template struct Functor { typedef Construct_point_cartesian_const_iterator type; }; - template struct Functor { + template struct Functor { typedef Construct_vector_cartesian_const_iterator type; }; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index f8307f2b35d..7b214f82230 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -14,7 +14,7 @@ template struct Orientation_of_points_2 : private Store_k typedef typename R_::template Type::type Point; typedef typename R_::Orientation result_type; typedef typename R_::FT FT; - typedef typename R_::template Functor::type CC; + typedef typename R_::template Functor::type CC; typedef typename Base_::template Functor::type Orientation_base; // TODO: Move this out for easy reuse struct Adapter { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index b7da88507c0..78f5e9a10e3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -18,7 +18,7 @@ template struct Construct_flat_orientation : private Store_kernel typedef R_ R; typedef typename R_::FT FT; typedef typename R::template Type::type Point; - typedef typename R::template Functor::type CCC; + typedef typename R::template Functor::type CCC; typedef typename R::LA LA; typedef typename Increment_dimension::type Dplusone; typedef typename LA::template Matrix::type Matrix; @@ -73,7 +73,7 @@ template struct Contained_in_affine_hull : private Store_kernel { typedef typename R::LA LA; typedef typename R::template Type::type Point; typedef typename R::Orientation result_type; - typedef typename R::template Functor::type CCC; + typedef typename R::template Functor::type CCC; typedef typename R::template Functor::type PD; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; @@ -136,7 +136,7 @@ template struct In_flat_orientation : private Store_kernel { template result_type operator()(Flat_orientation const&o, Iter f, Iter e) const { // TODO: work in the projection instead of the ambient space. - typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type c(this->kernel()); typename R::template Functor::type pd(this->kernel()); int d=pd(*f); Matrix m(d+1,d+1); @@ -173,7 +173,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel template result_type operator()(Flat_orientation const&o, Iter f, Iter e, Point const&x) const { // TODO: can't work in the projection, but we should at least remove the row of 1s. - typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type c(this->kernel()); typename R::template Functor::type pd(this->kernel()); int d=pd(*f); Matrix m(d+2,d+2); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h b/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h index 3d6cbd5325e..42e9e84b1c4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h @@ -9,7 +9,13 @@ #endif namespace CGAL { - template struct Define_kernel_types; + namespace internal { + template::is_iterator> + struct Type_or_iter : K::template Type {}; + template + struct Type_or_iter : K::template Iterator {}; + } + template::type> struct Define_kernel_types; template struct Define_kernel_types > : Base {}; template @@ -17,7 +23,7 @@ namespace CGAL { template struct Define_kernel_types : Typedef_tag_type::type, + typename internal::Type_or_iter::type, Define_kernel_types > {}; } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h index 1d2df381a22..a4b02bd9766 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -13,7 +13,7 @@ template struct Kernel_2_interface : public Base_ { typedef Kernel_2_interface Kernel; typedef typename Base::template Type::type Point_2; typedef typename Base::template Type::type Vector_2; - typedef typename Base::template Type::type Segment_2; + struct Segment_2 {}; typedef cpp0x::tuple Triangle_2; // triangulation insists... template struct Help_2p_i { typedef typename Base::template Functor::type LT; @@ -24,10 +24,10 @@ template struct Kernel_2_interface : public Base_ { return lt(a,b,i); } }; - typedef Help_2p_i Less_x_2; - typedef Help_2p_i Less_y_2; - typedef Help_2p_i Compare_x_2; - typedef Help_2p_i Compare_y_2; + typedef Help_2p_i Less_x_2; + typedef Help_2p_i Less_y_2; + typedef Help_2p_i Compare_x_2; + typedef Help_2p_i Compare_y_2; struct Compare_distance_2 { typedef typename Base::template Functor::type CD; typedef typename CD::result_type result_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 8a45a6fb093..c61a2b670cf 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -30,7 +30,7 @@ struct Point_converter_help,K1,K2> { typedef typename K2::template Type::type result_type; template result_type help(Indices, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { - typename K1::template Functor::type cc(k1); + typename K1::template Functor::type cc(k1); typename K2::template Functor >::type cp(k2); return cp(conv(cc(p,I))...); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 619f0195593..36b05ad8ed2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -86,15 +86,38 @@ struct Lazy_cartesian : Dimension_base typedef Lazy_construction type; }; - typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Point_cartesian_const_iterator; - typedef Iterator_from_indices::type, const FT, FT, typename Functor::type> Vector_cartesian_const_iterator; + typedef typename typeset_intersection< + typename Approximate_kernel::Iterator_list, + typename Exact_kernel::Iterator_list + >::type Iterator_list; - template struct Type { - typedef Point_cartesian_const_iterator type; + + //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; + } }; - template struct Type { - typedef Vector_cartesian_const_iterator type; +#endif + + template struct Iterator { + typedef Iterator_from_indices< + const typename Type::container>::type, + //FIXME: this fails because it is not lazy enough!!! + //const typename Read_tag_type::value_tag>::type, + //typename Read_tag_type::value_tag>::type, + const FT, FT, + typename Functor::nth_element>::type + > type; }; + //typedef typename Iterator::type Point_cartesian_const_iterator; + //typedef typename Iterator::type Vector_cartesian_const_iterator; template struct Construct_iter : private Store_kernel { @@ -111,13 +134,14 @@ struct Lazy_cartesian : Dimension_base return result_type(t,Self().dimension(),this->kernel()); } }; - template struct Functor { - typedef Construct_iter type; - }; - template struct Functor { - typedef Construct_iter type; + template struct Functor { + typedef Construct_iter::type>::type> type; }; + + //TODO: what about other functors of the Misc category? + // for Point_dimension, we should apply it to the approximate point + // for printing, we should??? just not do printing this way? }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index df75991b0d1..0cc02876a9f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -87,11 +87,11 @@ struct Cartesian_wrap : public Base_ #define CGAL_Kernel_obj(X,Y) \ templatestruct Type { typedef X##_d type; }; CGAL_Kernel_obj(Segment,segment) - //TODO: give a list to Cartesian_wrap + //TODO: use Object_list, intersected with the list of objects that do have a wrapper available. #include //Translate the arguments - template::type,bool=iterator_tag_traits::type>::is_iterator,bool=boost::is_same::type,Null_functor>::value> struct Functor { + template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { B b; @@ -116,11 +116,11 @@ struct Cartesian_wrap : public Base_ }; //Translate both the arguments and the result - template struct Functor { + template struct Functor { typedef Null_functor type; }; - template struct Functor { + template struct Functor { typedef typename Kernel_base::template Functor::type B; struct type { B b; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 2f9477cc76d..3f99b2cc77a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -24,7 +24,7 @@ class Point_d : public R_::Kernel_base::template Type::type typedef typename R_::Kernel_base Kbase; typedef typename R_::template Type::type Vector_; typedef typename Kbase::template Functor >::type CPBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Kbase::template Functor::type CCBase; typedef Point_d Self; BOOST_STATIC_ASSERT((boost::is_same::type>::value)); @@ -35,7 +35,7 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<0> Feature_dimension; - typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; + typedef typename R_::template Iterator::type Cartesian_const_iterator; typedef typename Kbase::template Type::type Rep; const Rep& rep() const diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index b5644bce86d..1ae32dab428 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -25,7 +25,7 @@ class Point_rc_d { typedef typename R_::Kernel_base Kbase; typedef typename Kbase::template Functor >::type CPBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Kbase::template Functor::type CCBase; typedef Point_rc_d Self; BOOST_STATIC_ASSERT((boost::is_same::type>::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index c86250b1181..16eae8f2902 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -23,7 +23,7 @@ class Vector_d : public R_::Kernel_base::template Type::type typedef typename R_::Kernel_base Kbase; typedef typename R_::template Type::type Point_; typedef typename Kbase::template Functor >::type CVBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Kbase::template Functor::type CCBase; typedef Vector_d Self; BOOST_STATIC_ASSERT((boost::is_same::type>::value)); @@ -34,7 +34,7 @@ public: 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 R_::template Iterator::type Cartesian_const_iterator; typedef typename Kbase::template Type::type Rep; const Rep& rep() const diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index 419e4039a1d..70732276d8c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -22,8 +22,8 @@ template class Vector_rc_d { typedef typename R_::Kernel_base Kbase; - typedef typename Kbase::template Functor >::type CPBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Kbase::template Functor >::type CVBase; + typedef typename Kbase::template Functor::type CCBase; typedef Vector_rc_d Self; BOOST_STATIC_ASSERT((boost::is_same::type>::value)); @@ -50,7 +50,7 @@ public: #ifdef CGAL_CXX0X template::type...>,std::tuple >::value>::type> explicit Vector_rc_d(U&&...u) - : data(Eval_functor(),CPBase(),std::forward(u)...){} + : data(Eval_functor(),CVBase(),std::forward(u)...){} template explicit Vector_rc_d(Eval_functor&&,F&&f,U&&...u) : data(Eval_functor(),std::forward(f),std::forward(u)...){} @@ -62,21 +62,21 @@ public: // this one should be implicit Vector_rc_d(Null_vector const& v) - : data(Eval_functor(),CPBase(),v) {} + : data(Eval_functor(),CVBase(),v) {} Vector_rc_d(Null_vector& v) - : data(Eval_functor(),CPBase(),v) {} + : data(Eval_functor(),CVBase(),v) {} Vector_rc_d(Null_vector&& v) - : data(Eval_functor(),CPBase(),std::move(v)) {} + : data(Eval_functor(),CVBase(),std::move(v)) {} #else - Vector_rc_d() : data(Eval_functor(),CPBase()) {} + Vector_rc_d() : data(Eval_functor(),CVBase()) {} Vector_rc_d(Rep const& v) : data(v) {} // try not to use it #define CODE(Z,N,_) template \ explicit Vector_rc_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : data(Eval_functor(),CPBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ + : data(Eval_functor(),CVBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ \ template \ Vector_rc_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ @@ -87,7 +87,7 @@ public: // this one should be implicit Vector_rc_d(Null_vector const& v) - : data(Eval_functor(),CPBase(),v) {} + : data(Eval_functor(),CVBase(),v) {} #endif 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 7579ae208c0..52620ff3940 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -35,7 +35,7 @@ template result_type operator()(Iter f, Iter e)const{ - typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type c(this->kernel()); typename R::template Functor::type pd(this->kernel()); Point const& p0=*f++; int d=pd(p0); @@ -69,7 +69,7 @@ template::type c(this->kernel()); \ + typename R::template Functor::type c(this->kernel()); \ Matrix m(N,N); \ BOOST_PP_REPEAT(N,VAR2,N) \ return R::LA::sign_of_determinant(CGAL_MOVE(m)); \ @@ -98,7 +98,7 @@ template struct Orientation_of_points,true> }; template result_type operator()(P0 const&x,P&&...p)const{ static_assert(d==sizeof...(P),"Wrong number of arguments"); - typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type c(this->kernel()); return Help::type>()(c,x,std::forward_as_tuple(std::forward

(p)...)); } @@ -129,7 +129,7 @@ template struct Orientation_of_points,true> : priv typedef typename R::template Type::type Point; \ typedef typename R::Orientation result_type; \ result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ - typename R::template Functor::type c(this->kernel()); \ + typename R::template Functor::type c(this->kernel()); \ BOOST_PP_REPEAT(N,VAR4,) \ return sign_of_determinant(BOOST_PP_ENUM(N,VAR2,N)); \ } \ @@ -160,7 +160,7 @@ template struct Orientation_of_vectors : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ - typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type c(this->kernel()); typename R::template Functor::type vd(this->kernel()); Vector const& v0=*f; int d=vd(v0); @@ -258,7 +258,7 @@ template struct Side_of_oriented_sphere : private Store_kernel { template result_type operator()(Iter f, Iter const& e)const{ - typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type c(this->kernel()); typename R::template Functor::type pd(this->kernel()); Point const& p0=*f++; int d=pd(p0); @@ -423,12 +423,12 @@ template struct Compare_distance : private Store_kernel { } }; -template struct Less_cartesian_coordinate : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Less_cartesian_coordinate) +template struct Less_point_cartesian_coordinate : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Less_point_cartesian_coordinate) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Boolean result_type; - typedef typename R::template Functor::type Cc; + typedef typename R::template Functor::type Cc; // 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; @@ -440,12 +440,12 @@ template struct Less_cartesian_coordinate : private Store_kernel { } }; -template struct Compare_cartesian_coordinate : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Compare_cartesian_coordinate) +template struct Compare_point_cartesian_coordinate : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Compare_point_cartesian_coordinate) typedef R_ R; typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; - typedef typename R::template Functor::type Cc; + typedef typename R::template Functor::type Cc; // 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/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 98a089183cb..bc00c159c67 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -57,8 +57,10 @@ CGAL_Kernel_cons2(Construct_midpoint, //CGAL_Kernel_cons2(Construct_segment_extremity, // construct_segment_extremity_object) -CGAL_Kernel_comp1(Compute_cartesian_coordinate, - compute_cartesian_coordinate_object) +CGAL_Kernel_comp1(Compute_point_cartesian_coordinate, + compute_point_cartesian_coordinate_object) +CGAL_Kernel_comp1(Compute_vector_cartesian_coordinate, + compute_vector_cartesian_coordinate_object) #if 0 CGAL_Kernel_pred(Orientation, @@ -70,10 +72,10 @@ CGAL_Kernel_pred(Orientation_of_vectors, orientation_of_vectors_object) CGAL_Kernel_pred(Side_of_oriented_sphere, side_of_oriented_sphere_object) -CGAL_Kernel_pred(Less_cartesian_coordinate, - less_cartesian_coordinate_object) -CGAL_Kernel_pred(Compare_cartesian_coordinate, - compare_cartesian_coordinate_object) +CGAL_Kernel_pred(Less_point_cartesian_coordinate, + less_point_cartesian_coordinate_object) +CGAL_Kernel_pred(Compare_point_cartesian_coordinate, + compare_point_cartesian_coordinate_object) CGAL_Kernel_pred(Compare_distance, compare_distance_object) CGAL_Kernel_pred(Compare_lexicographically, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index faf717b37de..60bf7301811 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -8,6 +8,7 @@ namespace CGAL { struct Predicate_tag {}; struct Construct_tag {}; + struct Construct_iterator_tag {}; struct Compute_tag {}; struct Misc_tag {}; @@ -36,22 +37,33 @@ namespace CGAL { #undef DECL_OBJ template struct iterator_tag_traits { - enum { is_iterator = false }; + enum { is_iterator = false, has_nth_element = false }; typedef Null_tag value_tag; }; -#define DECL_ITER_OBJ(X,Y) struct X##_tag {}; \ +#define DECL_COMPUTE(X) struct X##_tag {}; \ + template<>struct map_functor_type{typedef Compute_tag type;} + DECL_COMPUTE(Compute_point_cartesian_coordinate); + DECL_COMPUTE(Compute_vector_cartesian_coordinate); + DECL_COMPUTE(Compute_homogeneous_coordinate); + DECL_COMPUTE(Compute_squared_distance); + DECL_COMPUTE(Compute_squared_length); +#undef DECL_COMPUTE + +#define DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \ template<>struct iterator_tag_traits { \ - enum { is_iterator = true }; \ + enum { is_iterator = true, has_nth_element = true }; \ typedef Y##_tag value_tag; \ + typedef Z##_tag nth_element; \ + typedef C##_tag container; \ }; \ template \ struct Typedef_tag_type : Base { typedef Obj X; }; \ template \ struct Read_tag_type { typedef typename Kernel::X type; } - DECL_ITER_OBJ(Vector_cartesian_const_iterator, FT); - DECL_ITER_OBJ(Point_cartesian_const_iterator, FT); + DECL_ITER_OBJ(Vector_cartesian_const_iterator, FT, Compute_vector_cartesian_coordinate, Vector); + DECL_ITER_OBJ(Point_cartesian_const_iterator, FT, Compute_point_cartesian_coordinate, Point); #undef DECL_ITER_OBJ templatestruct Construct_ttag {}; @@ -74,23 +86,19 @@ namespace CGAL { DECL_CONSTRUCT(Construct_sum_of_vectors,Vector); DECL_CONSTRUCT(Construct_difference_of_vectors,Vector); DECL_CONSTRUCT(Construct_opposite_vector,Vector); - DECL_CONSTRUCT(Construct_point_cartesian_const_iterator,Point_cartesian_const_iterator); - DECL_CONSTRUCT(Construct_vector_cartesian_const_iterator,Vector_cartesian_const_iterator); #undef DECL_CONSTRUCT - -#define DECL_COMPUTE(X) struct X##_tag {}; \ - template<>struct map_functor_type{typedef Compute_tag type;} - DECL_COMPUTE(Compute_cartesian_coordinate); - DECL_COMPUTE(Compute_homogeneous_coordinate); - DECL_COMPUTE(Compute_squared_distance); - DECL_COMPUTE(Compute_squared_length); -#undef DECL_COMPUTE +#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 //FIXME: choose a convention: prefix with Predicate_ ? #define DECL_PREDICATE(X) struct X##_tag {}; \ template<>struct map_functor_type{typedef Predicate_tag type;} - DECL_PREDICATE(Less_cartesian_coordinate); - DECL_PREDICATE(Compare_cartesian_coordinate); + DECL_PREDICATE(Less_point_cartesian_coordinate); + DECL_PREDICATE(Compare_point_cartesian_coordinate); DECL_PREDICATE(Compare_distance); DECL_PREDICATE(Compare_lexicographically); DECL_PREDICATE(Orientation); diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index ad7edef0d23..d83c263b98a 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -27,7 +27,7 @@ class Iterator_from_indices //FIXME: use int to save space //FIXME: use a signed type typedef std::size_t index_t; - Container_& cont; + Container_* cont; index_t index; Coord_access ca; void increment(){ ++index; } @@ -42,14 +42,15 @@ class Iterator_from_indices } Ref_ dereference()const{ //FIXME: use the functor properly - return ca(cont,index); + //Uh, and what did I mean by that? + return ca(*cont,index); } public: Iterator_from_indices(Container_& cont_,std::size_t n) - : cont(cont_), index(n) {} + : cont(&cont_), index(n) {} template Iterator_from_indices(Container_& cont_,std::size_t n,T const&t) - : cont(cont_), index(n), ca(t) {} + : cont(&cont_), index(n), ca(t) {} }; } #endif // CGAL_ITERATOR_FROM_INDICES_H diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index bc31b04fbd3..3166fd89733 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -60,7 +60,7 @@ typedef CGAL::Cartesian_wrap KK; #if 0 typedef KK K1; typedef K1::Type::type P; -typedef K1::Type::type CI; +typedef K1::Iterator::type CI; typedef K1::Type::type V; typedef K1::Type::type S; #elif 1 @@ -80,7 +80,7 @@ typedef K1::Functor::type CC typedef K1::Functor::type PO; typedef K1::Functor::type SOS; //typedef K1::Point_cartesian_const_iterator CI; -typedef K1::Functor::type CC; +typedef K1::Functor::type CC; #if 1 #define Kinit (k) From 1e22b787c377e4c352fb366d9303fdf21c46b7d5 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 27 Mar 2012 20:30:45 +0000 Subject: [PATCH 100/210] minor lazy fix. --- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 36b05ad8ed2..6f499b3cefd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -61,6 +61,9 @@ struct Lazy_cartesian : Dimension_base typename Exact_kernel::template Type::type, typename Exact_kernel::FT, E2A> type; }; + template struct Type { + typedef FT type; + }; typedef typename typeset_intersection< typename Approximate_kernel::Object_list, typename Exact_kernel::Object_list @@ -107,12 +110,12 @@ struct Lazy_cartesian : Dimension_base #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 Iterator_from_indices< const typename Type::container>::type, - //FIXME: this fails because it is not lazy enough!!! - //const typename Read_tag_type::value_tag>::type, - //typename Read_tag_type::value_tag>::type, - const FT, FT, + const V, V, typename Functor::nth_element>::type > type; }; From 7fe5e1741be2df2a60282d0e54cdc9a6ce32d4be Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 28 Mar 2012 18:22:51 +0000 Subject: [PATCH 101/210] fix iterators in lazy kernel, seems ok now --- NewKernel_d/doc_tex/NewKernel_d_ref/Point.tex | 2 +- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 4 +- .../CGAL/Kernel_d/Cartesian_change_FT.h | 8 +-- .../CGAL/Kernel_d/Kernel_object_converter.h | 4 +- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 65 +++++++++++++------ .../Kernel_d/function_objects_cartesian.h | 14 ++-- NewKernel_d/include/CGAL/functor_tags.h | 24 +++++-- NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 8 files changed, 81 insertions(+), 42 deletions(-) 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; From 0cd1fdea4cbc7fa453d8bbde2676f80d889ea880 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 11 Apr 2012 10:09:46 +0000 Subject: [PATCH 102/210] Replace pair with Segment (lazier) in preparation for the switch away from Type<>. Used an implementation that was there, but it should probably derive from std::pair instead. --- .../include/CGAL/Kernel_d/Define_segment.h | 19 +++++++++++-------- NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 19 +++++++++++-------- NewKernel_d/include/CGAL/marcutils.h | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 24fe623af6d..73f0900ff40 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace CGAL { namespace CartesianDKernelFunctors { @@ -21,9 +22,9 @@ template struct Construct_segment { template result_type operator()(CGAL_FORWARDABLE(T),CGAL_FORWARDABLE(U) u,CGAL_FORWARDABLE(V) v)const{ CP cp(this->kernel()); - result_type r = { + result_type r = {{ call_on_tuple_elements(cp, CGAL_FORWARD(U,u)), - call_on_tuple_elements(cp, CGAL_FORWARD(V,v)) }; + call_on_tuple_elements(cp, CGAL_FORWARD(V,v)) }}; return r; } }; @@ -36,15 +37,15 @@ template struct Construct_segment_extremity { typedef typename R_::template Type::type Segment; typedef Point result_type; result_type operator()(Segment const&s, int i)const{ - if(i==0) return s.first; + if(i==0) return s.source(); CGAL_assertion(i==1); - return s.second; + return s.target(); } #ifdef CGAL_CXX0X result_type operator()(Segment &&s, int i)const{ - if(i==0) return std::move(s.first); + if(i==0) return std::move(s.source()); CGAL_assertion(i==1); - return std::move(s.second); + return std::move(s.target()); } #endif }; @@ -58,9 +59,11 @@ struct Define_segment : public Base_ { template struct Type : Base_::template Type {}; template struct Type { - typedef typename Derived::template Type::type Point; - typedef std::pair type; + //typedef typename Derived::template Type::type Point; + //typedef std::pair type; + typedef SegmentCd type; }; + typedef typename Type::type Segment; typedef typename Base::Object_list::template add::type Object_list; // TODO: forward the second Functor argument (like fast, no_filter) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index 385d3278886..d7abc9bc1a2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -7,34 +7,37 @@ namespace CGAL { template class Segmentd { typedef typename R_::FT FT_; typedef typename R_::template Type::type Point_; - typedef typename R_::template Type::type Vector_; - typedef typename R_::template Functor >::type Cv_; + //typedef typename R_::template Type::type Vector_; + //typedef typename R_::template Functor >::type Cv_; // typedef typename R_::Compute_squared_distance Csd_; typedef std::pair Data_; Data_ data; public: typedef Segmentd Segment; #ifdef CGAL_CXX0X + //FIXME: don't forward directly, piecewise_constuct should call the point construction functor (I guess? or is it unnecessary?) template::type...>,std::tuple>::value>::type> Segmentd(U&&...u):data(std::forward(u)...){} #else Segmentd(){} Segmentd(Point_ const&a, Point_ const&b): data(a,b) {} + //template + //Segmentd(A const&,T1 const&t1,T2 const&t2) #endif Point_ source()const{return data.first;} Point_ target()const{return data.second;} Point_ operator[](int i)const{ if((i%2)==0) - return data.first; + return source(); else - return data.second; + return target(); } Segmentd opposite()const{ - return Segmentd(data.second,data.first); - } - Vector_ vector()const{ - return Cv_()(data.first,data.second); + return Segmentd(target(),source()); } + //Vector_ vector()const{ + // return Cv_()(data.first,data.second); + //} // FT_ squared_length()const{ // return Csd_()(data.first,data.second); // } diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 36ac489124d..81e49662861 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -200,6 +200,25 @@ BOOST_PP_REPEAT_FROM_TO(0, 8, CODE, _ ) #undef CODE #undef VAR #endif + + template struct Factory { + typedef A result_type; +#ifdef CGAL_CXX0X + template result_type operator()(U&&...u)const{ + return A(std::forward(u)...); + } +#else + result_type operator()()const{ + return A(); + } +#define CODE(Z,N,_) template \ + result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ + return A(BOOST_PP_ENUM_PARAMS(N,u)); \ + } +BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) +#undef CODE +#endif + }; } #endif From 7c91385b878c714bba9b38d0b578dcb203f15bd6 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 12 Apr 2012 16:31:14 +0000 Subject: [PATCH 103/210] Remove Type<>. This should make users' life easier (although not mine...). --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 15 --- .../CGAL/Kernel_d/Cartesian_change_FT.h | 14 +-- .../CGAL/Kernel_d/Cartesian_complete.h | 12 ++- .../CGAL/Kernel_d/Cartesian_static_filters.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 8 +- .../include/CGAL/Kernel_d/Define_segment.h | 16 +--- .../include/CGAL/Kernel_d/KernelD_converter.h | 7 +- .../CGAL/Kernel_d/Kernel_2_interface.h | 4 +- .../CGAL/Kernel_d/Kernel_3_interface.h | 6 +- .../CGAL/Kernel_d/Kernel_d_interface.h | 6 +- .../CGAL/Kernel_d/Kernel_object_converter.h | 18 ++-- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 91 ++++++++++--------- NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 4 +- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 15 +-- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 10 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 4 +- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 8 +- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 10 +- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 4 +- .../Kernel_d/function_objects_cartesian.h | 24 ++--- NewKernel_d/include/CGAL/functor_tags.h | 10 +- NewKernel_d/test/NewKernel_d/test.cpp | 3 +- 22 files changed, 148 insertions(+), 143 deletions(-) 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 87fbced7624..465fa7c5e8a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -54,21 +54,6 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typename Vector_selector::const_iterator Point_cartesian_const_iterator; typedef typename Vector_selector::const_iterator Vector_cartesian_const_iterator; - template struct Type {}; - template struct Type { - typedef Vector type; - }; - template struct Type { - typedef Point type; - }; - template struct Iterator {}; - template struct Iterator { - typedef typename Vector_selector::const_iterator type; - }; - template struct Iterator { - typedef typename Vector_selector::const_iterator type; - }; - typedef typeset ::add::type Object_list; 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 b7172ba543c..580f7ddd6ac 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -39,20 +39,22 @@ struct Cartesian_change_FT_base : public typedef NT_converter FT_converter; typedef transforming_iterator Point_cartesian_const_iterator; typedef transforming_iterator Vector_cartesian_const_iterator; - + //FIXME: use Iterator_list! + /* template::value_tag,FT_tag>::value> - struct Type : Kernel_base::template Type {}; - template struct Type { - typedef transforming_iterator::type> type; + struct Iterator : Read_tag_type {}; + template struct Iterator { + typedef transforming_iterator::type> type; }; + */ - template + template struct Construct_cartesian_const_iterator_ { typedef typename Kernel_base::template Functor::type Functor_base; Construct_cartesian_const_iterator_(){} Construct_cartesian_const_iterator_(Self const&r):f(r){} Functor_base f; - typedef Type result_type; + typedef Type_ result_type; template result_type operator()(T const& v, Begin_tag)const{ return make_transforming_iterator(f(v,Begin_tag()),FT_converter()); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 25ff38b6ef9..5c04b6ddb84 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -45,15 +45,21 @@ template struct Cartesian_define_all_functors template struct Cartesian_complete_types : public R_ { +#if 0 typedef R_ Kernel_base; typedef typename Default::Get::type Derived; - template struct Type : Kernel_base::template Type {}; + template struct Type : Read_tag_type {}; #define CGAL_Kernel_obj2(X,Y) \ template struct Type { \ - typedef typename Kernel_base::template Type B_; \ - typedef typename boost::mpl::if_c::value,Wrap_type >,B_>::type::type type; \ + static const bool inbase = \ + Provides_tag_type::value; \ + typedef typename Read_tag_type B_; \ + typedef typename boost::mpl::if_c >,B_>::type::type type; \ }; + //FIXME: move away from Type<> + //Implement by chaining things like Define_segment? #include +#endif }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 7b214f82230..4169ce90b61 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -11,7 +11,7 @@ namespace SFA { // static filter adapter // Note that this would be quite a bit simpler without stateful kernels template struct Orientation_of_points_2 : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); - typedef typename R_::template Type::type Point; + typedef typename R_::Point Point; typedef typename R_::Orientation result_type; typedef typename R_::FT FT; typedef typename R_::template Functor::type CC; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 78f5e9a10e3..46e928b4fd3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -17,7 +17,7 @@ template struct Construct_flat_orientation : private Store_kernel CGAL_FUNCTOR_INIT_STORE(Construct_flat_orientation) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::template Functor::type CCC; typedef typename R::LA LA; typedef typename Increment_dimension::type Dplusone; @@ -71,7 +71,7 @@ template struct Contained_in_affine_hull : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::LA LA; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::Orientation result_type; typedef typename R::template Functor::type CCC; typedef typename R::template Functor::type PD; @@ -127,7 +127,7 @@ template struct In_flat_orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(In_flat_orientation) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::Orientation result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; @@ -164,7 +164,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel CGAL_FUNCTOR_INIT_STORE(In_flat_side_of_oriented_sphere) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::Orientation result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 73f0900ff40..d732a83c55e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -11,8 +11,8 @@ namespace CartesianDKernelFunctors { template struct Construct_segment { CGAL_FUNCTOR_INIT_IGNORE(Construct_segment) typedef R_ R; - typedef typename R_::template Type::type Point; - typedef typename R_::template Type::type Segment; + typedef typename R_::Point Point; + typedef typename R_::Segment Segment; typedef typename R_::template Functor >::type CP; typedef Segment result_type; result_type operator()(Point const&a, Point const&b)const{ @@ -33,8 +33,8 @@ template struct Construct_segment { template struct Construct_segment_extremity { CGAL_FUNCTOR_INIT_IGNORE(Construct_segment_extremity) typedef R_ R; - typedef typename R_::template Type::type Point; - typedef typename R_::template Type::type Segment; + typedef typename R_::Point Point; + typedef typename R_::Segment Segment; typedef Point result_type; result_type operator()(Segment const&s, int i)const{ if(i==0) return s.source(); @@ -57,13 +57,7 @@ struct Define_segment : public Base_ { typedef Define_segment Self; typedef typename Default::Get::type Derived; - template struct Type : Base_::template Type {}; - template struct Type { - //typedef typename Derived::template Type::type Point; - //typedef std::pair type; - typedef SegmentCd type; - }; - typedef typename Type::type Segment; + typedef SegmentCd Segment; typedef typename Base::Object_list::template add::type Object_list; // TODO: forward the second Functor argument (like fast, no_filter) diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index e45f3fa4de2..1e8d3f3fc2a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -18,7 +18,8 @@ namespace CGAL { namespace internal { // Reverses order, but that shouldn't matter. template struct Map_taglist_to_typelist : - Map_taglist_to_typelist::type::template add::type> + Map_taglist_to_typelist::type + ::template add::type> {}; template struct Map_taglist_to_typelist > : typeset<> {}; } @@ -54,8 +55,8 @@ class KernelD_converter_ typedef typename List::head Tag; typedef typename List::tail Rest; typedef KernelD_converter_ Base; - typedef typename K1::template Type::type K1_Obj; - typedef typename K2::template Type::type K2_Obj; + typedef typename Read_tag_type::type K1_Obj; + typedef typename Read_tag_type::type K2_Obj; typedef typename K1::template Functor >::type K1_Conv; typedef KO_converter KOC; typedef BOOSTD is_same no_converter; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h index a4b02bd9766..da2ed015f0a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -11,8 +11,8 @@ namespace CGAL { template struct Kernel_2_interface : public Base_ { typedef Base_ Base; typedef Kernel_2_interface Kernel; - typedef typename Base::template Type::type Point_2; - typedef typename Base::template Type::type Vector_2; + typedef typename Base::Point Point_2; + typedef typename Base::Vector Vector_2; struct Segment_2 {}; typedef cpp0x::tuple Triangle_2; // triangulation insists... template struct Help_2p_i { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h index 2fb2ad8e081..f9334f20515 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h @@ -11,9 +11,9 @@ namespace CGAL { template struct Kernel_3_interface : public Base_ { typedef Base_ Base; typedef Kernel_3_interface Kernel; - typedef typename Base::template Type::type Point_3; - typedef typename Base::template Type::type Vector_3; - typedef typename Base::template Type::type Segment_3; + typedef typename Base::Point Point_3; + typedef typename Base::Vector Vector_3; + typedef typename Base::Segment Segment_3; typedef cpp0x::tuple Triangle_3; // placeholder typedef cpp0x::tuple Tetrahedron_3; // placeholder struct Compare_xyz_3 { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 2466a0a3558..8f1526f9947 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -12,9 +12,9 @@ template struct Kernel_d_interface : public Base_ { typedef Base_ Base; typedef Kernel_d_interface Kernel; typedef typename Base::Flat_orientation Flat_orientation_d; - typedef typename Base::template Type::type Point_d; - typedef typename Base::template Type::type Vector_d; - //typedef typename Base::template Type::type Segment_d; + typedef typename Base::Point Point_d; + typedef typename Base::Vector Vector_d; + //typedef typename Base::Segment Segment_d; typedef typename Base::template Functor::type Compare_lexicographically_d; typedef typename Base::template Functor::type Orientation_d; typedef typename Base::template Functor::type Side_of_oriented_sphere_d; 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 e21f0690bd1..f66f5ba226d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -12,8 +12,8 @@ template struct KO_converter; namespace internal { template struct Point_converter_help { - typedef typename K1::template Type::type argument_type; - typedef typename K2::template Type::type result_type; + typedef typename K1::Point argument_type; + typedef typename K2::Point 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); @@ -26,8 +26,8 @@ struct Point_converter_help { // the iterators just as efficiently. template struct Point_converter_help,K1,K2> { - typedef typename K1::template Type::type argument_type; - typedef typename K2::template Type::type result_type; + typedef typename K1::Point argument_type; + typedef typename K2::Point result_type; template result_type help(Indices, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { typename K1::template Functor::type cc(k1); @@ -46,15 +46,15 @@ template struct KO_converter {}; template struct KO_converter{ - typedef typename K1::template Type::type K1_Vector; + typedef typename K1::Vector K1_Vector; // Disabling is now done in KernelD_converter // // can't use vector without at least a placeholder point because of this - // typedef typename K1::template Type< Point_tag>::type K1_Point; + // typedef typename K1:: Point K1_Point; // typedef typename First_if_different::Type argument_type; typedef K1_Vector argument_type; - typedef typename K2::template Type::type result_type; + typedef typename K2::Vector 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); @@ -64,8 +64,8 @@ template struct KO_converter{ }; template struct KO_converter{ - typedef typename K1::template Type::type argument_type; - typedef typename K2::template Type::type result_type; + typedef typename K1::Segment argument_type; + typedef typename K2::Segment result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { typename K1::template Functor::type f(k1); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index b4caa5ab14d..37031a84f8c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace CGAL { @@ -40,8 +41,52 @@ namespace internal { }; } +template +struct Lazy_cartesian_types +{ + typedef typename typeset_intersection< + typename AK_::Object_list, + typename EK_::Object_list + >::type Object_list; + + typedef typename typeset_intersection< + typename AK_::Iterator_list, + typename EK_::Iterator_list + >::type Iterator_list; + + template struct Type { + typedef Lazy< + typename Read_tag_type::type, + typename Read_tag_type::type, + typename EK_::FT, E2A_> type; + }; + template struct Type { + typedef CGAL::Lazy_exact_nt type; + }; + template struct Type { + typedef CGAL::Lazy_exact_nt type; + }; + + template struct Iterator { + 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, nth_elem + > type; + }; +}; + template -struct Lazy_cartesian : Dimension_base +struct Lazy_cartesian : Dimension_base, + Define_kernel_types > > { //CGAL_CONSTEXPR Lazy_cartesian(){} //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} @@ -54,7 +99,8 @@ struct Lazy_cartesian : Dimension_base AK_ const& approximate_kernel()const{return ak;} EK_ const& exact_kernel()const{return ek;} - typedef Lazy_cartesian Self; + typedef Lazy_cartesian Self; + typedef Define_kernel_types > Base; //typedef typename Default::Get::type Kernel; typedef Self Kernel; typedef AK_ Approximate_kernel; @@ -85,24 +131,6 @@ struct Lazy_cartesian : Dimension_base typedef typename Same_uncertainty_nt::type Angle; - // Doesn't look like we need an explicit list. - template struct Type { - typedef Lazy< - typename Approximate_kernel::template Type::type, - typename Exact_kernel::template Type::type, - typename Exact_kernel::FT, E2A> type; - }; - 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 - >::type Object_list; - template::type> struct Functor { typedef Null_functor type; }; @@ -123,27 +151,6 @@ struct Lazy_cartesian : Dimension_base typedef Lazy_construction type; }; - typedef typename typeset_intersection< - typename Approximate_kernel::Iterator_list, - typename Exact_kernel::Iterator_list - >::type Iterator_list; - - - template struct Iterator { - 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, nth_elem - > type; - }; //typedef typename Iterator::type Point_cartesian_const_iterator; //typedef typename Iterator::type Vector_cartesian_const_iterator; @@ -163,7 +170,7 @@ struct Lazy_cartesian : Dimension_base } }; template struct Functor { - typedef Construct_iter::type>::type> type; + typedef Construct_iter::type>::type> type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index d7abc9bc1a2..8b2ea70ef7e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -6,8 +6,8 @@ namespace CGAL { template class Segmentd { typedef typename R_::FT FT_; - typedef typename R_::template Type::type Point_; - //typedef typename R_::template Type::type Vector_; + typedef typename R_::Point Point_; + //typedef typename R_::Vector Vector_; //typedef typename R_::template Functor >::type Cv_; // typedef typename R_::Compute_squared_distance Csd_; typedef std::pair Data_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 0cc02876a9f..838e4d9c3a9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -82,10 +82,9 @@ struct Cartesian_wrap : public Base_ typedef Base_ Kernel_base; typedef Cartesian_wrap Self; - templatestruct Type : Kernel_base::template Type {}; - #define CGAL_Kernel_obj(X,Y) \ - templatestruct Type { typedef X##_d type; }; + typedef X##_d X; + CGAL_Kernel_obj(Segment,segment) //TODO: use Object_list, intersected with the list of objects that do have a wrapper available. #include @@ -127,7 +126,7 @@ struct Cartesian_wrap : public Base_ type(){} type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; - typedef typename Self::template Type::type result_type; + typedef typename Read_tag_type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); @@ -155,9 +154,11 @@ struct Cartesian_refcount : public Base_ typedef Base_ Kernel_base; typedef Cartesian_refcount Self; - templatestruct Type : Kernel_base::template Type {}; + //FIXME: Use object_list (or a list passed as argument) + //TODO: A generic object wrapper should work just fine, no need to have a different one for each type. #define CGAL_Kernel_obj(X,Y) \ - templatestruct Type { typedef X##_rc_d type; }; + typedef X##_rc_d X; + CGAL_Kernel_obj(Point,point) CGAL_Kernel_obj(Vector,vector) #undef CGAL_Kernel_obj @@ -211,7 +212,7 @@ struct Cartesian_refcount : public Base_ type(){} type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; - typedef typename Self::template Type::type result_type; + typedef typename Read_tag_type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 3f99b2cc77a..4ef9701fe0e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -16,18 +16,18 @@ namespace CGAL { template -class Point_d : public R_::Kernel_base::template Type::type +class Point_d : public R_::Kernel_base::Point // Deriving won't work if the point is just a __m256d. { typedef typename R_::RT RT_; typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::template Type::type Vector_; + typedef typename R_::Vector Vector_; typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor::type CCBase; typedef Point_d Self; - BOOST_STATIC_ASSERT((boost::is_same::type>::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); public: @@ -35,8 +35,8 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<0> Feature_dimension; - typedef typename R_::template Iterator::type Cartesian_const_iterator; - typedef typename Kbase::template Type::type Rep; + typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; + typedef typename Kbase::Point Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index 1ae32dab428..7112eccaa77 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -28,7 +28,7 @@ class Point_rc_d typedef typename Kbase::template Functor::type CCBase; typedef Point_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::type>::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); public: typedef R_ R; @@ -38,7 +38,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::template Type::type Rep; + typedef typename Kbase::Point Rep; typedef Handle_for Data; private: diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 1a9accc7313..6376b66b390 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -16,18 +16,18 @@ namespace CGAL { template -class Segment_d : public R_::Kernel_base::template Type::type +class Segment_d : public R_::Kernel_base::Segment { typedef typename R_::RT RT_; typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::template Type::type Point_; + typedef typename R_::Point Point_; typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor >::type CSBase; typedef typename Kbase::template Functor::type CSEBase; typedef Segment_d Self; - BOOST_STATIC_ASSERT((boost::is_same::type>::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); public: @@ -35,7 +35,7 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<1> Feature_dimension; - typedef typename Kbase::template Type::type Rep; + typedef typename Kbase::Segment Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 16eae8f2902..d5c25244524 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -16,17 +16,17 @@ namespace CGAL { template -class Vector_d : public R_::Kernel_base::template Type::type +class Vector_d : public R_::Kernel_base::Vector { typedef typename R_::RT RT_; typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::template Type::type Point_; + typedef typename R_::Point Point_; typedef typename Kbase::template Functor >::type CVBase; typedef typename Kbase::template Functor::type CCBase; typedef Vector_d Self; - BOOST_STATIC_ASSERT((boost::is_same::type>::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); public: @@ -34,8 +34,8 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<0> Feature_dimension; - typedef typename R_::template Iterator::type Cartesian_const_iterator; - typedef typename Kbase::template Type::type Rep; + typedef typename R_::Vector_cartesian_const_iterator Cartesian_const_iterator; + typedef typename Kbase::Vector Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index 70732276d8c..c9ff7db3efd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -26,7 +26,7 @@ class Vector_rc_d typedef typename Kbase::template Functor::type CCBase; typedef Vector_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::type>::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); public: typedef R_ R; @@ -36,7 +36,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Vector_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::template Type::type Rep; + typedef typename Kbase::Vector Rep; typedef Handle_for Data; private: 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 b66cff756d3..95bda72a62f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -29,7 +29,7 @@ template::type Point; + typedef typename R::Point Point; typedef typename R::Orientation result_type; typedef typename R::LA::template Matrix::type Matrix; @@ -88,7 +88,7 @@ template struct Orientation_of_points,true> CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::Orientation result_type; templatestruct Help; templatestruct Help > { @@ -126,7 +126,7 @@ template struct Orientation_of_points,true> : priv CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) \ typedef R_ R; \ typedef typename R_::FT FT; \ - typedef typename R::template Type::type Point; \ + typedef typename R::Point Point; \ typedef typename R::Orientation result_type; \ result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ typename R::template Functor::type c(this->kernel()); \ @@ -154,7 +154,7 @@ template struct Orientation_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Vector; + typedef typename R::Vector Vector; typedef typename R::Orientation result_type; typedef typename R::LA::template Matrix::type Matrix; @@ -250,7 +250,7 @@ template struct Side_of_oriented_sphere : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::Oriented_side result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; @@ -298,7 +298,7 @@ template struct Construct_opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_opposite_vector) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Vector; + typedef typename R::Vector Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor >::type CI; typedef Vector result_type; @@ -313,7 +313,7 @@ template struct Construct_sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_sum_of_vectors) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Vector; + typedef typename R::Vector Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor >::type CI; typedef Vector result_type; @@ -329,7 +329,7 @@ template struct Construct_difference_of_vectors : private Store_kernel CGAL_FUNCTOR_INIT_STORE(Construct_difference_of_vectors) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Vector; + typedef typename R::Vector Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor >::type CI; typedef Vector result_type; @@ -345,7 +345,7 @@ template struct Construct_midpoint : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_midpoint) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::template Functor >::type CP; typedef typename R::template Functor >::type CI; typedef Point result_type; @@ -368,7 +368,7 @@ template struct Compute_squared_length : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compute_squared_length) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Vector; + typedef typename R::Vector Vector; typedef typename R::template Functor >::type CI; typedef FT result_type; typedef Vector argument_type; @@ -384,7 +384,7 @@ template struct Compute_squared_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compute_squared_distance) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::template Functor >::type CI; typedef FT result_type; typedef Point first_argument_type; @@ -406,7 +406,7 @@ template struct Compare_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_distance) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::template Type::type Point; + typedef typename R::Point Point; typedef typename R::template Functor::type CSD; typedef typename R_::Comparison_result result_type; typedef Point first_argument_type; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 276385ae3af..acde16fd402 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -1,5 +1,6 @@ #ifndef CGAL_FUNCTOR_TAGS_H #define CGAL_FUNCTOR_TAGS_H +#include namespace CGAL { class Null_type {~Null_type();}; // no such object should be created @@ -19,12 +20,16 @@ namespace CGAL { template struct map_functor_type { typedef Misc_tag type; }; template struct Typedef_tag_type; - template struct Read_tag_type; + template struct Read_tag_type {}; + template struct Provides_tag_type; #define DECL_OBJ(X) struct X##_tag {}; \ template \ struct Typedef_tag_type : Base { typedef Obj X; }; \ + namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } \ + template \ + struct Provides_tag_type : has_object::has_##X {}; \ template \ struct Read_tag_type { typedef typename Kernel::X type; } @@ -68,6 +73,9 @@ namespace CGAL { }; \ template \ struct Typedef_tag_type : Base { typedef Obj X; }; \ + namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } \ + template \ + struct Provides_tag_type : has_object::has_##X {}; \ template \ struct Read_tag_type { typedef typename Kernel::X type; } diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index bbc46f8ee43..46318b98c77 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -64,7 +64,8 @@ typedef K1::Iterator::type CI; typedef K1::Type::type V; typedef K1::Type::type S; #elif 1 -typedef CGAL::Define_kernel_types K1; +//typedef CGAL::Define_kernel_types K1; +typedef KK K1; typedef K1::Point P; typedef K1::Point_cartesian_const_iterator CI; typedef K1::Vector V; From dee3b16c296bfaf1d04b98fe8f923a1b1cdb2c64 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 16 Apr 2012 16:18:56 +0000 Subject: [PATCH 104/210] LA has a fixed dimension + rebind, as Samuel did. Fold Vector back into LA (partially). --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 15 +- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 5 +- .../CGAL/Kernel_d/Cartesian_change_FT.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 18 ++- .../Kernel_d/function_objects_cartesian.h | 11 +- NewKernel_d/include/CGAL/LA_eigen/LA.h | 89 ++++++----- .../include/CGAL/LA_eigen/constructors.h | 148 ++++++++++-------- NewKernel_d/include/CGAL/Vector/array.h | 50 +++--- NewKernel_d/include/CGAL/Vector/eigen.h | 2 +- NewKernel_d/include/CGAL/Vector/vector.h | 55 ++++--- 10 files changed, 223 insertions(+), 172 deletions(-) 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 465fa7c5e8a..3064d5a2656 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -19,7 +19,8 @@ namespace CGAL { -template < typename FT_, typename Dim_, typename Vec_=Array_vector, typename LA_=LA_eigen > +template < typename FT_, typename Dim_, typename Vec_=Array_vector, typename LA_=LA_eigen > + /* Default LA to Vec or to LA_eigen? */ struct Cartesian_LA_base_d : public Dimension_base { typedef FT_ FT; @@ -47,12 +48,12 @@ struct Cartesian_LA_base_d : public Dimension_base Angle; typedef Vec_ Vector_selector; - typedef typename Vector_selector::type Point; - typedef typename Vector_selector::type Vector; - typedef typename Vector_selector::type Vector_; - typedef typename Vector_selector::Constructor Constructor; - typedef typename Vector_selector::const_iterator Point_cartesian_const_iterator; - typedef typename Vector_selector::const_iterator Vector_cartesian_const_iterator; + typedef typename Vector_selector::Vector Point; + typedef typename Vector_selector::Vector Vector; + typedef typename Vector_selector::Vector Vector_; + typedef typename Vector_selector::Construct_vector Constructor; + typedef typename Vector_selector::Vector_const_iterator Point_cartesian_const_iterator; + typedef typename Vector_selector::Vector_const_iterator Vector_cartesian_const_iterator; typedef typeset ::add::type diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 5c5272abb1c..60895b4f23b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -214,8 +214,9 @@ template struct PV_dimension { typedef int result_type; typedef Tag_true Is_exact; - // take a template argument instead? - result_type operator()(argument_type const& v)const{ + template + result_type operator()(T const& v) const { + //FIXME: size_of_vector comes from Vector, not LA return R::LA::size_of_vector(v); } }; 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 580f7ddd6ac..6a5646ed35a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -8,7 +8,7 @@ namespace CGAL { -template < typename Base_, typename FT_, typename LA_=CGAL::LA_eigen > +template < typename Base_, typename FT_, typename LA_=CGAL::LA_eigen > struct Cartesian_change_FT_base : public Base_ { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 46e928b4fd3..7037a887749 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -19,9 +19,9 @@ template struct Construct_flat_orientation : private Store_kernel typedef typename R_::FT FT; typedef typename R::Point Point; typedef typename R::template Functor::type CCC; - typedef typename R::LA LA; typedef typename Increment_dimension::type Dplusone; - typedef typename LA::template Matrix::type Matrix; + typedef typename R::LA::template Rebind_dimension::Other LA; + typedef typename LA::Square_matrix Matrix; typedef typename R::template Functor::type PD; typedef Flat_orientation result_type; @@ -70,14 +70,14 @@ template struct Contained_in_affine_hull : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Contained_in_affine_hull) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::LA LA; typedef typename R::Point Point; typedef typename R::Orientation result_type; typedef typename R::template Functor::type CCC; typedef typename R::template Functor::type PD; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; - typedef typename LA::template Matrix::type Matrix; + typedef typename R::LA::template Rebind_dimension::Other LA; + typedef typename LA::Square_matrix Matrix; // mostly copied from Construct_flat_orientation. TODO: dedup this code. template @@ -131,7 +131,8 @@ template struct In_flat_orientation : private Store_kernel { typedef typename R::Orientation result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; - typedef typename R::LA::template Matrix::type Matrix; + typedef typename R::LA::template Rebind_dimension::Other LA; + typedef typename LA::Square_matrix Matrix; template result_type operator()(Flat_orientation const&o, Iter f, Iter e) const { @@ -156,7 +157,7 @@ template struct In_flat_orientation : private Store_kernel { if(*it != d) m(i,1+*it)=1; } - return R::LA::sign_of_determinant(CGAL_MOVE(m)); + return LA::sign_of_determinant(CGAL_MOVE(m)); } }; @@ -168,7 +169,8 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel typedef typename R::Orientation result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; - typedef typename R::LA::template Matrix::type Matrix; + typedef typename R::LA::template Rebind_dimension::Other LA; + typedef typename LA::Square_matrix Matrix; template result_type operator()(Flat_orientation const&o, Iter f, Iter e, Point const&x) const { @@ -202,7 +204,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel m(d+1,d+1)+=CGAL_NTS square(m(d+1,j+1)); } - return R::LA::sign_of_determinant(CGAL_MOVE(m)); + return LA::sign_of_determinant(CGAL_MOVE(m)); } }; 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 95bda72a62f..8e23736ac62 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -31,7 +31,7 @@ template::type Matrix; + typedef typename R::LA::Square_matrix Matrix; template result_type operator()(Iter f, Iter e)const{ @@ -156,7 +156,7 @@ template struct Orientation_of_vectors : private Store_kernel { typedef typename R_::FT FT; typedef typename R::Vector Vector; typedef typename R::Orientation result_type; - typedef typename R::LA::template Matrix::type Matrix; + typedef typename R::LA::Square_matrix Matrix; template result_type operator()(Iter f, Iter e)const{ @@ -227,7 +227,7 @@ template struct Orientation : private Store_kernel { typedef typename R::Orientation result_type; typedef typename R::template Functor::type OP; typedef typename R::template Functor::type OV; - typedef typename R::LA::template Matrix::type Matrix; + typedef typename R::LA::Square_matrix Matrix; //FIXME!!! //when Point and Vector are distinct types, the dispatch should be made @@ -254,7 +254,8 @@ template struct Side_of_oriented_sphere : private Store_kernel { typedef typename R::Oriented_side result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; - typedef typename R::LA::template Matrix::type Matrix; + typedef typename R::LA::template Rebind_dimension::Other LA; + typedef typename LA::Square_matrix Matrix; template result_type operator()(Iter f, Iter const& e)const{ @@ -276,7 +277,7 @@ template struct Side_of_oriented_sphere : private Store_kernel { m(i,d)+=CGAL::square(x); } } - return R::LA::sign_of_determinant(CGAL_MOVE(m)); + return LA::sign_of_determinant(CGAL_MOVE(m)); } #ifdef CGAL_CXX0X diff --git a/NewKernel_d/include/CGAL/LA_eigen/LA.h b/NewKernel_d/include/CGAL/LA_eigen/LA.h index 4e40b9b2930..c51ea3238b5 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/LA_eigen/LA.h @@ -14,46 +14,56 @@ namespace CGAL { //FIXME: where could we use Matrix_base instead of Matrix? -template struct LA_eigen { +// Dim_ real dimension +// Max_dim_ upper bound on the dimension +template struct LA_eigen { typedef NT_ NT; - // Dim_ real dimension - // Max_dim_ upper bound on the dimension - template struct Vector { - typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> type; - typedef Construct_eigen Constructor; -#if (EIGEN_WORLD_VERSION>=3) - typedef NT const* const_iterator; -#else - typedef Iterator_from_indices const_iterator; -#endif - - templatestatic const_iterator vector_begin(Vec_ const&a){ -#if (EIGEN_WORLD_VERSION>=3) - return &a[0]; -#else - return const_iterator(a,0); -#endif - } - - templatestatic const_iterator vector_end(Vec_ const&a){ -#if (EIGEN_WORLD_VERSION>=3) - return &a[0]+a.size(); -#else - return const_iterator(a,a.size()); -#endif - } - + typedef Dim_ Dimension; + typedef Max_dim_ Max_dimension; + enum { dimension = Eigen_dimension::value }; + enum { max_dimension = Eigen_dimension::value }; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef LA_eigen< NT, D2, D3 > Other; }; - template struct Matrix { + template struct Property : boost::false_type {}; + + typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> Vector; + typedef Eigen::Matrix Dynamic_vector; + typedef Construct_eigen Construct_vector; + +#if (EIGEN_WORLD_VERSION>=3) + typedef NT const* Vector_const_iterator; +#else + typedef Iterator_from_indices Vector_const_iterator; +#endif + + templatestatic Vector_const_iterator vector_begin(Vec_ const&a){ +#if (EIGEN_WORLD_VERSION>=3) + return &a[0]; +#else + return Vector_const_iterator(a,0); +#endif + } + + templatestatic Vector_const_iterator vector_end(Vec_ const&a){ +#if (EIGEN_WORLD_VERSION>=3) + return &a[0]+a.size(); +#else + return Vector_const_iterator(a,a.size()); +#endif + } + + typedef Eigen::Matrix Square_matrix; + typedef Eigen::Matrix Dynamic_matrix; //TODO: don't pass on the values of Max_* for an expensive NT - typedef Eigen::Matrix::value,Eigen_dimension::value,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,Eigen_dimension::value> type; // typedef ... Constructor // typedef ... Accessor - }; +#if 0 private: template class Canonicalize_vector { typedef typename Dimension_eigen::type S1; @@ -62,6 +72,7 @@ template struct LA_eigen { typedef typename Vector::type type; }; public: +#endif templatestatic int size_of_vector(Vec_ const&v){ return v.size(); @@ -82,17 +93,17 @@ template struct LA_eigen { return CGAL::sign(m.determinant()); } - template static typename Canonicalize_vector::type homogeneous_add(Vec1 const&a,Vec2 const&b){ + template static Vector homogeneous_add(Vec1 const&a,Vec2 const&b){ //TODO: use compile-time size when available int d=a.size(); - typename Canonicalize_vector::type v(d); + Vector v(d); v << b[d-1]*a.topRows(d-1)+a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; return v; } - template static typename Canonicalize_vector::type homogeneous_sub(Vec1 const&a,Vec2 const&b){ + template static Vector homogeneous_sub(Vec1 const&a,Vec2 const&b){ int d=a.size(); - typename Canonicalize_vector::type v(d); + Vector v(d); v << b[d-1]*a.topRows(d-1)-a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; return v; } diff --git a/NewKernel_d/include/CGAL/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/LA_eigen/constructors.h index ee44a1e4513..accee085f0e 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/LA_eigen/constructors.h @@ -1,111 +1,133 @@ #ifndef ecs_h #define ecs_h + +#ifndef CGAL_USE_EIGEN +#error Requires Eigen +#endif +#include +#include +#include +#include +#include #include #include #include #include namespace CGAL { -template struct Construct_eigen { - typedef Vector_ result_type; - typedef typename Vector_::Scalar NT; + template struct Construct_eigen { + typedef Vector_ result_type; + typedef typename Vector_::Scalar NT; - struct Dimension { - result_type operator()(int d) const { - return result_type(d); - } - }; + private: + static void check_dim(int d){ + int m = result_type::MaxSizeAtCompileTime; + CGAL_assertion((m == Eigen::Dynamic) || (d <= m)); + // could omit the first check since they use a big value for Dynamic. + } + public: - struct Iterator { - template + struct Dimension { + // Initialize with NaN if possible? + result_type operator()(int d) const { + check_dim(d); + return result_type(d); + } + }; + + struct Iterator { + template result_type operator()(int d,Iter const& f,Iter const& e) const { - CGAL_assertion(d==std::distance(f,e)); - //FIXME: the std::min is useless? it causes problems for intel/clang - CGAL_assertion(d<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); - result_type a(d); - // TODO: check the right way to do this - std::copy(f,e,&a[0]); - return a; + check_dim(d); + CGAL_assertion(d==std::distance(f,e)); + result_type a(d); + // TODO: check the right way to do this + std::copy(f,e,&a[0]); + return a; } - }; + }; #if 0 - struct Iterator_add_one { - template + struct Iterator_add_one { + template result_type operator()(int d,Iter const& f,Iter const& e) const { - CGAL_assertion(d==std::distance(f,e)+1); - CGAL_assertion(d<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); - result_type a; - std::copy(f,e,&a[0]); - a[d-1]=1; - return a; + check_dim(d); + CGAL_assertion(d==std::distance(f,e)+1); + result_type a(d); + std::copy(f,e,&a[0]); + a[d-1]=1; + return a; } - }; + }; #endif - struct Iterator_and_last { - template + struct Iterator_and_last { + template result_type operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { - CGAL_assertion(d==std::distance(f,e)+1); - CGAL_assertion(d<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); - result_type a; - std::copy(f,e,&a[0]); - a[d-1]=CGAL_FORWARD(T,t); - return a; + check_dim(d); + CGAL_assertion(d==std::distance(f,e)+1); + result_type a(d); + std::copy(f,e,&a[0]); + a[d-1]=CGAL_FORWARD(T,t); + return a; } - }; + }; #ifdef CGAL_CXX0X - struct Initializer_list { - template - result_type operator()(std::initializer_list l) const { - return Iterator()(l.size(),l.begin(),l.end()); + struct Initializer_list { + // Fix T==NT? + template + result_type operator()(std::initializer_list l) const { + return Iterator()(l.size(),l.begin(),l.end()); } - }; + }; #endif - struct Values { + struct Values { #ifdef CGAL_CXX0X - template + // TODO avoid going through Initializer_list which may cause extra copies. Possibly use forward_as_tuple. + template result_type operator()(U&&...u) const { - return Initializer_list()({forward_safe(u)...}); + check_dim(sizeof...(U)); // TODO: use static_assert + return Initializer_list()({forward_safe(u)...}); } #else #define CODE(Z,N,_) result_type operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - CGAL_assertion(N<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); \ - result_type a(N); \ - a << BOOST_PP_ENUM_PARAMS(N,t); \ - return a; \ + check_dim(N); \ + result_type a(N); \ + a << BOOST_PP_ENUM_PARAMS(N,t); \ + return a; \ } BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) #undef CODE #endif - }; + }; - struct Values_divide { +struct Values_divide { #ifdef CGAL_CXX0X - template - result_type operator()(H const&h,U&&...u) const { - return Initializer_list()({Rational_traits().make_rational(std::forward(u),h)...}); - } + template + result_type operator()(H const&h,U&&...u) const { + check_dim(sizeof...(U)); // TODO: use static_assert + return Initializer_list()({Rational_traits().make_rational(std::forward(u),h)...}); + } #else -#define VAR(Z,N,_) ( t##N / h ) +#define VAR(Z,N,_) ( Rational_traits().make_rational( t##N ,h) ) #define CODE(Z,N,_) template result_type \ - operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - CGAL_assertion(N<=std::min(result_type::SizeAtCompileTime,result_type::MaxSizeAtCompileTime)); \ - result_type a(N); \ - a << BOOST_PP_ENUM(N,VAR,); \ - return a; \ -} -BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) + operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ + check_dim(N); \ + result_type a(N); \ + a << BOOST_PP_ENUM(N,VAR,); \ + return a; \ + } + BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) #undef CODE #undef VAR #endif - }; +}; }; } #endif diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 43594e59835..58ae05a1399 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -13,24 +13,30 @@ namespace CGAL { // In that case, we should store the real dim next to the array. template struct Array_vector { typedef NT_ NT; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef Array_vector< NT, D2, D3 > Other; + }; + template struct Property : boost::false_type {}; + static const unsigned d_=Max_dim_::value; - typedef cpp0x::array type; - struct Constructor { + typedef cpp0x::array Vector; + struct Construct_vector { struct Dimension { // Initialize with NaN if possible? - type operator()(unsigned d) const { + Vector operator()(unsigned d) const { CGAL_assertion(d<=d_); - return type(); + return Vector(); } }; struct Iterator { template - type operator()(unsigned d,Iter const& f,Iter const& e) const { + Vector operator()(unsigned d,Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)); CGAL_assertion(d<=d_); //TODO: optimize for forward iterators - type a; + Vector a; std::copy(f,e,a.begin()); return a; } @@ -39,11 +45,11 @@ template struct Array_vector { #if 0 struct Iterator_add_one { template - type operator()(unsigned d,Iter const& f,Iter const& e) const { + Vector operator()(unsigned d,Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)+1); CGAL_assertion(d<=d_); //TODO: optimize - type a; + Vector a; std::copy(f,e,a.begin()); a.back()=1; return a; @@ -53,11 +59,11 @@ template struct Array_vector { struct Iterator_and_last { template - type operator()(unsigned d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + Vector operator()(unsigned d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { CGAL_assertion(d==std::distance(f,e)+1); CGAL_assertion(d<=d_); //TODO: optimize for forward iterators - type a; + Vector a; std::copy(f,e,a.begin()); a.back()=CGAL_FORWARD(T,t); return a; @@ -67,16 +73,16 @@ template struct Array_vector { struct Values { #ifdef CGAL_CXX0X template - type operator()(U&&...u) const { + Vector operator()(U&&...u) const { static_assert(sizeof...(U)<=d_,"too many arguments"); - type a={{forward_safe(u)...}}; + Vector a={{forward_safe(u)...}}; return a; } #else -#define CODE(Z,N,_) type operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ +#define CODE(Z,N,_) Vector operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ CGAL_assertion(N<=d_); \ - type a={{BOOST_PP_ENUM_PARAMS(N,t)}}; \ + Vector a={{BOOST_PP_ENUM_PARAMS(N,t)}}; \ return a; \ } BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) @@ -88,18 +94,18 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) struct Values_divide { #ifdef CGAL_CXX0X template - type operator()(H const& h,U&&...u) const { + Vector operator()(H const& h,U&&...u) const { static_assert(sizeof...(U)<=d_,"too many arguments"); - type a={{Rational_traits().make_rational(std::forward(u),h)...}}; + Vector a={{Rational_traits().make_rational(std::forward(u),h)...}}; return a; } #else #define VAR(Z,N,_) Rational_traits().make_rational( t##N , h) -#define CODE(Z,N,_) template type \ +#define CODE(Z,N,_) template Vector \ operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ CGAL_assertion(N<=d_); \ - type a={{BOOST_PP_ENUM(N,VAR,_)}}; \ + Vector a={{BOOST_PP_ENUM(N,VAR,_)}}; \ return a; \ } BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) @@ -110,14 +116,14 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) }; }; - typedef NT const* const_iterator; - static const_iterator vector_begin(type const&a){ + typedef NT const* Vector_const_iterator; + static Vector_const_iterator vector_begin(Vector const&a){ return &a[0]; } - static const_iterator vector_end(type const&a){ + static Vector_const_iterator vector_end(Vector const&a){ return &a[0]+d_; // Don't know the real size } - static unsigned size_of_vector(type const&a){ + static unsigned size_of_vector(Vector const&a){ return d_; // Don't know the real size } diff --git a/NewKernel_d/include/CGAL/Vector/eigen.h b/NewKernel_d/include/CGAL/Vector/eigen.h index 2830b5afc2f..fc663cd875d 100644 --- a/NewKernel_d/include/CGAL/Vector/eigen.h +++ b/NewKernel_d/include/CGAL/Vector/eigen.h @@ -23,7 +23,7 @@ template struct Eigen_vector { typedef NT_ NT; typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> type; - struct Constructor { + struct Construct_vector { private: static void check_dim(int d){ int m = Eigen_dimension::value; diff --git a/NewKernel_d/include/CGAL/Vector/vector.h b/NewKernel_d/include/CGAL/Vector/vector.h index cf959c0c80b..a4a910a2137 100644 --- a/NewKernel_d/include/CGAL/Vector/vector.h +++ b/NewKernel_d/include/CGAL/Vector/vector.h @@ -9,21 +9,28 @@ #include namespace CGAL { +//Derive from a class that doesn't depend on Dim, or still use Dim for checking? template struct Vector_vector { typedef NT_ NT; - typedef std::vector type; - struct Constructor { + typedef std::vector Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef Vector_vector< NT, D2, D3 > Other; + }; + template struct Property : boost::false_type {}; + + struct Construct_vector { struct Dimension { - type operator()(int d) const { - return type(d); + Vector operator()(int d) const { + return Vector(d); } }; struct Iterator { template - type operator()(int d,Iter const& f,Iter const& e) const { + Vector operator()(int d,Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)); - return type(f,e); + return Vector(f,e); } }; @@ -31,9 +38,9 @@ template struct Vector_vector { #if 0 struct Iterator_add_one { template - type operator()(int d,Iter const& f,Iter const& e) const { + Vector operator()(int d,Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)+1); - type a; + Vector a; a.reserve(d+1); a.insert(a.end(),f,e); a.push_back(1); @@ -44,9 +51,9 @@ template struct Vector_vector { struct Iterator_and_last { template - type operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + Vector operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { CGAL_assertion(d==std::distance(f,e)+1); - type a; + Vector a; a.reserve(d+1); a.insert(a.end(),f,e); a.push_back(CGAL_FORWARD(T,t)); @@ -58,9 +65,9 @@ template struct Vector_vector { #if 0 struct Iterator_and_last_divide { template - type operator()(int d,Iter f,Iter const& e,T const&t) const { + Vector operator()(int d,Iter f,Iter const& e,T const&t) const { CGAL_assertion(d==std::distance(f,e)+1); - type a; + Vector a; a.reserve(d+1); for(;f!=e;++f){ a.push_back(*f/t); @@ -73,16 +80,16 @@ template struct Vector_vector { struct Values { #ifdef CGAL_CXX0X template - type operator()(U&&...u) const { + Vector operator()(U&&...u) const { //TODO: check the right number of {}, g++ accepts one and two - type a={forward_safe(u)...}; + Vector a={forward_safe(u)...}; return a; } #else #define VAR(Z,N,_) a.push_back(t##N); -#define CODE(Z,N,_) type operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - type a; \ +#define CODE(Z,N,_) Vector operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ + Vector a; \ a.reserve(N); \ BOOST_PP_REPEAT(N,VAR,) \ return a; \ @@ -97,19 +104,19 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) struct Values_divide { #ifdef CGAL_CXX0X template - type operator()(H const&h,U&&...u) const { + Vector operator()(H const&h,U&&...u) const { //TODO: do we want to cast at some point? //e.g. to avoid 1/2 in integers // ==> use Rational_traits().make_rational(x,y) ? - type a={Rational_traits().make_rational(std::forward(u),h)...}; + Vector a={Rational_traits().make_rational(std::forward(u),h)...}; return a; } #else #define VAR(Z,N,_) a.push_back(Rational_traits().make_rational( t##N ,h)); -#define CODE(Z,N,_) template type \ +#define CODE(Z,N,_) template Vector \ operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - type a; \ + Vector a; \ a.reserve(N); \ BOOST_PP_REPEAT(N,VAR,) \ return a; \ @@ -121,14 +128,14 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) #endif }; }; - typedef typename type::const_iterator const_iterator; - static const_iterator vector_begin(type const&a){ + typedef typename Vector::const_iterator Vector_const_iterator; + static Vector_const_iterator vector_begin(Vector const&a){ return a.begin(); } - static const_iterator vector_end(type const&a){ + static Vector_const_iterator vector_end(Vector const&a){ return a.end(); } - static int size_of_vector(type const&a){ + static int size_of_vector(Vector const&a){ return a.size(); } }; From 9ab9754a1be24bb12945abf2f56ab020fd4384b0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 18 Apr 2012 17:11:56 +0000 Subject: [PATCH 105/210] remove redundant file --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 14 +- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 2 +- NewKernel_d/include/CGAL/Vector/eigen.h | 208 ------------------ NewKernel_d/include/CGAL/functor_tags.h | 15 ++ 4 files changed, 23 insertions(+), 216 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/Vector/eigen.h 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 3064d5a2656..ec7f7693b16 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -47,13 +47,13 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typename Same_uncertainty_nt::type Angle; - typedef Vec_ Vector_selector; - typedef typename Vector_selector::Vector Point; - typedef typename Vector_selector::Vector Vector; - typedef typename Vector_selector::Vector Vector_; - typedef typename Vector_selector::Construct_vector Constructor; - typedef typename Vector_selector::Vector_const_iterator Point_cartesian_const_iterator; - typedef typename Vector_selector::Vector_const_iterator Vector_cartesian_const_iterator; + typedef Vec_ LA_vector; + typedef typename LA_vector::Vector Point; + typedef typename LA_vector::Vector Vector; + typedef typename LA_vector::Vector Vector_; + typedef typename LA_vector::Construct_vector Constructor; + typedef typename LA_vector::Vector_const_iterator Point_cartesian_const_iterator; + typedef typename LA_vector::Vector_const_iterator Vector_cartesian_const_iterator; typedef typeset ::add::type diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 60895b4f23b..2ca707d2746 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -132,7 +132,7 @@ template struct Construct_cartesian_const_iterator { CGAL_FUNCTOR_INIT_IGNORE(Construct_cartesian_const_iterator) typedef R_ R; typedef typename R::Vector_ argument_type; - typedef typename R::Vector_selector S_; + typedef typename R::LA_vector S_; typedef typename R::Point_cartesian_const_iterator result_type; // same as Vector typedef Tag_true Is_exact; diff --git a/NewKernel_d/include/CGAL/Vector/eigen.h b/NewKernel_d/include/CGAL/Vector/eigen.h deleted file mode 100644 index fc663cd875d..00000000000 --- a/NewKernel_d/include/CGAL/Vector/eigen.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef CGAL_VECTOR_EIGEN_H -#define CGAL_VECTOR_EIGEN_H - -#ifndef CGAL_USE_EIGEN -#error Requires Eigen -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace CGAL { - -// Dim_ real dimension -// Max_dim_ upper bound on the dimension -template struct Eigen_vector { - typedef NT_ NT; - typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> type; - - struct Construct_vector { - private: - static void check_dim(int d){ - int m = Eigen_dimension::value; - CGAL_assertion((m == Eigen::Dynamic) || (d <= m)); - } - public: - - struct Dimension { - // Initialize with NaN if possible? - type operator()(int d) const { - check_dim(d); - return type(d); - } - }; - - struct Iterator { - template - type operator()(int d,Iter const& f,Iter const& e) const { - check_dim(d); - CGAL_assertion(d==std::distance(f,e)); - type a(d); - // TODO: check the right way to do this - std::copy(f,e,&a[0]); - return a; - } - }; - -#if 0 - struct Iterator_add_one { - template - type operator()(int d,Iter const& f,Iter const& e) const { - check_dim(d); - CGAL_assertion(d==std::distance(f,e)+1); - type a(d); - std::copy(f,e,&a[0]); - a[d-1]=1; - return a; - } - }; -#endif - - struct Iterator_and_last { - template - type operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { - check_dim(d); - CGAL_assertion(d==std::distance(f,e)+1); - type a(d); - std::copy(f,e,&a[0]); - a[d-1]=CGAL_FORWARD(T,t); - return a; - } - }; - -#ifdef CGAL_CXX0X - struct Initializer_list { - // Fix T==NT? - template - type operator()(std::initializer_list l) const { - return Iterator()(l.size(),l.begin(),l.end()); - } - }; -#endif - - struct Values { -#ifdef CGAL_CXX0X - // TODO avoid going through Initializer_list which may cause extra copies. Possibly use forward_as_tuple. - template - type operator()(U&&...u) const { - check_dim(sizeof...(U)); // use static_assert - return Initializer_list()({forward_safe(u)...}); - } -#else - -#define CODE(Z,N,_) type operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - check_dim(N); \ - type a(N); \ - a << BOOST_PP_ENUM_PARAMS(N,t); \ - return a; \ -} -BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) -#undef CODE - -#endif - }; - - struct Values_divide { -#ifdef CGAL_CXX0X - template - type operator()(H const&h,U&&...u) const { - check_dim(sizeof...(U)); // use static_assert - return Initializer_list()({Rational_traits().make_rational(std::forward(u),h)...}); - } -#else - -#define VAR(Z,N,_) ( Rational_traits().make_rational( t##N ,h) ) -#define CODE(Z,N,_) template type \ - operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - CGAL_assertion(N<=std::min(type::SizeAtCompileTime,type::MaxSizeAtCompileTime)); \ - type a(N); \ - a << BOOST_PP_ENUM(N,VAR,); \ - return a; \ - } - BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) -#undef CODE -#undef VAR - -#endif - }; - }; - - - -#if (EIGEN_WORLD_VERSION>=3) - typedef NT const* const_iterator; -#else - typedef Iterator_from_indices const_iterator; -#endif - - templatestatic const_iterator vector_begin(Vec_ const&a){ -#if (EIGEN_WORLD_VERSION>=3) - return &a[0]; -#else - return const_iterator(a,0); -#endif - } - - templatestatic const_iterator vector_end(Vec_ const&a){ -#if (EIGEN_WORLD_VERSION>=3) - return &a[0]+a.size(); -#else - return const_iterator(a,a.size()); -#endif - } - -// Really needed? - templatestatic int size_of_vector(Vec_ const&v){ - return v.size(); - } - -// This complicates matter for little benefice -#if 0 -private: - template class Canonicalize_vector { - typedef typename Dimension_eigen::type S1; - typedef typename Dimension_eigen::type S2; - public: - typedef typename Vector::type type; - }; -public: - - templatestatic NT dot_product(Vec_ const&a,Vec_ const&b){ - return a.dot(b); - } - - template static typename Canonicalize_vector::type homogeneous_add(Vec1 const&a,Vec2 const&b){ - //TODO: use compile-time size when available - int d=a.size(); - typename Canonicalize_vector::type v(d); - v << b[d-1]*a.topRows(d-1)+a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; - return v; - } - - template static typename Canonicalize_vector::type homogeneous_sub(Vec1 const&a,Vec2 const&b){ - int d=a.size(); - typename Canonicalize_vector::type v(d); - v << b[d-1]*a.topRows(d-1)-a[d-1]*b.topRows(d-1), a[d-1]*b[d-1]; - return v; - } - - template static std::pair homogeneous_dot_product(Vec1 const&a,Vec2 const&b){ - int d=a.size(); - return make_pair(a.topRows(d-1).dot(b.topRows(d-1)), a[d-1]*b[d-1]); - } -#endif -}; -} - -#endif diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index acde16fd402..387db2095fe 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -4,9 +4,11 @@ namespace CGAL { class Null_type {~Null_type();}; // no such object should be created + // To construct iterators struct Begin_tag {}; struct End_tag {}; + // Functor category struct Predicate_tag {}; struct Construct_tag {}; struct Construct_iterator_tag {}; @@ -141,5 +143,18 @@ namespace CGAL { DECL_MISC(Point_dimension); DECL_MISC(Vector_dimension); #undef DECL_MISC + + + // Properties for LA + struct Has_extra_dimension_tag {}; + struct Has_plus_minus_tag {}; + struct Has_determinant_of_vectors_tag {}; + struct Has_determinant_of_points_tag {}; + struct Has_determinant_of_iterator_to_vectors_tag {}; + struct Has_determinant_of_iterator_to_points_tag {}; + + // Kernel properties + struct Point_stores_squared_distance_to_origin_tag {}; + } #endif // CGAL_FUNCTOR_TAGS_H From 26e611e45054155d3fb024de17bb43f85fa933f8 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 18 Apr 2012 17:22:30 +0000 Subject: [PATCH 106/210] Untested LA experiment. --- NewKernel_d/include/CGAL/Vector/array.h | 2 + .../CGAL/Vector/determinant_of_points.h | 90 +++++++++++++++++ .../Vector/determinant_of_vectors_small_dim.h | 97 +++++++++++++++++++ NewKernel_d/include/CGAL/Vector/vector.h | 2 + 4 files changed, 191 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Vector/determinant_of_points.h create mode 100644 NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 58ae05a1399..e7f63e31ccc 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -13,6 +13,8 @@ namespace CGAL { // In that case, we should store the real dim next to the array. template struct Array_vector { typedef NT_ NT; + typedef Dim_ Dimension; + typedef Max_dim_ Max_dimension; template< class D2, class D3=D2 > struct Rebind_dimension { typedef Array_vector< NT, D2, D3 > Other; diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_points.h b/NewKernel_d/include/CGAL/Vector/determinant_of_points.h new file mode 100644 index 00000000000..ecdcb47eac6 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_points.h @@ -0,0 +1,90 @@ +#ifndef CGAL_VECTOR_DETPTS_H +#define CGAL_VECTOR_DETPTS_H +#include +#include + +namespace CGAL { + +template ::value, + bool = LA::template Property::value + && LA::template Property::value> +struct Add_determinant_of_points_from_vectors_and_minus : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; +}; + +//FIXME: Use variadics and boost so it works in any dimension. +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c){ + return LA::determinant_of_vectors(b-a,c-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c){ + return LA::sign_of_determinant_of_vectors(b-a,c-a); + } +}; + +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return LA::determinant_of_vectors(b-a,c-a,d-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return LA::sign_of_determinant_of_vectors(b-a,c-a,d-a); + } +}; + +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return LA::determinant_of_vectors(b-a,c-a,d-a,e-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return LA::sign_of_determinant_of_vectors(b-a,c-a,d-a,e-a); + } +}; + +//TODO: Go up to 6. First check that it won't be done differently eventually. + +} +#endif diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h new file mode 100644 index 00000000000..9e3f5115fc7 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h @@ -0,0 +1,97 @@ +#ifndef CGAL_VECTOR_DETVEC_SMALL_H +#define CGAL_VECTOR_DETVEC_SMALL_H +#include +#include +#include +#include + +namespace CGAL { + +template ::value> +struct Add_determinant_of_vectors_small_dim : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_vectors(V1 const&a, V2 const&b){ + return determinant(a[0],a[1],b[0],b[1]); + } + template + static Sign sign_of_determinant_of_vectors(V1 const&a, V2 const&b){ + return sign_of_determinant(a[0],a[1],b[0],b[1]); + } +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c){ + return determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + } + static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c){ + return sign_of_determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + } +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return determinant( + a[0],a[1],a[2],a[3], + b[0],b[1],b[2],b[3], + c[0],c[1],c[2],c[3], + d[0],d[1],d[2],d[3]); + } + static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return sign_of_determinant( + a[0],a[1],a[2],a[3], + b[0],b[1],b[2],b[3], + c[0],c[1],c[2],c[3], + d[0],d[1],d[2],d[3]); + } +}; + +//TODO: Go up to 6. First check that it won't be done differently eventually. + +} +#endif diff --git a/NewKernel_d/include/CGAL/Vector/vector.h b/NewKernel_d/include/CGAL/Vector/vector.h index a4a910a2137..9db230b1b7d 100644 --- a/NewKernel_d/include/CGAL/Vector/vector.h +++ b/NewKernel_d/include/CGAL/Vector/vector.h @@ -12,6 +12,8 @@ namespace CGAL { //Derive from a class that doesn't depend on Dim, or still use Dim for checking? template struct Vector_vector { typedef NT_ NT; + typedef Dim_ Dimension; + typedef Max_dim_ Max_dimension; typedef std::vector Vector; template< class D2, class D3=D2 > struct Rebind_dimension { From 784156ba770333e90169f94c1217e789966f3610 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 19 Apr 2012 18:11:34 +0000 Subject: [PATCH 107/210] move determinants to their own file --- .../Vector/determinant_of_vectors_small_dim.h | 70 +++++++++---- .../include/CGAL/determinant_of_vectors.h | 97 +++++++++++++++++++ NewKernel_d/include/CGAL/functor_tags.h | 1 + 3 files changed, 150 insertions(+), 18 deletions(-) create mode 100644 NewKernel_d/include/CGAL/determinant_of_vectors.h diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h index 9e3f5115fc7..41b4bc9c995 100644 --- a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h @@ -2,8 +2,7 @@ #define CGAL_VECTOR_DETVEC_SMALL_H #include #include -#include -#include +#include namespace CGAL { @@ -29,13 +28,12 @@ struct Add_determinant_of_vectors_small_dim template struct Property : boost::true_type {}; - template - static NT determinant_of_vectors(V1 const&a, V2 const&b){ - return determinant(a[0],a[1],b[0],b[1]); + static NT determinant_of_vectors(Vector const&a, Vector const&b){ + return CGAL::determinant_of_vectors(a,b); } template static Sign sign_of_determinant_of_vectors(V1 const&a, V2 const&b){ - return sign_of_determinant(a[0],a[1],b[0],b[1]); + return CGAL::sign_of_determinant_of_vectors(a,b); } }; @@ -53,11 +51,11 @@ struct Add_determinant_of_vectors_small_dim static NT determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c){ - return determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + return CGAL::determinant_of_vectors(a,b,c); } static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c){ - return sign_of_determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + return CGAL::sign_of_determinant_of_vectors(a,b,c); } }; @@ -75,19 +73,55 @@ struct Add_determinant_of_vectors_small_dim static NT determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c, Vector const&d){ - return determinant( - a[0],a[1],a[2],a[3], - b[0],b[1],b[2],b[3], - c[0],c[1],c[2],c[3], - d[0],d[1],d[2],d[3]); + return CGAL::determinant_of_vectors(a,b,c,d); } static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c, Vector const&d){ - return sign_of_determinant( - a[0],a[1],a[2],a[3], - b[0],b[1],b[2],b[3], - c[0],c[1],c[2],c[3], - d[0],d[1],d[2],d[3]); + return CGAL::sign_of_determinant_of_vectors(a,b,c,d); + } +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return CGAL::determinant_of_vectors(a,b,c,d,e); + } + static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return CGAL::sign_of_determinant_of_vectors(a,b,c,d,e); + } +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return CGAL::determinant_of_vectors(a,b,c,d,e,f); + } + static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return CGAL::sign_of_determinant_of_vectors(a,b,c,d,e,f); } }; diff --git a/NewKernel_d/include/CGAL/determinant_of_vectors.h b/NewKernel_d/include/CGAL/determinant_of_vectors.h new file mode 100644 index 00000000000..da4a680f2fe --- /dev/null +++ b/NewKernel_d/include/CGAL/determinant_of_vectors.h @@ -0,0 +1,97 @@ +#ifndef CGAL_DETVEC_H +#define CGAL_DETVEC_H +#include +#include + +namespace CGAL { + // TODO: determine whether it is better to pass them by lines or columns. + + template inline + NT determinant_of_vectors(Vector const&a, Vector const&b){ + return determinant(a[0],a[1],b[0],b[1]); + } + template inline + typename Sgn::result_type + sign_of_determinant_of_vectors(Vector const&a, Vector const&b){ + return sign_of_determinant(a[0],a[1],b[0],b[1]); + + template + NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c){ + return determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + } + template + typename Sgn::result_type + sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c){ + return sign_of_determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + } + + template + NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return determinant( + a[0],a[1],a[2],a[3], + b[0],b[1],b[2],b[3], + c[0],c[1],c[2],c[3], + d[0],d[1],d[2],d[3]); + } + template + typename Sgn::result_type + sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return sign_of_determinant( + a[0],a[1],a[2],a[3], + b[0],b[1],b[2],b[3], + c[0],c[1],c[2],c[3], + d[0],d[1],d[2],d[3]); + } + + template + NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return determinant( + a[0],a[1],a[2],a[3],a[4], + b[0],b[1],b[2],b[3],b[4], + c[0],c[1],c[2],c[3],c[4], + d[0],d[1],d[2],d[3],d[4], + e[0],e[1],e[2],e[3],e[4]); + } + template + typename Sgn::result_type + sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return sign_of_determinant( + a[0],a[1],a[2],a[3],a[4], + b[0],b[1],b[2],b[3],b[4], + c[0],c[1],c[2],c[3],c[4], + d[0],d[1],d[2],d[3],d[4], + e[0],e[1],e[2],e[3],e[4]); + } + + template + NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return determinant( + a[0],a[1],a[2],a[3],a[4],a[5], + b[0],b[1],b[2],b[3],b[4],b[5], + c[0],c[1],c[2],c[3],c[4],c[5], + d[0],d[1],d[2],d[3],d[4],d[5], + e[0],e[1],e[2],e[3],e[4],e[5], + f[0],f[1],f[2],f[3],f[4],f[5]); + } + template + typename Sgn::result_type + sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return sign_of_determinant( + a[0],a[1],a[2],a[3],a[4],a[5], + b[0],b[1],b[2],b[3],b[4],b[5], + c[0],c[1],c[2],c[3],c[4],c[5], + d[0],d[1],d[2],d[3],d[4],d[5], + e[0],e[1],e[2],e[3],e[4],e[5], + f[0],f[1],f[2],f[3],f[4],f[5]); + } + +} +#endif diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 387db2095fe..f396df744ec 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -152,6 +152,7 @@ namespace CGAL { struct Has_determinant_of_points_tag {}; struct Has_determinant_of_iterator_to_vectors_tag {}; struct Has_determinant_of_iterator_to_points_tag {}; + struct Has_determinant_of_vectors_omit_last_tag {}; // Kernel properties struct Point_stores_squared_distance_to_origin_tag {}; From 8269d8129f1f7cff8276fdaaac213ef0517c09c1 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 20 Apr 2012 18:20:18 +0000 Subject: [PATCH 108/210] let it compile. let the kernel use what LA provides. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 34 +++++++--- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 35 +++++++++-- NewKernel_d/include/CGAL/LA_eigen/LA.h | 4 +- NewKernel_d/include/CGAL/Vector/array.h | 5 ++ .../CGAL/Vector/determinant_of_points.h | 63 +++++++++++++++++-- .../Vector/determinant_of_vectors_small_dim.h | 15 ++++- .../include/CGAL/determinant_of_vectors.h | 1 + NewKernel_d/include/CGAL/functor_tags.h | 3 +- 8 files changed, 138 insertions(+), 22 deletions(-) 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 ec7f7693b16..d3df999f745 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -19,7 +19,13 @@ namespace CGAL { -template < typename FT_, typename Dim_, typename Vec_=Array_vector, typename LA_=LA_eigen > +template < typename FT_, typename Dim_, +#if 1 + typename Vec_=Array_vector, +#else + typename Vec_=LA_eigen, +#endif + typename LA_=LA_eigen > /* Default LA to Vec or to LA_eigen? */ struct Cartesian_LA_base_d : public Dimension_base { @@ -63,7 +69,7 @@ struct Cartesian_LA_base_d : public Dimension_base ::add::type Iterator_list; - template struct Functor { + template struct Functor { typedef Null_functor type; }; template struct Functor,D> { @@ -78,21 +84,23 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Functor,D> { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; -#if 0 - // Doesn't seem worth the trouble. - template struct Functor { + template struct Functor::value> { typedef CartesianDVectorBase::Construct_sum_of_vectors type; }; - template struct Functor { + template struct Functor::value> { typedef CartesianDVectorBase::Construct_difference_of_vectors type; }; - template struct Functor { + template struct Functor::value> { typedef CartesianDVectorBase::Construct_opposite_vector type; }; - template struct Functor { + template struct Functor::value && + LA_vector::template Property::value> { typedef CartesianDVectorBase::Construct_midpoint type; }; -#endif template struct Functor { typedef CartesianDVectorBase::Compute_cartesian_coordinate type; }; @@ -105,6 +113,14 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Functor { typedef CartesianDVectorBase::PV_dimension type; }; + template struct Functor::value> { + typedef CartesianDVectorBase::Orientation_of_vectors type; + }; + template struct Functor::value> { + typedef CartesianDVectorBase::Orientation_of_points type; + }; CGAL_CONSTEXPR Cartesian_LA_base_d(){} CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 2ca707d2746..35981938c0d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -145,7 +145,6 @@ template struct Construct_cartesian_const_iterator { } }; -#if 0 template struct Construct_midpoint { CGAL_FUNCTOR_INIT_IGNORE(Construct_midpoint) typedef R_ R; @@ -196,7 +195,7 @@ template struct Construct_opposite_vector { template struct Compute_scalar_product { CGAL_FUNCTOR_INIT_IGNORE(Compute_scalar_product) typedef R_ R; - typedef typename R::LA LA; + typedef typename R::LA_vector LA; typedef typename R::FT result_type; typedef typename R::Vector first_argument_type; typedef typename R::Vector second_argument_type; @@ -205,19 +204,47 @@ template struct Compute_scalar_product { return LA::dot_product(a,b); } }; -#endif + +template struct Orientation_of_vectors { + CGAL_FUNCTOR_INIT_IGNORE(Orientation_of_vectors) + typedef R_ R; + typedef typename R::Vector_cartesian_const_iterator first_argument_type; + typedef typename R::Vector_cartesian_const_iterator second_argument_type; + typedef typename R::Orientation result_type; + typedef typename R::LA_vector LA; + + template + result_type operator()(Iter const& f, Iter const& e) const { + return LA::determinant_of_iterators_to_vectors(f,e); + } +}; + +template struct Orientation_of_points { + CGAL_FUNCTOR_INIT_IGNORE(Orientation_of_points) + typedef R_ R; + typedef typename R::Point_cartesian_const_iterator first_argument_type; + typedef typename R::Point_cartesian_const_iterator second_argument_type; + typedef typename R::Orientation result_type; + typedef typename R::LA_vector LA; + + template + result_type operator()(Iter const& f, Iter const& e) const { + return LA::determinant_of_iterators_to_points(f,e); + } +}; template struct PV_dimension { CGAL_FUNCTOR_INIT_IGNORE(PV_dimension) typedef R_ R; typedef typename R::Vector_ argument_type; typedef int result_type; + typedef typename R::LA_vector LA; typedef Tag_true Is_exact; template result_type operator()(T const& v) const { //FIXME: size_of_vector comes from Vector, not LA - return R::LA::size_of_vector(v); + return LA::size_of_vector(v); } }; diff --git a/NewKernel_d/include/CGAL/LA_eigen/LA.h b/NewKernel_d/include/CGAL/LA_eigen/LA.h index c51ea3238b5..ab887fc24ae 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/LA_eigen/LA.h @@ -26,7 +26,9 @@ template struct LA_eigen { struct Rebind_dimension { typedef LA_eigen< NT, D2, D3 > Other; }; - template struct Property : boost::false_type {}; + template struct Property : boost::false_type {}; + template struct Property : boost::true_type {}; + template struct Property : boost::true_type {}; typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> Vector; typedef Eigen::Matrix Dynamic_vector; diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index e7f63e31ccc..8897e59fbe1 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -7,6 +7,11 @@ #include #include #include + +#include +#include + + namespace CGAL { // May not be safe to use with dim!=max_dim. diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_points.h b/NewKernel_d/include/CGAL/Vector/determinant_of_points.h index ecdcb47eac6..a9520e17c27 100644 --- a/NewKernel_d/include/CGAL/Vector/determinant_of_points.h +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_points.h @@ -5,15 +5,16 @@ namespace CGAL { -template ::value, bool = LA::template Property::value - && LA::template Property::value> + && LA::template Property::value> struct Add_determinant_of_points_from_vectors_and_minus : LA { template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; - typedef Add_determinant_of_vectors_small_dim Other; + typedef Add_determinant_of_points_from_vectors_and_minus Other; }; }; @@ -21,6 +22,8 @@ struct Add_determinant_of_points_from_vectors_and_minus : LA { template struct Add_determinant_of_points_from_vectors_and_minus , Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -43,6 +46,8 @@ struct Add_determinant_of_points_from_vectors_and_minus template struct Add_determinant_of_points_from_vectors_and_minus , Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -65,6 +70,8 @@ struct Add_determinant_of_points_from_vectors_and_minus template struct Add_determinant_of_points_from_vectors_and_minus , Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -84,7 +91,55 @@ struct Add_determinant_of_points_from_vectors_and_minus } }; -//TODO: Go up to 6. First check that it won't be done differently eventually. +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return LA::determinant_of_vectors(b-a,c-a,d-a,e-a,f-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return LA::sign_of_determinant_of_vectors(b-a,c-a,d-a,e-a,f-a); + } +}; + +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f, + Vector const&g){ + return LA::determinant_of_vectors(b-a,c-a,d-a,e-a,f-a,g-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f, + Vector const&g){ + return LA::sign_of_determinant_of_vectors(b-a,c-a,d-a,e-a,f-a,g-a); + } +}; } #endif diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h index 41b4bc9c995..cf50bb9e89e 100644 --- a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h @@ -6,7 +6,8 @@ namespace CGAL { -template ::value> struct Add_determinant_of_vectors_small_dim : LA { template< class D2, class D3=D2 > @@ -19,6 +20,8 @@ struct Add_determinant_of_vectors_small_dim : LA { template struct Add_determinant_of_vectors_small_dim , Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -40,6 +43,8 @@ struct Add_determinant_of_vectors_small_dim template struct Add_determinant_of_vectors_small_dim , Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -62,6 +67,8 @@ struct Add_determinant_of_vectors_small_dim template struct Add_determinant_of_vectors_small_dim , Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -84,6 +91,8 @@ struct Add_determinant_of_vectors_small_dim template struct Add_determinant_of_vectors_small_dim , Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -106,6 +115,8 @@ struct Add_determinant_of_vectors_small_dim template struct Add_determinant_of_vectors_small_dim , Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; template< class D2, class D3=D2 > struct Rebind_dimension { typedef typename LA::template Rebind_dimension LA2; @@ -125,7 +136,5 @@ struct Add_determinant_of_vectors_small_dim } }; -//TODO: Go up to 6. First check that it won't be done differently eventually. - } #endif diff --git a/NewKernel_d/include/CGAL/determinant_of_vectors.h b/NewKernel_d/include/CGAL/determinant_of_vectors.h index da4a680f2fe..2759a780ef3 100644 --- a/NewKernel_d/include/CGAL/determinant_of_vectors.h +++ b/NewKernel_d/include/CGAL/determinant_of_vectors.h @@ -14,6 +14,7 @@ namespace CGAL { typename Sgn::result_type sign_of_determinant_of_vectors(Vector const&a, Vector const&b){ return sign_of_determinant(a[0],a[1],b[0],b[1]); + } template NT determinant_of_vectors(Vector const&a, Vector const&b, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index f396df744ec..4dff7560a98 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -147,7 +147,8 @@ namespace CGAL { // Properties for LA struct Has_extra_dimension_tag {}; - struct Has_plus_minus_tag {}; + struct Has_vector_plus_minus_tag {}; + struct Has_vector_scalar_ops_tag {}; struct Has_determinant_of_vectors_tag {}; struct Has_determinant_of_points_tag {}; struct Has_determinant_of_iterator_to_vectors_tag {}; From 7c96173f375ce0f053eac2c50d2d9e6e8b37c3d7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 20 Apr 2012 19:37:54 +0000 Subject: [PATCH 109/210] Different interfaces to determinant, may not all be useful. --- NewKernel_d/include/CGAL/Vector/array.h | 3 + ...rator_to_points_from_iterator_to_vectors.h | 57 ++++++ ...minant_of_iterator_to_points_from_points.h | 192 ++++++++++++++++++ 3 files changed, 252 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_iterator_to_vectors.h create mode 100644 NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_points.h diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 8897e59fbe1..af77798d699 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -10,6 +10,9 @@ #include #include +#include +#include + namespace CGAL { diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_iterator_to_vectors.h b/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_iterator_to_vectors.h new file mode 100644 index 00000000000..9bca268abf8 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_iterator_to_vectors.h @@ -0,0 +1,57 @@ +#ifndef CGAL_VECTOR_DET_ITER_PTS_ITER_VEC_H +#define CGAL_VECTOR_DET_ITER_PTS_ITER_VEC_H +#include +#include +#include +#include + +namespace CGAL { + +template ::value, + bool = LA::template Property::value> +struct Add_determinant_of_iterator_to_points_from_iterator_to_vectors : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_iterator_to_vectors Other; + }; +}; + +template +struct Add_determinant_of_iterator_to_points_from_iterator_to_vectors + : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_iterator_to_vectors Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + // TODO: use std::minus, std::bind, etc + template struct Minus_fixed { + T const& a; + Minus_fixed(T const&a_):a(a_){} + T operator()(T const&b)const{return b-a;} + }; + template + static NT determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Minus_fixed f(a); + return LA::determinant_of_iterator_to_vectors(make_transforming_iterator(first,f),make_transforming_iterator(end,f)); + } + template + static Sign sign_of_determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Minus_fixed f(a); + return LA::sign_of_determinant_of_iterator_to_vectors(make_transforming_iterator(first,f),make_transforming_iterator(end,f)); + } +}; + +} +#endif diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_points.h b/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_points.h new file mode 100644 index 00000000000..39f7dcf6545 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_points_from_points.h @@ -0,0 +1,192 @@ +#ifndef CGAL_VECTOR_DET_ITER_PTS_PTS_H +#define CGAL_VECTOR_DET_ITER_PTS_PTS_H +#include +#include + +namespace CGAL { + +template ::value, + bool = LA::template Property::value> +struct Add_determinant_of_iterator_to_points_from_points : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_points Other; + }; +}; + +//FIXME: Use variadics and boost so it works in any dimension. +template +struct Add_determinant_of_iterator_to_points_from_points +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_points Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; CGAL_assertion(++first==end); + return LA::determinant_of_points(a,b,c); + } + template + static Sign sign_of_determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_points(a,b,c); + } +}; + +template +struct Add_determinant_of_iterator_to_points_from_points +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_points Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; CGAL_assertion(++first==end); + return LA::determinant_of_points(a,b,c,d); + } + template + static Sign sign_of_determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_points(a,b,c,d); + } +}; + +template +struct Add_determinant_of_iterator_to_points_from_points +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_points Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; CGAL_assertion(++first==end); + return LA::determinant_of_points(a,b,c,d,e); + } + template + static Sign sign_of_determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_points(a,b,c,d,e); + } +}; + +template +struct Add_determinant_of_iterator_to_points_from_points +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_points Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; ++first; + Vector const&f=*first; CGAL_assertion(++first==end); + return LA::determinant_of_points(a,b,c,d,e,f); + } + template + static Sign sign_of_determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; ++first; + Vector const&f=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_points(a,b,c,d,e,f); + } +}; + +template +struct Add_determinant_of_iterator_to_points_from_points +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_points_from_points Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; ++first; + Vector const&f=*first; ++first; + Vector const&g=*first; CGAL_assertion(++first==end); + return LA::determinant_of_points(a,b,c,d,e,f,g); + } + template + static Sign sign_of_determinant_of_iterator_to_points(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; ++first; + Vector const&f=*first; ++first; + Vector const&g=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_points(a,b,c,d,e,f,g); + } +}; + +} +#endif From 4dd39cec38bd8f36e1606c031d815d191f8f2585 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 21 Apr 2012 10:04:19 +0000 Subject: [PATCH 110/210] One more. --- NewKernel_d/include/CGAL/Vector/array.h | 1 + ...nant_of_iterator_to_vectors_from_vectors.h | 182 ++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_vectors_from_vectors.h diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index af77798d699..65df5e08aed 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -12,6 +12,7 @@ #include #include #include +#include diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_vectors_from_vectors.h b/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_vectors_from_vectors.h new file mode 100644 index 00000000000..3032bcab345 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_iterator_to_vectors_from_vectors.h @@ -0,0 +1,182 @@ +#ifndef CGAL_VECTOR_DET_ITER_VEC_VEC_H +#define CGAL_VECTOR_DET_ITER_VEC_VEC_H +#include +#include + +namespace CGAL { + +template ::value, + bool = LA::template Property::value> +struct Add_determinant_of_iterator_to_vectors_from_vectors : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_vectors_from_vectors Other; + }; +}; + +//FIXME: Use variadics and boost so it works in any dimension. +template +struct Add_determinant_of_iterator_to_vectors_from_vectors +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_vectors_from_vectors Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; CGAL_assertion(++first==end); + return LA::determinant_of_vectors(a,b); + } + template + static Sign sign_of_determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_vectors(a,b); + } +}; + +template +struct Add_determinant_of_iterator_to_vectors_from_vectors +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_vectors_from_vectors Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; CGAL_assertion(++first==end); + return LA::determinant_of_vectors(a,b,c); + } + template + static Sign sign_of_determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_vectors(a,b,c); + } +}; + +template +struct Add_determinant_of_iterator_to_vectors_from_vectors +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_vectors_from_vectors Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; CGAL_assertion(++first==end); + return LA::determinant_of_vectors(a,b,c,d); + } + template + static Sign sign_of_determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_vectors(a,b,c,d); + } +}; + +template +struct Add_determinant_of_iterator_to_vectors_from_vectors +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_vectors_from_vectors Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; CGAL_assertion(++first==end); + return LA::determinant_of_vectors(a,b,c,d,e); + } + template + static Sign sign_of_determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_vectors(a,b,c,d,e); + } +}; + +template +struct Add_determinant_of_iterator_to_vectors_from_vectors +, Max_dim_, false, true> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_iterator_to_vectors_from_vectors Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; ++first; + Vector const&f=*first; CGAL_assertion(++first==end); + return LA::determinant_of_vectors(a,b,c,d,e,f); + } + template + static Sign sign_of_determinant_of_iterator_to_vectors(Iter const&first, Iter const&end){ + Vector const&a=*first; ++first; + Vector const&b=*first; ++first; + Vector const&c=*first; ++first; + Vector const&d=*first; ++first; + Vector const&e=*first; ++first; + Vector const&f=*first; CGAL_assertion(++first==end); + return LA::sign_of_determinant_of_vectors(a,b,c,d,e,f); + } +}; + +} +#endif From 8d8b159090a625601f6701b66c0524c9c70c2fc0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 21 Apr 2012 10:05:42 +0000 Subject: [PATCH 111/210] move --- NewKernel_d/include/CGAL/Vector/array.h | 2 +- ...rminant_of_points.h => determinant_of_points_from_vectors.h} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename NewKernel_d/include/CGAL/Vector/{determinant_of_points.h => determinant_of_points_from_vectors.h} (100%) diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 65df5e08aed..90249a721e9 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_points.h b/NewKernel_d/include/CGAL/Vector/determinant_of_points_from_vectors.h similarity index 100% rename from NewKernel_d/include/CGAL/Vector/determinant_of_points.h rename to NewKernel_d/include/CGAL/Vector/determinant_of_points_from_vectors.h From 789bf03909bb80dcb2b7f25e16b907a6694ca03a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 Apr 2012 11:05:40 +0000 Subject: [PATCH 112/210] Untested AVX Vector_4 --- NewKernel_d/include/CGAL/Vector/avx4.h | 184 ++++++++++++++++++++++++ NewKernel_d/include/CGAL/functor_tags.h | 15 ++ 2 files changed, 199 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Vector/avx4.h diff --git a/NewKernel_d/include/CGAL/Vector/avx4.h b/NewKernel_d/include/CGAL/Vector/avx4.h new file mode 100644 index 00000000000..a11bbbe8538 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/avx4.h @@ -0,0 +1,184 @@ +#ifndef CGAL_VECTOR_AVX4_H +#define CGAL_VECTOR_AVX4_H + +// Requires at least my patches for [], so maybe 4.8. Check intel, clang and MS. +#ifndef __AVX__ || (__GNUC_MAJOR__*100+__GNUC_MINOR__ < 408) +#error Only supported on gcc 4.8+ +#endif +#include + +#include +#include // CGAL::Sign +#include // CGAL::sign + + + +namespace CGAL { + + struct Avx_vector_4 { + typedef double NT; + typedef Dimension_tag<4> Dimension; + typedef Dimension_tag<4> Max_dimension; + // No Rebind_dimension, this is a building block + template struct Property : boost::false_type {}; + template struct Property + : boost::true_type {}; + /* MAYBE? + template struct Property + : boost::true_type {}; + */ + template struct Property + : boost::true_type {}; + template struct Property + : boost::true_type {}; + + typedef __m256d Vector; + struct Construct_vector { + struct Dimension { + // Initialize with NaN? + Vector operator()(unsigned d) const { + CGAL_assertion(d==4); + return Vector(); + } + }; + + struct Iterator { + template + Vector operator()(unsigned d,Iter const& f,Iter const& e) const { + CGAL_assertion(d==4); + double x0 = *f; + double x1 = *++f; + double x2 = *++f; + double x3 = *++f; + CGAL_assertion(++f==e); + Vector a = { x0, x1, x2, x3 }; + return a; + } + }; + + struct Iterator_and_last { + template + Vector operator()(unsigned d,Iter const& f,Iter const& e,double t) const { + CGAL_assertion(d==4); + double x0 = *f; + double x1 = *++f; + double x2 = *++f; + CGAL_assertion(++f==e); + Vector a = { x0, x1, x2, t }; + return a; + } + }; + + struct Values { + Vector operator()(double a,double b,double c,double d) const { + Vector r = { a, b, c, d }; + return r; + } + }; + + struct Values_divide { + Vector operator()(double h,double a,double b,double c,double d) const { + Vector r = { a/h, b/h, c/h, d/h }; + return r; + } + }; + }; + + typedef double const* Vector_const_iterator; + static inline Vector_const_iterator vector_begin(Vector const&a){ + return static_cast&a; + } + static inline Vector_const_iterator vector_end(Vector const&a){ + return static_cast&a+4; + } + static inline unsigned size_of_vector(Vector){ + return 4; + } + private: + static inline __m256d avx_sym(__m256d x){ +#if 0 + return __builtin_shuffle(x,(__m256i){2,3,0,1}); +#else + return _mm256_permute2f128_pd(x,x,1); +#endif + } + static inline __m256d avx_left(__m256d x){ +#if 0 + return __builtin_shuffle(x,(__m256i){1,2,3,0}); +#else +#ifdef __AVX2__ + return _mm256_permute4x64_pd(x,1+2*4+3*16+0*64); +#else + __m256d s = _mm256_permute2f128_pd(x,x,1); + return _mm256_shuffle_pd(x,s,5); +#endif +#endif + } + static inline __m256d avx_right(__m256d x){ +#if 0 + return __builtin_shuffle(x,(__m256i){3,0,1,2}); +#else +#ifdef __AVX2__ + return _mm256_permute4x64_pd(x,3+0*4+1*16+2*64); +#else + __m256d s = _mm256_permute2f128_pd(x,x,1); + return _mm256_shuffle_pd(s,x,5); +#endif +#endif + } + static inline double avx_altprod(__m256d x, __m256d y){ + __m256d p=x*y; + __m256d z=_mm256_hsub_pd(p,p); + return z[0]+z[2]; + } + public: + static double + determinant_of_vectors(Vector a, Vector b, Vector c, Vector d) { + __m256d x=a*avx_left(b)-avx_left(a)*b; + __m256d yy=a*avx_sym(b); + __m256d y=yy-avx_sym(yy); + __m256d z0=x*avx_sym(c); + __m256d z1=avx_left(x)*c; + __m256d z2=y*avx_left(c); + __m256d z=z0+z1-z2; + return avx_altprod(z,avx_right(d)); + } + static CGAL::Sign + sign_of_determinant_of_vectors(Vector a, Vector b, Vector c, Vector d) { + return CGAL::sign(determinant_of_vectors(a,b,c,d)); + } + + private: + static inline __m256d avx3_right(__m256d x){ +#if 0 + return __builtin_shuffle(x,(__m256i){2,0,1,3}); // can replace 3 with anything +#else +#ifdef __AVX2__ + return _mm256_permute4x64_pd(x,2+0*4+1*16+3*64); +#else + __m256d s = _mm256_permute2f128_pd(x,x,1); + return _mm256_shuffle_pd(s,x,12); +#endif +#endif + } + static inline double avx3_scal_prod(__m256d x, __m256d y){ + __m256d p=x*y; + __m128d q=_mm256_extractf128_pd(p,0); + double z=_mm_hadd_pd(q,q)[0]; + return z+p[2]; + } + public: + static double + determinant_of_vectors_omit_last(Vector a, Vector b, Vector c) { + __m256d x=a*avx3_right(b)-avx3_right(a)*b; + return avx3_scal_prod(c,avx3_right(x)); + } + static CGAL::Sign + sign_of_determinant_of_vectors_omit_last(Vector a, Vector b, Vector c) { + return CGAL::sign(determinant_of_vectors_omit_last(a,b,c)); + } + + }; + +} +#endif diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 4dff7560a98..c3345136903 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -155,6 +155,21 @@ namespace CGAL { struct Has_determinant_of_iterator_to_points_tag {}; struct Has_determinant_of_vectors_omit_last_tag {}; + template struct Preserved_by_non_linear_extra_coordinate + : boost::false_type {}; + template<> struct Preserved_by_non_linear_extra_coordinate + : boost::true_type {}; + template<> struct Preserved_by_non_linear_extra_coordinate + : boost::true_type {}; + template<> struct Preserved_by_non_linear_extra_coordinate + : boost::true_type {}; + template<> struct Preserved_by_non_linear_extra_coordinate + : boost::true_type {}; + template<> struct Preserved_by_non_linear_extra_coordinate + : boost::true_type {}; + template<> struct Preserved_by_non_linear_extra_coordinate + : boost::true_type {}; + // Kernel properties struct Point_stores_squared_distance_to_origin_tag {}; From e67e7ecdfc2cc3eeba896aff365a11d6c7641aac Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 Apr 2012 13:09:15 +0000 Subject: [PATCH 113/210] Untested SSE Vector_2 --- NewKernel_d/include/CGAL/Vector/avx4.h | 2 + NewKernel_d/include/CGAL/Vector/sse2.h | 109 +++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Vector/sse2.h diff --git a/NewKernel_d/include/CGAL/Vector/avx4.h b/NewKernel_d/include/CGAL/Vector/avx4.h index a11bbbe8538..4dbc6122605 100644 --- a/NewKernel_d/include/CGAL/Vector/avx4.h +++ b/NewKernel_d/include/CGAL/Vector/avx4.h @@ -78,6 +78,7 @@ namespace CGAL { struct Values_divide { Vector operator()(double h,double a,double b,double c,double d) const { + // {a,b,c,d}/{h,h,h,h} should be roughly the same Vector r = { a/h, b/h, c/h, d/h }; return r; } @@ -168,6 +169,7 @@ namespace CGAL { return z+p[2]; } public: + // Note: without AVX2, is it faster than the scalar computation? static double determinant_of_vectors_omit_last(Vector a, Vector b, Vector c) { __m256d x=a*avx3_right(b)-avx3_right(a)*b; diff --git a/NewKernel_d/include/CGAL/Vector/sse2.h b/NewKernel_d/include/CGAL/Vector/sse2.h new file mode 100644 index 00000000000..1b7b515157c --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/sse2.h @@ -0,0 +1,109 @@ +#ifndef CGAL_VECTOR_SSE2_H +#define CGAL_VECTOR_SSE2_H + +// Requires at least my patches for [], so maybe 4.8. Check intel, clang and MS. +#ifndef __SSE2__ || (__GNUC_MAJOR__*100+__GNUC_MINOR__ < 408) +#error Only supported on gcc 4.8+ +#endif +#include + +#include +#include // CGAL::Sign +#include // CGAL::sign + + + +namespace CGAL { + + struct Sse_vector_2 { + typedef double NT; + typedef Dimension_tag<2> Dimension; + typedef Dimension_tag<2> Max_dimension; + // No Rebind_dimension, this is a building block + template struct Property : boost::false_type {}; + template struct Property + : boost::true_type {}; + /* MAYBE? + template struct Property + : boost::true_type {}; + */ + template struct Property + : boost::true_type {}; + + typedef __m128d Vector; + struct Construct_vector { + struct Dimension { + // Initialize with NaN? + Vector operator()(unsigned d) const { + CGAL_assertion(d==2); + return Vector(); + } + }; + + struct Iterator { + template + Vector operator()(unsigned d,Iter const& f,Iter const& e) const { + CGAL_assertion(d==2); + double x0 = *f; + double x1 = *++f; + CGAL_assertion(++f==e); + Vector a = { x0, x1 }; + return a; + } + }; + + struct Iterator_and_last { + template + Vector operator()(unsigned d,Iter const& f,Iter const& e,double t) const { + CGAL_assertion(d==2); + Vector a = { *f, t }; + CGAL_assertion(++f==e); + return a; + } + }; + + struct Values { + Vector operator()(double a,double b) const { + Vector r = { a, b }; + return r; + } + }; + + struct Values_divide { + Vector operator()(double h,double a,double b) const { + // {a,b}/{h,h} is probably slower + Vector r = { a/h, b/h }; + return r; + } + }; + }; + + typedef double const* Vector_const_iterator; + static inline Vector_const_iterator vector_begin(Vector const&a){ + return static_cast&a; + } + static inline Vector_const_iterator vector_end(Vector const&a){ + return static_cast&a+2; + } + static inline unsigned size_of_vector(Vector){ + return 2; + } + + static double determinant_of_vectors(Vector a, Vector b) { + __m128d c = _mm_shuffle_pd (b, b, 1); // b1, b0 + __m128d d = a * c; // a0*b1, a1*b0 +#ifdef __SSE3__ + __m128d e = _mm_hsub_pd (d, d); + return e[0]; +#else + return d[0]-d[1]; +#endif + } + static CGAL::Sign sign_of_determinant_of_vectors(Vector a, Vector b) { + return CGAL::sign(determinant_of_vectors(a,b)); + } + + }; + +} +#endif From 8d4e68ab329891c7c7866d7edd872a5f4313006c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 Apr 2012 13:44:23 +0000 Subject: [PATCH 114/210] determinant omit last coordinate --- .../Vector/determinant_of_vectors_small_dim.h | 149 +++--------------- ...eterminant_of_vectors_small_dim_internal.h | 145 +++++++++++++++++ 2 files changed, 169 insertions(+), 125 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim_internal.h diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h index cf50bb9e89e..5f004cf168d 100644 --- a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h @@ -4,137 +4,36 @@ #include #include -namespace CGAL { +#define CGAL_ALLOWED_INCLUSION 1 -template ::value> -struct Add_determinant_of_vectors_small_dim : LA { - template< class D2, class D3=D2 > - struct Rebind_dimension { - typedef typename LA::template Rebind_dimension LA2; - typedef Add_determinant_of_vectors_small_dim Other; - }; -}; +#define CGAL_CLASS Add_determinant_of_vectors_small_dim +#define CGAL_TAG Has_determinant_of_vectors_tag +#define CGAL_FUNC determinant_of_vectors +#define CGAL_SIGN_FUNC sign_of_determinant_of_vectors +#define CGAL_SHIFT 0 -template -struct Add_determinant_of_vectors_small_dim -, Max_dim_, false> : LA { - using typename LA::NT; - using typename LA::Vector; - template< class D2, class D3=D2 > - struct Rebind_dimension { - typedef typename LA::template Rebind_dimension LA2; - typedef Add_determinant_of_vectors_small_dim Other; - }; - template struct Property : LA::template Property

{}; - template struct Property : - boost::true_type {}; +#include - static NT determinant_of_vectors(Vector const&a, Vector const&b){ - return CGAL::determinant_of_vectors(a,b); - } - template - static Sign sign_of_determinant_of_vectors(V1 const&a, V2 const&b){ - return CGAL::sign_of_determinant_of_vectors(a,b); - } -}; +#undef CGAL_CLASS +#undef CGAL_TAG +#undef CGAL_FUNC +#undef CGAL_SIGN_FUNC +#undef CGAL_SHIFT -template -struct Add_determinant_of_vectors_small_dim -, Max_dim_, false> : LA { - using typename LA::NT; - using typename LA::Vector; - template< class D2, class D3=D2 > - struct Rebind_dimension { - typedef typename LA::template Rebind_dimension LA2; - typedef Add_determinant_of_vectors_small_dim Other; - }; - template struct Property : LA::template Property

{}; - template struct Property : - boost::true_type {}; +#define CGAL_CLASS Add_determinant_of_vectors_omit_last_small_dim +#define CGAL_TAG Has_determinant_of_vectors_omit_last_tag +#define CGAL_FUNC determinant_of_vectors_omit_last +#define CGAL_SIGN_FUNC sign_of_determinant_of_vectors_omit_last +#define CGAL_SHIFT 1 - static NT determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c){ - return CGAL::determinant_of_vectors(a,b,c); - } - static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c){ - return CGAL::sign_of_determinant_of_vectors(a,b,c); - } -}; +#include -template -struct Add_determinant_of_vectors_small_dim -, Max_dim_, false> : LA { - using typename LA::NT; - using typename LA::Vector; - template< class D2, class D3=D2 > - struct Rebind_dimension { - typedef typename LA::template Rebind_dimension LA2; - typedef Add_determinant_of_vectors_small_dim Other; - }; - template struct Property : LA::template Property

{}; - template struct Property : - boost::true_type {}; +#undef CGAL_CLASS +#undef CGAL_TAG +#undef CGAL_FUNC +#undef CGAL_SIGN_FUNC +#undef CGAL_SHIFT - static NT determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c, Vector const&d){ - return CGAL::determinant_of_vectors(a,b,c,d); - } - static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c, Vector const&d){ - return CGAL::sign_of_determinant_of_vectors(a,b,c,d); - } -}; +#undef CGAL_ALLOWED_INCLUSION -template -struct Add_determinant_of_vectors_small_dim -, Max_dim_, false> : LA { - using typename LA::NT; - using typename LA::Vector; - template< class D2, class D3=D2 > - struct Rebind_dimension { - typedef typename LA::template Rebind_dimension LA2; - typedef Add_determinant_of_vectors_small_dim Other; - }; - template struct Property : LA::template Property

{}; - template struct Property : - boost::true_type {}; - - static NT determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c, Vector const&d, Vector const&e){ - return CGAL::determinant_of_vectors(a,b,c,d,e); - } - static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c, Vector const&d, Vector const&e){ - return CGAL::sign_of_determinant_of_vectors(a,b,c,d,e); - } -}; - -template -struct Add_determinant_of_vectors_small_dim -, Max_dim_, false> : LA { - using typename LA::NT; - using typename LA::Vector; - template< class D2, class D3=D2 > - struct Rebind_dimension { - typedef typename LA::template Rebind_dimension LA2; - typedef Add_determinant_of_vectors_small_dim Other; - }; - template struct Property : LA::template Property

{}; - template struct Property : - boost::true_type {}; - - static NT determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c, Vector const&d, Vector const&e, Vector const&f){ - return CGAL::determinant_of_vectors(a,b,c,d,e,f); - } - static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, - Vector const&c, Vector const&d, Vector const&e, Vector const&f){ - return CGAL::sign_of_determinant_of_vectors(a,b,c,d,e,f); - } -}; - -} #endif diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim_internal.h b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim_internal.h new file mode 100644 index 00000000000..19d7995dfcb --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim_internal.h @@ -0,0 +1,145 @@ +#ifndef CGAL_ALLOWED_INCLUSION +#error Must not include this header directly +#endif +#if !defined(CGAL_TAG) \ + || ! defined(CGAL_CLASS) \ + || ! defined(CGAL_FUNC) \ + || ! defined(CGAL_SIGN_FUNC) \ + || ! defined(CGAL_SHIFT) + +#error Forgot one macro +#endif + +namespace CGAL { + +template ::value> +struct CGAL_CLASS : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef CGAL_CLASS Other; + }; +}; + +template +struct CGAL_CLASS +, Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef CGAL_CLASS Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT CGAL_FUNC(Vector const&a, Vector const&b){ + return CGAL::determinant_of_vectors(a,b); + } + template + static Sign CGAL_SIGN_FUNC(V1 const&a, V2 const&b){ + return CGAL::sign_of_determinant_of_vectors(a,b); + } +}; + +template +struct CGAL_CLASS +, Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef CGAL_CLASS Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT CGAL_FUNC(Vector const&a, Vector const&b, + Vector const&c){ + return CGAL::determinant_of_vectors(a,b,c); + } + static Sign CGAL_SIGN_FUNC(Vector const&a, Vector const&b, + Vector const&c){ + return CGAL::sign_of_determinant_of_vectors(a,b,c); + } +}; + +template +struct CGAL_CLASS +, Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef CGAL_CLASS Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT CGAL_FUNC(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return CGAL::determinant_of_vectors(a,b,c,d); + } + static Sign CGAL_SIGN_FUNC(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return CGAL::sign_of_determinant_of_vectors(a,b,c,d); + } +}; + +template +struct CGAL_CLASS +, Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef CGAL_CLASS Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT CGAL_FUNC(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return CGAL::determinant_of_vectors(a,b,c,d,e); + } + static Sign CGAL_SIGN_FUNC(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return CGAL::sign_of_determinant_of_vectors(a,b,c,d,e); + } +}; + +template +struct CGAL_CLASS +, Max_dim_, false> : LA { + using typename LA::NT; + using typename LA::Vector; + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef CGAL_CLASS Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT CGAL_FUNC(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return CGAL::determinant_of_vectors(a,b,c,d,e,f); + } + static Sign CGAL_SIGN_FUNC(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e, Vector const&f){ + return CGAL::sign_of_determinant_of_vectors(a,b,c,d,e,f); + } +}; + +} From 485d5d38946e51f7bb743c88c0249e1d9ac575da Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 Apr 2012 14:34:12 +0000 Subject: [PATCH 115/210] dot product --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 4 ++++ NewKernel_d/include/CGAL/LA_eigen/LA.h | 1 + NewKernel_d/include/CGAL/Vector/sse2.h | 15 +++++++++++++++ NewKernel_d/include/CGAL/functor_tags.h | 2 ++ 4 files changed, 22 insertions(+) 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 d3df999f745..52c76486266 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -121,6 +121,10 @@ struct Cartesian_LA_base_d : public Dimension_base LA_vector::template Property::value> { typedef CartesianDVectorBase::Orientation_of_points type; }; + template struct Functor::value> { + typedef CartesianDVectorBase::Compute_scalar_product type; + }; CGAL_CONSTEXPR Cartesian_LA_base_d(){} CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} diff --git a/NewKernel_d/include/CGAL/LA_eigen/LA.h b/NewKernel_d/include/CGAL/LA_eigen/LA.h index ab887fc24ae..a7eca2f32db 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/LA_eigen/LA.h @@ -29,6 +29,7 @@ template struct LA_eigen { template struct Property : boost::false_type {}; template struct Property : boost::true_type {}; template struct Property : boost::true_type {}; + template struct Property : boost::true_type {}; typedef Eigen::Matrix::value,1,Eigen::ColMajor|Eigen::AutoAlign,Eigen_dimension::value,1> Vector; typedef Eigen::Matrix Dynamic_vector; diff --git a/NewKernel_d/include/CGAL/Vector/sse2.h b/NewKernel_d/include/CGAL/Vector/sse2.h index 1b7b515157c..2e247989338 100644 --- a/NewKernel_d/include/CGAL/Vector/sse2.h +++ b/NewKernel_d/include/CGAL/Vector/sse2.h @@ -29,6 +29,8 @@ namespace CGAL { */ template struct Property : boost::true_type {}; + template struct Property + : boost::true_type {}; typedef __m128d Vector; struct Construct_vector { @@ -103,6 +105,19 @@ namespace CGAL { return CGAL::sign(determinant_of_vectors(a,b)); } + static double dot_product(Vector a,Vector b){ +#ifdef __SSE4_1__ + return _mm_dp_pd (a, b, 1+16+32) [0]; +#else + __m128d p = a * b; +#if defined __SSE3__ + __m128d s = _mm_hadd_pd (p, p); + return s[0]; +#else + return p[0]+p[1]; +#endif +#endif + }; }; } diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index c3345136903..b3c82f5f025 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -64,6 +64,7 @@ namespace CGAL { DECL_COMPUTE(Compute_homogeneous_coordinate); DECL_COMPUTE(Compute_squared_distance); DECL_COMPUTE(Compute_squared_length); + DECL_COMPUTE(Compute_scalar_product); #undef DECL_COMPUTE #define DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \ @@ -149,6 +150,7 @@ namespace CGAL { struct Has_extra_dimension_tag {}; struct Has_vector_plus_minus_tag {}; struct Has_vector_scalar_ops_tag {}; + struct Has_dot_product_tag {}; struct Has_determinant_of_vectors_tag {}; struct Has_determinant_of_points_tag {}; struct Has_determinant_of_iterator_to_vectors_tag {}; From 5de77673eef00b7011f25fbbcc128a62f69b13d2 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 Apr 2012 14:35:14 +0000 Subject: [PATCH 116/210] dot product (forgot one file) --- NewKernel_d/include/CGAL/Vector/avx4.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Vector/avx4.h b/NewKernel_d/include/CGAL/Vector/avx4.h index 4dbc6122605..768913c936d 100644 --- a/NewKernel_d/include/CGAL/Vector/avx4.h +++ b/NewKernel_d/include/CGAL/Vector/avx4.h @@ -29,6 +29,8 @@ namespace CGAL { */ template struct Property : boost::true_type {}; + template struct Property + : boost::true_type {}; template struct Property : boost::true_type {}; @@ -95,6 +97,11 @@ namespace CGAL { static inline unsigned size_of_vector(Vector){ return 4; } + static inline double dot_product(__m256d x, __m256d y){ + __m256d p=x*y; + __m256d z=_mm256_hadd_pd(p,p); + return z[0]+z[2]; + } private: static inline __m256d avx_sym(__m256d x){ #if 0 @@ -169,11 +176,17 @@ namespace CGAL { return z+p[2]; } public: + static inline double dot_product_omit_last(__m256d x, __m256d y){ + __m256d p=x*y; + __m128d q=_mm256_extractf128_pd(p,0); + double z=_mm_hadd_pd(q,q)[0]; + return z+p[2]; + } // Note: without AVX2, is it faster than the scalar computation? static double determinant_of_vectors_omit_last(Vector a, Vector b, Vector c) { __m256d x=a*avx3_right(b)-avx3_right(a)*b; - return avx3_scal_prod(c,avx3_right(x)); + return dot_product_omit_last(c,avx3_right(x)); } static CGAL::Sign sign_of_determinant_of_vectors_omit_last(Vector a, Vector b, Vector c) { From d52193df2587fc55d42f07d82ddaa521c5f01575 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 23 Apr 2012 20:58:35 +0000 Subject: [PATCH 117/210] start on integer coordinates --- NewKernel_d/include/CGAL/Vector/v2int.h | 135 ++++++++++++++++++ .../include/CGAL/determinant_of_vectors.h | 10 +- 2 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Vector/v2int.h diff --git a/NewKernel_d/include/CGAL/Vector/v2int.h b/NewKernel_d/include/CGAL/Vector/v2int.h new file mode 100644 index 00000000000..68f63c0f282 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/v2int.h @@ -0,0 +1,135 @@ +#ifndef CGAL_VECTOR_2INT_H +#define CGAL_VECTOR_2INT_H + +#include +#include +#include +#include +#include +#include +#include +#include + + + +namespace CGAL { + + struct Vector_2_int { +#if 1 + typedef double NT; // try lying a bit + typedef int32_t NT1; // what is really stored + // (sign_of_)determinant_of_vectors needs adapting for unsigned NT1 + //typedef unsigned int NTu1; + typedef int_least64_t NT2; // longer type for computations + //typedef uint_least64_t NTu2; +#else + typedef long double NT; + typedef int64_t NT1; + //typedef uint64_t NTu1; + typedef __int128 NT2; + //typedef unsigned __int128 NTu2; +#endif + + typedef Dimension_tag<2> Dimension; + typedef Dimension_tag<2> Max_dimension; + // No Rebind_dimension, this is a building block + template struct Property : boost::false_type {}; + //template struct Property + // : boost::true_type {}; + template struct Property + : boost::true_type {}; + //template struct Property + // : boost::true_type {}; + // Advertise somehow that the sign_of_determinant* are exact? + + typedef cpp0x::array Vector; + struct Construct_vector { + struct Dimension { + Vector operator()(unsigned d) const { + CGAL_assertion(d==2); + return Vector(); + } + }; + + // TODO (for all constructors): check that input fits in NT1... + struct Iterator { + template + Vector operator()(unsigned d,Iter const& f,Iter const& e) const { + CGAL_assertion(d==2); + NT1 x0 = *f; + NT1 x1 = *++f; + CGAL_assertion(++f==e); + Vector a = { x0, x1 }; + return a; + } + }; + + struct Iterator_and_last { + template + Vector operator()(unsigned d,Iter const& f,Iter const& e,double t) const { + CGAL_assertion(d==2); + Vector a = { static_cast(*f), t }; + CGAL_assertion(++f==e); + return a; + } + }; + + struct Values { + Vector operator()(NT1 a,NT1 b) const { + Vector r = { a, b }; + return r; + } + }; + + /* + // Maybe safer not to provide it + struct Values_divide { + Vector operator()(double h,double a,double b) const { + Vector r = { a/h, b/h }; + return r; + } + }; + */ + }; + + // Since we lie about NT, be consistent about it + typedef transforming_iterator,NT1 const*> Vector_const_iterator; + static inline Vector_const_iterator vector_begin(Vector const&a){ + return Vector_const_iterator(a.begin()); + } + static inline Vector_const_iterator vector_end(Vector const&a){ + return Vector_const_iterator(a.end()); + } + static inline unsigned size_of_vector(Vector){ + return 2; + } + + // for unsigned NT1, check what changes to do. + // return NT instead? + static NT2 determinant_of_vectors(Vector a, Vector b) { + return CGAL::determinant_of_vectors(a,b); + } + static CGAL::Sign sign_of_determinant_of_vectors(Vector a, Vector b) { + return CGAL::sign_of_determinant_of_vectors(a,b); + } + +#if 0 + // WARNING: FIXME: Completely broken as is + // TODO: put an assertion at construction that abs(coord)(x0,x1,y0,y1); + } + static CGAL::Sign sign_of_determinant_of_points(Vector a, Vector b, Vector c) { + NT2 a0=a[0]; NT2 a1=a[1]; + NT2 x0=b[0]-a0; NT2 x1=b[1]-a1; + NT2 y0=c[0]-a0; NT2 y1=c[1]-a1; + return CGAL::compare(x0*y1,x1*y0); + } +#endif + }; + +} +#endif diff --git a/NewKernel_d/include/CGAL/determinant_of_vectors.h b/NewKernel_d/include/CGAL/determinant_of_vectors.h index 2759a780ef3..e0af0a62365 100644 --- a/NewKernel_d/include/CGAL/determinant_of_vectors.h +++ b/NewKernel_d/include/CGAL/determinant_of_vectors.h @@ -13,7 +13,7 @@ namespace CGAL { template inline typename Sgn::result_type sign_of_determinant_of_vectors(Vector const&a, Vector const&b){ - return sign_of_determinant(a[0],a[1],b[0],b[1]); + return sign_of_determinant(a[0],a[1],b[0],b[1]); } template @@ -25,7 +25,7 @@ namespace CGAL { typename Sgn::result_type sign_of_determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c){ - return sign_of_determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + return sign_of_determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); } template @@ -41,7 +41,7 @@ namespace CGAL { typename Sgn::result_type sign_of_determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c, Vector const&d){ - return sign_of_determinant( + return sign_of_determinant( a[0],a[1],a[2],a[3], b[0],b[1],b[2],b[3], c[0],c[1],c[2],c[3], @@ -62,7 +62,7 @@ namespace CGAL { typename Sgn::result_type sign_of_determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c, Vector const&d, Vector const&e){ - return sign_of_determinant( + return sign_of_determinant( a[0],a[1],a[2],a[3],a[4], b[0],b[1],b[2],b[3],b[4], c[0],c[1],c[2],c[3],c[4], @@ -85,7 +85,7 @@ namespace CGAL { typename Sgn::result_type sign_of_determinant_of_vectors(Vector const&a, Vector const&b, Vector const&c, Vector const&d, Vector const&e, Vector const&f){ - return sign_of_determinant( + return sign_of_determinant( a[0],a[1],a[2],a[3],a[4],a[5], b[0],b[1],b[2],b[3],b[4],b[5], c[0],c[1],c[2],c[3],c[4],c[5], From f531e331d3fe48164299b2756940c76b10a59946 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 25 Apr 2012 17:28:48 +0000 Subject: [PATCH 118/210] Minor fixes. CGAL::compare<__int128> (yeah, I'll recycle the small feature once the unsigned thing is integrated) --- NewKernel_d/include/CGAL/Vector/avx4.h | 27 ++++--- NewKernel_d/include/CGAL/Vector/sse2.h | 25 ++++--- NewKernel_d/include/CGAL/Vector/v2int.h | 77 +++++++++++++------- NewKernel_d/include/CGAL/functor_tags.h | 2 + NewKernel_d/include/CGAL/long_long.h | 93 +++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 46 deletions(-) create mode 100644 NewKernel_d/include/CGAL/long_long.h diff --git a/NewKernel_d/include/CGAL/Vector/avx4.h b/NewKernel_d/include/CGAL/Vector/avx4.h index 768913c936d..11713801bc4 100644 --- a/NewKernel_d/include/CGAL/Vector/avx4.h +++ b/NewKernel_d/include/CGAL/Vector/avx4.h @@ -2,11 +2,12 @@ #define CGAL_VECTOR_AVX4_H // Requires at least my patches for [], so maybe 4.8. Check intel, clang and MS. -#ifndef __AVX__ || (__GNUC_MAJOR__*100+__GNUC_MINOR__ < 408) -#error Only supported on gcc 4.8+ +#if !defined __AVX__ || (__GNUC__ * 100 + __GNUC_MINOR__ < 408) +#error Only supported on gcc 4.8+ with AVX #endif #include +#include #include #include // CGAL::Sign #include // CGAL::sign @@ -87,12 +88,18 @@ namespace CGAL { }; }; + private: + template + static inline double extract(T x, int i){ + return ((double*)&x)[i]; + } + public: typedef double const* Vector_const_iterator; static inline Vector_const_iterator vector_begin(Vector const&a){ - return static_cast&a; + return (Vector_const_iterator)(&a); } static inline Vector_const_iterator vector_end(Vector const&a){ - return static_cast&a+4; + return (Vector_const_iterator)(&a)+4; } static inline unsigned size_of_vector(Vector){ return 4; @@ -100,7 +107,7 @@ namespace CGAL { static inline double dot_product(__m256d x, __m256d y){ __m256d p=x*y; __m256d z=_mm256_hadd_pd(p,p); - return z[0]+z[2]; + return extract(z,0)+extract(z,2); } private: static inline __m256d avx_sym(__m256d x){ @@ -137,7 +144,7 @@ namespace CGAL { static inline double avx_altprod(__m256d x, __m256d y){ __m256d p=x*y; __m256d z=_mm256_hsub_pd(p,p); - return z[0]+z[2]; + return extract(z,0)+extract(z,2); } public: static double @@ -172,15 +179,15 @@ namespace CGAL { static inline double avx3_scal_prod(__m256d x, __m256d y){ __m256d p=x*y; __m128d q=_mm256_extractf128_pd(p,0); - double z=_mm_hadd_pd(q,q)[0]; - return z+p[2]; + double z=extract(_mm_hadd_pd(q,q),0); + return z+extract(p,2); } public: static inline double dot_product_omit_last(__m256d x, __m256d y){ __m256d p=x*y; __m128d q=_mm256_extractf128_pd(p,0); - double z=_mm_hadd_pd(q,q)[0]; - return z+p[2]; + double z=extract(_mm_hadd_pd(q,q),0); + return z+extract(p,2); } // Note: without AVX2, is it faster than the scalar computation? static double diff --git a/NewKernel_d/include/CGAL/Vector/sse2.h b/NewKernel_d/include/CGAL/Vector/sse2.h index 2e247989338..8f50521ee18 100644 --- a/NewKernel_d/include/CGAL/Vector/sse2.h +++ b/NewKernel_d/include/CGAL/Vector/sse2.h @@ -1,12 +1,12 @@ #ifndef CGAL_VECTOR_SSE2_H #define CGAL_VECTOR_SSE2_H -// Requires at least my patches for [], so maybe 4.8. Check intel, clang and MS. -#ifndef __SSE2__ || (__GNUC_MAJOR__*100+__GNUC_MINOR__ < 408) -#error Only supported on gcc 4.8+ +#if !defined __SSE2__ +#error Requires SSE2 #endif -#include +#include // FIXME: other platforms call it differently +#include #include #include // CGAL::Sign #include // CGAL::sign @@ -82,23 +82,26 @@ namespace CGAL { typedef double const* Vector_const_iterator; static inline Vector_const_iterator vector_begin(Vector const&a){ - return static_cast&a; + return (Vector_const_iterator)(&a); } static inline Vector_const_iterator vector_end(Vector const&a){ - return static_cast&a+2; + return (Vector_const_iterator)(&a)+2; } static inline unsigned size_of_vector(Vector){ return 2; } + private: + static inline double extract(__m128d x, int i) { return ((double*)&x)[i]; } + public: static double determinant_of_vectors(Vector a, Vector b) { __m128d c = _mm_shuffle_pd (b, b, 1); // b1, b0 __m128d d = a * c; // a0*b1, a1*b0 #ifdef __SSE3__ __m128d e = _mm_hsub_pd (d, d); - return e[0]; + return extract(e,0); #else - return d[0]-d[1]; + return extract(d,0)-extract(d,1); #endif } static CGAL::Sign sign_of_determinant_of_vectors(Vector a, Vector b) { @@ -107,14 +110,14 @@ namespace CGAL { static double dot_product(Vector a,Vector b){ #ifdef __SSE4_1__ - return _mm_dp_pd (a, b, 1+16+32) [0]; + return extract (_mm_dp_pd (a, b, 1+16+32), 0); #else __m128d p = a * b; #if defined __SSE3__ __m128d s = _mm_hadd_pd (p, p); - return s[0]; + return extract(s,0); #else - return p[0]+p[1]; + return extract(p,0)+extract(p,1); #endif #endif }; diff --git a/NewKernel_d/include/CGAL/Vector/v2int.h b/NewKernel_d/include/CGAL/Vector/v2int.h index 68f63c0f282..7a6be6163a8 100644 --- a/NewKernel_d/include/CGAL/Vector/v2int.h +++ b/NewKernel_d/include/CGAL/Vector/v2int.h @@ -2,6 +2,7 @@ #define CGAL_VECTOR_2INT_H #include +#include #include #include #include @@ -9,27 +10,52 @@ #include #include #include +#include +// What are the pros and cons of having NT be int vs double? namespace CGAL { - - struct Vector_2_int { -#if 1 + struct Vector_2_int_prop1 { typedef double NT; // try lying a bit typedef int32_t NT1; // what is really stored - // (sign_of_)determinant_of_vectors needs adapting for unsigned NT1 - //typedef unsigned int NTu1; - typedef int_least64_t NT2; // longer type for computations - //typedef uint_least64_t NTu2; -#else + typedef int32_t NT1b; // slightly longer + typedef int_fast64_t NT2; // longer type for computations + typedef int_fast64_t NT2b; // slightly longer + bool check_limits(int32_t x){return std::abs(x)<(1<<30);} + // TODO: find nice bounds + }; +#ifdef __SIZEOF_INT128__ + struct Vector_2_int_prop2 { + typedef double NT; + typedef int32_t NT1; + typedef int_fast64_t NT1b; + typedef int_fast64_t NT2; + typedef __int128 NT2b; + bool check_limits(int32_t){return true;} + // take a template/int64_t input and still check the limits? + }; + struct Vector_2_int_prop3 { typedef long double NT; typedef int64_t NT1; - //typedef uint64_t NTu1; + typedef int64_t NT1b; typedef __int128 NT2; - //typedef unsigned __int128 NTu2; + typedef __int128 NT2b; + enum { has_limit=true }; + bool check_limits(int32_t x){return std::abs(x)<(1L<<62);} + // TODO: find nice bounds + }; #endif + template + struct Vector_2_int : Prop { + using typename Prop::NT; + using typename Prop::NT1; + using typename Prop::NT1b; + using typename Prop::NT2; + using typename Prop::NT2b; + using Prop::check_limits; + typedef Dimension_tag<2> Dimension; typedef Dimension_tag<2> Max_dimension; // No Rebind_dimension, this is a building block @@ -58,7 +84,8 @@ namespace CGAL { CGAL_assertion(d==2); NT1 x0 = *f; NT1 x1 = *++f; - CGAL_assertion(++f==e); + CGAL_assertion (++f == e); + CGAL_assertion (check_limits(x0) && check_limits(x1)); Vector a = { x0, x1 }; return a; } @@ -68,14 +95,17 @@ namespace CGAL { template Vector operator()(unsigned d,Iter const& f,Iter const& e,double t) const { CGAL_assertion(d==2); - Vector a = { static_cast(*f), t }; - CGAL_assertion(++f==e); + NT1 x = *f; + CGAL_assertion (++f == e); + CGAL_assertion (check_limits(x) && check_limits(t)); + Vector a = { x, t }; return a; } }; struct Values { Vector operator()(NT1 a,NT1 b) const { + CGAL_assertion (check_limits(a) && check_limits(b)); Vector r = { a, b }; return r; } @@ -105,30 +135,27 @@ namespace CGAL { } // for unsigned NT1, check what changes to do. - // return NT instead? - static NT2 determinant_of_vectors(Vector a, Vector b) { + // return NT or NT2? + static NT determinant_of_vectors(Vector a, Vector b) { return CGAL::determinant_of_vectors(a,b); } static CGAL::Sign sign_of_determinant_of_vectors(Vector a, Vector b) { return CGAL::sign_of_determinant_of_vectors(a,b); } -#if 0 - // WARNING: FIXME: Completely broken as is - // TODO: put an assertion at construction that abs(coord)(x0,x1,y0,y1); } static CGAL::Sign sign_of_determinant_of_points(Vector a, Vector b, Vector c) { - NT2 a0=a[0]; NT2 a1=a[1]; - NT2 x0=b[0]-a0; NT2 x1=b[1]-a1; - NT2 y0=c[0]-a0; NT2 y1=c[1]-a1; + NT1b a0=a[0]; NT1b a1=a[1]; + NT1b x0=b[0]-a0; NT1b x1=b[1]-a1; + NT2b y0=c[0]-a0; NT2b y1=c[1]-a1; return CGAL::compare(x0*y1,x1*y0); } -#endif }; } diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index b3c82f5f025..61cccd1da61 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -1,5 +1,7 @@ #ifndef CGAL_FUNCTOR_TAGS_H #define CGAL_FUNCTOR_TAGS_H +#include // for Null_tag +#include #include namespace CGAL { class Null_type {~Null_type();}; // no such object should be created diff --git a/NewKernel_d/include/CGAL/long_long.h b/NewKernel_d/include/CGAL/long_long.h new file mode 100644 index 00000000000..ec5727a0baf --- /dev/null +++ b/NewKernel_d/include/CGAL/long_long.h @@ -0,0 +1,93 @@ +// Copyright (c) 1999,2001,2007 +// Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), +// INRIA Sophia-Antipolis (France), +// Max-Planck-Institute Saarbruecken (Germany), +// and Tel-Aviv University (Israel). All rights reserved. +// +// 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) : Stefan Schirra, Michael Hemmer + +// ISO C++ does not support `long long', but ISO C does, which means the next +// revision of ISO C++ probably will too. However, currently, g++ -pedantic +// produces a warning so we don't include this file by default. + +#ifndef CGAL_LONG_LONG_H +#define CGAL_LONG_LONG_H + +#include + +namespace CGAL { + +template<> class Algebraic_structure_traits< long long int > + : public Algebraic_structure_traits_base< long long int, + Euclidean_ring_tag > { + + public: + typedef Tag_true Is_exact; + typedef Tag_false Is_numerical_sensitive; + + typedef INTERN_AST::Div_per_operator< Type > Div; + typedef INTERN_AST::Mod_per_operator< Type > Mod; + + class Is_square + : public std::binary_function< Type, Type&, + bool > { + public: + bool operator()( const Type& x, + Type& y ) const { + y = (Type) std::sqrt( (double)x ); + return x == y * y; + } + bool operator()( const Type& x) const { + Type y + = (Type) std::sqrt( (double)x ); + return x == y * y; + } + }; +}; + +template <> class Real_embeddable_traits< long long int > + : public INTERN_RET::Real_embeddable_traits_base< long long int , CGAL::Tag_true > { + public: + + class To_interval + : public std::unary_function< Type, std::pair< double, double > > { + public: + std::pair operator()( const Type& x ) const { + Protect_FPU_rounding P(CGAL_FE_TONEAREST); + Interval_nt approx ((double) x); + FPU_set_cw(CGAL_FE_UPWARD); + approx += Interval_nt::smallest(); + return approx.pair(); + } + }; +}; + +#ifdef __SIZEOF_INT128__ +template <> class Real_embeddable_traits< __int128 > + : public INTERN_RET::Real_embeddable_traits_base< __int128 , CGAL::Tag_true > {}; + +template <> class Real_embeddable_traits< unsigned __int128 > + : public INTERN_RET::Real_embeddable_traits_base< unsigned __int128 , CGAL::Tag_true > {}; +#endif + +} //namespace CGAL + +#include + +#endif // CGAL_LONG_LONG_H From c5292798865911e1870d2b7ee8f483c2bb5d5766 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 25 Apr 2012 17:49:31 +0000 Subject: [PATCH 119/210] update comment --- NewKernel_d/include/CGAL/Vector/avx4.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/include/CGAL/Vector/avx4.h b/NewKernel_d/include/CGAL/Vector/avx4.h index 11713801bc4..9ba294111a8 100644 --- a/NewKernel_d/include/CGAL/Vector/avx4.h +++ b/NewKernel_d/include/CGAL/Vector/avx4.h @@ -1,9 +1,8 @@ #ifndef CGAL_VECTOR_AVX4_H #define CGAL_VECTOR_AVX4_H -// Requires at least my patches for [], so maybe 4.8. Check intel, clang and MS. -#if !defined __AVX__ || (__GNUC__ * 100 + __GNUC_MINOR__ < 408) -#error Only supported on gcc 4.8+ with AVX +#if !defined __AVX__ +#error Requires AVX #endif #include From cf02718e453ac164a7520a536a3267adfa385067 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 9 May 2012 10:20:26 +0000 Subject: [PATCH 120/210] Cleanup: - remove unused typedefs - FT -> RT where it makes sense - add a FIXME --- .../Kernel_d/function_objects_cartesian.h | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) 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 8e23736ac62..6e99b3bd6a7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -28,7 +28,6 @@ template struct Dimension_at_most,b> { template::value> struct Orientation_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Point Point; typedef typename R::Orientation result_type; typedef typename R::LA::Square_matrix Matrix; @@ -87,7 +86,6 @@ BOOST_PP_REPEAT_FROM_TO(7, 10, CODE, _ ) template struct Orientation_of_points,true> : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Point Point; typedef typename R::Orientation result_type; templatestruct Help; @@ -120,12 +118,12 @@ template struct Orientation_of_points,true> #define VAR(Z,J,I) c(p##I,J)-x##J #define VAR2(Z,I,N) BOOST_PP_ENUM(N,VAR,I) #define VAR3(Z,N,_) Point const&p##N=*++f; -#define VAR4(Z,N,_) FT const&x##N=c(x,N); +#define VAR4(Z,N,_) RT const&x##N=c(x,N); #define CODE(Z,N,_) \ template struct Orientation_of_points,true> : private Store_kernel { \ CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) \ typedef R_ R; \ - typedef typename R_::FT FT; \ + typedef typename R_::RT RT; \ typedef typename R::Point Point; \ typedef typename R::Orientation result_type; \ result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ @@ -153,7 +151,6 @@ template struct Orientation_of_points,true> : priv template struct Orientation_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Vector Vector; typedef typename R::Orientation result_type; typedef typename R::LA::Square_matrix Matrix; @@ -196,7 +193,6 @@ template struct Orientation_of_vectors : private Store_kernel { template::value> struct Orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Vector Vector; typedef typename R::Point Point; typedef typename R::Orientation result_type; @@ -221,7 +217,6 @@ template::v template struct Orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Vector Vector; typedef typename R::Point Point; typedef typename R::Orientation result_type; @@ -249,7 +244,7 @@ template struct Orientation : private Store_kernel { template struct Side_of_oriented_sphere : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere) typedef R_ R; - typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Point Point; typedef typename R::Oriented_side result_type; typedef typename Increment_dimension::type D1; @@ -263,18 +258,21 @@ template struct Side_of_oriented_sphere : private Store_kernel { typename R::template Functor::type pd(this->kernel()); Point const& p0=*f++; int d=pd(p0); - FT sq=0; + RT sq=0; for(int j=0;j struct Side_of_oriented_sphere : private Store_kernel { template struct Construct_opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_opposite_vector) typedef R_ R; - typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Vector Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor >::type CI; @@ -306,14 +304,14 @@ template struct Construct_opposite_vector : private Store_kernel { typedef Vector argument_type; result_type operator()(Vector const&v)const{ CI ci(this->kernel()); - return CV(this->kernel())(make_transforming_iterator(ci(v,Begin_tag()),std::negate()),make_transforming_iterator(ci(v,End_tag()),std::negate())); + return CV(this->kernel())(make_transforming_iterator(ci(v,Begin_tag()),std::negate()),make_transforming_iterator(ci(v,End_tag()),std::negate())); } }; template struct Construct_sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_sum_of_vectors) typedef R_ R; - typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Vector Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor >::type CI; @@ -322,14 +320,14 @@ template struct Construct_sum_of_vectors : private Store_kernel { typedef Vector second_argument_type; result_type operator()(Vector const&a, Vector const&b)const{ CI ci(this->kernel()); - return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::plus())); + return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::plus())); } }; template struct Construct_difference_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_difference_of_vectors) typedef R_ R; - typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Vector Vector; typedef typename R::template Functor >::type CV; typedef typename R::template Functor >::type CI; @@ -338,7 +336,7 @@ template struct Construct_difference_of_vectors : private Store_kernel typedef Vector second_argument_type; result_type operator()(Vector const&a, Vector const&b)const{ CI ci(this->kernel()); - return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); + return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); } }; @@ -346,14 +344,16 @@ template struct Construct_midpoint : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_midpoint) typedef R_ R; typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Point Point; typedef typename R::template Functor >::type CP; typedef typename R::template Functor >::type CI; typedef Point result_type; typedef Point first_argument_type; typedef Point second_argument_type; - struct Average : std::binary_function { - FT operator()(FT const&a, FT const&b)const{ + // There is a division, but it will be cast to RT afterwards anyway, so maybe we could use RT. + struct Average : std::binary_function { + FT operator()(FT const&a, RT const&b)const{ return (a+b)/2; } }; @@ -368,45 +368,44 @@ template struct Construct_midpoint : private Store_kernel { template struct Compute_squared_length : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compute_squared_length) typedef R_ R; - typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Vector Vector; typedef typename R::template Functor >::type CI; - typedef FT result_type; + typedef RT result_type; typedef Vector argument_type; result_type operator()(Vector const&a)const{ CI ci(this->kernel()); - typename Algebraic_structure_traits::Square f; - // TODO: avoid this FT(0)+... - return std::accumulate(make_transforming_iterator(ci(a,Begin_tag()),f),make_transforming_iterator(ci(a,End_tag()),f),FT(0)); + typename Algebraic_structure_traits::Square f; + // TODO: avoid this RT(0)+... + return std::accumulate(make_transforming_iterator(ci(a,Begin_tag()),f),make_transforming_iterator(ci(a,End_tag()),f),RT(0)); } }; template struct Compute_squared_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compute_squared_distance) typedef R_ R; - typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Point Point; typedef typename R::template Functor >::type CI; - typedef FT result_type; + typedef RT result_type; typedef Point first_argument_type; typedef Point second_argument_type; - struct Sq_diff : std::binary_function { - FT operator()(FT const&a, FT const&b)const{ + struct Sq_diff : std::binary_function { + RT operator()(RT const&a, RT const&b)const{ return CGAL::square(a-b); } }; result_type operator()(Point const&a, Point const&b)const{ CI ci(this->kernel()); Sq_diff f; - // TODO: avoid this FT(0)+... - return std::accumulate(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),f),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),f),FT(0)); + // TODO: avoid this RT(0)+... + return std::accumulate(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),f),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),f),RT(0)); } }; template struct Compare_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_distance) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Point Point; typedef typename R::template Functor::type CSD; typedef typename R_::Comparison_result result_type; @@ -427,7 +426,6 @@ template struct Compare_distance : private Store_kernel { template struct Less_point_cartesian_coordinate : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_point_cartesian_coordinate) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Boolean result_type; typedef typename R::template Functor::type Cc; // TODO: This is_exact thing should be reengineered. @@ -444,7 +442,6 @@ template struct Less_point_cartesian_coordinate : private Store_kernel template struct Compare_point_cartesian_coordinate : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_point_cartesian_coordinate) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; typedef typename R::template Functor::type Cc; // TODO: This is_exact thing should be reengineered. @@ -461,7 +458,6 @@ template struct Compare_point_cartesian_coordinate : private Store_ker template struct Compare_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_lexicographically) typedef R_ R; - typedef typename R_::FT FT; typedef typename R::Comparison_result result_type; typedef typename R::template Functor >::type CI; // TODO: This is_exact thing should be reengineered. From f442a9bb3bc7234fccfb6f8ae10ed61785eea762 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 9 May 2012 10:48:37 +0000 Subject: [PATCH 121/210] Same cleanup. --- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 35981938c0d..0612cb63424 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -18,14 +18,14 @@ template struct Construct_LA_vector_ { }; #define CODE(Z,N,_) template struct Construct_LA_vector_ { \ typedef typename R::Constructor Constructor; \ - typedef typename R::FT FT; \ + typedef typename R::RT RT; \ typedef typename R::Vector_ result_type; \ result_type operator() \ - (BOOST_PP_ENUM_PARAMS(N,FT const& t)) const { \ + (BOOST_PP_ENUM_PARAMS(N,RT const& t)) const { \ return typename Constructor::Values()(BOOST_PP_ENUM_PARAMS(N,t)); \ } \ result_type operator() \ - (BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N),FT const& t)) const { \ + (BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N),RT const& t)) const { \ return typename Constructor::Values_divide()(t##N,BOOST_PP_ENUM_PARAMS(N,t)); \ } \ }; @@ -42,6 +42,7 @@ template struct Construct_LA_vector CGAL_FUNCTOR_INIT_IGNORE(Construct_LA_vector) typedef R_ R; typedef typename R::Constructor Constructor; + typedef typename R::RT RT; typedef typename R::FT FT; typedef typename R::Vector_ result_type; typedef typename R_::Default_ambient_dimension Dimension; @@ -66,14 +67,14 @@ template struct Construct_LA_vector #endif #ifdef CGAL_CXX0X template - typename std::enable_if::value && + typename std::enable_if::value && (sizeof...(U)==dim), result_type>::type operator()(U&&...u)const{ return typename Constructor::Values()(std::forward(u)...); } - //template::value>::type,class=typename std::enable_if<(sizeof...(U)==dim+1)>::type,class=void> + //template::value>::type,class=typename std::enable_if<(sizeof...(U)==dim+1)>::type,class=void> template - typename std::enable_if::value && + typename std::enable_if::value && (sizeof...(U)==dim+1), result_type>::type operator()(U&&...u)const{ return Apply_to_last_then_rest()(typename Constructor::Values_divide(),std::forward(u)...); @@ -104,6 +105,7 @@ template struct Construct_LA_vector { int d=std::distance(f,g); CGAL_assertion(d==dim); + // RT? better be safe for now return typename Constructor::Iterator()(dim,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); } }; @@ -111,16 +113,16 @@ template struct Construct_LA_vector template struct Compute_cartesian_coordinate { CGAL_FUNCTOR_INIT_IGNORE(Compute_cartesian_coordinate) typedef R_ R; - typedef typename R_::FT FT; + typedef typename R_::RT RT; typedef typename R::Vector_ first_argument_type; typedef int second_argument_type; typedef Tag_true Is_exact; #ifdef CGAL_CXX0X typedef decltype(std::declval()[0]) result_type; #else - typedef FT const& result_type; - // FT const& doesn't work with some LA (Eigen2 for instance) so we - // should use plain FT or find a way to detect this. + typedef RT const& result_type; + // RT const& doesn't work with some LA (Eigen2 for instance) so we + // should use plain RT or find a way to detect this. #endif result_type operator()(first_argument_type const& v,int i)const{ @@ -196,7 +198,7 @@ template struct Compute_scalar_product { CGAL_FUNCTOR_INIT_IGNORE(Compute_scalar_product) typedef R_ R; typedef typename R::LA_vector LA; - typedef typename R::FT result_type; + typedef typename R::RT result_type; typedef typename R::Vector first_argument_type; typedef typename R::Vector second_argument_type; From e3031af169522019a180ebab8ee9fa923c4c9a4b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 9 May 2012 11:24:12 +0000 Subject: [PATCH 122/210] Mostly revert the last changes on those 2 files, there is no point trying to support older compilers this way, for them a wrapper class is necessary. --- NewKernel_d/include/CGAL/Vector/avx4.h | 23 ++++++----------------- NewKernel_d/include/CGAL/Vector/sse2.h | 17 ++++++++--------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/NewKernel_d/include/CGAL/Vector/avx4.h b/NewKernel_d/include/CGAL/Vector/avx4.h index 9ba294111a8..9f05a449502 100644 --- a/NewKernel_d/include/CGAL/Vector/avx4.h +++ b/NewKernel_d/include/CGAL/Vector/avx4.h @@ -1,8 +1,8 @@ #ifndef CGAL_VECTOR_AVX4_H #define CGAL_VECTOR_AVX4_H -#if !defined __AVX__ -#error Requires AVX +#if !defined __AVX__ || (__GNUC__ * 100 + __GNUC_MINOR__ < 408) +#error Requires AVX and gcc 4.8+ #endif #include @@ -87,11 +87,6 @@ namespace CGAL { }; }; - private: - template - static inline double extract(T x, int i){ - return ((double*)&x)[i]; - } public: typedef double const* Vector_const_iterator; static inline Vector_const_iterator vector_begin(Vector const&a){ @@ -106,7 +101,7 @@ namespace CGAL { static inline double dot_product(__m256d x, __m256d y){ __m256d p=x*y; __m256d z=_mm256_hadd_pd(p,p); - return extract(z,0)+extract(z,2); + return z[0]+z[2]; } private: static inline __m256d avx_sym(__m256d x){ @@ -143,7 +138,7 @@ namespace CGAL { static inline double avx_altprod(__m256d x, __m256d y){ __m256d p=x*y; __m256d z=_mm256_hsub_pd(p,p); - return extract(z,0)+extract(z,2); + return z[0]+z[2]; } public: static double @@ -175,18 +170,12 @@ namespace CGAL { #endif #endif } - static inline double avx3_scal_prod(__m256d x, __m256d y){ - __m256d p=x*y; - __m128d q=_mm256_extractf128_pd(p,0); - double z=extract(_mm_hadd_pd(q,q),0); - return z+extract(p,2); - } public: static inline double dot_product_omit_last(__m256d x, __m256d y){ __m256d p=x*y; __m128d q=_mm256_extractf128_pd(p,0); - double z=extract(_mm_hadd_pd(q,q),0); - return z+extract(p,2); + double z=_mm_hadd_pd(q,q)[0]; + return z+p[2]; } // Note: without AVX2, is it faster than the scalar computation? static double diff --git a/NewKernel_d/include/CGAL/Vector/sse2.h b/NewKernel_d/include/CGAL/Vector/sse2.h index 8f50521ee18..80cc96f24f7 100644 --- a/NewKernel_d/include/CGAL/Vector/sse2.h +++ b/NewKernel_d/include/CGAL/Vector/sse2.h @@ -1,8 +1,9 @@ #ifndef CGAL_VECTOR_SSE2_H #define CGAL_VECTOR_SSE2_H -#if !defined __SSE2__ -#error Requires SSE2 +// Check what needs adapting for clang, intel and microsoft +#if !defined __SSE2__ || (__GNUC__ * 100 + __GNUC_MINOR__ < 408) +#error Requires SSE2 and gcc 4.8+ #endif #include // FIXME: other platforms call it differently @@ -90,8 +91,6 @@ namespace CGAL { static inline unsigned size_of_vector(Vector){ return 2; } - private: - static inline double extract(__m128d x, int i) { return ((double*)&x)[i]; } public: static double determinant_of_vectors(Vector a, Vector b) { @@ -99,9 +98,9 @@ namespace CGAL { __m128d d = a * c; // a0*b1, a1*b0 #ifdef __SSE3__ __m128d e = _mm_hsub_pd (d, d); - return extract(e,0); + return e[0]; #else - return extract(d,0)-extract(d,1); + return d[0]-d[1]; #endif } static CGAL::Sign sign_of_determinant_of_vectors(Vector a, Vector b) { @@ -110,14 +109,14 @@ namespace CGAL { static double dot_product(Vector a,Vector b){ #ifdef __SSE4_1__ - return extract (_mm_dp_pd (a, b, 1+16+32), 0); + return _mm_dp_pd (a, b, 1+16+32)[0]; #else __m128d p = a * b; #if defined __SSE3__ __m128d s = _mm_hadd_pd (p, p); - return extract(s,0); + return s[0]; #else - return extract(p,0)+extract(p,1); + return p[0]+p[1]; #endif #endif }; From e86a11c0ca79260ff85a0354af80f6ff1e4d0669 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 16 May 2012 11:18:04 +0000 Subject: [PATCH 123/210] shorten some functor names --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 16 ++++++------- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 16 ++++++------- .../include/CGAL/Kernel_d/Define_segment.h | 8 +++---- .../CGAL/Kernel_d/Kernel_object_converter.h | 2 +- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 4 ++-- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 2 +- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 6 ++--- .../Kernel_d/function_objects_cartesian.h | 18 +++++++------- .../include/CGAL/Kernel_d/interface_macros.h | 24 ++++++++----------- NewKernel_d/include/CGAL/functor_tags.h | 16 ++++--------- NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 11 files changed, 52 insertions(+), 62 deletions(-) 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 52c76486266..ae64bf41b61 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -84,22 +84,22 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Functor,D> { typedef CartesianDVectorBase::Construct_cartesian_const_iterator type; }; - template struct Functor struct Functor::value> { - typedef CartesianDVectorBase::Construct_sum_of_vectors type; + typedef CartesianDVectorBase::Sum_of_vectors type; }; - template struct Functor struct Functor::value> { - typedef CartesianDVectorBase::Construct_difference_of_vectors type; + typedef CartesianDVectorBase::Difference_of_vectors type; }; - template struct Functor struct Functor::value> { - typedef CartesianDVectorBase::Construct_opposite_vector type; + typedef CartesianDVectorBase::Opposite_vector type; }; - template struct Functor struct Functor::value && LA_vector::template Property::value> { - typedef CartesianDVectorBase::Construct_midpoint type; + typedef CartesianDVectorBase::Midpoint type; }; template struct Functor { typedef CartesianDVectorBase::Compute_cartesian_coordinate type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 0612cb63424..37e58d64fc7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -147,8 +147,8 @@ template struct Construct_cartesian_const_iterator { } }; -template struct Construct_midpoint { - CGAL_FUNCTOR_INIT_IGNORE(Construct_midpoint) +template struct Midpoint { + CGAL_FUNCTOR_INIT_IGNORE(Midpoint) typedef R_ R; typedef typename R::Point first_argument_type; typedef typename R::Point second_argument_type; @@ -159,8 +159,8 @@ template struct Construct_midpoint { } }; -template struct Construct_sum_of_vectors { - CGAL_FUNCTOR_INIT_IGNORE(Construct_sum_of_vectors) +template struct Sum_of_vectors { + CGAL_FUNCTOR_INIT_IGNORE(Sum_of_vectors) typedef R_ R; typedef typename R::Vector first_argument_type; typedef typename R::Vector second_argument_type; @@ -171,8 +171,8 @@ template struct Construct_sum_of_vectors { } }; -template struct Construct_difference_of_vectors { - CGAL_FUNCTOR_INIT_IGNORE(Construct_difference_of_vectors) +template struct Difference_of_vectors { + CGAL_FUNCTOR_INIT_IGNORE(Difference_of_vectors) typedef R_ R; typedef typename R::Vector first_argument_type; typedef typename R::Vector second_argument_type; @@ -183,8 +183,8 @@ template struct Construct_difference_of_vectors { } }; -template struct Construct_opposite_vector { - CGAL_FUNCTOR_INIT_IGNORE(Construct_opposite_vector) +template struct Opposite_vector { + CGAL_FUNCTOR_INIT_IGNORE(Opposite_vector) typedef R_ R; typedef typename R::Vector result_type; typedef typename R::Vector argument_type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index d732a83c55e..874bcabcd37 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -30,8 +30,8 @@ template struct Construct_segment { }; // This should be part of Construct_point, according to Kernel_23 conventions -template struct Construct_segment_extremity { - CGAL_FUNCTOR_INIT_IGNORE(Construct_segment_extremity) +template struct Segment_extremity { + CGAL_FUNCTOR_INIT_IGNORE(Segment_extremity) typedef R_ R; typedef typename R_::Point Point; typedef typename R_::Segment Segment; @@ -66,8 +66,8 @@ struct Define_segment : public Base_ { template struct Functor,D> { typedef CartesianDKernelFunctors::Construct_segment type; }; - template struct Functor { - typedef CartesianDKernelFunctors::Construct_segment_extremity type; + template struct Functor { + typedef CartesianDKernelFunctors::Segment_extremity 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 f66f5ba226d..17f07dba134 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -68,7 +68,7 @@ template struct KO_converter{ typedef typename K2::Segment result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { - typename K1::template Functor::type f(k1); + typename K1::template Functor::type f(k1); typename K2::template Functor >::type cs(k2); return cs(conv(f(s,0)),conv(f(s,1))); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 4ef9701fe0e..e1f480b9e4d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -233,13 +233,13 @@ template Point_d::Point_d(Point_d &)=default; //template //Vector_d operator+(const Vector_d& v,const Vector_d& w) const //{ -// return typename R::template Construct::type()(v,w); +// return typename R::template Construct::type()(v,w); //} // //template //Vector_d operator-(const Vector_d& v,const Vector_d& w) const //{ -// return typename R::template Construct::type()(v,w); +// return typename R::template Construct::type()(v,w); //} } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 6376b66b390..1a1861a1159 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -24,7 +24,7 @@ class Segment_d : public R_::Kernel_base::Segment typedef typename R_::Point Point_; typedef typename Kbase::template Functor >::type CPBase; typedef typename Kbase::template Functor >::type CSBase; - typedef typename Kbase::template Functor::type CSEBase; + typedef typename Kbase::template Functor::type CSEBase; typedef Segment_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index d5c25244524..2f9f8608ae9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -114,7 +114,7 @@ public: Vector_d operator-() const { - return typename R::template Functor::type()(*this); + return typename R::template Functor::type()(*this); } /* @@ -236,13 +236,13 @@ template Vector_d::Vector_d(Vector_d &)=default; template Vector_d operator+(const Vector_d& v,const Vector_d& w) { - return typename R_::template Functor::type()(v,w); + return typename R_::template Functor::type()(v,w); } template Vector_d operator-(const Vector_d& v,const Vector_d& w) { - return typename R_::template Functor::type()(v,w); + return typename R_::template Functor::type()(v,w); } } //namespace CGAL 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 6e99b3bd6a7..b6331be402d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -260,7 +260,7 @@ template struct Side_of_oriented_sphere : private Store_kernel { int d=pd(p0); RT sq=0; for(int j=0;j struct Side_of_oriented_sphere : private Store_kernel { #endif }; -template struct Construct_opposite_vector : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Construct_opposite_vector) +template struct Opposite_vector : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Opposite_vector) typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; @@ -308,8 +308,8 @@ template struct Construct_opposite_vector : private Store_kernel { } }; -template struct Construct_sum_of_vectors : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Construct_sum_of_vectors) +template struct Sum_of_vectors : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors) typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; @@ -324,8 +324,8 @@ template struct Construct_sum_of_vectors : private Store_kernel { } }; -template struct Construct_difference_of_vectors : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Construct_difference_of_vectors) +template struct Difference_of_vectors : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Difference_of_vectors) typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; @@ -340,8 +340,8 @@ template struct Construct_difference_of_vectors : private Store_kernel } }; -template struct Construct_midpoint : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Construct_midpoint) +template struct Midpoint : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Midpoint) typedef R_ R; typedef typename R_::FT FT; typedef typename R_::RT RT; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index bc00c159c67..234a72c97f1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -36,26 +36,22 @@ CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) //CGAL_Kernel_obj2(Segment,segment) -CGAL_Kernel_cons1(Construct_vector, - construct_vector_object) -CGAL_Kernel_cons1(Construct_point, - construct_point_object) CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, construct_point_cartesian_const_iterator_object) CGAL_Kernel_cons1(Construct_vector_cartesian_const_iterator, construct_vector_cartesian_const_iterator_object) -CGAL_Kernel_cons2(Construct_sum_of_vectors, - construct_sum_of_vectors_object) -CGAL_Kernel_cons2(Construct_difference_of_vectors, - construct_difference_of_vectors_object) -CGAL_Kernel_cons2(Construct_opposite_vector, - construct_opposite_vector_object) -CGAL_Kernel_cons2(Construct_midpoint, - construct_midpoint_object) +CGAL_Kernel_cons2(Sum_of_vectors, + sum_of_vectors_object) +CGAL_Kernel_cons2(Difference_of_vectors, + difference_of_vectors_object) +CGAL_Kernel_cons2(Opposite_vector, + opposite_vector_object) +CGAL_Kernel_cons2(Midpoint, + midpoint_object) //CGAL_Kernel_cons2(Construct_segment, // construct_segment_object) -//CGAL_Kernel_cons2(Construct_segment_extremity, -// construct_segment_extremity_object) +//CGAL_Kernel_cons2(Segment_extremity, +// segment_extremity_object) CGAL_Kernel_comp1(Compute_point_cartesian_coordinate, compute_point_cartesian_coordinate_object) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 61cccd1da61..5858e6ba38f 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -100,17 +100,11 @@ namespace CGAL { #define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ template<>struct map_result_tag{typedef Y##_tag type;}; \ template<>struct map_functor_type{typedef Construct_tag type;} - DECL_CONSTRUCT(Construct_vector,Vector); - DECL_CONSTRUCT(Construct_point,Point); - DECL_CONSTRUCT(Construct_segment,Segment); - DECL_CONSTRUCT(Construct_line,Line); - DECL_CONSTRUCT(Construct_direction,Direction); - DECL_CONSTRUCT(Construct_ray,Ray); - DECL_CONSTRUCT(Construct_midpoint,Point); - DECL_CONSTRUCT(Construct_segment_extremity,Point); - DECL_CONSTRUCT(Construct_sum_of_vectors,Vector); - DECL_CONSTRUCT(Construct_difference_of_vectors,Vector); - DECL_CONSTRUCT(Construct_opposite_vector,Vector); + DECL_CONSTRUCT(Midpoint,Point); + DECL_CONSTRUCT(Segment_extremity,Point); + DECL_CONSTRUCT(Sum_of_vectors,Vector); + DECL_CONSTRUCT(Difference_of_vectors,Vector); + DECL_CONSTRUCT(Opposite_vector,Vector); #undef DECL_CONSTRUCT #if 0 #define DECL_ITER_CONSTRUCT(X,Y) struct X##_tag {}; \ diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 46318b98c77..f04181668f8 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -76,7 +76,7 @@ typedef K1::Segment S; typedef K1::Functor >::type CP; typedef K1::Functor >::type CV; typedef K1::Functor >::type CS; -typedef K1::Functor::type CSE; +typedef K1::Functor::type CSE; typedef K1::Functor >::type CCI; typedef K1::Functor::type PO; typedef K1::Functor::type SOS; From c850599085961f6715f5e5650e6cbe00d6998c77 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 16 May 2012 11:21:30 +0000 Subject: [PATCH 124/210] shorten some functor names --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h | 4 ++-- .../include/CGAL/Kernel_d/Cartesian_LA_functors.h | 4 ++-- NewKernel_d/include/CGAL/Kernel_d/Segmentd.h | 2 +- .../include/CGAL/Kernel_d/function_objects_cartesian.h | 10 +++++----- NewKernel_d/include/CGAL/functor_tags.h | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) 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 ae64bf41b61..d79afccbe01 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -121,9 +121,9 @@ struct Cartesian_LA_base_d : public Dimension_base LA_vector::template Property::value> { typedef CartesianDVectorBase::Orientation_of_points type; }; - template struct Functor struct Functor::value> { - typedef CartesianDVectorBase::Compute_scalar_product type; + typedef CartesianDVectorBase::Scalar_product type; }; CGAL_CONSTEXPR Cartesian_LA_base_d(){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 37e58d64fc7..b77abcbc530 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -194,8 +194,8 @@ template struct Opposite_vector { } }; -template struct Compute_scalar_product { - CGAL_FUNCTOR_INIT_IGNORE(Compute_scalar_product) +template struct Scalar_product { + CGAL_FUNCTOR_INIT_IGNORE(Scalar_product) typedef R_ R; typedef typename R::LA_vector LA; typedef typename R::RT result_type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h index 8b2ea70ef7e..fb348b8177f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h @@ -9,7 +9,7 @@ template class Segmentd { typedef typename R_::Point Point_; //typedef typename R_::Vector Vector_; //typedef typename R_::template Functor >::type Cv_; -// typedef typename R_::Compute_squared_distance Csd_; +// typedef typename R_::Squared_distance Csd_; typedef std::pair Data_; Data_ data; public: 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 b6331be402d..fc51c31222f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -365,8 +365,8 @@ template struct Midpoint : private Store_kernel { } }; -template struct Compute_squared_length : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Compute_squared_length) +template struct Squared_length : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Squared_length) typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; @@ -381,8 +381,8 @@ template struct Compute_squared_length : private Store_kernel { } }; -template struct Compute_squared_distance : private Store_kernel { - CGAL_FUNCTOR_INIT_STORE(Compute_squared_distance) +template struct Squared_distance : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Squared_distance) typedef R_ R; typedef typename R_::RT RT; typedef typename R::Point Point; @@ -407,7 +407,7 @@ template struct Compare_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_distance) typedef R_ R; typedef typename R::Point Point; - typedef typename R::template Functor::type CSD; + typedef typename R::template Functor::type CSD; typedef typename R_::Comparison_result result_type; typedef Point first_argument_type; typedef Point second_argument_type; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 5858e6ba38f..ec0a34450d1 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -64,9 +64,9 @@ namespace CGAL { DECL_COMPUTE(Compute_point_cartesian_coordinate); DECL_COMPUTE(Compute_vector_cartesian_coordinate); DECL_COMPUTE(Compute_homogeneous_coordinate); - DECL_COMPUTE(Compute_squared_distance); - DECL_COMPUTE(Compute_squared_length); - DECL_COMPUTE(Compute_scalar_product); + DECL_COMPUTE(Squared_distance); + DECL_COMPUTE(Squared_length); + DECL_COMPUTE(Scalar_product); #undef DECL_COMPUTE #define DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \ From 3e3e8efcc9ef2a7fbefc6424415df0970dbff3b3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 16 May 2012 12:26:27 +0000 Subject: [PATCH 125/210] in_sphere computation depending on whether the squared norm is precomputed. --- .../Kernel_d/function_objects_cartesian.h | 75 ++++++++++++------- .../include/CGAL/Kernel_d/interface_macros.h | 6 ++ NewKernel_d/include/CGAL/exactness.h | 19 ----- NewKernel_d/include/CGAL/functor_properties.h | 21 ++++++ NewKernel_d/include/CGAL/functor_tags.h | 1 + 5 files changed, 77 insertions(+), 45 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/exactness.h create mode 100644 NewKernel_d/include/CGAL/functor_properties.h 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 fc51c31222f..deea9b7ba46 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #ifdef CGAL_CXX0X #include @@ -254,28 +254,35 @@ template struct Side_of_oriented_sphere : private Store_kernel { template result_type operator()(Iter f, Iter const& e)const{ - typename R::template Functor::type c(this->kernel()); - typename R::template Functor::type pd(this->kernel()); - Point const& p0=*f++; - int d=pd(p0); - RT sq=0; - for(int j=0;j::type Sqdo; + typename R::template Functor::type c(this->kernel()); + typename R::template Functor::type pd(this->kernel()); + + Point const& p0=*f++; + int d=pd(p0); + Matrix m(d+1,d+1); + if(CGAL::Is_stored::value) { + Sqdo sqdo(this->kernel()); + for(int i=0;f!=e;++f,++i) { + Point const& p=*f; + for(int j=0;j struct Squared_length : private Store_kernel { } }; +template struct Squared_distance_to_origin : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Squared_distance_to_origin) + typedef R_ R; + typedef typename R_::RT RT; + typedef typename R::Point Point; + typedef typename R::template Functor >::type CI; + typedef RT result_type; + typedef Point argument_type; + result_type operator()(Point const&a)const{ + CI ci(this->kernel()); + typename Algebraic_structure_traits::Square f; + // TODO: avoid this RT(0)+... + return std::accumulate(make_transforming_iterator(ci(a,Begin_tag()),f),make_transforming_iterator(ci(a,End_tag()),f),RT(0)); + } +}; + template struct Squared_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_distance) typedef R_ R; @@ -430,7 +453,7 @@ template struct Less_point_cartesian_coordinate : private Store_kernel typedef typename R::template Functor::type Cc; // 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; + typedef typename CGAL::Is_exact Is_exact; template result_type operator()(V const&a, W const&b, I i)const{ @@ -446,7 +469,7 @@ template struct Compare_point_cartesian_coordinate : private Store_ker typedef typename R::template Functor::type Cc; // 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; + typedef typename CGAL::Is_exact Is_exact; template result_type operator()(V const&a, W const&b, I i)const{ @@ -462,7 +485,7 @@ template struct Compare_lexicographically : private Store_kernel { 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; + typedef typename CGAL::Is_exact Is_exact; template result_type operator()(V const&a, W const&b)const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 234a72c97f1..1b245404855 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -57,6 +57,12 @@ CGAL_Kernel_comp1(Compute_point_cartesian_coordinate, compute_point_cartesian_coordinate_object) CGAL_Kernel_comp1(Compute_vector_cartesian_coordinate, compute_vector_cartesian_coordinate_object) +CGAL_Kernel_comp2(Squared_length, + squared_length_object) +CGAL_Kernel_comp2(Squared_distance, + squared_distance_object) +CGAL_Kernel_comp2(Squared_distance_to_origin, + squared_distance_to_origin_object) #if 0 CGAL_Kernel_pred(Orientation, diff --git a/NewKernel_d/include/CGAL/exactness.h b/NewKernel_d/include/CGAL/exactness.h deleted file mode 100644 index 3dddca8123b..00000000000 --- a/NewKernel_d/include/CGAL/exactness.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CGAL_EXACTNESS_H -#define CGAL_EXACTNESS_H -#include -#include -namespace CGAL { -namespace internal { -BOOST_MPL_HAS_XXX_TRAIT_DEF(Is_exact) -} -template::value> struct Is_exact { - enum { value=false }; - typedef Tag_false type; -}; -template struct Is_exact { - typedef typename T::Is_exact type; - enum { value=type::value }; -}; - -} -#endif // CGAL_EXACTNESS_H diff --git a/NewKernel_d/include/CGAL/functor_properties.h b/NewKernel_d/include/CGAL/functor_properties.h new file mode 100644 index 00000000000..c849509b07d --- /dev/null +++ b/NewKernel_d/include/CGAL/functor_properties.h @@ -0,0 +1,21 @@ +#ifndef CGAL_EXACTNESS_H +#define CGAL_EXACTNESS_H +#include +#include +namespace CGAL { + +#define CGAL_STRAWBERRY(Is_pretty) \ + namespace internal { \ + BOOST_MPL_HAS_XXX_TRAIT_DEF(Is_pretty) \ + } \ + template::value> \ + struct Is_pretty : boost::false_type {}; \ + template \ + struct Is_pretty : T::Is_pretty {} + +CGAL_STRAWBERRY(Is_exact); +CGAL_STRAWBERRY(Is_fast); +CGAL_STRAWBERRY(Is_stored); +#undef CGAL_STRAWBERRY +} +#endif // CGAL_EXACTNESS_H diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index ec0a34450d1..3bcc7ca9e14 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -65,6 +65,7 @@ namespace CGAL { DECL_COMPUTE(Compute_vector_cartesian_coordinate); DECL_COMPUTE(Compute_homogeneous_coordinate); DECL_COMPUTE(Squared_distance); + DECL_COMPUTE(Squared_distance_to_origin); DECL_COMPUTE(Squared_length); DECL_COMPUTE(Scalar_product); #undef DECL_COMPUTE From ec3428bbfc5d1100eb18041093ff6f42b4c92ee0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 16 May 2012 12:44:44 +0000 Subject: [PATCH 126/210] More squared_distance_to_origin. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 9 +++++++ .../CGAL/Kernel_d/Cartesian_LA_functors.h | 24 +++++++++++++++++++ NewKernel_d/include/CGAL/functor_tags.h | 1 + 3 files changed, 34 insertions(+) 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 d79afccbe01..c03db2fc675 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -125,6 +125,15 @@ struct Cartesian_LA_base_d : public Dimension_base LA_vector::template Property::value> { typedef CartesianDVectorBase::Scalar_product type; }; + template struct Functor::value> { + typedef CartesianDVectorBase::Squared_distance_to_origin_stored type; + }; + template struct Functor::value && + LA_vector::template Property::value> { + typedef CartesianDVectorBase::Squared_distance_to_origin_via_dotprod type; + }; CGAL_CONSTEXPR Cartesian_LA_base_d(){} CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index b77abcbc530..f62740c703a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -207,6 +207,30 @@ template struct Scalar_product { } }; +template struct Squared_distance_to_origin_stored { + CGAL_FUNCTOR_INIT_IGNORE(Squared_distance_to_origin_stored) + typedef R_ R; + typedef typename R::LA_vector LA; + typedef typename R::RT result_type; + typedef typename R::Point argument_type; + + result_type operator()(argument_type const& a)const{ + return LA::squared_norm(a); + } +}; + +template struct Squared_distance_to_origin_via_dotprod { + CGAL_FUNCTOR_INIT_IGNORE(Squared_distance_to_origin_via_dotprod) + typedef R_ R; + typedef typename R::LA_vector LA; + typedef typename R::RT result_type; + typedef typename R::Point argument_type; + + result_type operator()(argument_type const& a)const{ + return LA::dot_product(a,a); + } +}; + template struct Orientation_of_vectors { CGAL_FUNCTOR_INIT_IGNORE(Orientation_of_vectors) typedef R_ R; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 3bcc7ca9e14..8f8468ddbd0 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -153,6 +153,7 @@ namespace CGAL { struct Has_determinant_of_iterator_to_vectors_tag {}; struct Has_determinant_of_iterator_to_points_tag {}; struct Has_determinant_of_vectors_omit_last_tag {}; + struct Stores_squared_norm_tag {}; template struct Preserved_by_non_linear_extra_coordinate : boost::false_type {}; From a031abe9a0ceec67373886c8e7acc28febe9b66a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 16 May 2012 14:49:32 +0000 Subject: [PATCH 127/210] minor preps for dynamic dimension --- NewKernel_d/include/CGAL/Dimension.h | 9 ++++++++- .../include/CGAL/Kernel_d/Cartesian_LA_functors.h | 11 +++++------ NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/NewKernel_d/include/CGAL/Dimension.h b/NewKernel_d/include/CGAL/Dimension.h index 06be888abb4..514b41b5020 100644 --- a/NewKernel_d/include/CGAL/Dimension.h +++ b/NewKernel_d/include/CGAL/Dimension.h @@ -35,10 +35,17 @@ const int UNKNOWN_DIMENSION=Eigen::Dynamic; const int UNKNOWN_DIMENSION=std::numeric_limits::max(); #endif -inline bool check_dimension(int d1, int d2){ +inline bool check_dimension_lt(int d1, int d2){ + //return (d2==UNKNOWN_DIMENSION)||(d1 struct Construct_LA_vector typedef typename R_::Default_ambient_dimension Dimension; static const int dim=Dimension::value; result_type operator()(int d)const{ - CGAL_assertion(d==dim); + CGAL_assertion(check_dimension_eq(d,dim)); return typename Constructor::Dimension()(d); } result_type operator()()const{ @@ -86,8 +86,8 @@ template struct Construct_LA_vector (Iter f,Iter g,Cartesian_tag)const { int d=std::distance(f,g); - CGAL_assertion(d==dim); - return typename Constructor::Iterator()(dim,f,g); + CGAL_assertion(check_dimension_eq(d,dim)); + return typename Constructor::Iterator()(d,f,g); } template typename boost::enable_if,result_type>::type operator() (Iter f,Iter g,Homogeneous_tag)const @@ -104,9 +104,9 @@ template struct Construct_LA_vector (Iter f,Iter g,NT const&l)const { int d=std::distance(f,g); - CGAL_assertion(d==dim); + CGAL_assertion(check_dimension_eq(d,dim)); // RT? better be safe for now - return typename Constructor::Iterator()(dim,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); + return typename Constructor::Iterator()(d,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); } }; @@ -269,7 +269,6 @@ template struct PV_dimension { template result_type operator()(T const& v) const { - //FIXME: size_of_vector comes from Vector, not LA return LA::size_of_vector(v); } }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h index 9788ee1867e..fb01403a14f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h @@ -6,7 +6,7 @@ namespace CGAL { template struct Dimension_base { //TODO: add some assertions - Dimension_base(int dim=-1):dim_(dim){} + Dimension_base(int dim=UNKNOWN_DIMENSION):dim_(dim){} int dimension()const{return dim_;} void set_dimension(int dim){dim_=dim;} private: From 794cd86431b69928fa5d657ac0d6938ecde5041a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 17 May 2012 10:59:55 +0000 Subject: [PATCH 128/210] minor dimension stuff --- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 24 ++++++++++--------- .../include/CGAL/Kernel_d/Dimension_base.h | 5 ++++ NewKernel_d/include/CGAL/Vector/array.h | 2 ++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 7f9beb7d540..89caa1feb78 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -35,27 +35,29 @@ BOOST_PP_REPEAT_FROM_TO(2, 11, CODE, _ ) #endif template struct Construct_LA_vector +: private Store_kernel #ifndef CGAL_CXX0X -: internal::Construct_LA_vector_ +, public internal::Construct_LA_vector_ #endif { - CGAL_FUNCTOR_INIT_IGNORE(Construct_LA_vector) + //CGAL_FUNCTOR_INIT_IGNORE(Construct_LA_vector) + CGAL_FUNCTOR_INIT_STORE(Construct_LA_vector) typedef R_ R; typedef typename R::Constructor Constructor; typedef typename R::RT RT; typedef typename R::FT FT; typedef typename R::Vector_ result_type; typedef typename R_::Default_ambient_dimension Dimension; - static const int dim=Dimension::value; + static const int static_dim=Dimension::value; result_type operator()(int d)const{ - CGAL_assertion(check_dimension_eq(d,dim)); + CGAL_assertion(check_dimension_eq(d,this->kernel().dimension())); return typename Constructor::Dimension()(d); } result_type operator()()const{ - return typename Constructor::Dimension()(dim); + return typename Constructor::Dimension()(this->kernel().dimension()); } result_type operator()(Zero_ const&)const{ - return typename Constructor::Dimension()(dim); + return typename Constructor::Dimension()(this->kernel().dimension()); } result_type operator()(result_type const& v)const{ return v; @@ -68,14 +70,14 @@ template struct Construct_LA_vector #ifdef CGAL_CXX0X template typename std::enable_if::value && - (sizeof...(U)==dim), result_type>::type + (sizeof...(U)==static_dim), result_type>::type operator()(U&&...u)const{ return typename Constructor::Values()(std::forward(u)...); } - //template::value>::type,class=typename std::enable_if<(sizeof...(U)==dim+1)>::type,class=void> + //template::value>::type,class=typename std::enable_if<(sizeof...(U)==static_dim+1)>::type,class=void> template typename std::enable_if::value && - (sizeof...(U)==dim+1), result_type>::type + (sizeof...(U)==static_dim+1), result_type>::type operator()(U&&...u)const{ return Apply_to_last_then_rest()(typename Constructor::Values_divide(),std::forward(u)...); } @@ -86,7 +88,7 @@ template struct Construct_LA_vector (Iter f,Iter g,Cartesian_tag)const { int d=std::distance(f,g); - CGAL_assertion(check_dimension_eq(d,dim)); + CGAL_assertion(check_dimension_eq(d,this->kernel().dimension())); return typename Constructor::Iterator()(d,f,g); } template typename boost::enable_if,result_type>::type operator() @@ -104,7 +106,7 @@ template struct Construct_LA_vector (Iter f,Iter g,NT const&l)const { int d=std::distance(f,g); - CGAL_assertion(check_dimension_eq(d,dim)); + CGAL_assertion(check_dimension_eq(d,this->kernel().dimension())); // RT? better be safe for now return typename Constructor::Iterator()(d,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h index fb01403a14f..35fc9a3d064 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h @@ -4,6 +4,11 @@ #include #include namespace CGAL { +struct No_dimension_base { + No_dimension_base(int = UNKNOWN_DIMENSION){} + int dimension() const { return UNKNOWN_DIMENSION; } + void set_dimension(int) {} +}; template struct Dimension_base { //TODO: add some assertions Dimension_base(int dim=UNKNOWN_DIMENSION):dim_(dim){} diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 90249a721e9..bf03145ebe3 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -31,6 +31,8 @@ template struct Array_vector { template struct Property : boost::false_type {}; static const unsigned d_=Max_dim_::value; + CGAL_static_assertion(d_ != UNKNOWN_DIMENSION); + typedef cpp0x::array Vector; struct Construct_vector { struct Dimension { From a4063dd4a0f186fbd4ecef8f8b45a88b792e55de Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 17 May 2012 11:05:15 +0000 Subject: [PATCH 129/210] signed/unsigned warning. Don't remember why I have unsigned here, I thought I'd put signed everywhere... --- NewKernel_d/include/CGAL/Vector/array.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index bf03145ebe3..e7ea3e09071 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -31,7 +31,7 @@ template struct Array_vector { template struct Property : boost::false_type {}; static const unsigned d_=Max_dim_::value; - CGAL_static_assertion(d_ != UNKNOWN_DIMENSION); + CGAL_static_assertion(d_ != (unsigned)UNKNOWN_DIMENSION); typedef cpp0x::array Vector; struct Construct_vector { From afacf014333f1c401ed31683b269400c6c98ef0f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 21 May 2012 07:27:47 +0000 Subject: [PATCH 130/210] comment --- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h | 1 + 1 file changed, 1 insertion(+) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index e1f480b9e4d..ef00a9a0037 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -18,6 +18,7 @@ namespace CGAL { template class Point_d : public R_::Kernel_base::Point // Deriving won't work if the point is just a __m256d. + // Test boost/std::is_class for instance { typedef typename R_::RT RT_; typedef typename R_::FT FT_; From e85b0b11e5946333465d867ff7f1052fbbe22afb Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 21 May 2012 15:56:28 +0000 Subject: [PATCH 131/210] start prekernel doc --- .../doc_tex/NewKernel_d_ref/Kernel.tex | 55 ------- .../doc_tex/NewKernel_d_ref/PreKernel.tex | 150 ++++++++++++++++++ NewKernel_d/doc_tex/NewKernel_d_ref/main.tex | 46 +++--- 3 files changed, 173 insertions(+), 78 deletions(-) delete mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex create mode 100644 NewKernel_d/doc_tex/NewKernel_d_ref/PreKernel.tex diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex deleted file mode 100644 index 3c84e34c134..00000000000 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/Kernel.tex +++ /dev/null @@ -1,55 +0,0 @@ -\begin{ccRefConcept}{Kernel} -The concept of a {\em kernel} is defined by a set of requirements on -the provision of certain types. The types are function object classes to be -used within the algorithms and data structures of \cgal. - -A kernel provides types, construction objects, and generalized predicates. -The former replace constructors of the kernel classes and constructive -procedures in the kernel. There are also function objects replacing operators, -especially for equality testing. - -Types and functors are identified by tags, which may be any type (like \ccc{CGAL::Segment_tag}). As a special case, the construction functor of a type identified by \ccc{Some_tag} is identified by the tag \ccc{Construct_ttag}, and the conversion functor by \ccc{Convert_ttag}. - -Depending on \ccc{Default_ambient_dimension}, a kernel has 2 constructors, a default constructor and a constructor that takes as argument an \ccc{int} for the dimension. - -\ccTypes - -\ccNestedType{Default_ambient_dimension}{\ccc{Dimension_tag} where \ccc{d} is the ambient dimension or \ccc{Dynamic_dimension_tag} if the dimension is unknown.} -\ccGlue -\ccNestedType{Max_ambient_dimension}{\ccc{Dimension_tag} where \ccc{d} is an upper bound on the ambient dimension or \ccc{Dynamic_dimension_tag}.} - -% Replace with Type::type? -\ccNestedType{FT}{a model of \ccc{FieldNumberType}} -\ccGlue -\ccNestedType{RT}{a model of \ccc{RingNumberType}} - -% Not documented in the first version -\ccNestedType{LA}{a model of \ccc{LinearAlgebraSomething} using \ccc{RT}} - -The following types describe the return types of predicates. They typically -map to \ccc{bool} and \cgal\ kernel enum types, except when an interval arithmetic -number type is used such as within the filtering kernels, in which case it is -\ccc{Uncertain} or similar. - -\ccNestedType{Boolean}{\ccc{bool} or \ccc{Uncertain}} -\ccGlue -\ccNestedType{Sign}{\ccc{CGAL::Sign} or \ccc{Uncertain}} -\ccGlue -\ccNestedType{Comparison_result}{\ccc{CGAL::Comparison_result} or \ccc{Uncertain}} -\ccGlue -\ccNestedType{Orientation}{\ccc{CGAL::Orientation} or \ccc{Uncertain}} -\ccGlue -\ccNestedType{Oriented_side}{\ccc{CGAL::Oriented_side} or \ccc{Uncertain}} -\ccGlue -\ccNestedType{Bounded_side}{\ccc{CGAL::Bounded_side} or \ccc{Uncertain}} -\ccGlue -\ccNestedType{Angle}{\ccc{CGAL::Angle} or \ccc{Uncertain}} - -\ccNestedType{template struct Type}{This nested template class defines an object type \ccc{type}. For instance, \ccc{Type::type} is the type of points.} - -\ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate. Functors that are not provided should all be \ccc{Null_functor}.} - -\ccNestedType{Object_list}{A typedef for \ccc{typeset} with the list of tags that can be passed to the \ccc{Type} template.} - -\end{ccRefConcept} - diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/PreKernel.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/PreKernel.tex new file mode 100644 index 00000000000..3370fdc5fc4 --- /dev/null +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/PreKernel.tex @@ -0,0 +1,150 @@ +% +------------------------------------------------------------------------+ +% | Reference manual page: PreKernel.tex +% +------------------------------------------------------------------------+ +% | 21.05.2012 Marc Glisse +% | Package: NewKernel_d +% | +\RCSdef{\RCSPreKernelRev}{$Id$} +\RCSdefDate{\RCSPreKernelDate}{$Date$} +% | +\ccRefPageBegin +%%RefPage: end of header, begin of main body +% +------------------------------------------------------------------------+ + + +\begin{ccRefConcept}{PreKernel} + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[concept]{} %% add further index entries + +\ccDefinition + +%copied from Kernel_23 +The concept of a {\em prekernel} is defined by a set of requirements on +the provision of certain types and access member functions to create +objects of these types. The types are function object classes to be used +within the algorithms and data structures of \cgal. This allows you to +use any model of a kernel as a traits class in the Cgal algorithms and +data structures, unless they require types beyond those provided by a +kernel. + +A kernel provides types, construction objects, and generalized +predicates. The former replace constructors of the kernel classes and +constructive procedures in the kernel. There are also function objects +replacing operators, especially for equality testing. + +Types and functors are identified by tags, which may be any type (like +\ccc{CGAL::Segment_tag}). As a special case, the construction functor of +a type identified by \ccc{Some_tag} is identified by the tag +\ccc{Construct_ttag}, and the conversion functor by +\ccc{Convert_ttag}. + +Depending on \ccc{Default_ambient_dimension}, a kernel has 2 +constructors, a default constructor and a constructor that takes as +argument an \ccc{int} for the dimension. + + +%\ccGeneralizes +% +%ThisConcept \\ +%ThatConcept + +\ccTypes + +\ccNestedType{Default_ambient_dimension}{\ccc{Dimension_tag} where \ccc{d} is the ambient dimension or \ccc{Dynamic_dimension_tag} if the dimension is unknown.} +\ccGlue +\ccNestedType{Max_ambient_dimension}{\ccc{Dimension_tag} where \ccc{d} is an upper bound on the ambient dimension or \ccc{Dynamic_dimension_tag}.} + +\ccNestedType{FT}{a model of \ccc{FieldNumberType}} +\ccGlue +\ccNestedType{RT}{a model of \ccc{RingNumberType}} + +% Not documented in the first version +\ccNestedType{LA}{a model of \ccc{LinearAlgebraSomething} using \ccc{RT}} + +The following types describe the return types of predicates. They typically +map to \ccc{bool} and \cgal\ kernel enum types, except when an interval arithmetic +number type is used such as within the filtering kernels, in which case it is +\ccc{Uncertain} or similar. + +\ccNestedType{Boolean}{\ccc{bool} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Sign}{\ccc{CGAL::Sign} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Comparison_result}{\ccc{CGAL::Comparison_result} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Orientation}{\ccc{CGAL::Orientation} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Oriented_side}{\ccc{CGAL::Oriented_side} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Bounded_side}{\ccc{CGAL::Bounded_side} or \ccc{Uncertain}} +\ccGlue +\ccNestedType{Angle}{\ccc{CGAL::Angle} or \ccc{Uncertain}} + +\ccHeading{Geometric Objects} + +%\ccNestedType{template struct Type}{This nested template class defines an object type \ccc{type}. For instance, \ccc{Type::type} is the type of points.} +\ccNestedType{Point, \ldots}{Geometric object type} + +\ccNestedType{Object_list}{A typedef for \ccc{typeset} +with the list of tags corresponding to the provided geometric object +types.} + +\ccHeading{Iterators} + +\ccNestedType{Point_cartesian_const_iterator, \ldots}{Iterator} + +\ccNestedType{Iterator_list}{A typedef for +\ccc{typeset} with the list of +tags corresponding to the provided iterators.} + + +\ccHeading{Function objects} + +\ccNestedType{template struct Functor}{This nested template class defines a functor type \ccc{type}. For instance, \ccc{Functor::type} is the orientation predicate. Functors that are not provided should all be \ccc{Null_functor}.} + + +\ccCreation +\ccCreationVariable{kernel} %% choose variable name + +\ccConstructor{PreKernel();}{default constructor.} +\ccConstructor{PreKernel(int d);}{constructor for dimension $d$.} + +\ccOperations + +\ccMethod{int dimension();}{returns the dimension (or UNKNOWN\_DIMENSION)} + +\ccHasModels + +\ccc{Some_class}, +\ccc{Some_other_class}. + +\ccSeeAlso + +Kernel\_d +%Some\_other\_concept, +%%\ccc{some_other_function}. + +%\ccExample +% +%A short example program. +%Instead of a short program fragment, a full running program can be +%included using the +%\verb|\ccIncludeExampleCode{Package/PreKernel.C}| +%macro. The program example would be part of the source code distribution and +%also part of the automatic test suite. +% +%\begin{ccExampleCode} +%void your_example_code() { +%} +%\end{ccExampleCode} + +%% \ccIncludeExampleCode{Package/PreKernel.C} + +\end{ccRefConcept} + +% +------------------------------------------------------------------------+ +%%RefPage: end of main body, begin of footer +\ccRefPageEnd +% EOF +% +------------------------------------------------------------------------+ diff --git a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex index 6b2cd3eba9f..8366d2fa080 100644 --- a/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex +++ b/NewKernel_d/doc_tex/NewKernel_d_ref/main.tex @@ -1,25 +1,25 @@ -\ccUserChapter{dD NewKernel\label{uddk}} -\label{ddk} -\ccChapterAuthor{Marc Glisse} +% +------------------------------------------------------------------------+ +% | CBP Reference Manual: main.tex +% +------------------------------------------------------------------------+ +% | Automatically generated driver file for the reference manual chapter +% | of this package. Do not edit manually, you may loose your changes. +% +------------------------------------------------------------------------+ -\input{NewKernel_d_ref/PkgDescription} +\input{NewKernel_d_ref/Cartesian_complete.tex} +\input{NewKernel_d_ref/Cartesian_filter_K.tex} +\input{NewKernel_d_ref/Cartesian_mini_d.tex} +\input{NewKernel_d_ref/Cartesian_wrap.tex} +\input{NewKernel_d_ref/Define_segment.tex} +\input{NewKernel_d_ref/KernelD_converter.tex} +\input{NewKernel_d_ref/Kernel_2_interface.tex} +\input{NewKernel_d_ref/Kernel_3_interface.tex} +\input{NewKernel_d_ref/Kernel_d_interface.tex} +\input{NewKernel_d_ref/Kernel_functor.tex} +\input{NewKernel_d_ref/Lazy_kernel.tex} +\input{NewKernel_d_ref/PkgDescription.tex} +\input{NewKernel_d_ref/Point.tex} +\input{NewKernel_d_ref/PreKernel.tex} +\input{NewKernel_d_ref/Segment.tex} +\input{NewKernel_d_ref/typeset.tex} -\minitoc - -\input{NewKernel_d_ref/Kernel} -\input{NewKernel_d_ref/Kernel_functor} -\input{NewKernel_d_ref/Point} -\input{NewKernel_d_ref/Segment} -\input{NewKernel_d_ref/Cartesian_filter_K} -\input{NewKernel_d_ref/Cartesian_mini_d} -\input{NewKernel_d_ref/Cartesian_complete} -\input{NewKernel_d_ref/Cartesian_wrap} -\input{NewKernel_d_ref/Define_segment} -\input{NewKernel_d_ref/Lazy_kernel} -\input{NewKernel_d_ref/KernelD_converter} -\input{NewKernel_d_ref/Kernel_2_interface} -\input{NewKernel_d_ref/Kernel_3_interface} -\input{NewKernel_d_ref/Kernel_d_interface} - -% move to another package -\input{NewKernel_d_ref/typeset} +%% EOF From 7fc5d1fe72201afe5dede13631685e8ffdf95e0a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 1 Jun 2012 16:35:29 +0000 Subject: [PATCH 132/210] add a few functors --- .../include/CGAL/Kernel_d/Define_segment.h | 2 +- .../CGAL/Kernel_d/Kernel_d_interface.h | 8 ++ .../CGAL/Kernel_d/{ => Types}/Segmentd.h | 0 .../Kernel_d/function_objects_cartesian.h | 77 +++++++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 10 +++ NewKernel_d/include/CGAL/functor_tags.h | 5 ++ 6 files changed, 101 insertions(+), 1 deletion(-) rename NewKernel_d/include/CGAL/Kernel_d/{ => Types}/Segmentd.h (100%) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 874bcabcd37..baf26102f6e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include namespace CGAL { namespace CartesianDKernelFunctors { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 8f1526f9947..9c4487ad7b7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -16,21 +16,29 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::Vector Vector_d; //typedef typename Base::Segment Segment_d; typedef typename Base::template Functor::type Compare_lexicographically_d; + typedef typename Base::template Functor::type Less_lexicographically_d; + typedef typename Base::template Functor::type Less_or_equal_lexicographically_d; typedef typename Base::template Functor::type Orientation_d; typedef typename Base::template Functor::type Side_of_oriented_sphere_d; typedef typename Base::template Functor::type Contained_in_affine_hull_d; typedef typename Base::template Functor::type Construct_flat_orientation_d; typedef typename Base::template Functor::type In_flat_orientation_d; typedef typename Base::template Functor::type In_flat_side_of_oriented_sphere_d; + typedef typename Base::template Functor::type Point_to_vector_d; + typedef typename Base::template Functor::type Vector_to_point_d; Compare_lexicographically_d compare_lexicographically_d_object()const{ return Compare_lexicographically_d(*this); } + Less_lexicographically_d less_lexicographically_d_object()const{ return Less_lexicographically_d(*this); } + Less_or_equal_lexicographically_d less_or_equal_lexicographically_d_object()const{ return Less_or_equal_lexicographically_d(*this); } Orientation_d orientation_d_object()const{ return Orientation_d(*this); } Side_of_oriented_sphere_d side_of_oriented_sphere_d_object()const{ return Side_of_oriented_sphere_d(*this); } Contained_in_affine_hull_d contained_in_affine_hull_d_object()const{ return Contained_in_affine_hull_d(*this); } Construct_flat_orientation_d construct_flat_orientation_d_object()const{ return Construct_flat_orientation_d(*this); } In_flat_orientation_d in_flat_orientation_d_object()const{ return In_flat_orientation_d(*this); } In_flat_side_of_oriented_sphere_d in_flat_side_of_oriented_sphere_d_object()const{ return In_flat_side_of_oriented_sphere_d(*this); } + Point_to_vector_d point_to_vector_d_object()const{ return Point_to_vector_d(*this); } + Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); } }; } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h similarity index 100% rename from NewKernel_d/include/CGAL/Kernel_d/Segmentd.h rename to NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h 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 deea9b7ba46..b69e52dc834 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -300,6 +300,38 @@ template struct Side_of_oriented_sphere : private Store_kernel { #endif }; +template struct Point_to_vector : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Point_to_vector) + typedef R_ R; + typedef typename R_::RT RT; + typedef typename R::Vector Vector; + typedef typename R::Point Point; + typedef typename R::template Functor >::type CV; + typedef typename R::template Functor >::type CI; + typedef Vector result_type; + typedef Point argument_type; + result_type operator()(argument_type const&v)const{ + CI ci(this->kernel()); + return CV(this->kernel())(ci(v,Begin_tag(),ci(v,End_tag()))); + } +}; + +template struct Vector_to_point : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Vector_to_point) + typedef R_ R; + typedef typename R_::RT RT; + typedef typename R::Vector Vector; + typedef typename R::Point Point; + typedef typename R::template Functor >::type CV; + typedef typename R::template Functor >::type CI; + typedef Point result_type; + typedef Vector argument_type; + result_type operator()(argument_type const&v)const{ + CI ci(this->kernel()); + return CV(this->kernel())(ci(v,Begin_tag(),ci(v,End_tag()))); + } +}; + template struct Opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Opposite_vector) typedef R_ R; @@ -347,6 +379,23 @@ template struct Difference_of_vectors : private Store_kernel { } }; +template struct Difference_of_points : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Difference_of_points) + typedef R_ R; + typedef typename R_::RT RT; + typedef typename R::Point Point; + typedef typename R::Vector Vector; + typedef typename R::template Functor >::type CV; + typedef typename R::template Functor >::type CI; + typedef Vector result_type; + typedef Point first_argument_type; + typedef Point second_argument_type; + result_type operator()(Point const&a, Point const&b)const{ + CI ci(this->kernel()); + return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); + } +}; + template struct Midpoint : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Midpoint) typedef R_ R; @@ -507,6 +556,34 @@ template struct Compare_lexicographically : private Store_kernel { } }; +template struct Less_lexicographically : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Less_lexicographically) + typedef R_ R; + typedef typename R::Boolean result_type; + typedef typename R::template Functor::type CL; + typedef typename CGAL::Is_exact Is_exact; + + template + result_type operator() (V const&a, W const&b) const { + CL c (this->kernel()); + return c(a,b) < 0; + } +}; + +template struct Less_or_equal_lexicographically : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Less_or_equal_lexicographically) + typedef R_ R; + typedef typename R::Boolean result_type; + typedef typename R::template Functor::type CL; + typedef typename CGAL::Is_exact Is_exact; + + template + result_type operator() (V const&a, W const&b) const { + CL c (this->kernel()); + return c(a,b) <= 0; + } +}; + } } diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 1b245404855..65d14e40b79 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -46,6 +46,12 @@ CGAL_Kernel_cons2(Difference_of_vectors, difference_of_vectors_object) CGAL_Kernel_cons2(Opposite_vector, opposite_vector_object) +CGAL_Kernel_cons2(Difference_of_points, + difference_of_points_object) +CGAL_Kernel_cons2(Vector_to_point, + vector_to_point_object) +CGAL_Kernel_cons2(Point_to_vector, + point_to_vector_object) CGAL_Kernel_cons2(Midpoint, midpoint_object) //CGAL_Kernel_cons2(Construct_segment, @@ -82,6 +88,10 @@ CGAL_Kernel_pred(Compare_distance, compare_distance_object) CGAL_Kernel_pred(Compare_lexicographically, compare_lexicographically_object) +CGAL_Kernel_pred(Less_lexicographically, + less_lexicographically_object) +CGAL_Kernel_pred(Less_or_equal_lexicographically, + less_or_equal_lexicographically_object) CGAL_Kernel_pred(Contained_in_affine_hull, contained_in_affine_hull_object) CGAL_Kernel_pred(In_flat_orientation, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 8f8468ddbd0..068e7878c7d 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -106,6 +106,9 @@ namespace CGAL { DECL_CONSTRUCT(Sum_of_vectors,Vector); DECL_CONSTRUCT(Difference_of_vectors,Vector); DECL_CONSTRUCT(Opposite_vector,Vector); + DECL_CONSTRUCT(Difference_of_points,Vector); + DECL_CONSTRUCT(Point_to_vector,Vector); + DECL_CONSTRUCT(Vector_to_point,Point); #undef DECL_CONSTRUCT #if 0 #define DECL_ITER_CONSTRUCT(X,Y) struct X##_tag {}; \ @@ -123,6 +126,8 @@ namespace CGAL { DECL_PREDICATE(Compare_point_cartesian_coordinate); DECL_PREDICATE(Compare_distance); DECL_PREDICATE(Compare_lexicographically); + DECL_PREDICATE(Less_lexicographically); + DECL_PREDICATE(Less_or_equal_lexicographically); DECL_PREDICATE(Orientation); DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_vectors); From c705ad66971779ed25bab4ee22669fcc66cdd2ab Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 1 Jun 2012 17:23:08 +0000 Subject: [PATCH 133/210] more functors --- .../CGAL/Kernel_d/Kernel_d_interface.h | 23 +++++++++++++++ .../Kernel_d/function_objects_cartesian.h | 29 +++++++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 2 ++ NewKernel_d/include/CGAL/functor_tags.h | 1 + 4 files changed, 55 insertions(+) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 9c4487ad7b7..a55512395de 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -15,10 +15,13 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::Point Point_d; typedef typename Base::Vector Vector_d; //typedef typename Base::Segment Segment_d; + typedef typename Base::template Functor::type Compute_coordinate_d; typedef typename Base::template Functor::type Compare_lexicographically_d; + typedef typename Base::template Functor::type Equal_d; typedef typename Base::template Functor::type Less_lexicographically_d; typedef typename Base::template Functor::type Less_or_equal_lexicographically_d; typedef typename Base::template Functor::type Orientation_d; + typedef typename Base::template Functor::type Point_dimension_d; typedef typename Base::template Functor::type Side_of_oriented_sphere_d; typedef typename Base::template Functor::type Contained_in_affine_hull_d; typedef typename Base::template Functor::type Construct_flat_orientation_d; @@ -26,12 +29,31 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor::type In_flat_side_of_oriented_sphere_d; typedef typename Base::template Functor::type Point_to_vector_d; typedef typename Base::template Functor::type Vector_to_point_d; + struct Component_accessor_d : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) + typedef typename Base::Point Point; + typedef typename Base::RT RT; + typedef typename Base::FT FT; + int dimension(Point const&p){ + return this->kernel().point_dimension_d_object()(p); + } + FT cartesian(Point const&p, int i){ + return this->kernel().compute_coordinate_d_object()(p); + } + RT homogeneous(Point const&p, int i){ + // FIXME + return this->kernel().compute_coordinate_d_object()(p); + } + }; + Compute_coordinate_d compute_coordinate_d_object()const{ return Compute_coordinate_d(*this); } Compare_lexicographically_d compare_lexicographically_d_object()const{ return Compare_lexicographically_d(*this); } + Equal_d equal_d_object()const{ return Equal_d(*this); } Less_lexicographically_d less_lexicographically_d_object()const{ return Less_lexicographically_d(*this); } Less_or_equal_lexicographically_d less_or_equal_lexicographically_d_object()const{ return Less_or_equal_lexicographically_d(*this); } Orientation_d orientation_d_object()const{ return Orientation_d(*this); } + Point_dimension_d point_dimension_d_object()const{ return Point_dimension_d(*this); } Side_of_oriented_sphere_d side_of_oriented_sphere_d_object()const{ return Side_of_oriented_sphere_d(*this); } Contained_in_affine_hull_d contained_in_affine_hull_d_object()const{ return Contained_in_affine_hull_d(*this); } Construct_flat_orientation_d construct_flat_orientation_d_object()const{ return Construct_flat_orientation_d(*this); } @@ -39,6 +61,7 @@ template struct Kernel_d_interface : public Base_ { In_flat_side_of_oriented_sphere_d in_flat_side_of_oriented_sphere_d_object()const{ return In_flat_side_of_oriented_sphere_d(*this); } Point_to_vector_d point_to_vector_d_object()const{ return Point_to_vector_d(*this); } Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); } + Component_accessor_d component_accessor_d_object()const{ return Component_accessor_d(*this); } }; } 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 b69e52dc834..2ce97eb5aea 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -584,6 +585,34 @@ template struct Less_or_equal_lexicographically : private Store_kernel } }; +template struct Equal_points : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Equal_points) + typedef R_ R; + typedef typename R::Boolean result_type; + 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 Is_exact; + + template + result_type operator()(V const&a, W const&b)const{ + CI c(this->kernel()); +#ifdef CGAL_CXX0X + auto +#else + typename CI::result_type +#endif + a_begin=c(a,Begin_tag()), + b_begin=c(b,Begin_tag()), + a_end=c(a,End_tag()); + result_type res = true; + // Is using CGAL::possibly for Uncertain really an optimization? + do res = res & (*a_begin++ == *b_begin++); + while(a_begin!=a_end && possibly(res)); + return res; + } +}; + } } diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 65d14e40b79..1b02b3ca463 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -90,6 +90,8 @@ CGAL_Kernel_pred(Compare_lexicographically, compare_lexicographically_object) CGAL_Kernel_pred(Less_lexicographically, less_lexicographically_object) +CGAL_Kernel_pred(Equal_points, + equal_points_object) CGAL_Kernel_pred(Less_or_equal_lexicographically, less_or_equal_lexicographically_object) CGAL_Kernel_pred(Contained_in_affine_hull, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 068e7878c7d..65771b53380 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -128,6 +128,7 @@ namespace CGAL { DECL_PREDICATE(Compare_lexicographically); DECL_PREDICATE(Less_lexicographically); DECL_PREDICATE(Less_or_equal_lexicographically); + DECL_PREDICATE(Equal_points); DECL_PREDICATE(Orientation); DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_vectors); From 8565eee63b0295cd8561452c96b19f186342e174 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 3 Jun 2012 15:20:48 +0000 Subject: [PATCH 134/210] Placeholder sphere, hyperplane. Unused and untested. --- .../CGAL/Kernel_d/Types/Aff_transformation.h | 36 +++++++++++++ .../include/CGAL/Kernel_d/Types/Hyperplane.h | 54 +++++++++++++++++++ .../include/CGAL/Kernel_d/Types/Sphere.h | 52 ++++++++++++++++++ NewKernel_d/include/CGAL/functor_tags.h | 7 +++ 4 files changed, 149 insertions(+) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h new file mode 100644 index 00000000000..e5114b31cfa --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h @@ -0,0 +1,36 @@ +#ifndef CGAL_KD_TYPE_AFF_TRANSFORMATION_H +#define CGAL_KD_TYPE_AFF_TRANSFORMATION_H +#include +#include + +// Dummy, that's all the Kernel_d concept requires, so a useful class will wait. + +namespace CGAL { +template +struct Aff_transformation { + typedef R_ R; +}; +namespace CartesianDKernelFunctors { +template struct Construct_aff_transformation { + CGAL_FUNCTOR_INIT_IGNORE(Construct_aff_transformation) + typedef R_ R; + typedef typename R::Aff_transformation result_type; +#ifdef CGAL_CXX0X + template + result_type operator()(T&&...)const{return result_type();} +#else + result_type operator()()const{ + return result_type(); + } +#define CODE(Z,N,_) template \ + result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const& BOOST_PP_INTERCEPT))const{ \ + return result_type(); \ + } + BOOST_PP_REPEAT_FROM_TO(1, 9, CODE, _ ) +#undef CODE + +#endif +}; +} +} +#endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h new file mode 100644 index 00000000000..4a3c2a2cb5c --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h @@ -0,0 +1,54 @@ +#ifndef CGAL_KD_TYPE_SPHERE_H +#define CGAL_KD_TYPE_SPHERE_H +#include +namespace CGAL { +template class Hyperplane { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef typename R_::Vector Vector_; + Vector_ v_; + FT_ s_; + + public: + Hyperplane(Vector_ const&v, FT_ const&s): v_(v), s_(s) {} + // TODO: Add a piecewise constructor? + + Vector_ orthogonal_vector()const{return v_;} + FT_ translation()const{return s_;} +}; +namespace CartesianDKernelFunctors { +template struct Construct_hyperplane : Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_hyperplane) + typedef typename R_::Hyperplane result_type; + typedef typename R_::Point Point; + typedef typename R_::Vector Vector; + typedef typename R_::FT FT; + typedef typename R_::LA LA; + result_type operator()(Vector const&a, FT const&b)const{ + return result_type(a,b); + } + template + result_type operator()(Iter f, Iter e)const{ + throw "not implemented yet!"; + } +}; +template struct Orthogonal_vector { + CGAL_FUNCTOR_INIT_IGNORE(Orthogonal_vector) + typedef typename R_::Hyperplane Hyperplane; + typedef typename R_::Point result_type; + result_type operator()(Hyperplane const&s)const{ + return s.orthogonal_vector(); + } +}; +template struct Hyperplane_translation { + CGAL_FUNCTOR_INIT_IGNORE(Hyperplane_translation) + typedef typename R_::Hyperplane Hyperplane; + typedef typename R_::FT result_type; + // TODO: Is_exact? + result_type operator()(Hyperplane const&s)const{ + return s.translation(); + } +}; +} +} // namespace CGAL +#endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h new file mode 100644 index 00000000000..db64fe42dc1 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h @@ -0,0 +1,52 @@ +#ifndef CGAL_KD_TYPE_SPHERE_H +#define CGAL_KD_TYPE_SPHERE_H +#include +namespace CGAL { +template class Sphere { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + Point_ c_; + FT_ r2_; + + public: + Sphere(Point_ const&p, FT_ const&r2): c_(p), r2_(r2) {} + // TODO: Add a piecewise constructor? + + Point_ center()const{return c_;} + FT_ squared_radius()const{return r2_;} +}; +namespace CartesianDKernelFunctors { +template struct Construct_sphere : Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_sphere) + typedef typename R_::Sphere result_type; + typedef typename R_::Point Point; + typedef typename R_::FT FT; + typedef typename R_::LA LA; + result_type operator()(Point const&a, FT const&b)const{ + return result_type(a,b); + } + template + result_type operator()(Iter f, Iter e)const{ + throw "not implemented yet!"; + } +}; +template struct Center_of_sphere { + CGAL_FUNCTOR_INIT_IGNORE(Center_of_sphere) + typedef typename R_::Sphere Sphere; + typedef typename R_::Point result_type; + result_type operator()(Sphere const&s)const{ + return s.center(); + } +}; +template struct Squared_radius { + CGAL_FUNCTOR_INIT_IGNORE(Squared_radius) + typedef typename R_::Sphere Sphere; + typedef typename R_::FT result_type; + // TODO: Is_exact? + result_type operator()(Sphere const&s)const{ + return s.squared_radius(); + } +}; +} +} // namespace CGAL +#endif diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 65771b53380..b4525ea9b77 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -44,10 +44,13 @@ namespace CGAL { DECL_OBJ(Vector); DECL_OBJ(Point); DECL_OBJ(Segment); + DECL_OBJ(Sphere); DECL_OBJ(Line); DECL_OBJ(Direction); + DECL_OBJ(Hyperplane); DECL_OBJ(Ray); DECL_OBJ(Bbox); + DECL_OBJ(Aff_transformation); #undef DECL_OBJ template struct is_NT_tag { enum { value = false }; }; @@ -67,7 +70,9 @@ namespace CGAL { DECL_COMPUTE(Squared_distance); DECL_COMPUTE(Squared_distance_to_origin); DECL_COMPUTE(Squared_length); + DECL_COMPUTE(Squared_radius); DECL_COMPUTE(Scalar_product); + DECL_COMPUTE(Hyperplane_translation); #undef DECL_COMPUTE #define DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \ @@ -102,10 +107,12 @@ namespace CGAL { template<>struct map_result_tag{typedef Y##_tag type;}; \ template<>struct map_functor_type{typedef Construct_tag type;} DECL_CONSTRUCT(Midpoint,Point); + DECL_CONSTRUCT(Center_of_sphere,Point); DECL_CONSTRUCT(Segment_extremity,Point); DECL_CONSTRUCT(Sum_of_vectors,Vector); DECL_CONSTRUCT(Difference_of_vectors,Vector); DECL_CONSTRUCT(Opposite_vector,Vector); + DECL_CONSTRUCT(Orthogonal_vector,Vector); DECL_CONSTRUCT(Difference_of_points,Vector); DECL_CONSTRUCT(Point_to_vector,Vector); DECL_CONSTRUCT(Vector_to_point,Point); From 940f6efccfc86b436aacfc8225b3b462eeff1c87 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 11 Aug 2012 08:36:11 +0000 Subject: [PATCH 135/210] iterator in the interface --- .../CGAL/Kernel_d/Kernel_d_interface.h | 24 +++- NewKernel_d/test/NewKernel_d/test.cpp | 108 ++++++++++-------- 2 files changed, 83 insertions(+), 49 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index a55512395de..812b8dce733 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -11,6 +11,7 @@ namespace CGAL { template struct Kernel_d_interface : public Base_ { typedef Base_ Base; typedef Kernel_d_interface Kernel; + typedef Kernel R_; // for the macros typedef typename Base::Flat_orientation Flat_orientation_d; typedef typename Base::Point Point_d; typedef typename Base::Vector Vector_d; @@ -41,10 +42,30 @@ template struct Kernel_d_interface : public Base_ { return this->kernel().compute_coordinate_d_object()(p); } RT homogeneous(Point const&p, int i){ + throw "not implemented yet"; + return 0; // FIXME - return this->kernel().compute_coordinate_d_object()(p); + //return this->kernel().compute_coordinate_d_object()(p); } }; + struct Construct_cartesian_const_iterator_d : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_cartesian_const_iterator_d) + typedef typename Base::template Functor >::type CPI; + typedef typename Base::template Functor >::type CVI; + typedef typename CGAL::decay::type>::type result_type; + // Kernel_d requires a common iterator type for points and vectors + // TODO: provide this mixed functor in preKernel? + CGAL_static_assertion((boost::is_same::type>::type, result_type>::value)); + template + result_type operator()(Point_d const&p, Tag t)const{ + return CPI(this->kernel())(p,t); + } + template + result_type operator()(Vector_d const&v, Tag t)const{ + return CVI(this->kernel())(v,t); + } + }; + typedef typename Construct_cartesian_const_iterator_d::result_type Cartesian_const_iterator_d; Compute_coordinate_d compute_coordinate_d_object()const{ return Compute_coordinate_d(*this); } @@ -62,6 +83,7 @@ template struct Kernel_d_interface : public Base_ { Point_to_vector_d point_to_vector_d_object()const{ return Point_to_vector_d(*this); } Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); } Component_accessor_d component_accessor_d_object()const{ return Component_accessor_d(*this); } + Construct_cartesian_const_iterator_d construct_cartesian_const_iterator_d_object()const{ return Construct_cartesian_const_iterator_d(*this); } }; } diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index f04181668f8..141a3272071 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -1,3 +1,4 @@ +#define BOOST_RESULT_OF_USE_DECLTYPE 1 #include #include #include @@ -8,9 +9,14 @@ #include #include #include +#include #include #include #include + +templatevoid marc_use(){} +#define USE_TYPE(T) marc_use() + //typedef CGAL::Cartesian_base_d > K0; //typedef CGAL::Cartesian_base_d > KA; struct KA : CGAL::Cartesian_static_filters, CGAL::Define_segment,KA>, KA>, KA> {}; @@ -57,62 +63,68 @@ typedef CGAL::Cartesian_wrap K3; typedef CGAL::Cartesian_wrap KK; #endif +template +void test(){ #if 0 -typedef KK K1; -typedef K1::Type::type P; -typedef K1::Iterator::type CI; -typedef K1::Type::type V; -typedef K1::Type::type S; + typedef Ker K1; + typedef typename K1::Type::type P; + typedef typename K1::Iterator::type CI; + typedef typename K1::Type::type V; + typedef typename K1::Type::type S; #elif 1 -//typedef CGAL::Define_kernel_types K1; -typedef KK K1; -typedef K1::Point P; -typedef K1::Point_cartesian_const_iterator CI; -typedef K1::Vector V; -typedef K1::Segment S; + //typedef CGAL::Define_kernel_types K1; + typedef Ker K1; + typedef typename K1::Point P; + //typedef typename K1::Point_cartesian_const_iterator CI; + typedef typename K1::Vector V; + typedef typename K1::Segment S; #endif -//typedef K1::Construct_point CP; -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 PO; -typedef K1::Functor::type SOS; -//typedef K1::Point_cartesian_const_iterator CI; -typedef K1::Functor::type CC; - #if 1 #define Kinit (k) #else #define Kinit #endif -int main(){ - K1 k; - CP cp Kinit; - CCI ci Kinit; - CC cc Kinit; - PO po Kinit; - CS cs Kinit; - CSE cse Kinit; - SOS sos Kinit; - P a=cp(3,4); - P b=cp(5,6,7); - int rr[]={3,5,2}; - int* r=rr; - P c=cp(r,r+2); - P d=cp(r,r+3,CGAL::Homogeneous_tag()); - S s=cs(c,d); - std::cout << cc(a,1) << std::endl; - std::cout << cc(b,1) << std::endl; - std::cout << cc(cse(s,0),1) << std::endl; - std::cout << cc(cse(s,1),1) << std::endl; - for(CI i=ci(a,CGAL::Begin_tag());i!=ci(a,CGAL::End_tag());++i) - std::cout << *i << ' '; - std::cout << '\n'; - P tab[]={a,b,c,d}; - std::cout << po (&tab[0],tab+3) << std::endl; - std::cout << sos(&tab[0],tab+4) << std::endl; + //typedef K1::Construct_point CP; + typedef typename K1::template Functor >::type CP; + typedef typename K1::template Functor >::type CV; + typedef typename K1::template Functor >::type CS; + typedef typename K1::template Functor::type CSE; + typedef typename K1::template Functor >::type CCI; + typedef typename K1::template Functor::type PO; + typedef typename K1::template Functor::type SOS; + typedef typename K1::template Functor::type CC; + typedef typename CGAL::decay::type>::type CI; + + USE_TYPE(V); + USE_TYPE(CV); + Ker k; + CP cp Kinit; + CCI ci Kinit; + CC cc Kinit; + PO po Kinit; + CS cs Kinit; + CSE cse Kinit; + SOS sos Kinit; + P a=cp(3,4); + P b=cp(5,6,7); + int rr[]={3,5,2}; + int* r=rr; + P c=cp(r,r+2); + P d=cp(r,r+3,CGAL::Homogeneous_tag()); + S s=cs(c,d); + std::cout << cc(a,1) << std::endl; + std::cout << cc(b,1) << std::endl; + std::cout << cc(cse(s,0),1) << std::endl; + std::cout << cc(cse(s,1),1) << std::endl; + for(CI i=ci(a,CGAL::Begin_tag());i!=ci(a,CGAL::End_tag());++i) + std::cout << *i << ' '; + std::cout << '\n'; + P tab[]={a,b,c,d}; + std::cout << po (&tab[0],tab+3) << std::endl; + std::cout << sos(&tab[0],tab+4) << std::endl; +} +int main(){ + test(); } From 6eb31e6f87769018de60986526dbeafddad40a0b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 11 Aug 2012 14:47:19 +0000 Subject: [PATCH 136/210] test kernel_d interface --- .../CGAL/Kernel_d/Kernel_d_interface.h | 12 ++++--- NewKernel_d/test/NewKernel_d/test.cpp | 36 +++++++------------ 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 812b8dce733..43ba30a139a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -11,16 +11,17 @@ namespace CGAL { template struct Kernel_d_interface : public Base_ { typedef Base_ Base; typedef Kernel_d_interface Kernel; - typedef Kernel R_; // for the macros + typedef Base_ R_; // for the macros typedef typename Base::Flat_orientation Flat_orientation_d; typedef typename Base::Point Point_d; typedef typename Base::Vector Vector_d; - //typedef typename Base::Segment Segment_d; + typedef typename Base::Segment Segment_d; typedef typename Base::template Functor::type Compute_coordinate_d; typedef typename Base::template Functor::type Compare_lexicographically_d; typedef typename Base::template Functor::type Equal_d; typedef typename Base::template Functor::type Less_lexicographically_d; typedef typename Base::template Functor::type Less_or_equal_lexicographically_d; + // FIXME: and vectors? typedef typename Base::template Functor::type Orientation_d; typedef typename Base::template Functor::type Point_dimension_d; typedef typename Base::template Functor::type Side_of_oriented_sphere_d; @@ -30,7 +31,10 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor::type In_flat_side_of_oriented_sphere_d; typedef typename Base::template Functor::type Point_to_vector_d; typedef typename Base::template Functor::type Vector_to_point_d; - struct Component_accessor_d : private Store_kernel { + typedef typename Base::template Functor >::type Construct_point_d; + typedef typename Base::template Functor >::type Construct_vector_d; + typedef typename Base::template Functor >::type Construct_segment_d; + struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) typedef typename Base::Point Point; typedef typename Base::RT RT; @@ -48,7 +52,7 @@ template struct Kernel_d_interface : public Base_ { //return this->kernel().compute_coordinate_d_object()(p); } }; - struct Construct_cartesian_const_iterator_d : private Store_kernel { + struct Construct_cartesian_const_iterator_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_cartesian_const_iterator_d) typedef typename Base::template Functor >::type CPI; typedef typename Base::template Functor >::type CVI; diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 141a3272071..7dcca855eec 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -64,21 +64,12 @@ typedef CGAL::Cartesian_wrap KK; #endif template -void test(){ -#if 0 +void test2(){ typedef Ker K1; - typedef typename K1::Type::type P; - typedef typename K1::Iterator::type CI; - typedef typename K1::Type::type V; - typedef typename K1::Type::type S; -#elif 1 - //typedef CGAL::Define_kernel_types K1; - typedef Ker K1; - typedef typename K1::Point P; - //typedef typename K1::Point_cartesian_const_iterator CI; - typedef typename K1::Vector V; - typedef typename K1::Segment S; -#endif + typedef typename K1::Point_d P; + typedef typename K1::Cartesian_const_iterator_d CI; + typedef typename K1::Vector_d V; + typedef typename K1::Segment_d S; #if 1 #define Kinit (k) @@ -87,15 +78,14 @@ void test(){ #endif //typedef K1::Construct_point CP; - typedef typename K1::template Functor >::type CP; - typedef typename K1::template Functor >::type CV; - typedef typename K1::template Functor >::type CS; + typedef typename K1::Construct_point_d CP; + typedef typename K1::Construct_vector_d CV; + typedef typename K1::Construct_segment_d CS; typedef typename K1::template Functor::type CSE; - typedef typename K1::template Functor >::type CCI; - typedef typename K1::template Functor::type PO; - typedef typename K1::template Functor::type SOS; - typedef typename K1::template Functor::type CC; - typedef typename CGAL::decay::type>::type CI; + typedef typename K1::Construct_cartesian_const_iterator_d CCI; + typedef typename K1::Orientation_d PO; + typedef typename K1::Side_of_oriented_sphere_d SOS; + typedef typename K1::Compute_coordinate_d CC; USE_TYPE(V); USE_TYPE(CV); @@ -126,5 +116,5 @@ void test(){ std::cout << sos(&tab[0],tab+4) << std::endl; } int main(){ - test(); + test2 >(); } From 9e9decda2d5c76a646e478f0b35736171e8d298c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 11 Aug 2012 15:28:40 +0000 Subject: [PATCH 137/210] matching access functions --- NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 43ba30a139a..e2b8a5415a7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -23,6 +23,7 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor::type Less_or_equal_lexicographically_d; // FIXME: and vectors? typedef typename Base::template Functor::type Orientation_d; + typedef typename Base::template Functor::type Less_coordinate_d; typedef typename Base::template Functor::type Point_dimension_d; typedef typename Base::template Functor::type Side_of_oriented_sphere_d; typedef typename Base::template Functor::type Contained_in_affine_hull_d; @@ -34,6 +35,7 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor >::type Construct_point_d; typedef typename Base::template Functor >::type Construct_vector_d; typedef typename Base::template Functor >::type Construct_segment_d; + typedef typename Base::template Functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) typedef typename Base::Point Point; @@ -77,6 +79,7 @@ template struct Kernel_d_interface : public Base_ { Equal_d equal_d_object()const{ return Equal_d(*this); } Less_lexicographically_d less_lexicographically_d_object()const{ return Less_lexicographically_d(*this); } Less_or_equal_lexicographically_d less_or_equal_lexicographically_d_object()const{ return Less_or_equal_lexicographically_d(*this); } + Less_coordinate_d less_coordinate_d_object()const{ return Less_coordinate_d(*this); } Orientation_d orientation_d_object()const{ return Orientation_d(*this); } Point_dimension_d point_dimension_d_object()const{ return Point_dimension_d(*this); } Side_of_oriented_sphere_d side_of_oriented_sphere_d_object()const{ return Side_of_oriented_sphere_d(*this); } @@ -86,8 +89,12 @@ template struct Kernel_d_interface : public Base_ { In_flat_side_of_oriented_sphere_d in_flat_side_of_oriented_sphere_d_object()const{ return In_flat_side_of_oriented_sphere_d(*this); } Point_to_vector_d point_to_vector_d_object()const{ return Point_to_vector_d(*this); } Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); } + Midpoint_d midpoint_d_object()const{ return Midpoint_d(*this); } Component_accessor_d component_accessor_d_object()const{ return Component_accessor_d(*this); } Construct_cartesian_const_iterator_d construct_cartesian_const_iterator_d_object()const{ return Construct_cartesian_const_iterator_d(*this); } + Construct_point_d construct_point_d_object()const{ return Construct_point_d(*this); } + Construct_vector_d construct_vector_d_object()const{ return Construct_vector_d(*this); } + Construct_segment_d construct_segment_d_object()const{ return Construct_segment_d(*this); } }; } From 4ca9d09b8789906a0152eee8b1d591c94142ed1f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 12 Aug 2012 10:08:10 +0000 Subject: [PATCH 138/210] warnings --- .../CGAL/Kernel_d/function_objects_cartesian.h | 1 + NewKernel_d/include/CGAL/Vector/array.h | 2 +- NewKernel_d/test/NewKernel_d/Makefile | 4 ++-- NewKernel_d/test/NewKernel_d/test.cpp | 18 +++++++++--------- 4 files changed, 13 insertions(+), 12 deletions(-) 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 2ce97eb5aea..7a9f5ede18c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -136,6 +136,7 @@ template struct Orientation_of_points,true> : priv result_type operator()(Iter f, Iter e)const{ \ Point const&x=*f; \ BOOST_PP_REPEAT(N,VAR3,) \ + CGAL_assertion(++f==e); \ return operator()(x,BOOST_PP_ENUM_PARAMS(N,p)); \ } \ }; diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index e7ea3e09071..19d74d04780 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -136,7 +136,7 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CODE, _ ) static Vector_const_iterator vector_end(Vector const&a){ return &a[0]+d_; // Don't know the real size } - static unsigned size_of_vector(Vector const&a){ + static unsigned size_of_vector(Vector const&){ return d_; // Don't know the real size } diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index eea4c7d2ab0..886a6233b8d 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -5,11 +5,11 @@ CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_USE_EIGEN normal: - g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -I../../include ${EIGEN_INC} ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV + g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -I../../include ${EIGEN_INC} ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV ./a.out cxx0x: - g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include ${EIGEN_INC} ${CGAL_INC} + g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include ${EIGEN_INC} ${CGAL_INC} ./a.out #-DBOOST_RESULT_OF_USE_DECLTYPE diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 7dcca855eec..e8307806dd9 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -72,9 +72,9 @@ void test2(){ typedef typename K1::Segment_d S; #if 1 -#define Kinit (k) +#define Kinit(f) =k.f() #else -#define Kinit +#define Kinit(f) #endif //typedef K1::Construct_point CP; @@ -90,13 +90,13 @@ void test2(){ USE_TYPE(V); USE_TYPE(CV); Ker k; - CP cp Kinit; - CCI ci Kinit; - CC cc Kinit; - PO po Kinit; - CS cs Kinit; - CSE cse Kinit; - SOS sos Kinit; + CP cp Kinit(construct_point_d_object); + CCI ci Kinit(construct_cartesian_const_iterator_d_object); + CC cc Kinit(compute_coordinate_d_object); + PO po Kinit(orientation_d_object); + CS cs Kinit(construct_segment_d_object); + CSE cse (k); + SOS sos Kinit(side_of_oriented_sphere_d_object); P a=cp(3,4); P b=cp(5,6,7); int rr[]={3,5,2}; From 1e8fc14029980bf6749a0ccc7a25af2ba060d1ae Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 12 Aug 2012 11:08:12 +0000 Subject: [PATCH 139/210] Flat_orientation in Lazy_kernel --- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 37031a84f8c..ff35ea535dd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -115,6 +115,8 @@ struct Lazy_cartesian : Dimension_base, typedef typename Exact_kernel::Kernel_tag Kernel_tag; typedef typename Exact_kernel::Default_ambient_dimension Default_ambient_dimension; typedef typename Exact_kernel::Max_ambient_dimension Max_ambient_dimension; + typedef typename Exact_kernel::Flat_orientation Flat_orientation; + // Check that Approximate_kernel agrees with all that... typedef typename Same_uncertainty_nt::type Boolean; From e6ef3d45fe4c1c3aea56145bba0bbf878a230c6a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 15 Aug 2012 16:20:39 +0000 Subject: [PATCH 140/210] Add Epick_d --- NewKernel_d/include/CGAL/Epick_d.h | 30 +++++++++++++++++++ .../CGAL/Kernel_d/Cartesian_complete.h | 8 +++-- .../include/CGAL/Kernel_d/Define_segment.h | 2 +- .../include/CGAL/Kernel_d/Types/Segmentd.h | 20 ++++++------- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 2 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 1 + .../include/CGAL/Kernel_d/interface_macros.h | 6 ++-- NewKernel_d/test/NewKernel_d/test.cpp | 2 ++ 8 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Epick_d.h diff --git a/NewKernel_d/include/CGAL/Epick_d.h b/NewKernel_d/include/CGAL/Epick_d.h new file mode 100644 index 00000000000..1f54fe65f73 --- /dev/null +++ b/NewKernel_d/include/CGAL/Epick_d.h @@ -0,0 +1,30 @@ +#ifndef CGAL_EPICK_D_H +#define CGAL_EPICK_D_H +#include +#include +#include +#include +#include +#include +#include + + +namespace CGAL { +template +struct Epick_d_help1 +: Cartesian_filter_K< + Cartesian_base_d >, + Cartesian_base_d >, + Cartesian_base_d > + > +{}; +template +struct Epick_d_help2 +: Cartesian_static_filters,Epick_d_help1,Epick_d_help2 > +{}; +template +struct Epick_d +: Kernel_d_interface > > +{}; +} +#endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 5c04b6ddb84..20fd553a13d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -45,9 +46,9 @@ template struct Cartesian_define_all_functors template struct Cartesian_complete_types : public R_ { -#if 0 typedef R_ Kernel_base; typedef typename Default::Get::type Derived; +#if 0 template struct Type : Read_tag_type {}; #define CGAL_Kernel_obj2(X,Y) \ template struct Type { \ @@ -58,8 +59,11 @@ template struct Cartesian_com }; //FIXME: move away from Type<> //Implement by chaining things like Define_segment? -#include #endif + //FIXME: needs to be conditional!!! +#define CGAL_Kernel_obj2(X,Y) \ + typedef CGAL::X X; +#include }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index baf26102f6e..70e14a7145b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -57,7 +57,7 @@ struct Define_segment : public Base_ { typedef Define_segment Self; typedef typename Default::Get::type Derived; - typedef SegmentCd Segment; + typedef CGAL::Segment Segment; typedef typename Base::Object_list::template add::type Object_list; // TODO: forward the second Functor argument (like fast, no_filter) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h index fb348b8177f..a6aafb9ade3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h @@ -2,9 +2,8 @@ #define CGAL_KERNELD_SEGMENTD_H #include #include -#define Segmentd SegmentCd namespace CGAL { -template class Segmentd { +template class Segment { typedef typename R_::FT FT_; typedef typename R_::Point Point_; //typedef typename R_::Vector Vector_; @@ -13,16 +12,16 @@ template class Segmentd { typedef std::pair Data_; Data_ data; public: - typedef Segmentd Segment; + //typedef Segmentd Segment; #ifdef CGAL_CXX0X //FIXME: don't forward directly, piecewise_constuct should call the point construction functor (I guess? or is it unnecessary?) - template::type...>,std::tuple>::value>::type> - Segmentd(U&&...u):data(std::forward(u)...){} + template::type...>,std::tuple>::value>::type> + Segment(U&&...u):data(std::forward(u)...){} #else - Segmentd(){} - Segmentd(Point_ const&a, Point_ const&b): data(a,b) {} + Segment(){} + Segment(Point_ const&a, Point_ const&b): data(a,b) {} //template - //Segmentd(A const&,T1 const&t1,T2 const&t2) + //Segment(A const&,T1 const&t1,T2 const&t2) #endif Point_ source()const{return data.first;} Point_ target()const{return data.second;} @@ -32,8 +31,8 @@ template class Segmentd { else return target(); } - Segmentd opposite()const{ - return Segmentd(target(),source()); + Segment opposite()const{ + return Segment(target(),source()); } //Vector_ vector()const{ // return Cv_()(data.first,data.second); @@ -45,5 +44,4 @@ template class Segmentd { } // namespace CGAL -#undef Segmentd #endif // CGAL_KERNELD_SEGMENTD_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 838e4d9c3a9..f05b1dab5d4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -85,7 +85,7 @@ struct Cartesian_wrap : public Base_ #define CGAL_Kernel_obj(X,Y) \ typedef X##_d X; - CGAL_Kernel_obj(Segment,segment) + //CGAL_Kernel_obj(Segment,segment) //TODO: use Object_list, intersected with the list of objects that do have a wrapper available. #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index 7112eccaa77..0ee2c23efb4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -2,6 +2,7 @@ #define CGAL_WRAPPER_POINT_RC_D_H #include +#include #include #include #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 1b02b3ca463..499c6be7864 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -34,7 +34,7 @@ CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) -//CGAL_Kernel_obj2(Segment,segment) +CGAL_Kernel_obj2(Segment,segment) CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, construct_point_cartesian_const_iterator_object) @@ -56,8 +56,8 @@ CGAL_Kernel_cons2(Midpoint, midpoint_object) //CGAL_Kernel_cons2(Construct_segment, // construct_segment_object) -//CGAL_Kernel_cons2(Segment_extremity, -// segment_extremity_object) +CGAL_Kernel_cons2(Segment_extremity, + segment_extremity_object) CGAL_Kernel_comp1(Compute_point_cartesian_coordinate, compute_point_cartesian_coordinate_object) diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index e8307806dd9..687467dda21 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -1,4 +1,5 @@ #define BOOST_RESULT_OF_USE_DECLTYPE 1 +#include #include #include #include @@ -117,4 +118,5 @@ void test2(){ } int main(){ test2 >(); + test2 >(); } From 5de10d887bf03fb42b10b28d2d398ee51860a60b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 15 Aug 2012 17:31:05 +0000 Subject: [PATCH 141/210] connect a few more types --- .../CGAL/Kernel_d/Cartesian_complete.h | 3 + .../CGAL/Kernel_d/Kernel_d_interface.h | 6 + .../CGAL/Kernel_d/Types/Aff_transformation.h | 2 +- .../include/CGAL/Kernel_d/Types/Hyperplane.h | 4 +- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 2 + .../include/CGAL/Kernel_d/Wrapper/Sphere_d.h | 109 ++++++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 7 ++ 7 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 20fd553a13d..d9f6d3e5877 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include #include #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index e2b8a5415a7..82706289c37 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -16,6 +16,8 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::Point Point_d; typedef typename Base::Vector Vector_d; typedef typename Base::Segment Segment_d; + typedef typename Base::Sphere Sphere_d; + typedef typename Base::Hyperplane Hyperplane_d; typedef typename Base::template Functor::type Compute_coordinate_d; typedef typename Base::template Functor::type Compare_lexicographically_d; typedef typename Base::template Functor::type Equal_d; @@ -35,6 +37,8 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor >::type Construct_point_d; typedef typename Base::template Functor >::type Construct_vector_d; typedef typename Base::template Functor >::type Construct_segment_d; + typedef typename Base::template Functor >::type Construct_sphere_d; + typedef typename Base::template Functor >::type Construct_hyperplane_d; typedef typename Base::template Functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) @@ -95,6 +99,8 @@ template struct Kernel_d_interface : public Base_ { Construct_point_d construct_point_d_object()const{ return Construct_point_d(*this); } Construct_vector_d construct_vector_d_object()const{ return Construct_vector_d(*this); } Construct_segment_d construct_segment_d_object()const{ return Construct_segment_d(*this); } + Construct_sphere_d construct_sphere_d_object()const{ return Construct_sphere_d(*this); } + Construct_hyperplane_d construct_hyperplane_d_object()const{ return Construct_hyperplane_d(*this); } }; } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h index e5114b31cfa..836862666c9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h @@ -16,7 +16,7 @@ template struct Construct_aff_transformation { typedef R_ R; typedef typename R::Aff_transformation result_type; #ifdef CGAL_CXX0X - template + template result_type operator()(T&&...)const{return result_type();} #else result_type operator()()const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h index 4a3c2a2cb5c..1ffb881d49d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h @@ -1,5 +1,5 @@ -#ifndef CGAL_KD_TYPE_SPHERE_H -#define CGAL_KD_TYPE_SPHERE_H +#ifndef CGAL_KD_TYPE_HYPERPLANE_H +#define CGAL_KD_TYPE_HYPERPLANE_H #include namespace CGAL { template class Hyperplane { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index f05b1dab5d4..d36dda6a105 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -84,6 +85,7 @@ struct Cartesian_wrap : public Base_ #define CGAL_Kernel_obj(X,Y) \ typedef X##_d X; +#define CGAL_Kernel_obj3(X,Y) //CGAL_Kernel_obj(Segment,segment) //TODO: use Object_list, intersected with the list of objects that do have a wrapper available. diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h new file mode 100644 index 00000000000..2d4ec021ea2 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h @@ -0,0 +1,109 @@ +#ifndef CGAL_WRAPPER_SPHERE_D_H +#define CGAL_WRAPPER_SPHERE_D_H + +#include +#include +#include +#include +#include +#ifndef CGAL_CXX0X +#include +#endif +#include + +namespace CGAL { + +template +class Sphere_d : public R_::Kernel_base::Sphere +{ + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename R_::Point Point_; + typedef typename Kbase::template Functor >::type CSBase; + typedef typename Kbase::template Functor::type COSBase; + typedef typename Kbase::template Functor::type SRBase; + + typedef Sphere_d Self; + BOOST_STATIC_ASSERT((boost::is_same::value)); + +public: + + typedef Tag_true Is_wrapper; + typedef typename R_::Default_ambient_dimension Ambient_dimension; + typedef typename Increment_dimension::type Feature_dimension; + + typedef typename Kbase::Sphere Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + typedef R_ R; + +#ifdef CGAL_CXX0X + template::type...>,std::tuple >::value>::type> explicit Sphere_d(U&&...u) + : Rep(CSBase()(std::forward(u)...)){} + +// // called from Construct_point_d +// template explicit Point_d(Eval_functor&&,U&&...u) +// : Rep(Eval_functor(), std::forward(u)...){} + template explicit Sphere_d(Eval_functor&&,F&&f,U&&...u) + : Rep(std::forward(f)(std::forward(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(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 CODE(Z,N,_) template \ + explicit Sphere_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : Rep(CSBase()( \ + BOOST_PP_ENUM_PARAMS(N,t))) {} \ + \ + template \ + 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 \ + 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,CODE,_) +#undef 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 CGAL + +#endif // CGAL_WRAPPER_SPHERE_D_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 499c6be7864..b18e7c881d9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -31,10 +31,16 @@ #ifndef CGAL_Kernel_obj2 # define CGAL_Kernel_obj2(X,Y) CGAL_Kernel_obj(X,Y) #endif +#ifndef CGAL_Kernel_obj3 +# define CGAL_Kernel_obj3(X,Y) CGAL_Kernel_obj2(X,Y) +#endif CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) CGAL_Kernel_obj2(Segment,segment) +CGAL_Kernel_obj2(Sphere,sphere) +CGAL_Kernel_obj3(Hyperplane,hyperplane) +CGAL_Kernel_obj3(Aff_transformation,aff_transformation) CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, construct_point_cartesian_const_iterator_object) @@ -113,3 +119,4 @@ CGAL_Kernel_pred(Construct_flat_orientation, #undef CGAL_Kernel_obj #undef CGAL_Kernel_obj1 #undef CGAL_Kernel_obj2 +#undef CGAL_Kernel_obj3 From 8856fbb93891c7c78846c68d4fce9f0a6ad66503 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 19 Aug 2012 10:44:14 +0000 Subject: [PATCH 142/210] More testing, less warning. --- .../CGAL/Kernel_d/Cartesian_static_filters.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 33 ++++++- .../Kernel_d/function_objects_cartesian.h | 4 +- NewKernel_d/include/CGAL/Vector/array.h | 2 +- NewKernel_d/test/NewKernel_d/Makefile | 4 +- NewKernel_d/test/NewKernel_d/test.cpp | 88 +++++++++++++++++-- 6 files changed, 117 insertions(+), 16 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 4169ce90b61..36042fd4911 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -35,7 +35,7 @@ template struct Orientation_of_points_2 : private Store_k } }; }; - template result_type operator()(Iter f, Iter e)const{ + template result_type operator()(Iter f, Iter CGAL_assertion_code(e))const{ CC c(this->kernel()); Point const& A=*f; Point const& B=*++f; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 7037a887749..01a9d6674eb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -13,6 +13,33 @@ struct Flat_orientation { std::vector rest; }; +// For debugging purposes +inline std::ostream& operator<< (std::ostream& o, Flat_orientation const& f) { + o << "Proj: "; + for(std::vector::const_iterator i=f.proj.begin(); + i!=f.proj.end(); ++i) + o << *i << ' '; + o << "\nRest: "; + for(std::vector::const_iterator i=f.rest.begin(); + i!=f.rest.end(); ++i) + o << *i << ' '; + return o << '\n'; +} + +namespace internal { +namespace coaffine { +template +inline void debug_matrix(std::ostream& o, Mat const&mat) { + for(int i=0;i struct Construct_flat_orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_flat_orientation) typedef R_ R; @@ -32,7 +59,7 @@ template struct Construct_flat_orientation : private Store_kernel PD pd (this->kernel()); CCC ccc (this->kernel()); int dim = pd(*f); - Matrix coord (dim+1, dim+1); // use distance(f,e)? + Matrix coord (dim+1, dim+1); // use distance(f,e)? This matrix doesn't need to be square. int col = 0; Flat_orientation o; std::vector& proj=o.proj; @@ -51,7 +78,8 @@ template struct Construct_flat_orientation : private Store_kernel m(i,j) = coord(i, proj[j]); // Try to complete with any other coordinate // TODO: iterate on rest by the end, or use a (forward_)list. - for(std::vector::iterator it=rest.begin();it!=rest.end();++it) { + for(std::vector::iterator it=rest.begin();;++it) { + CGAL_assertion(it!=rest.end()); for(int i=0; i struct Construct_flat_orientation : private Store_kernel break; } } - //CGAL_assertion(it!=rest.end()); } std::sort(proj.begin(),proj.end()); return o; 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 7a9f5ede18c..73ca7d88fec 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -106,7 +106,7 @@ template struct Orientation_of_points,true> auto const&p=*f; return help2(Dimension_tag(),++f,e,std::forward(u)...,p); } - template result_type help2(Dimension_tag<0>, Iter f, Iter const&e, U&&...u)const{ + template result_type help2(Dimension_tag<0>, Iter CGAL_assertion_code(f), Iter const& CGAL_assertion_code(e), U&&...u)const{ CGAL_assertion(f==e); return operator()(std::forward(u)...); } @@ -133,7 +133,7 @@ template struct Orientation_of_points,true> : priv return sign_of_determinant(BOOST_PP_ENUM(N,VAR2,N)); \ } \ template \ - result_type operator()(Iter f, Iter e)const{ \ + result_type operator()(Iter f, Iter CGAL_assertion_code(e))const{ \ Point const&x=*f; \ BOOST_PP_REPEAT(N,VAR3,) \ CGAL_assertion(++f==e); \ diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 19d74d04780..6f32da9eda6 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -45,7 +45,7 @@ template struct Array_vector { struct Iterator { template - Vector operator()(unsigned d,Iter const& f,Iter const& e) const { + Vector operator()(unsigned CGAL_assertion_code(d),Iter const& f,Iter const& e) const { CGAL_assertion(d==std::distance(f,e)); CGAL_assertion(d<=d_); //TODO: optimize for forward iterators diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 886a6233b8d..d8d5ed8e046 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -1,8 +1,8 @@ all: normal cxx0x -CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK +CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/home/glisse/repos/cgal/trunk/Number_types/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Number_types/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK -EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_USE_EIGEN +EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_USE_EIGEN -DCGAL_EIGEN3_ENABLED normal: g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -I../../include ${EIGEN_INC} ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 687467dda21..30588375636 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -1,7 +1,6 @@ #define BOOST_RESULT_OF_USE_DECLTYPE 1 #include #include -#include #include #include #include @@ -64,6 +63,12 @@ typedef CGAL::Cartesian_wrap K3; typedef CGAL::Cartesian_wrap KK; #endif +#if 1 +#define Kinit(f) =k.f() +#else +#define Kinit(f) +#endif + template void test2(){ typedef Ker K1; @@ -71,12 +76,7 @@ void test2(){ typedef typename K1::Cartesian_const_iterator_d CI; typedef typename K1::Vector_d V; typedef typename K1::Segment_d S; - -#if 1 -#define Kinit(f) =k.f() -#else -#define Kinit(f) -#endif + typedef typename K1::Flat_orientation_d FO; //typedef K1::Construct_point CP; typedef typename K1::Construct_point_d CP; @@ -87,9 +87,13 @@ void test2(){ typedef typename K1::Orientation_d PO; typedef typename K1::Side_of_oriented_sphere_d SOS; typedef typename K1::Compute_coordinate_d CC; + typedef typename K1::Construct_flat_orientation_d CFO; + typedef typename K1::In_flat_orientation_d IFO; + typedef typename K1::In_flat_side_of_oriented_sphere_d IFSOS; USE_TYPE(V); USE_TYPE(CV); + USE_TYPE(FO); Ker k; CP cp Kinit(construct_point_d_object); CCI ci Kinit(construct_cartesian_const_iterator_d_object); @@ -98,6 +102,9 @@ void test2(){ CS cs Kinit(construct_segment_d_object); CSE cse (k); SOS sos Kinit(side_of_oriented_sphere_d_object); + CFO cfo Kinit(construct_flat_orientation_d_object); + IFO ifo Kinit(in_flat_orientation_d_object); + IFSOS ifsos Kinit(in_flat_side_of_oriented_sphere_d_object); P a=cp(3,4); P b=cp(5,6,7); int rr[]={3,5,2}; @@ -116,7 +123,74 @@ void test2(){ std::cout << po (&tab[0],tab+3) << std::endl; std::cout << sos(&tab[0],tab+4) << std::endl; } + +template +void test3(){ + typedef Ker K1; + typedef typename K1::Point_d P; + typedef typename K1::Cartesian_const_iterator_d CI; + typedef typename K1::Vector_d V; + typedef typename K1::Segment_d S; + typedef typename K1::Flat_orientation_d FO; + + //typedef K1::Construct_point CP; + typedef typename K1::Construct_point_d CP; + typedef typename K1::Construct_vector_d CV; + typedef typename K1::Construct_segment_d CS; + typedef typename K1::template Functor::type CSE; + typedef typename K1::Construct_cartesian_const_iterator_d CCI; + typedef typename K1::Orientation_d PO; + typedef typename K1::Side_of_oriented_sphere_d SOS; + typedef typename K1::Compute_coordinate_d CC; + typedef typename K1::Construct_flat_orientation_d CFO; + typedef typename K1::In_flat_orientation_d IFO; + typedef typename K1::In_flat_side_of_oriented_sphere_d IFSOS; + + USE_TYPE(V); + USE_TYPE(CV); + USE_TYPE(FO); + Ker k; + CP cp Kinit(construct_point_d_object); + CCI ci Kinit(construct_cartesian_const_iterator_d_object); + CC cc Kinit(compute_coordinate_d_object); + PO po Kinit(orientation_d_object); + CS cs Kinit(construct_segment_d_object); + CSE cse (k); + SOS sos Kinit(side_of_oriented_sphere_d_object); + CFO cfo Kinit(construct_flat_orientation_d_object); + IFO ifo Kinit(in_flat_orientation_d_object); + IFSOS ifsos Kinit(in_flat_side_of_oriented_sphere_d_object); + P a=cp(2,3,4); + P b=cp(5,6,7,8); + int rr[]={3,5,2,3}; + int* r=rr; + P c=cp(r,r+3); + P d=cp(r,r+4,CGAL::Homogeneous_tag()); + S s=cs(c,d); + std::cout << cc(a,1) << std::endl; + std::cout << cc(b,2) << std::endl; + std::cout << cc(cse(s,0),1) << std::endl; + std::cout << cc(cse(s,1),2) << std::endl; + for(CI i=ci(a,CGAL::Begin_tag());i!=ci(a,CGAL::End_tag());++i) + std::cout << *i << ' '; + std::cout << '\n'; + P e=cp(-2,3,0); + P tab[]={a,b,c,d,e}; + std::cout << po (&tab[0],tab+4) << std::endl; + std::cout << sos(&tab[0],tab+5) << std::endl; + FO fo=cfo(&tab[0],tab+3); + std::cout << fo; + P x[]={cp(2,2,3),cp(2,2,0),cp(1,2,1)}; + FO fo2=cfo(&x[0],x+3); + std::cout << fo2; + P y[]={cp(0,2,4),cp(3,1,2),cp(3,3,6)}; + FO fo3=cfo(&y[0],y+3); + assert(fo3.rest.size()==1 && fo3.rest[0]!=3); + std::cout << fo3; +} + int main(){ test2 >(); test2 >(); + test3 >(); } From b185997a71c2a94e20ac87ab954fd3702fc0b49c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 22 Aug 2012 14:31:11 +0000 Subject: [PATCH 143/210] Kill warning, convert Flat_orientation (may need something nicer later), test in_flat_orientation. --- .../include/CGAL/Kernel_d/KernelD_converter.h | 1 + NewKernel_d/include/CGAL/typeset.h | 12 ++++++++---- NewKernel_d/test/NewKernel_d/test.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index 1e8d3f3fc2a..fd87fac62f2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -138,6 +138,7 @@ typename typeset_intersection::Type const&x)const{return cr(x);} + typename K2::Flat_orientation const& operator()(typename K1::Flat_orientation const&o)const{return o;} // Both kernels should have the same, returning a reference should warn if not. template transforming_iterator,It>::type> diff --git a/NewKernel_d/include/CGAL/typeset.h b/NewKernel_d/include/CGAL/typeset.h index d9bad3c39a7..422a768a18d 100644 --- a/NewKernel_d/include/CGAL/typeset.h +++ b/NewKernel_d/include/CGAL/typeset.h @@ -45,17 +45,21 @@ namespace CGAL { template struct contains : boost::mpl::if_,boost::true_type,typename tail::template contains >::type {}; - template struct add : + template struct add; //boost::mpl::if_,typeset,typeset >::type - typeset::type> - {}; - template struct add : typeset {}; }; template<> struct typeset<> { typedef typeset type; template struct contains : boost::false_type {}; template struct add : typeset {}; }; + + template + template + struct typeset::add : typeset::type> {}; + template + template + struct typeset::add : typeset {}; #endif template struct typeset_union_ : diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 30588375636..ff5e1007860 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -183,10 +183,15 @@ void test3(){ P x[]={cp(2,2,3),cp(2,2,0),cp(1,2,1)}; FO fo2=cfo(&x[0],x+3); std::cout << fo2; - P y[]={cp(0,2,4),cp(3,1,2),cp(3,3,6)}; + P y[]={cp(0,2,4),cp(3,1,2),cp(3,3,6),cp(0,4,8)}; FO fo3=cfo(&y[0],y+3); assert(fo3.rest.size()==1 && fo3.rest[0]!=3); std::cout << fo3; + CGAL::Orientation base=ifo(fo3,&y[0],y+3); + assert(ifo(fo3,y+1,y+4)==base); + P yy[]={y[1],y[3],y[0],y[2]}; + assert(ifo(fo3,yy+0,yy+3)==base); + assert(ifo(fo3,yy+1,yy+4)==base); } int main(){ From d270e6711792eb89a18783608e252fdf8841513a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 22 Aug 2012 15:57:26 +0000 Subject: [PATCH 144/210] Test in_flat_side_of_oriented_sphere --- NewKernel_d/test/NewKernel_d/Makefile | 4 ++-- NewKernel_d/test/NewKernel_d/test.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index d8d5ed8e046..8143ea0482b 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -5,11 +5,11 @@ CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_USE_EIGEN -DCGAL_EIGEN3_ENABLED normal: - g++ test.cpp -O2 -g -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -I../../include ${EIGEN_INC} ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV + g++ test.cpp -O2 -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -I../../include ${EIGEN_INC} ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV ./a.out cxx0x: - g++ -std=c++0x -O2 -g test.cpp -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include ${EIGEN_INC} ${CGAL_INC} + g++ -std=c++0x -O2 test.cpp -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include ${EIGEN_INC} ${CGAL_INC} ./a.out #-DBOOST_RESULT_OF_USE_DECLTYPE diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index ff5e1007860..ba87dd34bae 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -192,6 +192,18 @@ void test3(){ P yy[]={y[1],y[3],y[0],y[2]}; assert(ifo(fo3,yy+0,yy+3)==base); assert(ifo(fo3,yy+1,yy+4)==base); + std::cout << ifsos(fo3,y+0,y+3,y[3]) << ' '; + std::cout << ifsos(fo3,y+1,y+4,y[0]) << ' '; + std::cout << ifsos(fo3,yy+0,yy+3,yy[3]) << ' '; + std::cout << ifsos(fo3,yy+1,yy+4,yy[0]) << '\n'; + P buf[]={cp(100,900,0),y[0],y[1],y[2],y[3]}; + std::cout << sos(buf+0,buf+5) << ' '; + buf[1]=y[1];buf[2]=y[2];buf[3]=y[3];buf[4]=y[0]; + std::cout << sos(buf+0,buf+5) << ' '; + buf[1]=yy[0];buf[2]=yy[1];buf[3]=yy[2];buf[4]=yy[3]; + std::cout << sos(buf+0,buf+5) << ' '; + buf[1]=yy[1];buf[2]=yy[2];buf[3]=yy[3];buf[4]=yy[0]; + std::cout << sos(buf+0,buf+5) << '\n'; } int main(){ From 18193f12980bb4d0c0eecf356158d14840f9c821 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 22 Aug 2012 16:16:32 +0000 Subject: [PATCH 145/210] Test (and fix) Contained_in_affine_hull_d --- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 10 ++++++---- NewKernel_d/test/NewKernel_d/test.cpp | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 01a9d6674eb..5452bd11fe1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -98,12 +98,14 @@ template struct Contained_in_affine_hull : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; - typedef typename R::Orientation result_type; + typedef typename R::Boolean result_type; typedef typename R::template Functor::type CCC; typedef typename R::template Functor::type PD; - typedef typename Increment_dimension::type D1; - typedef typename Increment_dimension::type D2; - typedef typename R::LA::template Rebind_dimension::Other LA; + //typedef typename Increment_dimension::type D1; + //typedef typename Increment_dimension::type D2; + //typedef typename R::LA::template Rebind_dimension::Other LA; + typedef typename Increment_dimension::type Dplusone; + typedef typename R::LA::template Rebind_dimension::Other LA; typedef typename LA::Square_matrix Matrix; // mostly copied from Construct_flat_orientation. TODO: dedup this code. diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index ba87dd34bae..bd8b08056fb 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -90,6 +90,7 @@ void test2(){ typedef typename K1::Construct_flat_orientation_d CFO; typedef typename K1::In_flat_orientation_d IFO; typedef typename K1::In_flat_side_of_oriented_sphere_d IFSOS; + typedef typename K1::Contained_in_affine_hull_d CAH; USE_TYPE(V); USE_TYPE(CV); @@ -105,6 +106,7 @@ void test2(){ CFO cfo Kinit(construct_flat_orientation_d_object); IFO ifo Kinit(in_flat_orientation_d_object); IFSOS ifsos Kinit(in_flat_side_of_oriented_sphere_d_object); + CAH cah Kinit(contained_in_affine_hull_d_object); P a=cp(3,4); P b=cp(5,6,7); int rr[]={3,5,2}; @@ -145,6 +147,7 @@ void test3(){ typedef typename K1::Construct_flat_orientation_d CFO; typedef typename K1::In_flat_orientation_d IFO; typedef typename K1::In_flat_side_of_oriented_sphere_d IFSOS; + typedef typename K1::Contained_in_affine_hull_d CAH; USE_TYPE(V); USE_TYPE(CV); @@ -160,6 +163,7 @@ void test3(){ CFO cfo Kinit(construct_flat_orientation_d_object); IFO ifo Kinit(in_flat_orientation_d_object); IFSOS ifsos Kinit(in_flat_side_of_oriented_sphere_d_object); + CAH cah Kinit(contained_in_affine_hull_d_object); P a=cp(2,3,4); P b=cp(5,6,7,8); int rr[]={3,5,2,3}; @@ -204,6 +208,8 @@ void test3(){ std::cout << sos(buf+0,buf+5) << ' '; buf[1]=yy[1];buf[2]=yy[2];buf[3]=yy[3];buf[4]=yy[0]; std::cout << sos(buf+0,buf+5) << '\n'; + assert(cah(y+0,y+3,y[3])); + assert(!cah(y+0,y+3,buf[0])); } int main(){ From e067f7fcdf217cf0277136e97ccd3b811093a66c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 23 Aug 2012 11:50:46 +0000 Subject: [PATCH 146/210] Test lexicographic comparison. Make kernel constructors more uniform. --- NewKernel_d/include/CGAL/Epick_d.h | 47 ++++++++++++++----- .../include/CGAL/Kernel_d/Cartesian_base.h | 29 ++++++------ .../CGAL/Kernel_d/Cartesian_complete.h | 12 +++++ .../CGAL/Kernel_d/Cartesian_static_filters.h | 11 ++++- .../CGAL/Kernel_d/Kernel_d_interface.h | 3 ++ NewKernel_d/test/NewKernel_d/test.cpp | 18 ++++++- 6 files changed, 90 insertions(+), 30 deletions(-) diff --git a/NewKernel_d/include/CGAL/Epick_d.h b/NewKernel_d/include/CGAL/Epick_d.h index 1f54fe65f73..9052004009e 100644 --- a/NewKernel_d/include/CGAL/Epick_d.h +++ b/NewKernel_d/include/CGAL/Epick_d.h @@ -10,21 +10,44 @@ namespace CGAL { -template -struct Epick_d_help1 -: Cartesian_filter_K< - Cartesian_base_d >, - Cartesian_base_d >, - Cartesian_base_d > +#define CGAL_BASE \ + Cartesian_filter_K< \ + Cartesian_base_d, \ + Cartesian_base_d, \ + Cartesian_base_d \ > -{}; -template +template +struct Epick_d_help1 +: CGAL_BASE +{ + CGAL_CONSTEXPR Epick_d_help1(){} + CGAL_CONSTEXPR Epick_d_help1(int d):CGAL_BASE(d){} +}; +#undef CGAL_BASE +#define CGAL_BASE \ + Cartesian_static_filters,Epick_d_help2 > +template struct Epick_d_help2 -: Cartesian_static_filters,Epick_d_help1,Epick_d_help2 > -{}; +: CGAL_BASE +{ + CGAL_CONSTEXPR Epick_d_help2(){} + CGAL_CONSTEXPR Epick_d_help2(int d):CGAL_BASE(d){} +}; +#undef CGAL_BASE +#define CGAL_BASE \ + Kernel_d_interface< Cartesian_wrap< Epick_d_help2< \ + typename boost::conditional< d_==UNKNOWN_DIMENSION, \ + Dynamic_dimension_tag, \ + Dimension_tag \ + >::type \ + > > > template struct Epick_d -: Kernel_d_interface > > -{}; +: CGAL_BASE +{ + CGAL_CONSTEXPR Epick_d(){} + CGAL_CONSTEXPR Epick_d(int d):CGAL_BASE(d){} +}; +#undef CGAL_BASE } #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h index 8060a39222b..f97e6e015d3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h @@ -6,24 +6,25 @@ #include namespace CGAL { - -template < typename FT_, typename Dim_, typename Derived_=Default> -struct Cartesian_base_d : public -Cartesian_complete_predicates< -Cartesian_complete_constructors< -Cartesian_complete_computes< -Cartesian_complete_types< -Cartesian_LA_base_d< - FT_, Dim_ ->, false, typename Default::Get >::type ->, false, typename Default::Get >::type ->, false, typename Default::Get >::type ->, false, typename Default::Get >::type +#define CGAL_BASE \ +Cartesian_complete_predicates< \ +Cartesian_complete_constructors< \ +Cartesian_complete_computes< \ +Cartesian_complete_types< \ +Cartesian_LA_base_d< \ + FT_, Dim_ \ +>, false, typename Default::Get >::type \ +>, false, typename Default::Get >::type \ +>, false, typename Default::Get >::type \ +>, false, typename Default::Get >::type \ > +template < typename FT_, typename Dim_, typename Derived_=Default> +struct Cartesian_base_d : public CGAL_BASE { CGAL_CONSTEXPR Cartesian_base_d(){} - CGAL_CONSTEXPR Cartesian_base_d(int d):Dimension_base(d){} + CGAL_CONSTEXPR Cartesian_base_d(int d):CGAL_BASE(d){} }; +#undef CGAL_BASE } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index d9f6d3e5877..a81f7ed3bca 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -49,6 +49,9 @@ template struct Cartesian_define_all_functors template struct Cartesian_complete_types : public R_ { + CGAL_CONSTEXPR Cartesian_complete_types(){} + CGAL_CONSTEXPR Cartesian_complete_types(int d):R_(d){} + typedef R_ Kernel_base; typedef typename Default::Get::type Derived; #if 0 @@ -73,6 +76,9 @@ template struct Cartesian_com template struct Cartesian_complete_constructors : public R_ { + CGAL_CONSTEXPR Cartesian_complete_constructors(){} + CGAL_CONSTEXPR Cartesian_complete_constructors(int d):R_(d){} + typedef R_ Kernel_base; typedef typename Default::Get::type Derived; template::type> struct Functor : @@ -89,6 +95,9 @@ template struct Cartesian_com template struct Cartesian_complete_predicates : public R_ { + CGAL_CONSTEXPR Cartesian_complete_predicates(){} + CGAL_CONSTEXPR Cartesian_complete_predicates(int d):R_(d){} + // TODO: this doesn't look like the right place for this typedef... typedef CartesianDKernelFunctors::Flat_orientation Flat_orientation; @@ -108,6 +117,9 @@ template struct Cartesian_com template struct Cartesian_complete_computes : public R_ { + CGAL_CONSTEXPR Cartesian_complete_computes(){} + CGAL_CONSTEXPR Cartesian_complete_computes(int d):R_(d){} + typedef R_ Kernel_base; typedef typename Default::Get::type Derived; template::type> struct Functor : diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 36042fd4911..64948d910f1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -47,9 +47,16 @@ template struct Orientation_of_points_2 : private Store_k }; } -template struct Cartesian_static_filters : public R_ {}; +template +struct Cartesian_static_filters : public R_ { + CGAL_CONSTEXPR Cartesian_static_filters(){} + CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} +}; -template struct Cartesian_static_filters, R_, Derived_> : public R_ { +template +struct Cartesian_static_filters, R_, Derived_> : public R_ { + CGAL_CONSTEXPR Cartesian_static_filters(){} + CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} typedef Cartesian_static_filters, R_, Derived_> Self; typedef typename Default::Get::type Derived; template struct Functor : R_::template Functor {}; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 82706289c37..5e944725fae 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -9,6 +9,9 @@ namespace CGAL { template struct Kernel_d_interface : public Base_ { + CGAL_CONSTEXPR Kernel_d_interface(){} + CGAL_CONSTEXPR Kernel_d_interface(int d):Base_(d){} + typedef Base_ Base; typedef Kernel_d_interface Kernel; typedef Base_ R_; // for the macros diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index bd8b08056fb..9b83adac7e4 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -91,11 +91,17 @@ void test2(){ typedef typename K1::In_flat_orientation_d IFO; typedef typename K1::In_flat_side_of_oriented_sphere_d IFSOS; typedef typename K1::Contained_in_affine_hull_d CAH; + typedef typename K1::Compare_lexicographically_d CL; USE_TYPE(V); USE_TYPE(CV); USE_TYPE(FO); - Ker k; + USE_TYPE(CL); + Ker k +#if 0 + (2) +#endif + ; CP cp Kinit(construct_point_d_object); CCI ci Kinit(construct_cartesian_const_iterator_d_object); CC cc Kinit(compute_coordinate_d_object); @@ -148,14 +154,20 @@ void test3(){ typedef typename K1::In_flat_orientation_d IFO; typedef typename K1::In_flat_side_of_oriented_sphere_d IFSOS; typedef typename K1::Contained_in_affine_hull_d CAH; + typedef typename K1::Compare_lexicographically_d CL; USE_TYPE(V); USE_TYPE(CV); USE_TYPE(FO); - Ker k; + Ker k +#if 0 + (3) +#endif + ; CP cp Kinit(construct_point_d_object); CCI ci Kinit(construct_cartesian_const_iterator_d_object); CC cc Kinit(compute_coordinate_d_object); + CL cl Kinit(compare_lexicographically_d_object); PO po Kinit(orientation_d_object); CS cs Kinit(construct_segment_d_object); CSE cse (k); @@ -210,6 +222,8 @@ void test3(){ std::cout << sos(buf+0,buf+5) << '\n'; assert(cah(y+0,y+3,y[3])); assert(!cah(y+0,y+3,buf[0])); + assert(cl(a,a)==CGAL::EQUAL); + assert(cl(a,b)==CGAL::LARGER); } int main(){ From ce307dc5855441e59be664631ceb7fc093b273e6 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 23 Aug 2012 12:51:27 +0000 Subject: [PATCH 147/210] Buh, the tests just pass for dynamic dimension... --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 2 +- .../include/CGAL/Kernel_d/Dimension_base.h | 18 +++++++------ NewKernel_d/test/NewKernel_d/test.cpp | 25 ++++++++++++++++--- 3 files changed, 32 insertions(+), 13 deletions(-) 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 c03db2fc675..316f67e6fcd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -20,7 +20,7 @@ namespace CGAL { template < typename FT_, typename Dim_, -#if 1 +#if 0 typename Vec_=Array_vector, #else typename Vec_=LA_eigen, diff --git a/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h index 35fc9a3d064..98e64f0c99d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Dimension_base.h @@ -4,20 +4,22 @@ #include #include namespace CGAL { -struct No_dimension_base { - No_dimension_base(int = UNKNOWN_DIMENSION){} - int dimension() const { return UNKNOWN_DIMENSION; } - void set_dimension(int) {} -}; -template struct Dimension_base { +struct Store_dimension_base { //TODO: add some assertions - Dimension_base(int dim=UNKNOWN_DIMENSION):dim_(dim){} + Store_dimension_base(int dim=UNKNOWN_DIMENSION):dim_(dim){} int dimension()const{return dim_;} void set_dimension(int dim){dim_=dim;} private: int dim_; }; -template struct Dimension_base > { +template +struct Dimension_base { + Dimension_base(int = UNKNOWN_DIMENSION){} + int dimension() const { return UNKNOWN_DIMENSION; } + void set_dimension(int) {} +}; +template +struct Dimension_base > { Dimension_base(){} Dimension_base(int dim){CGAL_assertion(dim_==dim);} int dimension()const{return dim_;} diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 9b83adac7e4..6d7b62dbb85 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -132,6 +132,21 @@ void test2(){ std::cout << sos(&tab[0],tab+4) << std::endl; } +template struct Construct_point3_helper { + CP const& cp; + Construct_point3_helper(CP const& x) : cp(x) {} + template + typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3)const{ + double tab[]={(double)t1,(double)t2,(double)t3}; + return cp(tab+0,tab+3); + } + template + typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3, T4 const&t4)const{ + double tab[]={(double)t1,(double)t2,(double)t3}; + return cp(tab+0,tab+3,t4); + } +}; + template void test3(){ typedef Ker K1; @@ -142,7 +157,7 @@ void test3(){ typedef typename K1::Flat_orientation_d FO; //typedef K1::Construct_point CP; - typedef typename K1::Construct_point_d CP; + typedef typename K1::Construct_point_d CP_; typedef typename K1::Construct_vector_d CV; typedef typename K1::Construct_segment_d CS; typedef typename K1::template Functor::type CSE; @@ -164,7 +179,8 @@ void test3(){ (3) #endif ; - CP cp Kinit(construct_point_d_object); + CP_ cp_ Kinit(construct_point_d_object); + typename boost::conditional::value,Construct_point3_helper,CP_>::type cp(cp_); CCI ci Kinit(construct_cartesian_const_iterator_d_object); CC cc Kinit(compute_coordinate_d_object); CL cl Kinit(compare_lexicographically_d_object); @@ -180,8 +196,8 @@ void test3(){ P b=cp(5,6,7,8); int rr[]={3,5,2,3}; int* r=rr; - P c=cp(r,r+3); - P d=cp(r,r+4,CGAL::Homogeneous_tag()); + P c=cp_(r,r+3); + P d=cp_(r,r+4,CGAL::Homogeneous_tag()); S s=cs(c,d); std::cout << cc(a,1) << std::endl; std::cout << cc(b,2) << std::endl; @@ -230,4 +246,5 @@ int main(){ test2 >(); test2 >(); test3 >(); + test3 >(); } From 6df643c53849ea159a55340529de9f47bbf7344e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 23 Aug 2012 15:53:49 +0000 Subject: [PATCH 148/210] List the missing functors --- .../CGAL/Kernel_d/Kernel_d_interface.h | 44 +++++++++++++++++++ NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 5e944725fae..e8eed2c00fc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -21,6 +21,11 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::Segment Segment_d; typedef typename Base::Sphere Sphere_d; typedef typename Base::Hyperplane Hyperplane_d; + //typedef typename Base::Direction Direction_d; + //typedef typename Base::Line Line_d; + //typedef typename Base::Ray Ray_d; + //typedef typename Base::Iso_box Iso_box_d; + //typedef typename Base::Aff_transformation Aff_transformation_d; typedef typename Base::template Functor::type Compute_coordinate_d; typedef typename Base::template Functor::type Compare_lexicographically_d; typedef typename Base::template Functor::type Equal_d; @@ -42,6 +47,11 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor >::type Construct_segment_d; typedef typename Base::template Functor >::type Construct_sphere_d; typedef typename Base::template Functor >::type Construct_hyperplane_d; + //typedef typename Base::template Functor >::type Construct_direction_d; + //typedef typename Base::template Functor >::type Construct_line_d; + //typedef typename Base::template Functor >::type Construct_ray_d; + //typedef typename Base::template Functor >::type Construct_iso_box_d; + //typedef typename Base::template Functor >::type Construct_aff_transformation_d; typedef typename Base::template Functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) @@ -79,6 +89,24 @@ template struct Kernel_d_interface : public Base_ { } }; typedef typename Construct_cartesian_const_iterator_d::result_type Cartesian_const_iterator_d; + //typedef typename Base::template Functor::type Affine_rank_d; + //typedef typename Base::template Functor::type Affinely_independent_d; + //typedef typename Base::template Functor::type Contained_in_linear_hull_d; + //typedef typename Base::template Functor::type Contained_in_simplex_d; + //typedef typename Base::template Functor::type Has_on_positive_side_d; + //typedef typename Base::template Functor::type Linear_rank_d; + //typedef typename Base::template Functor::type Linearly_independent_d; + //typedef typename Base::template Functor::type Oriented_side_d; + //typedef typename Base::template Functor::type Side_of_bounded_sphere_d; + + //typedef typename Base::template Functor::type Center_of_sphere_d; + //typedef typename Base::template Functor::type Squared_distance_d; + //typedef typename Base::template Functor::type Value_at_d; + //typedef typename Base::template Functor::type Point_of_sphere_d; + //typedef typename Base::template Functor::type Orthogonal_vector_d; + //typedef typename Base::template Functor::type Linear_base_d; + + //typedef ??? Intersect_d; Compute_coordinate_d compute_coordinate_d_object()const{ return Compute_coordinate_d(*this); } @@ -104,6 +132,22 @@ template struct Kernel_d_interface : public Base_ { Construct_segment_d construct_segment_d_object()const{ return Construct_segment_d(*this); } Construct_sphere_d construct_sphere_d_object()const{ return Construct_sphere_d(*this); } Construct_hyperplane_d construct_hyperplane_d_object()const{ return Construct_hyperplane_d(*this); } + //Construct_direction_d construct_direction_d_object()const{ return Construct_direction_d(*this); } + //Construct_line_d construct_line_d_object()const{ return Construct_line_d(*this); } + //Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); } + //Construct_iso_box_d construct_iso_box_d_object()const{ return Construct_iso_box_d(*this); } + //Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); } + + // Dummies for those required functors missing a concept. + typedef Null_functor Position_on_line_d; + Position_on_line_d position_on_line_d_object()const{return Null_functor();} + typedef Null_functor Barycentric_coordinates_d; + Barycentric_coordinates_d barycentric_coordinates_d_object()const{return Null_functor();} + + /* Not provided because they don't make sense here: + Lift_to_paraboloid_d + Project_along_d_axis_d + */ }; } diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 6d7b62dbb85..b4993c6b132 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -175,7 +175,7 @@ void test3(){ USE_TYPE(CV); USE_TYPE(FO); Ker k -#if 0 +#if 1 (3) #endif ; From 4fc9c340be4e4a09111d0e4e096f0d78fd1d403e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 23 Aug 2012 16:26:22 +0000 Subject: [PATCH 149/210] this functor was already there --- NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index e8eed2c00fc..db05e089717 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -89,6 +89,7 @@ template struct Kernel_d_interface : public Base_ { } }; typedef typename Construct_cartesian_const_iterator_d::result_type Cartesian_const_iterator_d; + typedef typename Base::template Functor::type Squared_distance_d; //typedef typename Base::template Functor::type Affine_rank_d; //typedef typename Base::template Functor::type Affinely_independent_d; //typedef typename Base::template Functor::type Contained_in_linear_hull_d; @@ -100,7 +101,6 @@ template struct Kernel_d_interface : public Base_ { //typedef typename Base::template Functor::type Side_of_bounded_sphere_d; //typedef typename Base::template Functor::type Center_of_sphere_d; - //typedef typename Base::template Functor::type Squared_distance_d; //typedef typename Base::template Functor::type Value_at_d; //typedef typename Base::template Functor::type Point_of_sphere_d; //typedef typename Base::template Functor::type Orthogonal_vector_d; @@ -132,6 +132,7 @@ template struct Kernel_d_interface : public Base_ { Construct_segment_d construct_segment_d_object()const{ return Construct_segment_d(*this); } Construct_sphere_d construct_sphere_d_object()const{ return Construct_sphere_d(*this); } Construct_hyperplane_d construct_hyperplane_d_object()const{ return Construct_hyperplane_d(*this); } + Squared_distance_d squared_distance_d_object()const{ return Squared_distance_d(*this); } //Construct_direction_d construct_direction_d_object()const{ return Construct_direction_d(*this); } //Construct_line_d construct_line_d_object()const{ return Construct_line_d(*this); } //Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); } From bf119fc83f1f6ba65e568109e7588de53a1502e2 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 31 Aug 2012 20:24:47 +0000 Subject: [PATCH 150/210] s/CGAL_USE_EIGEN/CGAL_EIGEN3_ENABLED/g That doesn't look very consistent, but it's what cgal uses. --- NewKernel_d/include/CGAL/Dimension.h | 6 +++--- NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h | 2 +- NewKernel_d/include/CGAL/LA_eigen/LA.h | 2 +- NewKernel_d/include/CGAL/LA_eigen/constructors.h | 2 +- NewKernel_d/test/NewKernel_d/Makefile | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/NewKernel_d/include/CGAL/Dimension.h b/NewKernel_d/include/CGAL/Dimension.h index 514b41b5020..c89f1d96db1 100644 --- a/NewKernel_d/include/CGAL/Dimension.h +++ b/NewKernel_d/include/CGAL/Dimension.h @@ -23,13 +23,13 @@ #include #include #include -#ifdef CGAL_USE_EIGEN +#ifdef CGAL_EIGEN3_ENABLED #include #endif namespace CGAL { -#ifdef CGAL_USE_EIGEN +#ifdef CGAL_EIGEN3_ENABLED const int UNKNOWN_DIMENSION=Eigen::Dynamic; #else const int UNKNOWN_DIMENSION=std::numeric_limits::max(); @@ -107,7 +107,7 @@ templatestruct Product_dimension,Dimension_tag< typedef Dimension_tag type; }; -#ifdef CGAL_USE_EIGEN +#ifdef CGAL_EIGEN3_ENABLED // Convert to Eigen's notion of dimension template struct Eigen_dimension { enum { value=Eigen::Dynamic }; 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 316f67e6fcd..14661576c8c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -11,7 +11,7 @@ #include #include #include -#ifdef CGAL_USE_EIGEN +#ifdef CGAL_EIGEN3_ENABLED #include #else #include diff --git a/NewKernel_d/include/CGAL/LA_eigen/LA.h b/NewKernel_d/include/CGAL/LA_eigen/LA.h index a7eca2f32db..4eaffd6db75 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/LA_eigen/LA.h @@ -1,7 +1,7 @@ #ifndef CGAL_LA_EIGEN_H #define CGAL_LA_EIGEN_H -#ifndef CGAL_USE_EIGEN +#ifndef CGAL_EIGEN3_ENABLED #error Requires Eigen #endif #include diff --git a/NewKernel_d/include/CGAL/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/LA_eigen/constructors.h index accee085f0e..97492a68fa6 100644 --- a/NewKernel_d/include/CGAL/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/LA_eigen/constructors.h @@ -1,7 +1,7 @@ #ifndef ecs_h #define ecs_h -#ifndef CGAL_USE_EIGEN +#ifndef CGAL_EIGEN3_ENABLED #error Requires Eigen #endif #include diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 8143ea0482b..810900fa935 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -2,7 +2,7 @@ all: normal cxx0x CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/home/glisse/repos/cgal/trunk/Number_types/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Number_types/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK -EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_USE_EIGEN -DCGAL_EIGEN3_ENABLED +EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_EIGEN3_ENABLED normal: g++ test.cpp -O2 -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -I../../include ${EIGEN_INC} ${CGAL_INC} -DCGAL_CFG_NO_CPP0X_COPY_N -DCGAL_CFG_NO_CPP0X_NEXT_PREV From 879d16096ec5653bbf2736bb4272cfb39946faac Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 9 Sep 2012 13:20:02 +0000 Subject: [PATCH 151/210] follow kernel_d concept to construct an iterator --- .../include/CGAL/Kernel_d/Kernel_d_interface.h | 11 +++++++++++ NewKernel_d/test/NewKernel_d/test.cpp | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index db05e089717..79d37647d65 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -87,6 +87,17 @@ template struct Kernel_d_interface : public Base_ { result_type operator()(Vector_d const&v, Tag t)const{ return CVI(this->kernel())(v,t); } + + template + result_type operator()(Obj const&o)const{ + return operator()(o, Begin_tag()); + } + result_type operator()(Point_d const&p, int)const{ + return operator()(p, End_tag()); + } + result_type operator()(Vector_d const&v, int)const{ + return operator()(v, End_tag()); + } }; typedef typename Construct_cartesian_const_iterator_d::result_type Cartesian_const_iterator_d; typedef typename Base::template Functor::type Squared_distance_d; diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index b4993c6b132..f5ebafdf844 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -124,7 +124,7 @@ void test2(){ std::cout << cc(b,1) << std::endl; std::cout << cc(cse(s,0),1) << std::endl; std::cout << cc(cse(s,1),1) << std::endl; - for(CI i=ci(a,CGAL::Begin_tag());i!=ci(a,CGAL::End_tag());++i) + for(CI i=ci(a);i!=ci(a,0);++i) std::cout << *i << ' '; std::cout << '\n'; P tab[]={a,b,c,d}; @@ -203,7 +203,7 @@ void test3(){ std::cout << cc(b,2) << std::endl; std::cout << cc(cse(s,0),1) << std::endl; std::cout << cc(cse(s,1),2) << std::endl; - for(CI i=ci(a,CGAL::Begin_tag());i!=ci(a,CGAL::End_tag());++i) + for(CI i=ci(a);i!=ci(a,0);++i) std::cout << *i << ' '; std::cout << '\n'; P e=cp(-2,3,0); From 7daca6fb9bd7d2e9f45d2f72a7a17975f9578c1a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 19 Sep 2012 14:37:44 +0000 Subject: [PATCH 152/210] More types and functors from the Kernel_d concept. --- .../CGAL/Kernel_d/Cartesian_complete.h | 3 ++ .../CGAL/Kernel_d/Kernel_d_interface.h | 33 ++++++------- .../include/CGAL/Kernel_d/Types/Iso_box.h | 48 +++++++++++++++++++ .../include/CGAL/Kernel_d/Types/Line.h | 45 +++++++++++++++++ NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h | 45 +++++++++++++++++ .../Kernel_d/function_objects_cartesian.h | 35 ++++++++++++++ .../include/CGAL/Kernel_d/interface_macros.h | 11 +++++ NewKernel_d/include/CGAL/functor_tags.h | 3 ++ 8 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Line.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index a81f7ed3bca..c507f947aa9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include #include #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 79d37647d65..8ba2c3bad8b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -21,11 +21,11 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::Segment Segment_d; typedef typename Base::Sphere Sphere_d; typedef typename Base::Hyperplane Hyperplane_d; - //typedef typename Base::Direction Direction_d; - //typedef typename Base::Line Line_d; - //typedef typename Base::Ray Ray_d; - //typedef typename Base::Iso_box Iso_box_d; - //typedef typename Base::Aff_transformation Aff_transformation_d; + typedef Vector_d Direction_d; + typedef typename Base::Line Line_d; + typedef typename Base::Ray Ray_d; + typedef typename Base::Iso_box Iso_box_d; + typedef typename Base::Aff_transformation Aff_transformation_d; typedef typename Base::template Functor::type Compute_coordinate_d; typedef typename Base::template Functor::type Compare_lexicographically_d; typedef typename Base::template Functor::type Equal_d; @@ -47,11 +47,11 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::template Functor >::type Construct_segment_d; typedef typename Base::template Functor >::type Construct_sphere_d; typedef typename Base::template Functor >::type Construct_hyperplane_d; - //typedef typename Base::template Functor >::type Construct_direction_d; - //typedef typename Base::template Functor >::type Construct_line_d; - //typedef typename Base::template Functor >::type Construct_ray_d; - //typedef typename Base::template Functor >::type Construct_iso_box_d; - //typedef typename Base::template Functor >::type Construct_aff_transformation_d; + typedef Construct_vector_d Construct_direction_d; + typedef typename Base::template Functor >::type Construct_line_d; + typedef typename Base::template Functor >::type Construct_ray_d; + typedef typename Base::template Functor >::type Construct_iso_box_d; + typedef typename Base::template Functor >::type Construct_aff_transformation_d; typedef typename Base::template Functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) @@ -114,7 +114,7 @@ template struct Kernel_d_interface : public Base_ { //typedef typename Base::template Functor::type Center_of_sphere_d; //typedef typename Base::template Functor::type Value_at_d; //typedef typename Base::template Functor::type Point_of_sphere_d; - //typedef typename Base::template Functor::type Orthogonal_vector_d; + typedef typename Base::template Functor::type Orthogonal_vector_d; //typedef typename Base::template Functor::type Linear_base_d; //typedef ??? Intersect_d; @@ -137,6 +137,7 @@ template struct Kernel_d_interface : public Base_ { Vector_to_point_d vector_to_point_d_object()const{ return Vector_to_point_d(*this); } Midpoint_d midpoint_d_object()const{ return Midpoint_d(*this); } Component_accessor_d component_accessor_d_object()const{ return Component_accessor_d(*this); } + Orthogonal_vector_d orthogonal_vector_d_object()const{ return Orthogonal_vector_d(*this); } Construct_cartesian_const_iterator_d construct_cartesian_const_iterator_d_object()const{ return Construct_cartesian_const_iterator_d(*this); } Construct_point_d construct_point_d_object()const{ return Construct_point_d(*this); } Construct_vector_d construct_vector_d_object()const{ return Construct_vector_d(*this); } @@ -144,11 +145,11 @@ template struct Kernel_d_interface : public Base_ { Construct_sphere_d construct_sphere_d_object()const{ return Construct_sphere_d(*this); } Construct_hyperplane_d construct_hyperplane_d_object()const{ return Construct_hyperplane_d(*this); } Squared_distance_d squared_distance_d_object()const{ return Squared_distance_d(*this); } - //Construct_direction_d construct_direction_d_object()const{ return Construct_direction_d(*this); } - //Construct_line_d construct_line_d_object()const{ return Construct_line_d(*this); } - //Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); } - //Construct_iso_box_d construct_iso_box_d_object()const{ return Construct_iso_box_d(*this); } - //Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); } + Construct_direction_d construct_direction_d_object()const{ return Construct_direction_d(*this); } + Construct_line_d construct_line_d_object()const{ return Construct_line_d(*this); } + Construct_ray_d construct_ray_d_object()const{ return Construct_ray_d(*this); } + Construct_iso_box_d construct_iso_box_d_object()const{ return Construct_iso_box_d(*this); } + Construct_aff_transformation_d construct_aff_transformation_d_object()const{ return Construct_aff_transformation_d(*this); } // Dummies for those required functors missing a concept. typedef Null_functor Position_on_line_d; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h new file mode 100644 index 00000000000..088b484ae8c --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h @@ -0,0 +1,48 @@ +#ifndef CGAL_KERNELD_TYPES_ISO_BOX_H +#define CGAL_KERNELD_TYPES_ISO_BOX_H +#include +#include +#include +#include +#include +namespace CGAL { +template class Iso_box { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef std::pair Data_; + Data_ data; + public: + Iso_box(){} + Iso_box(Point_ const&a, Point_ const&b): data(a,b) {} + Point_ min()const{ + return data.first; + } + Point_ max()const{ + return data.second; + } +}; +namespace CartesianDKernelFunctors { + template struct Construct_iso_box : Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_iso_box) + typedef typename R_::Iso_box result_type; + typedef typename R_::RT RT; + typedef typename R_::Point Point; + typedef typename R_::Vector Vector; + typedef typename R_::template Functor >::type Cp_; + typedef typename R_::template Functor >::type Ci_; + result_type operator()(Point const&a, Point const&b)const{ + Cp_ cp(this->kernel()); + Ci_ ci(this->kernel()); + return result_type(cp( + make_transforming_pair_iterator(ci(a,Begin_tag()), ci(b,Begin_tag()), Min()), + make_transforming_pair_iterator(ci(a,End_tag()), ci(b,End_tag()), Min())), + cp( + make_transforming_pair_iterator(ci(a,Begin_tag()), ci(b,Begin_tag()), Max()), + make_transforming_pair_iterator(ci(a,End_tag()), ci(b,End_tag()), Max()))); + } + }; +} + +} // namespace CGAL + +#endif // CGAL_KERNELD_TYPES_ISO_BOX_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h new file mode 100644 index 00000000000..bc1db94f166 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h @@ -0,0 +1,45 @@ +#ifndef CGAL_KERNELD_TYPES_LINE_H +#define CGAL_KERNELD_TYPES_LINE_H +#include +#include +#include +namespace CGAL { +template class Line { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef std::pair Data_; + Data_ data; + public: + Line(){} + Line(Point_ const&a, Point_ const&b): data(a,b) {} + Point_ point(int i)const{ + if(i==0) return data.first; + if(i==1) return data.second; + throw "not implemented"; + } + Line opposite()const{ + return Line(data.second,data.first); + } +}; +namespace CartesianDKernelFunctors { + template struct Construct_line : Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_line) + typedef typename R_::Line result_type; + typedef typename R_::Point Point; + typedef typename R_::Vector Vector; + typedef typename R_::template Functor::type Tp_; + //typedef typename R_::template Functor::type Dp_; + //typedef typename R_::template Functor::type Sv_; + result_type operator()(Point const&a, Point const&b)const{ + return result_type(a,b); + } + result_type operator()(Point const&a, typename First_if_different::Type const&b)const{ + Tp_ tp(this->kernel()); + return result_type(a,tp(a,b)); + } + }; +} + +} // namespace CGAL + +#endif // CGAL_KERNELD_TYPES_LINE_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h new file mode 100644 index 00000000000..5987bcacf62 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h @@ -0,0 +1,45 @@ +#ifndef CGAL_KERNELD_TYPES_RAY_H +#define CGAL_KERNELD_TYPES_RAY_H +#include +#include +#include +namespace CGAL { +template class Ray { + typedef typename R_::FT FT_; + typedef typename R_::Point Point_; + typedef typename R_::Vector Vector_; + typedef std::pair Data_; + Data_ data; + public: + Ray(){} + Ray(Point_ const&a, Vector_ const&b): data(a,b) {} + Point_ source()const{ + return data.first; + } + // FIXME: return a R_::Direction? + Vector_ direction()const{ + return data.second; + } +}; +namespace CartesianDKernelFunctors { + template struct Construct_ray : Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Construct_ray) + typedef typename R_::Ray result_type; + typedef typename R_::Point Point; + typedef typename R_::Vector Vector; + typedef typename R_::template Functor::type Dp_; + //typedef typename R_::template Functor::type Tp_; + //typedef typename R_::template Functor::type Sv_; + result_type operator()(Point const&a, Vector const&b)const{ + return result_type(a,b); + } + result_type operator()(Point const&a, typename First_if_different::Type const&b)const{ + Dp_ dp(this->kernel()); + return result_type(a,dp(b,a)); + } + }; +} + +} // namespace CGAL + +#endif // CGAL_KERNELD_TYPES_RAY_H 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 73ca7d88fec..9f74ef63bd4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -349,6 +349,22 @@ template struct Opposite_vector : private Store_kernel { } }; +template struct Scaled_vector : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Scaled_vector) + typedef R_ R; + typedef typename R_::FT FT; + typedef typename R::Vector Vector; + typedef typename R::template Functor >::type CV; + typedef typename R::template Functor >::type CI; + typedef Vector result_type; + typedef Vector first_argument_type; + typedef FT second_argument_type; + result_type operator()(Vector const&v,FT const& s)const{ + CI ci(this->kernel()); + return CV(this->kernel())(make_transforming_iterator(ci(v,Begin_tag()),Scale(s)),make_transforming_iterator(ci(v,End_tag()),Scale(s))); + } +}; + template struct Sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors) typedef R_ R; @@ -381,6 +397,25 @@ template struct Difference_of_vectors : private Store_kernel { } }; +template struct Translated_point : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Translated_point) + typedef R_ R; + typedef typename R_::RT RT; + typedef typename R::Vector Vector; + typedef typename R::Point Point; + typedef typename R::template Functor >::type CP; + typedef typename R::template Functor >::type CVI; + typedef typename R::template Functor >::type CPI; + typedef Point result_type; + typedef Point first_argument_type; + typedef Vector second_argument_type; + result_type operator()(Point const&a, Vector const&b)const{ + CVI cvi(this->kernel()); + CPI cpi(this->kernel()); + return CP(this->kernel())(make_transforming_pair_iterator(cpi(a,Begin_tag()),cvi(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(cpi(a,End_tag()),cvi(b,End_tag()),std::plus())); + } +}; + template struct Difference_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_points) typedef R_ R; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index b18e7c881d9..9c1b1668003 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -39,8 +39,11 @@ CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) CGAL_Kernel_obj2(Segment,segment) CGAL_Kernel_obj2(Sphere,sphere) +CGAL_Kernel_obj3(Line,line) +CGAL_Kernel_obj3(Ray,ray) CGAL_Kernel_obj3(Hyperplane,hyperplane) CGAL_Kernel_obj3(Aff_transformation,aff_transformation) +CGAL_Kernel_obj3(Iso_box,iso_box) CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, construct_point_cartesian_const_iterator_object) @@ -50,8 +53,12 @@ CGAL_Kernel_cons2(Sum_of_vectors, sum_of_vectors_object) CGAL_Kernel_cons2(Difference_of_vectors, difference_of_vectors_object) +CGAL_Kernel_cons2(Translated_point, + translated_point_object) CGAL_Kernel_cons2(Opposite_vector, opposite_vector_object) +CGAL_Kernel_cons2(Scaled_vector, + scaled_vector_object) CGAL_Kernel_cons2(Difference_of_points, difference_of_points_object) CGAL_Kernel_cons2(Vector_to_point, @@ -60,6 +67,10 @@ CGAL_Kernel_cons2(Point_to_vector, point_to_vector_object) CGAL_Kernel_cons2(Midpoint, midpoint_object) +CGAL_Kernel_cons2(Orthogonal_vector, + orthogonal_vector_object) +CGAL_Kernel_cons2(Hyperplane_translation, + hyperplane_translation_object) //CGAL_Kernel_cons2(Construct_segment, // construct_segment_object) CGAL_Kernel_cons2(Segment_extremity, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index b4525ea9b77..f5fc7fcbcbf 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -49,6 +49,7 @@ namespace CGAL { DECL_OBJ(Direction); DECL_OBJ(Hyperplane); DECL_OBJ(Ray); + DECL_OBJ(Iso_box); DECL_OBJ(Bbox); DECL_OBJ(Aff_transformation); #undef DECL_OBJ @@ -112,8 +113,10 @@ namespace CGAL { DECL_CONSTRUCT(Sum_of_vectors,Vector); DECL_CONSTRUCT(Difference_of_vectors,Vector); DECL_CONSTRUCT(Opposite_vector,Vector); + DECL_CONSTRUCT(Scaled_vector,Vector); DECL_CONSTRUCT(Orthogonal_vector,Vector); DECL_CONSTRUCT(Difference_of_points,Vector); + DECL_CONSTRUCT(Translated_point,Point); DECL_CONSTRUCT(Point_to_vector,Vector); DECL_CONSTRUCT(Vector_to_point,Point); #undef DECL_CONSTRUCT From 2eaf86ec1a47c8ee3feec1e20e9a8e25f97cfe17 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 20 Sep 2012 13:49:34 +0000 Subject: [PATCH 153/210] Epick_d doc --- .../Kernel_d/kernel_representation_d.tex | 6 ++++ Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex | 29 +++++++++++++++++++ .../doc_tex/Kernel_d_ref/Homogeneous_d.tex | 4 +-- Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex | 2 +- Kernel_d/doc_tex/Kernel_d_ref/main.tex | 2 ++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex diff --git a/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex b/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex index bd0daf32851..08673449b01 100644 --- a/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex +++ b/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex @@ -132,6 +132,12 @@ circumvented. With \ccc{Homogeneous_d}, \ccc{Homogeneous_d::LA} is mapped to the type \ccc{LinearAlgebra}. +\subsection{Epick Kernel} + +The kernel \ccc{Epick_d}, short for Exact Predicates Inexact Constructions Kernel is an experimental kernel useful when the dimension of the space is known at compile-time. It uses a Cartesian representation and supports construction of points from \ccc{double} coordinates. It provides exact geometric predicates, but inexact geometric constructions. + +Note that it is a rather strict model of the \ccc{Kernel_d} concept. The type of a point is \ccc{Epick_d::Point_d}, \emph{not} \ccc{Point_d>}. + \subsection{Naming conventions} The use of representation classes not only avoids problems, it also diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex new file mode 100644 index 00000000000..917d4b9c918 --- /dev/null +++ b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex @@ -0,0 +1,29 @@ +\begin{ccRefClass}{Epick_d} + +\ccInclude{CGAL/Epick_d.h} + +\ccDefinition +A model for \ccc{Kernel_d} and \ccc{DelaunayTriangulationTraits} that +uses Cartesian coordinates to represent the geometric objects. The +integer parameter \ccc{dimension} is the dimension of the ambient +Euclidean space. It supports construction of points from \ccc{double} +Cartesian coordinates. It provides exact geometric predicates, but +inexact geometric constructions. + +Note that this kernel does not completely conform to the \ccc{Kernel_d} +concept: it is missing the constructions \ccc{Lift_to_paraboloid_d} and +\ccc{Project_along_d_axis_d} which do not make sense with a fixed +dimension. + +\ccIsModel +\ccRefConceptPage{Kernel_d} + +\ccRefConceptPage{DelaunayTriangulationTraits} + +\ccSeeAlso +\ccRefIdfierPage{CGAL::Cartesian_d} + +\ccRefIdfierPage{CGAL::Homogeneous_d} + + +\end{ccRefClass} diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Homogeneous_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Homogeneous_d.tex index a1bf9bb9ce3..fd43aa8eade 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/Homogeneous_d.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/Homogeneous_d.tex @@ -1,4 +1,4 @@ -\begin{ccRefClass}{Homogeneous} +\begin{ccRefClass}{Homogeneous_d} \ccInclude{CGAL/Homogeneous_d.h} \ccDefinition @@ -16,6 +16,6 @@ the kernel is only an approximation of Euclidean geometry. \ccRefConceptPage{Kernel_d} \ccSeeAlso -\ccRefIdfierPage{CGAL::Cartesian_d} +\ccRefIdfierPage{CGAL::Cartesian_d} \end{ccRefClass} diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex b/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex index 4dde1fb02a4..c74f3cac3af 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex @@ -166,6 +166,6 @@ corresponding functions are: \ccHasModels -\ccc{Cartesian_d}, \ccc{Homogeneous_d} +\ccc{Cartesian_d}, \ccc{Homogeneous_d}, \ccc{Epick_d} \end{ccRefConcept} diff --git a/Kernel_d/doc_tex/Kernel_d_ref/main.tex b/Kernel_d/doc_tex/Kernel_d_ref/main.tex index 9ad0cc9a3d7..182519caf6b 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/main.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/main.tex @@ -20,6 +20,7 @@ \input{Kernel_d_ref/Cartesian_d.tex} \gdef\ccRefPageBreak{\ccTrue} \input{Kernel_d_ref/Homogeneous_d.tex} +\input{Kernel_d_ref/Epick_d.tex} \clearpage \section{Kernel Objects} @@ -36,6 +37,7 @@ \input{Kernel_d_ref/Sphere_d.tex} \input{Kernel_d_ref/Iso_box_d.tex} \input{Kernel_d_ref/Aff_transformation_d.tex} +\input{Kernel_d_ref/Epick_d_Point_d.tex} From c9b1a6867c42cf2c2e684793b41af673b6f37b27 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 20 Sep 2012 13:50:43 +0000 Subject: [PATCH 154/210] missed a file --- .../doc_tex/Kernel_d_ref/Epick_d_Point_d.tex | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex new file mode 100644 index 00000000000..0856b39556c --- /dev/null +++ b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex @@ -0,0 +1,18 @@ +\begin{ccRefClass} {Epick_d::Point_d} + +\ccDefinition +An object of the class \ccRefName\ is a point in the Euclidean space $\E^{dimension}$. + +This class is DefaultConstructible, Copyable, Assignable, and provides the following additional interfaces: + +\ccCreation +\ccCreationVariable{p} +\ccConstructor{Point_d(double $x_0$, \ldots, double $x_{dimension-1}$);} +{introduces a point \ccVar\ initialized to $(x_0, \ldots, x_{dimension-1})$.} + +\ccOperations +\ccMethod{double operator[](int i) const;} + {returns the i'th Cartesian coordinate of \ccVar. + \ccPrecond $0\leq i < dimension$.} + +\end{ccRefClass} From f90ce73f63134cadc46a4a8d01d4c2c457a42ac3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 20 Sep 2012 13:53:53 +0000 Subject: [PATCH 155/210] spell dimension the same everywhere --- Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex b/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex index 08673449b01..67b0b56ad35 100644 --- a/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex +++ b/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex @@ -134,9 +134,9 @@ type \ccc{LinearAlgebra}. \subsection{Epick Kernel} -The kernel \ccc{Epick_d}, short for Exact Predicates Inexact Constructions Kernel is an experimental kernel useful when the dimension of the space is known at compile-time. It uses a Cartesian representation and supports construction of points from \ccc{double} coordinates. It provides exact geometric predicates, but inexact geometric constructions. +The kernel \ccc{Epick_d}, short for Exact Predicates Inexact Constructions Kernel is an experimental kernel useful when the dimension of the space is known at compile-time. It uses a Cartesian representation and supports construction of points from \ccc{double} coordinates. It provides exact geometric predicates, but inexact geometric constructions. -Note that it is a rather strict model of the \ccc{Kernel_d} concept. The type of a point is \ccc{Epick_d::Point_d}, \emph{not} \ccc{Point_d>}. +Note that it is a rather strict model of the \ccc{Kernel_d} concept. The type of a point is \ccc{Epick_d::Point_d}, \emph{not} \ccc{Point_d>}. \subsection{Naming conventions} From 09ab3822bc29ef723e64a50336507a1e006c4a8d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 20 Sep 2012 16:21:08 +0000 Subject: [PATCH 156/210] doc details --- Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex | 2 +- Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex b/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex index 67b0b56ad35..f1aec33956e 100644 --- a/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex +++ b/Kernel_d/doc_tex/Kernel_d/kernel_representation_d.tex @@ -136,7 +136,7 @@ type \ccc{LinearAlgebra}. The kernel \ccc{Epick_d}, short for Exact Predicates Inexact Constructions Kernel is an experimental kernel useful when the dimension of the space is known at compile-time. It uses a Cartesian representation and supports construction of points from \ccc{double} coordinates. It provides exact geometric predicates, but inexact geometric constructions. -Note that it is a rather strict model of the \ccc{Kernel_d} concept. The type of a point is \ccc{Epick_d::Point_d}, \emph{not} \ccc{Point_d>}. +Note that it is a rather strict model of the \ccc{Kernel_d} concept. The type of a point is \ccc{Epick_d::Point_d}, {\bf not} \ccc{Point_d>}. \subsection{Naming conventions} diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex index 917d4b9c918..1d93def4a70 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex @@ -21,6 +21,8 @@ dimension. \ccRefConceptPage{DelaunayTriangulationTraits} \ccSeeAlso +\ccRefIdfierPage{CGAL::Epick_d::Point_d} + \ccRefIdfierPage{CGAL::Cartesian_d} \ccRefIdfierPage{CGAL::Homogeneous_d} From 2a83bd85186134bdfbbc567a48e60f7b3a5f3915 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 28 Sep 2012 11:47:25 +0000 Subject: [PATCH 157/210] constructing the kernel --- Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex index 1d93def4a70..aa971a77e33 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex @@ -10,6 +10,8 @@ Euclidean space. It supports construction of points from \ccc{double} Cartesian coordinates. It provides exact geometric predicates, but inexact geometric constructions. +This kernel is default constructible and copyable. It does not carry any state so it is possible to use objects created by one instance with functors created by another one. + Note that this kernel does not completely conform to the \ccc{Kernel_d} concept: it is missing the constructions \ccc{Lift_to_paraboloid_d} and \ccc{Project_along_d_axis_d} which do not make sense with a fixed From 5dd6bdca7345bca316611c8c65ca4debcf221c9b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 28 Sep 2012 14:09:07 +0000 Subject: [PATCH 158/210] missing include --- NewKernel_d/include/CGAL/Lazy.h | 1 + 1 file changed, 1 insertion(+) diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index 68ce0adb9f0..3dbd7cc275d 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -22,6 +22,7 @@ #define CGAL_LAZY_H #include +#include #include #include #include From 4b074f2960894f13b378e486cb7ed05314dbbb6a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 28 Sep 2012 15:48:49 +0000 Subject: [PATCH 159/210] nits --- Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex | 7 +++++-- Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex index aa971a77e33..a4c6a600aea 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d.tex @@ -8,9 +8,12 @@ uses Cartesian coordinates to represent the geometric objects. The integer parameter \ccc{dimension} is the dimension of the ambient Euclidean space. It supports construction of points from \ccc{double} Cartesian coordinates. It provides exact geometric predicates, but -inexact geometric constructions. +inexact geometric constructions. The geometric predicates are made exact +without sacrificing speed thanks to the use of filters. -This kernel is default constructible and copyable. It does not carry any state so it is possible to use objects created by one instance with functors created by another one. +This kernel is default constructible and copyable. It does not carry any +state so it is possible to use objects created by one instance with +functors created by another one. Note that this kernel does not completely conform to the \ccc{Kernel_d} concept: it is missing the constructions \ccc{Lift_to_paraboloid_d} and diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex index 0856b39556c..b246ac76f42 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/Epick_d_Point_d.tex @@ -7,7 +7,7 @@ This class is DefaultConstructible, Copyable, Assignable, and provides the follo \ccCreation \ccCreationVariable{p} -\ccConstructor{Point_d(double $x_0$, \ldots, double $x_{dimension-1}$);} +\ccConstructor{Point_d(double x_0, \ldots, double x_{dimension-1});} {introduces a point \ccVar\ initialized to $(x_0, \ldots, x_{dimension-1})$.} \ccOperations From 940603a746c1b19ac4cdf14f617d52a82fa8334e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 3 Oct 2012 15:15:55 +0000 Subject: [PATCH 160/210] Allow point construction compatible with Generator_d (I think). --- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 50 +++++++++++++++---- NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 89caa1feb78..eb05c1baf39 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -84,32 +84,64 @@ template struct Construct_LA_vector #else using internal::Construct_LA_vector_::operator(); #endif - template typename boost::enable_if,result_type>::type operator() - (Iter f,Iter g,Cartesian_tag)const + template inline + typename boost::enable_if,result_type>::type operator() + (Iter f,Iter g,Cartesian_tag t)const { - int d=std::distance(f,g); + return this->operator()(std::distance(f,g),f,g,t); + } + template inline + typename boost::enable_if,result_type>::type operator() + (int d,Iter f,Iter g,Cartesian_tag)const + { + CGAL_assertion(d==std::distance(f,g)); CGAL_assertion(check_dimension_eq(d,this->kernel().dimension())); return typename Constructor::Iterator()(d,f,g); } - template typename boost::enable_if,result_type>::type operator() + template inline + typename boost::enable_if,result_type>::type operator() (Iter f,Iter g,Homogeneous_tag)const { --g; - return this->operator()(f,g,*g); + return this->operator()(std::distance(f,g),f,g,*g); } - template typename boost::enable_if,result_type>::type operator() + template inline + typename boost::enable_if,result_type>::type operator() + (int d,Iter f,Iter g,Homogeneous_tag)const + { + --g; + return this->operator()(d,f,g,*g); + } + template inline + typename boost::enable_if,result_type>::type operator() (Iter f,Iter g)const { + // Shouldn't it try comparing dist(f,g) to the dimension if it is known? return this->operator()(f,g,typename R::Rep_tag()); } - template typename boost::enable_if,result_type>::type operator() - (Iter f,Iter g,NT const&l)const + template inline + typename boost::enable_if,result_type>::type operator() + (int d,Iter f,Iter g)const { - int d=std::distance(f,g); + return this->operator()(d,f,g,typename R::Rep_tag()); + } + + // Last homogeneous coordinate given separately + template inline + typename boost::enable_if,result_type>::type operator() + (int d,Iter f,Iter g,NT const&l)const + { + CGAL_assertion(d==std::distance(f,g)); CGAL_assertion(check_dimension_eq(d,this->kernel().dimension())); // RT? better be safe for now return typename Constructor::Iterator()(d,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); } + template inline + typename boost::enable_if,result_type>::type operator() + (Iter f,Iter g,NT const&l)const + { + return this->operator()(std::distance(f,g),f,g,l); + } }; template struct Compute_cartesian_coordinate { diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index f5ebafdf844..568bb9a0b51 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -196,7 +196,7 @@ void test3(){ P b=cp(5,6,7,8); int rr[]={3,5,2,3}; int* r=rr; - P c=cp_(r,r+3); + P c=cp_(3,r,r+3); P d=cp_(r,r+4,CGAL::Homogeneous_tag()); S s=cs(c,d); std::cout << cc(a,1) << std::endl; From e73ed3a989ab4c313d5d0994c369fc4e545fc922 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 9 Oct 2012 06:33:29 +0000 Subject: [PATCH 161/210] Help programs that rely on Kernel_traits --- NewKernel_d/include/CGAL/Epick_d.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/include/CGAL/Epick_d.h b/NewKernel_d/include/CGAL/Epick_d.h index 9052004009e..a289c55e373 100644 --- a/NewKernel_d/include/CGAL/Epick_d.h +++ b/NewKernel_d/include/CGAL/Epick_d.h @@ -40,7 +40,7 @@ struct Epick_d_help2 Dynamic_dimension_tag, \ Dimension_tag \ >::type \ - > > > + >, Epick_d > > template struct Epick_d : CGAL_BASE diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index d36dda6a105..137995a5b30 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -75,16 +75,17 @@ template transforming_iterator +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; + typedef typename Default::Get::type Derived; #define CGAL_Kernel_obj(X,Y) \ - typedef X##_d X; + typedef X##_d X; #define CGAL_Kernel_obj3(X,Y) //CGAL_Kernel_obj(Segment,segment) @@ -128,6 +129,7 @@ struct Cartesian_wrap : public Base_ type(){} type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; + // FIXME: Self or Derived? typedef typename Read_tag_type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ From cb7ac0d4f0161f360dfc9122225ff05a6c158d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Tue, 18 Dec 2012 15:16:28 +0100 Subject: [PATCH 162/210] Fix the include guard --- NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 8ba2c3bad8b..635305e37df 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -1,5 +1,5 @@ -#ifndef CGAL_KD_KERNEL_3_INTERFACE_H -#define CGAL_KD_KERNEL_3_INTERFACE_H +#ifndef CGAL_KD_KERNEL_D_INTERFACE_H +#define CGAL_KD_KERNEL_D_INTERFACE_H #include #include @@ -164,4 +164,4 @@ template struct Kernel_d_interface : public Base_ { }; } -#endif +#endif // CGAL_KD_KERNEL_D_INTERFACE_H From 276a2cea3bbb5065816d892e2737350f51f14a18 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 29 Dec 2012 17:29:28 +0100 Subject: [PATCH 163/210] Update paths in my private Makefile. --- NewKernel_d/test/NewKernel_d/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 810900fa935..3cfabe8b3b2 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -1,6 +1,6 @@ all: normal cxx0x -CGAL_INC = -I/home/glisse/repos/cgal/trunk/Algebraic_foundations/include -I/home/glisse/repos/cgal/trunk/STL_Extension/include -I/home/glisse/repos/cgal/trunk/Number_types/include -I/data/repos/cgal/trunk/Algebraic_foundations/include -I/data/repos/cgal/trunk/STL_Extension/include -I/data/repos/cgal/trunk/Number_types/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK +CGAL_INC = -I/home/glisse/repos/cgal/master/Algebraic_foundations/include -I/home/glisse/repos/cgal/master/STL_Extension/include -I/home/glisse/repos/cgal/master/Number_types/include -I/data/repos/cgal/master/Algebraic_foundations/include -I/data/repos/cgal/master/STL_Extension/include -I/data/repos/cgal/master/Number_types/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_EIGEN3_ENABLED From e4b8499c36dd4ba5fee11511788e050f054e992e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 29 Dec 2012 19:10:40 +0100 Subject: [PATCH 164/210] Start using Get_functor. --- .../CGAL/Kernel_d/Cartesian_change_FT.h | 4 +- .../CGAL/Kernel_d/Cartesian_complete.h | 12 +-- .../CGAL/Kernel_d/Cartesian_filter_K.h | 4 +- .../CGAL/Kernel_d/Cartesian_filter_NT.h | 4 +- .../CGAL/Kernel_d/Cartesian_static_filters.h | 8 +- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 16 ++-- .../include/CGAL/Kernel_d/Define_segment.h | 4 +- .../include/CGAL/Kernel_d/KernelD_converter.h | 2 +- .../CGAL/Kernel_d/Kernel_2_interface.h | 8 +- .../CGAL/Kernel_d/Kernel_3_interface.h | 8 +- .../CGAL/Kernel_d/Kernel_d_interface.h | 84 +++++++++--------- .../CGAL/Kernel_d/Kernel_object_converter.h | 16 ++-- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 16 ++-- .../include/CGAL/Kernel_d/Types/Iso_box.h | 4 +- .../include/CGAL/Kernel_d/Types/Line.h | 6 +- NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h | 6 +- .../include/CGAL/Kernel_d/Types/Segmentd.h | 2 +- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 12 +-- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 4 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 4 +- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 6 +- .../include/CGAL/Kernel_d/Wrapper/Sphere_d.h | 6 +- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 10 +-- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 4 +- .../Kernel_d/function_objects_cartesian.h | 88 +++++++++---------- NewKernel_d/include/CGAL/functor_tags.h | 8 ++ 26 files changed, 177 insertions(+), 169 deletions(-) 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 6a5646ed35a..994b15f01f3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -50,7 +50,7 @@ struct Cartesian_change_FT_base : public template struct Construct_cartesian_const_iterator_ { - typedef typename Kernel_base::template Functor::type Functor_base; + typedef typename Get_functor::type Functor_base; Construct_cartesian_const_iterator_(){} Construct_cartesian_const_iterator_(Self const&r):f(r){} Functor_base f; @@ -69,7 +69,7 @@ struct Cartesian_change_FT_base : public template struct Compute_cartesian_coordinate { - typedef typename Kernel_base::template Functor::type Functor_base; + typedef typename Get_functor::type Functor_base; Compute_cartesian_coordinate(){} Compute_cartesian_coordinate(Self const&r):f(r){} Functor_base f; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index c507f947aa9..6903843c5ff 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -87,9 +87,9 @@ template struct Cartesian_com template::type> struct Functor : R_::template Functor {}; template struct Functor { - typedef typename Kernel_base::template Functor::type Base_functor; + typedef typename Get_functor::type Base_functor; typedef typename boost::mpl::if_c::value, - typename Cartesian_define_all_functors::template Functor::type, + typename Get_functor, F>::type, Base_functor>::type type; }; @@ -109,9 +109,9 @@ template struct Cartesian_com template::type> struct Functor : R_::template Functor {}; template struct Functor { - typedef typename Kernel_base::template Functor::type Base_functor; + typedef typename Get_functor::type Base_functor; typedef typename boost::mpl::if_c::value, - typename Cartesian_define_all_functors::template Functor::type, + typename Get_functor, F>::type, Base_functor>::type type; }; @@ -128,9 +128,9 @@ template struct Cartesian_com template::type> struct Functor : R_::template Functor {}; template struct Functor { - typedef typename Kernel_base::template Functor::type Base_functor; + typedef typename Get_functor::type Base_functor; typedef typename boost::mpl::if_c::value, - typename Cartesian_define_all_functors::template Functor::type, + typename Get_functor, F>::type, Base_functor>::type type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index 8c4cd4463c7..b0828594172 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -33,8 +33,8 @@ struct Cartesian_filter_K : public Base_, template::type> struct Functor : Kernel_base::template Functor {}; template struct Functor { - typedef typename AK::template Functor::type AP; - typedef typename EK::template Functor::type EP; + typedef typename Get_functor::type AP; + typedef typename Get_functor::type EP; typedef Filtered_predicate type; }; // TODO: diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h index 5f0bc94c963..8d4041707aa 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -22,8 +22,8 @@ struct Cartesian_filter_NT : public Base_ template struct Functor { struct type { //TODO: use compression (derive from a compressed_pair?) - typedef typename K1::template Functor::type P1; P1 p1; - typedef typename K2::template Functor::type P2; P2 p2; + typedef typename Get_functor::type P1; P1 p1; + typedef typename Get_functor::type P2; P2 p2; typedef typename P2::result_type result_type; type(){} type(Cartesian_filter_NT const&k):p1(reinterpret_cast(k)),p2(reinterpret_cast(k)){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 64948d910f1..87c1e31556b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -14,8 +14,8 @@ template struct Orientation_of_points_2 : private Store_k typedef typename R_::Point Point; typedef typename R_::Orientation result_type; typedef typename R_::FT FT; - typedef typename R_::template Functor::type CC; - typedef typename Base_::template Functor::type Orientation_base; + typedef typename Get_functor::type CC; + typedef typename Get_functor::type Orientation_base; // TODO: Move this out for easy reuse struct Adapter { struct Point_2 { @@ -59,12 +59,12 @@ struct Cartesian_static_filters, R_, Derived_> : public R_ { CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} typedef Cartesian_static_filters, R_, Derived_> Self; typedef typename Default::Get::type Derived; - template struct Functor : R_::template Functor {}; + template struct Functor : Get_functor {}; template struct Functor { typedef //typename boost::conditional< //boost::is_same::value, - //typename R_::template Functor::type, + //typename Get_functor::type, SFA::Orientation_of_points_2 // >::type type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 5452bd11fe1..07e2a814d86 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -45,11 +45,11 @@ template struct Construct_flat_orientation : private Store_kernel typedef R_ R; typedef typename R_::FT FT; typedef typename R::Point Point; - typedef typename R::template Functor::type CCC; typedef typename Increment_dimension::type Dplusone; typedef typename R::LA::template Rebind_dimension::Other LA; typedef typename LA::Square_matrix Matrix; - typedef typename R::template Functor::type PD; + typedef typename Get_functor::type CCC; + typedef typename Get_functor::type PD; typedef Flat_orientation result_type; // This implementation is going to suck. Maybe we should push the @@ -99,8 +99,8 @@ template struct Contained_in_affine_hull : private Store_kernel { typedef typename R_::FT FT; typedef typename R::Point Point; typedef typename R::Boolean result_type; - typedef typename R::template Functor::type CCC; - typedef typename R::template Functor::type PD; + typedef typename Get_functor::type CCC; + typedef typename Get_functor::type PD; //typedef typename Increment_dimension::type D1; //typedef typename Increment_dimension::type D2; //typedef typename R::LA::template Rebind_dimension::Other LA; @@ -166,8 +166,8 @@ template struct In_flat_orientation : private Store_kernel { template result_type operator()(Flat_orientation const&o, Iter f, Iter e) const { // TODO: work in the projection instead of the ambient space. - typename R::template Functor::type c(this->kernel()); - typename R::template Functor::type pd(this->kernel()); + typename Get_functor::type c(this->kernel()); + typename Get_functor::type pd(this->kernel()); int d=pd(*f); Matrix m(d+1,d+1); int i=0; @@ -204,8 +204,8 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel template result_type operator()(Flat_orientation const&o, Iter f, Iter e, Point const&x) const { // TODO: can't work in the projection, but we should at least remove the row of 1s. - typename R::template Functor::type c(this->kernel()); - typename R::template Functor::type pd(this->kernel()); + typename Get_functor::type c(this->kernel()); + typename Get_functor::type pd(this->kernel()); int d=pd(*f); Matrix m(d+2,d+2); int i=0; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 70e14a7145b..620aa1abab6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -13,7 +13,7 @@ template struct Construct_segment { typedef R_ R; typedef typename R_::Point Point; typedef typename R_::Segment Segment; - typedef typename R_::template Functor >::type CP; + typedef typename Get_functor >::type CP; typedef Segment result_type; result_type operator()(Point const&a, Point const&b)const{ return result_type(a,b); @@ -61,7 +61,7 @@ struct Define_segment : public Base_ { typedef typename Base::Object_list::template add::type Object_list; // TODO: forward the second Functor argument (like fast, no_filter) - template struct Functor : Base_::template Functor {}; + template struct Functor : Get_functor {}; template struct Functor,D> { typedef CartesianDKernelFunctors::Construct_segment type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index fd87fac62f2..0854b770ecc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -57,7 +57,7 @@ class KernelD_converter_ typedef KernelD_converter_ Base; typedef typename Read_tag_type::type K1_Obj; typedef typename Read_tag_type::type K2_Obj; - typedef typename K1::template Functor >::type K1_Conv; + typedef typename Get_functor >::type K1_Conv; typedef KO_converter KOC; typedef BOOSTD is_same no_converter; typedef typename internal::Map_taglist_to_typelist::type::template contains duplicate; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h index da2ed015f0a..f675f190792 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -16,7 +16,7 @@ template struct Kernel_2_interface : public Base_ { struct Segment_2 {}; typedef cpp0x::tuple Triangle_2; // triangulation insists... template struct Help_2p_i { - typedef typename Base::template Functor::type LT; + typedef typename Get_functor::type LT; typedef typename LT::result_type result_type; LT lt; Help_2p_i(Kernel const&k):lt(k){} @@ -29,7 +29,7 @@ template struct Kernel_2_interface : public Base_ { typedef Help_2p_i Compare_x_2; typedef Help_2p_i Compare_y_2; struct Compare_distance_2 { - typedef typename Base::template Functor::type CD; + typedef typename Get_functor::type CD; typedef typename CD::result_type result_type; CD cd; Compare_distance_2(Kernel const&k):cd(k){} @@ -41,7 +41,7 @@ template struct Kernel_2_interface : public Base_ { } }; struct Orientation_2 { - typedef typename Base::template Functor::type O; + typedef typename Get_functor::type O; typedef typename O::result_type result_type; O o; Orientation_2(Kernel const&k):o(k){} @@ -53,7 +53,7 @@ template struct Kernel_2_interface : public Base_ { } }; struct Side_of_oriented_sphere_2 { - typedef typename Base::template Functor::type SOS; + typedef typename Get_functor::type SOS; typedef typename SOS::result_type result_type; SOS sos; Side_of_oriented_sphere_2(Kernel const&k):sos(k){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h index f9334f20515..00ce6323592 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h @@ -17,7 +17,7 @@ template struct Kernel_3_interface : public Base_ { typedef cpp0x::tuple Triangle_3; // placeholder typedef cpp0x::tuple Tetrahedron_3; // placeholder struct Compare_xyz_3 { - typedef typename Base::template Functor::type CL; + typedef typename Get_functor::type CL; typedef typename CL::result_type result_type; CL cl; Compare_xyz_3(Kernel const&k):cl(k){} @@ -26,7 +26,7 @@ template struct Kernel_3_interface : public Base_ { } }; struct Compare_distance_3 { - typedef typename Base::template Functor::type CD; + typedef typename Get_functor::type CD; typedef typename CD::result_type result_type; CD cd; Compare_distance_3(Kernel const&k):cd(k){} @@ -38,7 +38,7 @@ template struct Kernel_3_interface : public Base_ { } }; struct Orientation_3 { - typedef typename Base::template Functor::type O; + typedef typename Get_functor::type O; typedef typename O::result_type result_type; O o; Orientation_3(Kernel const&k):o(k){} @@ -50,7 +50,7 @@ template struct Kernel_3_interface : public Base_ { } }; struct Side_of_oriented_sphere_3 { - typedef typename Base::template Functor::type SOS; + typedef typename Get_functor::type SOS; typedef typename SOS::result_type result_type; SOS sos; Side_of_oriented_sphere_3(Kernel const&k):sos(k){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 635305e37df..9e3b4f1bcca 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -26,33 +26,33 @@ template struct Kernel_d_interface : public Base_ { typedef typename Base::Ray Ray_d; typedef typename Base::Iso_box Iso_box_d; typedef typename Base::Aff_transformation Aff_transformation_d; - typedef typename Base::template Functor::type Compute_coordinate_d; - typedef typename Base::template Functor::type Compare_lexicographically_d; - typedef typename Base::template Functor::type Equal_d; - typedef typename Base::template Functor::type Less_lexicographically_d; - typedef typename Base::template Functor::type Less_or_equal_lexicographically_d; + typedef typename Get_functor::type Compute_coordinate_d; + typedef typename Get_functor::type Compare_lexicographically_d; + typedef typename Get_functor::type Equal_d; + typedef typename Get_functor::type Less_lexicographically_d; + typedef typename Get_functor::type Less_or_equal_lexicographically_d; // FIXME: and vectors? - typedef typename Base::template Functor::type Orientation_d; - typedef typename Base::template Functor::type Less_coordinate_d; - typedef typename Base::template Functor::type Point_dimension_d; - typedef typename Base::template Functor::type Side_of_oriented_sphere_d; - typedef typename Base::template Functor::type Contained_in_affine_hull_d; - typedef typename Base::template Functor::type Construct_flat_orientation_d; - typedef typename Base::template Functor::type In_flat_orientation_d; - typedef typename Base::template Functor::type In_flat_side_of_oriented_sphere_d; - typedef typename Base::template Functor::type Point_to_vector_d; - typedef typename Base::template Functor::type Vector_to_point_d; - typedef typename Base::template Functor >::type Construct_point_d; - typedef typename Base::template Functor >::type Construct_vector_d; - typedef typename Base::template Functor >::type Construct_segment_d; - typedef typename Base::template Functor >::type Construct_sphere_d; - typedef typename Base::template Functor >::type Construct_hyperplane_d; + typedef typename Get_functor::type Orientation_d; + typedef typename Get_functor::type Less_coordinate_d; + typedef typename Get_functor::type Point_dimension_d; + typedef typename Get_functor::type Side_of_oriented_sphere_d; + typedef typename Get_functor::type Contained_in_affine_hull_d; + typedef typename Get_functor::type Construct_flat_orientation_d; + typedef typename Get_functor::type In_flat_orientation_d; + typedef typename Get_functor::type In_flat_side_of_oriented_sphere_d; + typedef typename Get_functor::type Point_to_vector_d; + typedef typename Get_functor::type Vector_to_point_d; + typedef typename Get_functor >::type Construct_point_d; + typedef typename Get_functor >::type Construct_vector_d; + typedef typename Get_functor >::type Construct_segment_d; + typedef typename Get_functor >::type Construct_sphere_d; + typedef typename Get_functor >::type Construct_hyperplane_d; typedef Construct_vector_d Construct_direction_d; - typedef typename Base::template Functor >::type Construct_line_d; - typedef typename Base::template Functor >::type Construct_ray_d; - typedef typename Base::template Functor >::type Construct_iso_box_d; - typedef typename Base::template Functor >::type Construct_aff_transformation_d; - typedef typename Base::template Functor::type Midpoint_d; + typedef typename Get_functor >::type Construct_line_d; + typedef typename Get_functor >::type Construct_ray_d; + typedef typename Get_functor >::type Construct_iso_box_d; + typedef typename Get_functor >::type Construct_aff_transformation_d; + typedef typename Get_functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) typedef typename Base::Point Point; @@ -73,8 +73,8 @@ template struct Kernel_d_interface : public Base_ { }; struct Construct_cartesian_const_iterator_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_cartesian_const_iterator_d) - typedef typename Base::template Functor >::type CPI; - typedef typename Base::template Functor >::type CVI; + typedef typename Get_functor >::type CPI; + typedef typename Get_functor >::type CVI; typedef typename CGAL::decay::type>::type result_type; // Kernel_d requires a common iterator type for points and vectors // TODO: provide this mixed functor in preKernel? @@ -100,22 +100,22 @@ template struct Kernel_d_interface : public Base_ { } }; typedef typename Construct_cartesian_const_iterator_d::result_type Cartesian_const_iterator_d; - typedef typename Base::template Functor::type Squared_distance_d; - //typedef typename Base::template Functor::type Affine_rank_d; - //typedef typename Base::template Functor::type Affinely_independent_d; - //typedef typename Base::template Functor::type Contained_in_linear_hull_d; - //typedef typename Base::template Functor::type Contained_in_simplex_d; - //typedef typename Base::template Functor::type Has_on_positive_side_d; - //typedef typename Base::template Functor::type Linear_rank_d; - //typedef typename Base::template Functor::type Linearly_independent_d; - //typedef typename Base::template Functor::type Oriented_side_d; - //typedef typename Base::template Functor::type Side_of_bounded_sphere_d; + typedef typename Get_functor::type Squared_distance_d; + //typedef typename Get_functor::type Affine_rank_d; + //typedef typename Get_functor::type Affinely_independent_d; + //typedef typename Get_functor::type Contained_in_linear_hull_d; + //typedef typename Get_functor::type Contained_in_simplex_d; + //typedef typename Get_functor::type Has_on_positive_side_d; + //typedef typename Get_functor::type Linear_rank_d; + //typedef typename Get_functor::type Linearly_independent_d; + //typedef typename Get_functor::type Oriented_side_d; + //typedef typename Get_functor::type Side_of_bounded_sphere_d; - //typedef typename Base::template Functor::type Center_of_sphere_d; - //typedef typename Base::template Functor::type Value_at_d; - //typedef typename Base::template Functor::type Point_of_sphere_d; - typedef typename Base::template Functor::type Orthogonal_vector_d; - //typedef typename Base::template Functor::type Linear_base_d; + //typedef typename Get_functor::type Center_of_sphere_d; + //typedef typename Get_functor::type Value_at_d; + //typedef typename Get_functor::type Point_of_sphere_d; + typedef typename Get_functor::type Orthogonal_vector_d; + //typedef typename Get_functor::type Linear_base_d; //typedef ??? Intersect_d; 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 17f07dba134..31010519eb4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -16,8 +16,8 @@ struct Point_converter_help { typedef typename K2::Point 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 K2::template Functor >::type cp(k2); + typename Get_functor >::type i(k1); + typename Get_functor >::type cp(k2); return cp(conv(i(p,Begin_tag())),conv(i(p,End_tag()))); } }; @@ -30,8 +30,8 @@ struct Point_converter_help,K1,K2> { typedef typename K2::Point result_type; template result_type help(Indices, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { - typename K1::template Functor::type cc(k1); - typename K2::template Functor >::type cp(k2); + typename Get_functor::type cc(k1); + typename Get_functor >::type cp(k2); return cp(conv(cc(p,I))...); } template @@ -57,8 +57,8 @@ template struct KO_converter{ typedef typename K2::Vector 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 K2::template Functor >::type cp(k2); + typename Get_functor >::type i(k1); + typename Get_functor >::type cp(k2); return cp(conv(i(v,Begin_tag())),conv(i(v,End_tag()))); } }; @@ -68,8 +68,8 @@ template struct KO_converter{ typedef typename K2::Segment result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { - typename K1::template Functor::type f(k1); - typename K2::template Functor >::type cs(k2); + typename Get_functor::type f(k1); + typename Get_functor >::type cs(k2); return cs(conv(f(s,0)),conv(f(s,1))); } }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index ff35ea535dd..7a720f939a9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -17,7 +17,7 @@ struct Nth_iterator_element : private Store_kernel { 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()); + typename Get_functor >::type ci(this->kernel()); return *cpp0x::next(ci(CGAL_FORWARD(U,u),Begin_tag()),i); } }; @@ -28,7 +28,7 @@ struct Select_nth_element_functor { }; template struct Select_nth_element_functor : - K::template Functor::nth_element> {}; + Get_functor::nth_element> {}; namespace internal { template @@ -138,18 +138,18 @@ struct Lazy_cartesian : Dimension_base, }; //FIXME: what do we do with D here? template struct Functor { - typedef typename Approximate_kernel::template Functor::type FA; - typedef typename Exact_kernel::template Functor::type FE; + typedef typename Get_functor::type FA; + typedef typename Get_functor::type FE; typedef Filtered_predicate type; }; template struct Functor { - typedef typename Approximate_kernel::template Functor::type FA; - typedef typename Exact_kernel::template Functor::type FE; + typedef typename Get_functor::type FA; + typedef typename Get_functor::type FE; typedef Lazy_construction_nt type; }; template struct Functor { - typedef typename Approximate_kernel::template Functor::type FA; - typedef typename Exact_kernel::template Functor::type FE; + typedef typename Get_functor::type FA; + typedef typename Get_functor::type FE; typedef Lazy_construction type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h index 088b484ae8c..106286154fc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h @@ -28,8 +28,8 @@ namespace CartesianDKernelFunctors { typedef typename R_::RT RT; typedef typename R_::Point Point; typedef typename R_::Vector Vector; - typedef typename R_::template Functor >::type Cp_; - typedef typename R_::template Functor >::type Ci_; + typedef typename Get_functor >::type Cp_; + typedef typename Get_functor >::type Ci_; result_type operator()(Point const&a, Point const&b)const{ Cp_ cp(this->kernel()); Ci_ ci(this->kernel()); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h index bc1db94f166..ff7d05f51bc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h @@ -27,9 +27,9 @@ namespace CartesianDKernelFunctors { typedef typename R_::Line result_type; typedef typename R_::Point Point; typedef typename R_::Vector Vector; - typedef typename R_::template Functor::type Tp_; - //typedef typename R_::template Functor::type Dp_; - //typedef typename R_::template Functor::type Sv_; + typedef typename Get_functor::type Tp_; + //typedef typename Get_functor::type Dp_; + //typedef typename Get_functor::type Sv_; result_type operator()(Point const&a, Point const&b)const{ return result_type(a,b); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h index 5987bcacf62..99b7db0828a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h @@ -27,9 +27,9 @@ namespace CartesianDKernelFunctors { typedef typename R_::Ray result_type; typedef typename R_::Point Point; typedef typename R_::Vector Vector; - typedef typename R_::template Functor::type Dp_; - //typedef typename R_::template Functor::type Tp_; - //typedef typename R_::template Functor::type Sv_; + typedef typename Get_functor::type Dp_; + //typedef typename Get_functor::type Tp_; + //typedef typename Get_functor::type Sv_; result_type operator()(Point const&a, Vector const&b)const{ return result_type(a,b); } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h index a6aafb9ade3..8a117ac6c03 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h @@ -7,7 +7,7 @@ template class Segment { typedef typename R_::FT FT_; typedef typename R_::Point Point_; //typedef typename R_::Vector Vector_; - //typedef typename R_::template Functor >::type Cv_; + //typedef typename Get_functor >::type Cv_; // typedef typename R_::Squared_distance Csd_; typedef std::pair Data_; Data_ data; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 137995a5b30..266597ce324 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -93,8 +93,8 @@ struct Cartesian_wrap : public Base_ #include //Translate the arguments - template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { - typedef typename Kernel_base::template Functor::type B; + template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { + typedef typename Get_functor::type B; struct type { B b; type(){} @@ -123,7 +123,7 @@ struct Cartesian_wrap : public Base_ }; template struct Functor { - typedef typename Kernel_base::template Functor::type B; + typedef typename Get_functor::type B; struct type { B b; type(){} @@ -171,14 +171,14 @@ struct Cartesian_refcount : public Base_ //typedef typename map_functor_type::type f_t; typedef typename map_result_tag::type r_t; enum { - is_nul = boost::is_same::type,Null_functor>::value, + is_nul = boost::is_same::type,Null_functor>::value, ret_rcobj = boost::is_same::value || boost::is_same::value }; }; //Translate the arguments template::is_nul,bool=Dispatch::ret_rcobj> struct Functor { - typedef typename Kernel_base::template Functor::type B; + typedef typename Get_functor::type B; struct type { B b; type(){} @@ -210,7 +210,7 @@ struct Cartesian_refcount : public Base_ }; template struct Functor { - typedef typename Kernel_base::template Functor::type B; + typedef typename Get_functor::type B; struct type { B b; type(){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index ef00a9a0037..17fe1e1df9a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -24,8 +24,8 @@ class Point_d : public R_::Kernel_base::Point typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Vector Vector_; - typedef typename Kbase::template Functor >::type CPBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Get_functor >::type CPBase; + typedef typename Get_functor::type CCBase; typedef Point_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index 0ee2c23efb4..d0689a1fc0d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -25,8 +25,8 @@ template class Point_rc_d { typedef typename R_::Kernel_base Kbase; - typedef typename Kbase::template Functor >::type CPBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Get_functor >::type CPBase; + typedef typename Get_functor::type CCBase; typedef Point_rc_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 1a1861a1159..567814c64e3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -22,9 +22,9 @@ class Segment_d : public R_::Kernel_base::Segment typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Point Point_; - typedef typename Kbase::template Functor >::type CPBase; - typedef typename Kbase::template Functor >::type CSBase; - typedef typename Kbase::template Functor::type CSEBase; + typedef typename Get_functor >::type CPBase; + typedef typename Get_functor >::type CSBase; + typedef typename Get_functor::type CSEBase; typedef Segment_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h index 2d4ec021ea2..542a0bac5a2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h @@ -19,9 +19,9 @@ class Sphere_d : public R_::Kernel_base::Sphere typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Point Point_; - typedef typename Kbase::template Functor >::type CSBase; - typedef typename Kbase::template Functor::type COSBase; - typedef typename Kbase::template Functor::type SRBase; + typedef typename Get_functor >::type CSBase; + typedef typename Get_functor::type COSBase; + typedef typename Get_functor::type SRBase; typedef Sphere_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 2f9f8608ae9..931cd221df4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -22,8 +22,8 @@ class Vector_d : public R_::Kernel_base::Vector typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; typedef typename R_::Point Point_; - typedef typename Kbase::template Functor >::type CVBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Get_functor >::type CVBase; + typedef typename Get_functor::type CCBase; typedef Vector_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); @@ -114,7 +114,7 @@ public: Vector_d operator-() const { - return typename R::template Functor::type()(*this); + return typename Get_functor::type()(*this); } /* @@ -236,13 +236,13 @@ template Vector_d::Vector_d(Vector_d &)=default; template Vector_d operator+(const Vector_d& v,const Vector_d& w) { - return typename R_::template Functor::type()(v,w); + return typename Get_functor::type()(v,w); } template Vector_d operator-(const Vector_d& v,const Vector_d& w) { - return typename R_::template Functor::type()(v,w); + return typename Get_functor::type()(v,w); } } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index c9ff7db3efd..c1290fed8d4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -22,8 +22,8 @@ template class Vector_rc_d { typedef typename R_::Kernel_base Kbase; - typedef typename Kbase::template Functor >::type CVBase; - typedef typename Kbase::template Functor::type CCBase; + typedef typename Get_functor >::type CVBase; + typedef typename Get_functor::type CCBase; typedef Vector_rc_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); 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 9f74ef63bd4..06a4516d19a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -35,8 +35,8 @@ template result_type operator()(Iter f, Iter e)const{ - typename R::template Functor::type c(this->kernel()); - typename R::template Functor::type pd(this->kernel()); + typename Get_functor::type c(this->kernel()); + typename Get_functor::type pd(this->kernel()); Point const& p0=*f++; int d=pd(p0); Matrix m(d,d); @@ -69,7 +69,7 @@ template::type c(this->kernel()); \ + typename Get_functor::type c(this->kernel()); \ Matrix m(N,N); \ BOOST_PP_REPEAT(N,VAR2,N) \ return R::LA::sign_of_determinant(CGAL_MOVE(m)); \ @@ -97,7 +97,7 @@ template struct Orientation_of_points,true> }; template result_type operator()(P0 const&x,P&&...p)const{ static_assert(d==sizeof...(P),"Wrong number of arguments"); - typename R::template Functor::type c(this->kernel()); + typename Get_functor::type c(this->kernel()); return Help::type>()(c,x,std::forward_as_tuple(std::forward

(p)...)); } @@ -128,7 +128,7 @@ template struct Orientation_of_points,true> : priv typedef typename R::Point Point; \ typedef typename R::Orientation result_type; \ result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ - typename R::template Functor::type c(this->kernel()); \ + typename Get_functor::type c(this->kernel()); \ BOOST_PP_REPEAT(N,VAR4,) \ return sign_of_determinant(BOOST_PP_ENUM(N,VAR2,N)); \ } \ @@ -159,8 +159,8 @@ template struct Orientation_of_vectors : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ - typename R::template Functor::type c(this->kernel()); - typename R::template Functor::type vd(this->kernel()); + typename Get_functor::type c(this->kernel()); + typename Get_functor::type vd(this->kernel()); Vector const& v0=*f; int d=vd(v0); Matrix m(d,d); @@ -198,15 +198,15 @@ template::v typedef typename R::Vector Vector; typedef typename R::Point Point; typedef typename R::Orientation result_type; - typedef typename R::template Functor::type OP; - typedef typename R::template Functor::type OV; + typedef typename Get_functor::type OP; + typedef typename Get_functor::type OV; //FIXME!!! //when Point and Vector are distinct types, the dispatch should be made //in a way that doesn't instantiate a conversion from Point to Vector template result_type operator()(Iter const&f, Iter const& e)const{ - typename R::template Functor::type pd(this->kernel()); + typename Get_functor::type pd(this->kernel()); typename std::iterator_traits::difference_type d=std::distance(f,e); int dim=pd(*f); // BAD if(d==dim) return OV(this->kernel())(f,e); @@ -222,8 +222,8 @@ template struct Orientation : private Store_kernel { typedef typename R::Vector Vector; typedef typename R::Point Point; typedef typename R::Orientation result_type; - typedef typename R::template Functor::type OP; - typedef typename R::template Functor::type OV; + typedef typename Get_functor::type OP; + typedef typename Get_functor::type OV; typedef typename R::LA::Square_matrix Matrix; //FIXME!!! @@ -256,9 +256,9 @@ template struct Side_of_oriented_sphere : private Store_kernel { template result_type operator()(Iter f, Iter const& e)const{ - typedef typename R::template Functor::type Sqdo; - typename R::template Functor::type c(this->kernel()); - typename R::template Functor::type pd(this->kernel()); + typedef typename Get_functor::type Sqdo; + typename Get_functor::type c(this->kernel()); + typename Get_functor::type pd(this->kernel()); Point const& p0=*f++; int d=pd(p0); @@ -308,8 +308,8 @@ template struct Point_to_vector : private Store_kernel { typedef typename R_::RT RT; typedef typename R::Vector Vector; typedef typename R::Point Point; - typedef typename R::template Functor >::type CV; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CV; + typedef typename Get_functor >::type CI; typedef Vector result_type; typedef Point argument_type; result_type operator()(argument_type const&v)const{ @@ -324,8 +324,8 @@ template struct Vector_to_point : private Store_kernel { typedef typename R_::RT RT; typedef typename R::Vector Vector; typedef typename R::Point Point; - typedef typename R::template Functor >::type CV; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CV; + typedef typename Get_functor >::type CI; typedef Point result_type; typedef Vector argument_type; result_type operator()(argument_type const&v)const{ @@ -339,8 +339,8 @@ template struct Opposite_vector : private Store_kernel { typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; - typedef typename R::template Functor >::type CV; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CV; + typedef typename Get_functor >::type CI; typedef Vector result_type; typedef Vector argument_type; result_type operator()(Vector const&v)const{ @@ -354,8 +354,8 @@ template struct Scaled_vector : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R::Vector Vector; - typedef typename R::template Functor >::type CV; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CV; + typedef typename Get_functor >::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef FT second_argument_type; @@ -370,8 +370,8 @@ template struct Sum_of_vectors : private Store_kernel { typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; - typedef typename R::template Functor >::type CV; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CV; + typedef typename Get_functor >::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -386,8 +386,8 @@ template struct Difference_of_vectors : private Store_kernel { typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; - typedef typename R::template Functor >::type CV; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CV; + typedef typename Get_functor >::type CI; typedef Vector result_type; typedef Vector first_argument_type; typedef Vector second_argument_type; @@ -403,9 +403,9 @@ template struct Translated_point : private Store_kernel { typedef typename R_::RT RT; typedef typename R::Vector Vector; typedef typename R::Point Point; - typedef typename R::template Functor >::type CP; - typedef typename R::template Functor >::type CVI; - typedef typename R::template Functor >::type CPI; + typedef typename Get_functor >::type CP; + typedef typename Get_functor >::type CVI; + typedef typename Get_functor >::type CPI; typedef Point result_type; typedef Point first_argument_type; typedef Vector second_argument_type; @@ -422,8 +422,8 @@ template struct Difference_of_points : private Store_kernel { typedef typename R_::RT RT; typedef typename R::Point Point; typedef typename R::Vector Vector; - typedef typename R::template Functor >::type CV; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CV; + typedef typename Get_functor >::type CI; typedef Vector result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -439,8 +439,8 @@ template struct Midpoint : private Store_kernel { typedef typename R_::FT FT; typedef typename R_::RT RT; typedef typename R::Point Point; - typedef typename R::template Functor >::type CP; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CP; + typedef typename Get_functor >::type CI; typedef Point result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -463,7 +463,7 @@ template struct Squared_length : private Store_kernel { typedef R_ R; typedef typename R_::RT RT; typedef typename R::Vector Vector; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CI; typedef RT result_type; typedef Vector argument_type; result_type operator()(Vector const&a)const{ @@ -479,7 +479,7 @@ template struct Squared_distance_to_origin : private Store_kernel typedef R_ R; typedef typename R_::RT RT; typedef typename R::Point Point; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CI; typedef RT result_type; typedef Point argument_type; result_type operator()(Point const&a)const{ @@ -495,7 +495,7 @@ template struct Squared_distance : private Store_kernel { typedef R_ R; typedef typename R_::RT RT; typedef typename R::Point Point; - typedef typename R::template Functor >::type CI; + typedef typename Get_functor >::type CI; typedef RT result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -516,7 +516,7 @@ template struct Compare_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_distance) typedef R_ R; typedef typename R::Point Point; - typedef typename R::template Functor::type CSD; + typedef typename Get_functor::type CSD; typedef typename R_::Comparison_result result_type; typedef Point first_argument_type; typedef Point second_argument_type; @@ -536,7 +536,7 @@ template struct Less_point_cartesian_coordinate : private Store_kernel CGAL_FUNCTOR_INIT_STORE(Less_point_cartesian_coordinate) typedef R_ R; typedef typename R::Boolean result_type; - typedef typename R::template Functor::type Cc; + typedef typename Get_functor::type Cc; // 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 Is_exact; @@ -552,7 +552,7 @@ template struct Compare_point_cartesian_coordinate : private Store_ker CGAL_FUNCTOR_INIT_STORE(Compare_point_cartesian_coordinate) typedef R_ R; typedef typename R::Comparison_result result_type; - typedef typename R::template Functor::type Cc; + typedef typename Get_functor::type Cc; // 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 Is_exact; @@ -568,7 +568,7 @@ template struct Compare_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_lexicographically) typedef R_ R; typedef typename R::Comparison_result result_type; - typedef typename R::template Functor >::type CI; + typedef typename Get_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 Is_exact; @@ -597,7 +597,7 @@ template struct Less_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_lexicographically) typedef R_ R; typedef typename R::Boolean result_type; - typedef typename R::template Functor::type CL; + typedef typename Get_functor::type CL; typedef typename CGAL::Is_exact Is_exact; template @@ -611,7 +611,7 @@ template struct Less_or_equal_lexicographically : private Store_kernel CGAL_FUNCTOR_INIT_STORE(Less_or_equal_lexicographically) typedef R_ R; typedef typename R::Boolean result_type; - typedef typename R::template Functor::type CL; + typedef typename Get_functor::type CL; typedef typename CGAL::Is_exact Is_exact; template @@ -625,7 +625,7 @@ template struct Equal_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Equal_points) typedef R_ R; typedef typename R::Boolean result_type; - typedef typename R::template Functor >::type CI; + typedef typename Get_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 Is_exact; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index f5fc7fcbcbf..bc203e0c232 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -4,6 +4,14 @@ #include #include namespace CGAL { + + // Find a better place for this later + + template struct Get_type + : K::template Type {}; + template struct Get_functor + : K::template Functor {}; + class Null_type {~Null_type();}; // no such object should be created // To construct iterators From 7c17e3cc07aed6b10abc41981c03bf4a8292bc55 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 29 Dec 2012 19:44:24 +0100 Subject: [PATCH 165/210] More Get_functor. --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h | 8 ++++---- NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h | 2 +- NewKernel_d/include/CGAL/functor_tags.h | 4 ++-- NewKernel_d/test/NewKernel_d/test.cpp | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) 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 994b15f01f3..d4cdd6bd4e8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -81,7 +81,7 @@ struct Cartesian_change_FT_base : public }; template::type> struct Functor : - Kernel_base::template Functor { }; + Get_functor { }; template struct Functor { typedef Null_functor type; }; template struct Functor diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 6903843c5ff..d328de3ea21 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -28,7 +28,7 @@ template struct Cartesian_define_all_functors_ { typedef R_ Kernel_base; template struct Functor - : Kernel_base::template Functor + : Get_functor { }; #define CGAL_Kernel_cons2(F,f) \ template struct Functor { \ @@ -85,7 +85,7 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; template::type> struct Functor : - R_::template Functor {}; + Get_functor {}; template struct Functor { typedef typename Get_functor::type Base_functor; typedef typename boost::mpl::if_c::value, @@ -107,7 +107,7 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; template::type> struct Functor : - R_::template Functor {}; + Get_functor {}; template struct Functor { typedef typename Get_functor::type Base_functor; typedef typename boost::mpl::if_c::value, @@ -126,7 +126,7 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; template::type> struct Functor : - R_::template Functor {}; + Get_functor {}; template struct Functor { typedef typename Get_functor::type Base_functor; typedef typename boost::mpl::if_c::value, diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index b0828594172..34bd69ee1e2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -31,7 +31,7 @@ struct Cartesian_filter_K : public Base_, typedef KernelD_converter C2E; template::type> struct Functor : - Kernel_base::template Functor {}; + Get_functor {}; template struct Functor { typedef typename Get_functor::type AP; typedef typename Get_functor::type EP; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h index 8d4041707aa..3b7f510fe67 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -18,7 +18,7 @@ struct Cartesian_filter_NT : public Base_ typedef Cartesian_change_FT K2; template::type> struct Functor : - Kernel_base::template Functor {}; + Get_functor {}; template struct Functor { struct type { //TODO: use compression (derive from a compressed_pair?) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index bc203e0c232..133f3e0d4ef 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -9,8 +9,8 @@ namespace CGAL { template struct Get_type : K::template Type {}; - template struct Get_functor - : K::template Functor {}; + template struct Get_functor + : K::template Functor {}; class Null_type {~Null_type();}; // no such object should be created diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 568bb9a0b51..f615b7b6a41 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -82,7 +82,7 @@ void test2(){ typedef typename K1::Construct_point_d CP; typedef typename K1::Construct_vector_d CV; typedef typename K1::Construct_segment_d CS; - typedef typename K1::template Functor::type CSE; + typedef typename CGAL::Get_functor::type CSE; typedef typename K1::Construct_cartesian_const_iterator_d CCI; typedef typename K1::Orientation_d PO; typedef typename K1::Side_of_oriented_sphere_d SOS; @@ -160,7 +160,7 @@ void test3(){ typedef typename K1::Construct_point_d CP_; typedef typename K1::Construct_vector_d CV; typedef typename K1::Construct_segment_d CS; - typedef typename K1::template Functor::type CSE; + typedef typename CGAL::Get_functor::type CSE; typedef typename K1::Construct_cartesian_const_iterator_d CCI; typedef typename K1::Orientation_d PO; typedef typename K1::Side_of_oriented_sphere_d SOS; From e3ea6e50114f163baf834465121395aef45dc2ed Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 29 Dec 2012 22:17:45 +0100 Subject: [PATCH 166/210] (re-)introduce Get_type. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 4 ++ .../CGAL/Kernel_d/Cartesian_LA_functors.h | 30 +++++------ .../CGAL/Kernel_d/Cartesian_complete.h | 14 ++--- .../CGAL/Kernel_d/Cartesian_static_filters.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 8 +-- .../include/CGAL/Kernel_d/Define_segment.h | 12 +++-- .../CGAL/Kernel_d/Kernel_2_interface.h | 4 +- .../CGAL/Kernel_d/Kernel_3_interface.h | 10 ++-- .../CGAL/Kernel_d/Kernel_d_interface.h | 20 +++---- .../CGAL/Kernel_d/Kernel_object_converter.h | 16 +++--- .../include/CGAL/Kernel_d/Types/Hyperplane.h | 16 +++--- .../include/CGAL/Kernel_d/Types/Iso_box.h | 8 +-- .../include/CGAL/Kernel_d/Types/Line.h | 8 +-- NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h | 10 ++-- .../include/CGAL/Kernel_d/Types/Segmentd.h | 2 +- .../include/CGAL/Kernel_d/Types/Sphere.h | 12 ++--- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 4 ++ .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 14 ++--- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 4 +- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 14 ++--- .../include/CGAL/Kernel_d/Wrapper/Sphere_d.h | 14 ++--- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 8 +-- .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 4 +- .../Kernel_d/function_objects_cartesian.h | 52 +++++++++---------- NewKernel_d/include/CGAL/functor_tags.h | 4 ++ 25 files changed, 153 insertions(+), 141 deletions(-) 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 14661576c8c..192a3024b5b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -61,6 +61,10 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typename LA_vector::Vector_const_iterator Point_cartesian_const_iterator; typedef typename LA_vector::Vector_const_iterator Vector_cartesian_const_iterator; + template struct Type {}; + template struct Type< Point_tag, D> { typedef Vector_ type; }; + template struct Type { typedef Vector_ type; }; + typedef typeset ::add::type Object_list; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index eb05c1baf39..0f26ab701fb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -184,9 +184,9 @@ template struct Construct_cartesian_const_iterator { template struct Midpoint { CGAL_FUNCTOR_INIT_IGNORE(Midpoint) typedef R_ R; - typedef typename R::Point first_argument_type; - typedef typename R::Point second_argument_type; - typedef typename R::Point result_type; + typedef typename Get_type::type first_argument_type; + typedef typename Get_type::type second_argument_type; + typedef typename Get_type::type result_type; result_type operator()(result_type const& a, result_type const& b)const{ return (a+b)/2; @@ -196,9 +196,9 @@ template struct Midpoint { template struct Sum_of_vectors { CGAL_FUNCTOR_INIT_IGNORE(Sum_of_vectors) typedef R_ R; - typedef typename R::Vector first_argument_type; - typedef typename R::Vector second_argument_type; - typedef typename R::Vector result_type; + typedef typename Get_type::type first_argument_type; + typedef typename Get_type::type second_argument_type; + typedef typename Get_type::type result_type; result_type operator()(result_type const& a, result_type const& b)const{ return a+b; @@ -208,9 +208,9 @@ template struct Sum_of_vectors { template struct Difference_of_vectors { CGAL_FUNCTOR_INIT_IGNORE(Difference_of_vectors) typedef R_ R; - typedef typename R::Vector first_argument_type; - typedef typename R::Vector second_argument_type; - typedef typename R::Vector result_type; + typedef typename Get_type::type first_argument_type; + typedef typename Get_type::type second_argument_type; + typedef typename Get_type::type result_type; result_type operator()(result_type const& a, result_type const& b)const{ return a-b; @@ -220,8 +220,8 @@ template struct Difference_of_vectors { template struct Opposite_vector { CGAL_FUNCTOR_INIT_IGNORE(Opposite_vector) typedef R_ R; - typedef typename R::Vector result_type; - typedef typename R::Vector argument_type; + typedef typename Get_type::type result_type; + typedef typename Get_type::type argument_type; result_type operator()(result_type const& v)const{ return -v; @@ -233,8 +233,8 @@ template struct Scalar_product { typedef R_ R; typedef typename R::LA_vector LA; typedef typename R::RT result_type; - typedef typename R::Vector first_argument_type; - typedef typename R::Vector second_argument_type; + typedef typename Get_type::type first_argument_type; + typedef typename Get_type::type second_argument_type; result_type operator()(first_argument_type const& a, second_argument_type const& b)const{ return LA::dot_product(a,b); @@ -246,7 +246,7 @@ template struct Squared_distance_to_origin_stored { typedef R_ R; typedef typename R::LA_vector LA; typedef typename R::RT result_type; - typedef typename R::Point argument_type; + typedef typename Get_type::type argument_type; result_type operator()(argument_type const& a)const{ return LA::squared_norm(a); @@ -258,7 +258,7 @@ template struct Squared_distance_to_origin_via_dotprod { typedef R_ R; typedef typename R::LA_vector LA; typedef typename R::RT result_type; - typedef typename R::Point argument_type; + typedef typename Get_type::type argument_type; result_type operator()(argument_type const& a)const{ return LA::dot_product(a,a); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index d328de3ea21..c78c3ecb902 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -57,21 +57,17 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; -#if 0 template struct Type : Read_tag_type {}; #define CGAL_Kernel_obj2(X,Y) \ template struct Type { \ static const bool inbase = \ Provides_tag_type::value; \ - typedef typename Read_tag_type B_; \ - typedef typename boost::mpl::if_c >,B_>::type::type type; \ - }; - //FIXME: move away from Type<> - //Implement by chaining things like Define_segment? -#endif - //FIXME: needs to be conditional!!! -#define CGAL_Kernel_obj2(X,Y) \ + typedef Get_type B_; \ + typedef typename boost::mpl::if_c >,B_>::type::type type; \ + }; \ typedef CGAL::X X; + //Implement by chaining things like Define_segment? + //FIXME: needs to be conditional!!! #include }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 87c1e31556b..77e34eb4c04 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -11,7 +11,7 @@ namespace SFA { // static filter adapter // Note that this would be quite a bit simpler without stateful kernels template struct Orientation_of_points_2 : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); - typedef typename R_::Point Point; + typedef typename Get_type::type Point; typedef typename R_::Orientation result_type; typedef typename R_::FT FT; typedef typename Get_functor::type CC; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 07e2a814d86..6cfe8b7c423 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -44,7 +44,7 @@ template struct Construct_flat_orientation : private Store_kernel CGAL_FUNCTOR_INIT_STORE(Construct_flat_orientation) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename Increment_dimension::type Dplusone; typedef typename R::LA::template Rebind_dimension::Other LA; typedef typename LA::Square_matrix Matrix; @@ -97,7 +97,7 @@ template struct Contained_in_affine_hull : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Contained_in_affine_hull) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename R::Boolean result_type; typedef typename Get_functor::type CCC; typedef typename Get_functor::type PD; @@ -156,7 +156,7 @@ template struct In_flat_orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(In_flat_orientation) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename R::Orientation result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; @@ -194,7 +194,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel CGAL_FUNCTOR_INIT_STORE(In_flat_side_of_oriented_sphere) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename R::Orientation result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 620aa1abab6..d71e51f4d4f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -11,8 +11,8 @@ namespace CartesianDKernelFunctors { template struct Construct_segment { CGAL_FUNCTOR_INIT_IGNORE(Construct_segment) typedef R_ R; - typedef typename R_::Point Point; - typedef typename R_::Segment Segment; + typedef typename Get_type::type Point; + typedef typename Get_type::type Segment; typedef typename Get_functor >::type CP; typedef Segment result_type; result_type operator()(Point const&a, Point const&b)const{ @@ -33,8 +33,8 @@ template struct Construct_segment { template struct Segment_extremity { CGAL_FUNCTOR_INIT_IGNORE(Segment_extremity) typedef R_ R; - typedef typename R_::Point Point; - typedef typename R_::Segment Segment; + typedef typename Get_type::type Point; + typedef typename Get_type::type Segment; typedef Point result_type; result_type operator()(Segment const&s, int i)const{ if(i==0) return s.source(); @@ -59,6 +59,10 @@ struct Define_segment : public Base_ { typedef CGAL::Segment Segment; typedef typename Base::Object_list::template add::type Object_list; + template struct Type : Get_type {}; + template struct Type { + typedef CGAL::Segment type; + }; // TODO: forward the second Functor argument (like fast, no_filter) template struct Functor : Get_functor {}; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h index f675f190792..2f2251fd16c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -11,8 +11,8 @@ namespace CGAL { template struct Kernel_2_interface : public Base_ { typedef Base_ Base; typedef Kernel_2_interface Kernel; - typedef typename Base::Point Point_2; - typedef typename Base::Vector Vector_2; + typedef typename Get_type::type Point_2; + typedef typename Get_type::type Vector_2; struct Segment_2 {}; typedef cpp0x::tuple Triangle_2; // triangulation insists... template struct Help_2p_i { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h index 00ce6323592..d8bd7db3ce8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h @@ -11,11 +11,11 @@ namespace CGAL { template struct Kernel_3_interface : public Base_ { typedef Base_ Base; typedef Kernel_3_interface Kernel; - typedef typename Base::Point Point_3; - typedef typename Base::Vector Vector_3; - typedef typename Base::Segment Segment_3; - typedef cpp0x::tuple Triangle_3; // placeholder - typedef cpp0x::tuple Tetrahedron_3; // placeholder + typedef typename Get_type::type Point_3; + typedef typename Get_type::type Vector_3; + typedef typename Get_type::type Segment_3; + typedef cpp0x::tuple Triangle_3; // placeholder + typedef cpp0x::tuple Tetrahedron_3; // placeholder struct Compare_xyz_3 { typedef typename Get_functor::type CL; typedef typename CL::result_type result_type; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 9e3b4f1bcca..ddad6f1cfe1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -16,16 +16,16 @@ template struct Kernel_d_interface : public Base_ { typedef Kernel_d_interface Kernel; typedef Base_ R_; // for the macros typedef typename Base::Flat_orientation Flat_orientation_d; - typedef typename Base::Point Point_d; - typedef typename Base::Vector Vector_d; - typedef typename Base::Segment Segment_d; - typedef typename Base::Sphere Sphere_d; - typedef typename Base::Hyperplane Hyperplane_d; + typedef typename Get_type::type Point_d; + typedef typename Get_type::type Vector_d; + typedef typename Get_type::type Segment_d; + typedef typename Get_type::type Sphere_d; + typedef typename Get_type::type Hyperplane_d; typedef Vector_d Direction_d; - typedef typename Base::Line Line_d; - typedef typename Base::Ray Ray_d; - typedef typename Base::Iso_box Iso_box_d; - typedef typename Base::Aff_transformation Aff_transformation_d; + typedef typename Get_type::type Line_d; + typedef typename Get_type::type Ray_d; + typedef typename Get_type::type Iso_box_d; + typedef typename Get_type::type Aff_transformation_d; typedef typename Get_functor::type Compute_coordinate_d; typedef typename Get_functor::type Compare_lexicographically_d; typedef typename Get_functor::type Equal_d; @@ -55,7 +55,7 @@ template struct Kernel_d_interface : public Base_ { typedef typename Get_functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) - typedef typename Base::Point Point; + typedef typename Get_type::type Point; typedef typename Base::RT RT; typedef typename Base::FT FT; int dimension(Point const&p){ 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 31010519eb4..ba233fea139 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_object_converter.h @@ -12,8 +12,8 @@ template struct KO_converter; namespace internal { template struct Point_converter_help { - typedef typename K1::Point argument_type; - typedef typename K2::Point result_type; + typedef typename Get_type::type argument_type; + typedef typename Get_type::type result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { typename Get_functor >::type i(k1); @@ -26,8 +26,8 @@ struct Point_converter_help { // the iterators just as efficiently. template struct Point_converter_help,K1,K2> { - typedef typename K1::Point argument_type; - typedef typename K2::Point result_type; + typedef typename Get_type::type argument_type; + typedef typename Get_type::type result_type; template result_type help(Indices, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { typename Get_functor::type cc(k1); @@ -46,7 +46,7 @@ template struct KO_converter {}; template struct KO_converter{ - typedef typename K1::Vector K1_Vector; + typedef typename Get_type::type K1_Vector; // Disabling is now done in KernelD_converter // // can't use vector without at least a placeholder point because of this @@ -54,7 +54,7 @@ template struct KO_converter{ // typedef typename First_if_different::Type argument_type; typedef K1_Vector argument_type; - typedef typename K2::Vector result_type; + typedef typename Get_type::type result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& v) const { typename Get_functor >::type i(k1); @@ -64,8 +64,8 @@ template struct KO_converter{ }; template struct KO_converter{ - typedef typename K1::Segment argument_type; - typedef typename K2::Segment result_type; + typedef typename Get_type::type argument_type; + typedef typename Get_type::type result_type; template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { typename Get_functor::type f(k1); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h index 1ffb881d49d..464432f07b6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h @@ -4,8 +4,8 @@ namespace CGAL { template class Hyperplane { typedef typename R_::FT FT_; - typedef typename R_::Point Point_; - typedef typename R_::Vector Vector_; + typedef typename Get_type::type Point_; + typedef typename Get_type::type Vector_; Vector_ v_; FT_ s_; @@ -19,9 +19,9 @@ template class Hyperplane { namespace CartesianDKernelFunctors { template struct Construct_hyperplane : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_hyperplane) - typedef typename R_::Hyperplane result_type; - typedef typename R_::Point Point; - typedef typename R_::Vector Vector; + typedef typename Get_type::type result_type; + typedef typename Get_type::type Point; + typedef typename Get_type::type Vector; typedef typename R_::FT FT; typedef typename R_::LA LA; result_type operator()(Vector const&a, FT const&b)const{ @@ -34,15 +34,15 @@ template struct Construct_hyperplane : Store_kernel { }; template struct Orthogonal_vector { CGAL_FUNCTOR_INIT_IGNORE(Orthogonal_vector) - typedef typename R_::Hyperplane Hyperplane; - typedef typename R_::Point result_type; + typedef typename Get_type::type Hyperplane; + typedef typename Get_type::type result_type; result_type operator()(Hyperplane const&s)const{ return s.orthogonal_vector(); } }; template struct Hyperplane_translation { CGAL_FUNCTOR_INIT_IGNORE(Hyperplane_translation) - typedef typename R_::Hyperplane Hyperplane; + typedef typename Get_type::type Hyperplane; typedef typename R_::FT result_type; // TODO: Is_exact? result_type operator()(Hyperplane const&s)const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h index 106286154fc..3cf982f1281 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h @@ -8,7 +8,7 @@ namespace CGAL { template class Iso_box { typedef typename R_::FT FT_; - typedef typename R_::Point Point_; + typedef typename Get_type::type Point_; typedef std::pair Data_; Data_ data; public: @@ -24,10 +24,10 @@ template class Iso_box { namespace CartesianDKernelFunctors { template struct Construct_iso_box : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_iso_box) - typedef typename R_::Iso_box result_type; + typedef typename Get_type::type result_type; typedef typename R_::RT RT; - typedef typename R_::Point Point; - typedef typename R_::Vector Vector; + typedef typename Get_type::type Point; + typedef typename Get_type::type Vector; typedef typename Get_functor >::type Cp_; typedef typename Get_functor >::type Ci_; result_type operator()(Point const&a, Point const&b)const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h index ff7d05f51bc..3c84429d7ed 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h @@ -6,7 +6,7 @@ namespace CGAL { template class Line { typedef typename R_::FT FT_; - typedef typename R_::Point Point_; + typedef typename Get_type::type Point_; typedef std::pair Data_; Data_ data; public: @@ -24,9 +24,9 @@ template class Line { namespace CartesianDKernelFunctors { template struct Construct_line : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_line) - typedef typename R_::Line result_type; - typedef typename R_::Point Point; - typedef typename R_::Vector Vector; + typedef typename Get_type::type result_type; + typedef typename Get_type::type Point; + typedef typename Get_type::type Vector; typedef typename Get_functor::type Tp_; //typedef typename Get_functor::type Dp_; //typedef typename Get_functor::type Sv_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h index 99b7db0828a..591c4641fa5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h @@ -6,8 +6,8 @@ namespace CGAL { template class Ray { typedef typename R_::FT FT_; - typedef typename R_::Point Point_; - typedef typename R_::Vector Vector_; + typedef typename Get_type::type Point_; + typedef typename Get_type::type Vector_; typedef std::pair Data_; Data_ data; public: @@ -24,9 +24,9 @@ template class Ray { namespace CartesianDKernelFunctors { template struct Construct_ray : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_ray) - typedef typename R_::Ray result_type; - typedef typename R_::Point Point; - typedef typename R_::Vector Vector; + typedef typename Get_type::type result_type; + typedef typename Get_type::type Point; + typedef typename Get_type::type Vector; typedef typename Get_functor::type Dp_; //typedef typename Get_functor::type Tp_; //typedef typename Get_functor::type Sv_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h index 8a117ac6c03..b8ae5b29253 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h @@ -5,7 +5,7 @@ namespace CGAL { template class Segment { typedef typename R_::FT FT_; - typedef typename R_::Point Point_; + typedef typename Get_type::type Point_; //typedef typename R_::Vector Vector_; //typedef typename Get_functor >::type Cv_; // typedef typename R_::Squared_distance Csd_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h index db64fe42dc1..a5e20cf568c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h @@ -4,7 +4,7 @@ namespace CGAL { template class Sphere { typedef typename R_::FT FT_; - typedef typename R_::Point Point_; + typedef typename Get_type::type Point_; Point_ c_; FT_ r2_; @@ -18,8 +18,8 @@ template class Sphere { namespace CartesianDKernelFunctors { template struct Construct_sphere : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_sphere) - typedef typename R_::Sphere result_type; - typedef typename R_::Point Point; + typedef typename Get_type::type result_type; + typedef typename Get_type::type Point; typedef typename R_::FT FT; typedef typename R_::LA LA; result_type operator()(Point const&a, FT const&b)const{ @@ -32,15 +32,15 @@ template struct Construct_sphere : Store_kernel { }; template struct Center_of_sphere { CGAL_FUNCTOR_INIT_IGNORE(Center_of_sphere) - typedef typename R_::Sphere Sphere; - typedef typename R_::Point result_type; + typedef typename Get_type::type Sphere; + typedef typename Get_type::type result_type; result_type operator()(Sphere const&s)const{ return s.center(); } }; template struct Squared_radius { CGAL_FUNCTOR_INIT_IGNORE(Squared_radius) - typedef typename R_::Sphere Sphere; + typedef typename Get_type::type Sphere; typedef typename R_::FT result_type; // TODO: Is_exact? result_type operator()(Sphere const&s)const{ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 266597ce324..a54125a9845 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -84,7 +84,9 @@ struct Cartesian_wrap : public Base_ typedef Cartesian_wrap Self; typedef typename Default::Get::type Derived; + template struct Type : Get_type {}; #define CGAL_Kernel_obj(X,Y) \ + template struct Type { typedef X##_d type; }; \ typedef X##_d X; #define CGAL_Kernel_obj3(X,Y) @@ -160,7 +162,9 @@ struct Cartesian_refcount : public Base_ //FIXME: Use object_list (or a list passed as argument) //TODO: A generic object wrapper should work just fine, no need to have a different one for each type. + template struct Type : Get_type {}; #define CGAL_Kernel_obj(X,Y) \ + template struct Type { typedef X##_rc_d type; }; \ typedef X##_rc_d X; CGAL_Kernel_obj(Point,point) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 17fe1e1df9a..8d832bc92ad 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -16,19 +16,19 @@ namespace CGAL { template -class Point_d : public R_::Kernel_base::Point +class Point_d : public Get_type::type // Deriving won't work if the point is just a __m256d. // Test boost/std::is_class for instance { - typedef typename R_::RT RT_; - typedef typename R_::FT FT_; - typedef typename R_::Kernel_base Kbase; - typedef typename R_::Vector Vector_; + typedef typename R_::RT RT_; + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type::type Vector_; typedef typename Get_functor >::type CPBase; typedef typename Get_functor::type CCBase; typedef Point_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: @@ -37,7 +37,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Point Rep; + typedef typename Get_type::type Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h index d0689a1fc0d..7a07ad0a036 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h @@ -29,7 +29,7 @@ class Point_rc_d typedef typename Get_functor::type CCBase; typedef Point_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: typedef R_ R; @@ -39,7 +39,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Point Rep; + typedef typename Get_type::type Rep; typedef Handle_for Data; private: diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 567814c64e3..10dc1d5829c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -16,18 +16,18 @@ namespace CGAL { template -class Segment_d : public R_::Kernel_base::Segment +class Segment_d : public Get_type::type { - typedef typename R_::RT RT_; - typedef typename R_::FT FT_; - typedef typename R_::Kernel_base Kbase; - typedef typename R_::Point Point_; + typedef typename R_::RT RT_; + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type::type Point_; typedef typename Get_functor >::type CPBase; typedef typename Get_functor >::type CSBase; typedef typename Get_functor::type CSEBase; typedef Segment_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: @@ -35,7 +35,7 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<1> Feature_dimension; - typedef typename Kbase::Segment Rep; + typedef typename Get_type::type Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h index 542a0bac5a2..b8f8be38534 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h @@ -16,12 +16,12 @@ namespace CGAL { template class Sphere_d : public R_::Kernel_base::Sphere { - typedef typename R_::FT FT_; - typedef typename R_::Kernel_base Kbase; - typedef typename R_::Point Point_; - typedef typename Get_functor >::type CSBase; - typedef typename Get_functor::type COSBase; - typedef typename Get_functor::type SRBase; + typedef typename R_::FT FT_; + typedef typename R_::Kernel_base Kbase; + typedef typename Get_type::type Point_; + typedef typename Get_functor >::type CSBase; + typedef typename Get_functor::type COSBase; + typedef typename Get_functor::type SRBase; typedef Sphere_d Self; BOOST_STATIC_ASSERT((boost::is_same::value)); @@ -32,7 +32,7 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef typename Increment_dimension::type Feature_dimension; - typedef typename Kbase::Sphere Rep; + typedef typename Get_type::type Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 931cd221df4..63f363aa7af 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -16,17 +16,17 @@ namespace CGAL { template -class Vector_d : public R_::Kernel_base::Vector +class Vector_d : public Get_type::type { typedef typename R_::RT RT_; typedef typename R_::FT FT_; typedef typename R_::Kernel_base Kbase; - typedef typename R_::Point Point_; + typedef typename Get_type::type Point_; typedef typename Get_functor >::type CVBase; typedef typename Get_functor::type CCBase; typedef Vector_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: @@ -35,7 +35,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Vector_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Vector Rep; + typedef typename Get_type::type Rep; const Rep& rep() const { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h index c1290fed8d4..1f044fd937f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h @@ -26,7 +26,7 @@ class Vector_rc_d typedef typename Get_functor::type CCBase; typedef Vector_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: typedef R_ R; @@ -36,7 +36,7 @@ public: typedef Dimension_tag<0> Feature_dimension; typedef typename R_::Vector_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Kbase::Vector Rep; + typedef typename Get_type::type Rep; typedef Handle_for Data; private: 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 06a4516d19a..21a46c1c2a0 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -29,7 +29,7 @@ template struct Dimension_at_most,b> { template::value> struct Orientation_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename R::Orientation result_type; typedef typename R::LA::Square_matrix Matrix; @@ -87,7 +87,7 @@ BOOST_PP_REPEAT_FROM_TO(7, 10, CODE, _ ) template struct Orientation_of_points,true> : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename R::Orientation result_type; templatestruct Help; templatestruct Help > { @@ -125,7 +125,7 @@ template struct Orientation_of_points,true> : priv CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) \ typedef R_ R; \ typedef typename R_::RT RT; \ - typedef typename R::Point Point; \ + typedef typename Get_type::type Point; \ typedef typename R::Orientation result_type; \ result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ typename Get_functor::type c(this->kernel()); \ @@ -153,7 +153,7 @@ template struct Orientation_of_points,true> : priv template struct Orientation_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) typedef R_ R; - typedef typename R::Vector Vector; + typedef typename Get_type::type Vector; typedef typename R::Orientation result_type; typedef typename R::LA::Square_matrix Matrix; @@ -195,8 +195,8 @@ template struct Orientation_of_vectors : private Store_kernel { template::value> struct Orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation) typedef R_ R; - typedef typename R::Vector Vector; - typedef typename R::Point Point; + typedef typename Get_type::type Vector; + typedef typename Get_type::type Point; typedef typename R::Orientation result_type; typedef typename Get_functor::type OP; typedef typename Get_functor::type OV; @@ -219,8 +219,8 @@ template::v template struct Orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation) typedef R_ R; - typedef typename R::Vector Vector; - typedef typename R::Point Point; + typedef typename Get_type::type Vector; + typedef typename Get_type::type Point; typedef typename R::Orientation result_type; typedef typename Get_functor::type OP; typedef typename Get_functor::type OV; @@ -247,7 +247,7 @@ template struct Side_of_oriented_sphere : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename R::Oriented_side result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; @@ -306,8 +306,8 @@ template struct Point_to_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Point_to_vector) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Vector Vector; - typedef typename R::Point Point; + typedef typename Get_type::type Vector; + typedef typename Get_type::type Point; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; typedef Vector result_type; @@ -322,8 +322,8 @@ template struct Vector_to_point : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Vector_to_point) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Vector Vector; - typedef typename R::Point Point; + typedef typename Get_type::type Vector; + typedef typename Get_type::type Point; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; typedef Point result_type; @@ -338,7 +338,7 @@ template struct Opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Opposite_vector) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Vector Vector; + typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; typedef Vector result_type; @@ -353,7 +353,7 @@ template struct Scaled_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Scaled_vector) typedef R_ R; typedef typename R_::FT FT; - typedef typename R::Vector Vector; + typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; typedef Vector result_type; @@ -369,7 +369,7 @@ template struct Sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Vector Vector; + typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; typedef Vector result_type; @@ -385,7 +385,7 @@ template struct Difference_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_vectors) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Vector Vector; + typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; typedef Vector result_type; @@ -401,8 +401,8 @@ template struct Translated_point : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Translated_point) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Vector Vector; - typedef typename R::Point Point; + typedef typename Get_type::type Vector; + typedef typename Get_type::type Point; typedef typename Get_functor >::type CP; typedef typename Get_functor >::type CVI; typedef typename Get_functor >::type CPI; @@ -420,8 +420,8 @@ template struct Difference_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_points) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Point Point; - typedef typename R::Vector Vector; + typedef typename Get_type::type Point; + typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; typedef Vector result_type; @@ -438,7 +438,7 @@ template struct Midpoint : private Store_kernel { typedef R_ R; typedef typename R_::FT FT; typedef typename R_::RT RT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename Get_functor >::type CP; typedef typename Get_functor >::type CI; typedef Point result_type; @@ -462,7 +462,7 @@ template struct Squared_length : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_length) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Vector Vector; + typedef typename Get_type::type Vector; typedef typename Get_functor >::type CI; typedef RT result_type; typedef Vector argument_type; @@ -478,7 +478,7 @@ template struct Squared_distance_to_origin : private Store_kernel CGAL_FUNCTOR_INIT_STORE(Squared_distance_to_origin) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename Get_functor >::type CI; typedef RT result_type; typedef Point argument_type; @@ -494,7 +494,7 @@ template struct Squared_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_distance) typedef R_ R; typedef typename R_::RT RT; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename Get_functor >::type CI; typedef RT result_type; typedef Point first_argument_type; @@ -515,7 +515,7 @@ template struct Squared_distance : private Store_kernel { template struct Compare_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_distance) typedef R_ R; - typedef typename R::Point Point; + typedef typename Get_type::type Point; typedef typename Get_functor::type CSD; typedef typename R_::Comparison_result result_type; typedef Point first_argument_type; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 133f3e0d4ef..459f4fbf520 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -7,8 +7,12 @@ namespace CGAL { // Find a better place for this later +#if 1 template struct Get_type : K::template Type {}; +#else +#define Get_type Read_tag_type +#endif template struct Get_functor : K::template Functor {}; From 74e9067fbddce2dc716799747ef86b94525e150b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 30 Dec 2012 22:04:19 +0100 Subject: [PATCH 167/210] More Get_type. --- .../CGAL/Kernel_d/Cartesian_change_FT.h | 4 +- .../CGAL/Kernel_d/Cartesian_complete.h | 4 +- .../include/CGAL/Kernel_d/KernelD_converter.h | 6 +-- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 8 +-- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 4 +- NewKernel_d/include/CGAL/functor_tags.h | 51 ++++++++++++------- 6 files changed, 45 insertions(+), 32 deletions(-) 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 d4cdd6bd4e8..f906581e2eb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -42,9 +42,9 @@ struct Cartesian_change_FT_base : public //FIXME: use Iterator_list! /* template::value_tag,FT_tag>::value> - struct Iterator : Read_tag_type {}; + struct Iterator : Get_type {}; template struct Iterator { - typedef transforming_iterator::type> type; + typedef transforming_iterator::type> type; }; */ diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index c78c3ecb902..4cefee0dfe8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -57,11 +57,11 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; - template struct Type : Read_tag_type {}; + template struct Type : Get_type {}; #define CGAL_Kernel_obj2(X,Y) \ template struct Type { \ static const bool inbase = \ - Provides_tag_type::value; \ + Provides_type::value; \ typedef Get_type B_; \ typedef typename boost::mpl::if_c >,B_>::type::type type; \ }; \ diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index 0854b770ecc..f53eaed3998 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -19,7 +19,7 @@ namespace internal { // Reverses order, but that shouldn't matter. template struct Map_taglist_to_typelist : Map_taglist_to_typelist::type - ::template add::type> + ::template add::type> {}; template struct Map_taglist_to_typelist > : typeset<> {}; } @@ -55,8 +55,8 @@ class KernelD_converter_ typedef typename List::head Tag; typedef typename List::tail Rest; typedef KernelD_converter_ Base; - typedef typename Read_tag_type::type K1_Obj; - typedef typename Read_tag_type::type K2_Obj; + typedef typename Get_type::type K1_Obj; + typedef typename Get_type::type K2_Obj; typedef typename Get_functor >::type K1_Conv; typedef KO_converter KOC; typedef BOOSTD is_same no_converter; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 7a720f939a9..913a5dd5c20 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -15,7 +15,7 @@ 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; + typedef typename Get_type::value_tag>::type result_type; template result_type operator()(CGAL_FORWARDABLE(U) u, int i) const { typename Get_functor >::type ci(this->kernel()); return *cpp0x::next(ci(CGAL_FORWARD(U,u),Begin_tag()),i); @@ -56,8 +56,8 @@ struct Lazy_cartesian_types template struct Type { typedef Lazy< - typename Read_tag_type::type, - typename Read_tag_type::type, + typename Get_type::type, + typename Get_type::type, typename EK_::FT, E2A_> type; }; template struct Type { @@ -172,7 +172,7 @@ struct Lazy_cartesian : Dimension_base, } }; template struct Functor { - typedef Construct_iter::type>::type> type; + typedef Construct_iter::type>::type> type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index a54125a9845..e0ff344805f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -132,7 +132,7 @@ struct Cartesian_wrap : public Base_ type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; // FIXME: Self or Derived? - typedef typename Read_tag_type::type result_type; + typedef typename Get_type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); @@ -220,7 +220,7 @@ struct Cartesian_refcount : public Base_ type(){} type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; - typedef typename Read_tag_type::type result_type; + typedef typename Get_type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 459f4fbf520..c884288c5f6 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -3,20 +3,18 @@ #include // for Null_tag #include #include +#include +#include namespace CGAL { // Find a better place for this later -#if 1 template struct Get_type : K::template Type {}; -#else -#define Get_type Read_tag_type -#endif template struct Get_functor : K::template Functor {}; - class Null_type {~Null_type();}; // no such object should be created + class Null_type {~Null_type();}; // no such object should be created // To construct iterators struct Begin_tag {}; @@ -36,18 +34,32 @@ namespace CGAL { template struct map_functor_type { typedef Misc_tag type; }; template struct Typedef_tag_type; - template struct Read_tag_type {}; - template struct Provides_tag_type; + //template struct Read_tag_type {}; + + template, + bool = internal::has_type::value /* false */> + struct Provides_type : boost::false_type {}; + template + struct Provides_type + : boost::mpl::not_ > {}; + + template, + bool = internal::has_type::value /* false */> + struct Provides_functor : boost::false_type {}; + template + struct Provides_functor + : boost::mpl::not_ > {}; #define DECL_OBJ(X) struct X##_tag {}; \ template \ - struct Typedef_tag_type : Base { typedef Obj X; }; \ - namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } \ - template \ - struct Provides_tag_type : has_object::has_##X {}; \ - template \ - struct Read_tag_type { typedef typename Kernel::X type; } + struct Typedef_tag_type : Base { typedef Obj X; }; + + //namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } + //template + //struct Provides_tag_type : has_object::has_##X {}; + //template + //struct Read_tag_type { typedef typename Kernel::X type; } // Not exactly objects, but the extras can't hurt. DECL_OBJ(FT); @@ -96,12 +108,13 @@ namespace CGAL { typedef C##_tag container; \ }; \ template \ - struct Typedef_tag_type : Base { typedef Obj X; }; \ - namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } \ - template \ - struct Provides_tag_type : has_object::has_##X {}; \ - template \ - struct Read_tag_type { typedef typename Kernel::X type; } + struct Typedef_tag_type : Base { typedef Obj X; }; + + //namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } + //template + //struct Provides_tag_type : has_object::has_##X {}; + //template + //struct Read_tag_type { typedef typename Kernel::X type; } DECL_ITER_OBJ(Vector_cartesian_const_iterator, FT, Compute_vector_cartesian_coordinate, Vector); DECL_ITER_OBJ(Point_cartesian_const_iterator, FT, Compute_point_cartesian_coordinate, Point); From 7b2752ae32732c9ab2c399d1e4b259263f060c6b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 30 Dec 2012 23:11:48 +0100 Subject: [PATCH 168/210] Minor Get_type-related fixes (previous change was a bit too automatic). --- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 6 +++--- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h | 2 +- NewKernel_d/test/NewKernel_d/test.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 913a5dd5c20..795388f3e0d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -86,7 +86,7 @@ struct Lazy_cartesian_types template struct Lazy_cartesian : Dimension_base, - Define_kernel_types > > + Lazy_cartesian_types > { //CGAL_CONSTEXPR Lazy_cartesian(){} //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} @@ -100,7 +100,7 @@ struct Lazy_cartesian : Dimension_base, EK_ const& exact_kernel()const{return ek;} typedef Lazy_cartesian Self; - typedef Define_kernel_types > Base; + typedef Lazy_cartesian_types Base; //typedef typename Default::Get::type Kernel; typedef Self Kernel; typedef AK_ Approximate_kernel; @@ -172,7 +172,7 @@ struct Lazy_cartesian : Dimension_base, } }; template struct Functor { - typedef Construct_iter::type>::type> type; + typedef Construct_iter::type>::type> type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 8d832bc92ad..8c92c77f2f8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -36,7 +36,7 @@ public: typedef typename R_::Default_ambient_dimension Ambient_dimension; typedef Dimension_tag<0> Feature_dimension; - typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; + //typedef typename R_::Point_cartesian_const_iterator Cartesian_const_iterator; typedef typename Get_type::type Rep; const Rep& rep() const diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 63f363aa7af..845575baf8a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -34,7 +34,7 @@ public: 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 R_::Vector_cartesian_const_iterator Cartesian_const_iterator; typedef typename Get_type::type Rep; const Rep& rep() const diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index f615b7b6a41..072238147c9 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -48,7 +48,7 @@ typedef CGAL::Define_segment K0; typedef K0 K2; #elif 0 typedef CGAL::Cartesian_filter_NT K2; -#elif 1 +#elif 0 typedef CGAL::Cartesian_filter_K K2; #elif 1 typedef CGAL::Lazy_cartesian > K2; From 023eaa2270cd2cbc44fd7dd6d29073aff03205ce Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 31 Dec 2012 16:20:32 +0100 Subject: [PATCH 169/210] Some meta-programming helpers around Get_type/Get_functor, so the list of functors in interface_macros.h can disappear. --- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 1 + .../Kernel_d/function_objects_cartesian.h | 4 ++ .../include/CGAL/Kernel_d/interface_macros.h | 8 +-- NewKernel_d/include/CGAL/functor_tags.h | 60 ++++++++++++++----- NewKernel_d/include/CGAL/marcutils.h | 39 ++++++++++++ 5 files changed, 94 insertions(+), 18 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 6cfe8b7c423..72bfc7128ba 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -239,5 +239,6 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel } +CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,CartesianDKernelFunctors::In_flat_orientation,(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); } #endif 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 21a46c1c2a0..c59dba6f279 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -621,6 +621,10 @@ template struct Less_or_equal_lexicographically : private Store_kernel } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Less_or_equal_lexicographically_tag,CartesianDKernelFunctors::Less_or_equal_lexicographically,(),(Compare_lexicographically_tag)); +namespace CartesianDKernelFunctors { + template struct Equal_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Equal_points) typedef R_ R; diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 9c1b1668003..daa95585852 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -109,12 +109,12 @@ CGAL_Kernel_pred(Less_lexicographically, less_lexicographically_object) CGAL_Kernel_pred(Equal_points, equal_points_object) -CGAL_Kernel_pred(Less_or_equal_lexicographically, - less_or_equal_lexicographically_object) +//CGAL_Kernel_pred(Less_or_equal_lexicographically, +// less_or_equal_lexicographically_object) CGAL_Kernel_pred(Contained_in_affine_hull, contained_in_affine_hull_object) -CGAL_Kernel_pred(In_flat_orientation, - in_flat_orientation_object) +//CGAL_Kernel_pred(In_flat_orientation, +// in_flat_orientation_object) CGAL_Kernel_pred(In_flat_side_of_oriented_sphere, in_flat_side_of_oriented_sphere_object) CGAL_Kernel_pred(Construct_flat_orientation, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index c884288c5f6..94e99dda802 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -5,14 +5,22 @@ #include #include #include +#include +#include +#include +#include namespace CGAL { // Find a better place for this later - template struct Get_type + template struct Get_type : K::template Type {}; - template struct Get_functor + template struct Get_functor : K::template Functor {}; +#ifdef CGAL_CXX0X + template using Type = typename Get_type::type; + template using Functor = typename Get_functor::type; +#endif class Null_type {~Null_type();}; // no such object should be created @@ -36,19 +44,43 @@ namespace CGAL { template struct Typedef_tag_type; //template struct Read_tag_type {}; - template, - bool = internal::has_type::value /* false */> - struct Provides_type : boost::false_type {}; - template - struct Provides_type - : boost::mpl::not_ > {}; + template + struct Provides_type + : Has_type_different_from, Null_type> {}; - template, - bool = internal::has_type::value /* false */> - struct Provides_functor : boost::false_type {}; - template - struct Provides_functor - : boost::mpl::not_ > {}; + template + struct Provides_functor + : Has_type_different_from, Null_functor> {}; + + template::type::value> + struct Provides_functors : boost::mpl::and_ < + Provides_functor::type>, + Provides_functors::type> > {}; + template + struct Provides_functors : boost::true_type {}; + + template::type::value> + struct Provides_types : boost::mpl::and_ < + Provides_type::type>, + Provides_types::type> > {}; + template + struct Provides_types : boost::true_type {}; + + namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Type) } + template::value /* false */> + struct Provides_type_i : boost::false_type {}; + template + struct Provides_type_i + : Has_type_different_from, Null_type> {}; + + namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Functor) } + template::value /* false */> + struct Provides_functor_i : boost::false_type {}; + template + struct Provides_functor_i + : Has_type_different_from, Null_type> {}; #define DECL_OBJ(X) struct X##_tag {}; \ diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 81e49662861..38256545e8e 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #ifdef CGAL_CXX0X #define BOOSTD std:: @@ -31,6 +34,13 @@ namespace internal { BOOST_MPL_HAS_XXX_TRAIT_DEF(type) } +template ::value /*false*/> +struct Has_type_different_from : boost::false_type {}; +template +struct Has_type_different_from +: boost::mpl::not_ > {}; + + template struct Wrap_type { typedef T type; }; // tell a function f(a,b,c) that its real argument is a(b,c) @@ -221,4 +231,33 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) }; } +#define CGAL_STRIP_PAREN_(...) __VA_ARGS__ +#define CGAL_STRIP_PAREN(...) CGAL_STRIP_PAREN_ __VA_ARGS__ +// What to do with O? pass it down to other functors or drop it? +#define CGAL_KD_DEFAULT_FUNCTOR(Tag,Name,ReqTyp,ReqFun) \ + template \ + struct Get_functor::value \ + || !Provides_types >::value \ + || !Provides_functors >::value \ + , int, void>::type> \ + { \ + typedef Name type; \ + } + +// Not used yet, may need some changes. +#define CGAL_KD_DEFAULT_TYPE(Tag,Name,ReqTyp,ReqFun) \ + template \ + struct Get_type::value \ + || !Provides_types >::value \ + || !Provides_functors >::value \ + , int, void>::type> \ + { \ + typedef Name type; \ + } + + #endif From e71d7c93b1d5fa5bc86b1afb27539de88580d69c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 1 Jan 2013 13:25:40 +0100 Subject: [PATCH 170/210] Rename Tag. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 2 + .../CGAL/Kernel_d/Cartesian_change_FT.h | 8 +-- .../CGAL/Kernel_d/Define_kernel_types.h | 8 +-- .../include/CGAL/Kernel_d/KernelD_converter.h | 12 ++--- .../CGAL/Kernel_d/Kernel_d_interface.h | 8 +-- NewKernel_d/include/CGAL/functor_tags.h | 51 ++++++++++++------- NewKernel_d/include/CGAL/is_iterator.h | 4 +- NewKernel_d/include/CGAL/marcutils.h | 13 ++--- 8 files changed, 61 insertions(+), 45 deletions(-) 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 192a3024b5b..482a8912b07 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -64,6 +64,8 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type {}; template struct Type< Point_tag, D> { typedef Vector_ type; }; template struct Type { typedef Vector_ type; }; + template struct Type< RT_tag, D> { typedef RT type; }; + template struct Type< FT_tag, D> { typedef FT type; }; typedef typeset ::add::type 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 f906581e2eb..d9a05bb0dad 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -48,9 +48,9 @@ struct Cartesian_change_FT_base : public }; */ - template + template struct Construct_cartesian_const_iterator_ { - typedef typename Get_functor::type Functor_base; + typedef typename Get_functor::type Functor_base; Construct_cartesian_const_iterator_(){} Construct_cartesian_const_iterator_(Self const&r):f(r){} Functor_base f; @@ -67,9 +67,9 @@ struct Cartesian_change_FT_base : public 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 + template struct Compute_cartesian_coordinate { - typedef typename Get_functor::type Functor_base; + typedef typename Get_functor::type Functor_base; Compute_cartesian_coordinate(){} Compute_cartesian_coordinate(Self const&r):f(r){} Functor_base f; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h b/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h index 42e9e84b1c4..bbf981b8848 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_kernel_types.h @@ -10,10 +10,10 @@ namespace CGAL { namespace internal { - template::is_iterator> - struct Type_or_iter : K::template Type {}; - template - struct Type_or_iter : K::template Iterator {}; + template::is_iterator> + struct Type_or_iter : K::template Type {}; + template + struct Type_or_iter : K::template Iterator {}; } template::type> struct Define_kernel_types; template diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index f53eaed3998..5a4b45bbf4c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -52,13 +52,13 @@ template class KernelD_converter_ : public KernelD_converter_ { - typedef typename List::head Tag; + typedef typename List::head Tag_; typedef typename List::tail Rest; typedef KernelD_converter_ Base; - typedef typename Get_type::type K1_Obj; - typedef typename Get_type::type K2_Obj; - typedef typename Get_functor >::type K1_Conv; - typedef KO_converter KOC; + typedef typename Get_type::type K1_Obj; + typedef typename Get_type::type K2_Obj; + typedef typename Get_functor >::type K1_Conv; + typedef KO_converter KOC; typedef BOOSTD is_same no_converter; typedef typename internal::Map_taglist_to_typelist::type::template contains duplicate; @@ -68,7 +68,7 @@ class KernelD_converter_ // If Point==Vector, keep only one conversion duplicate::value || // For iterator objects, the default is make_transforming_iterator - (iterator_tag_traits::is_iterator && no_converter::value), + (iterator_tag_traits::is_iterator && no_converter::value), Do_not_use,K1_Obj>::type argument_type; //typedef typename KOC::argument_type K1_Obj; //typedef typename KOC::result_type K2_Obj; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index ddad6f1cfe1..799708205b6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -79,12 +79,12 @@ template struct Kernel_d_interface : public Base_ { // Kernel_d requires a common iterator type for points and vectors // TODO: provide this mixed functor in preKernel? CGAL_static_assertion((boost::is_same::type>::type, result_type>::value)); - template - result_type operator()(Point_d const&p, Tag t)const{ + template + result_type operator()(Point_d const&p, Tag_ t)const{ return CPI(this->kernel())(p,t); } - template - result_type operator()(Vector_d const&v, Tag t)const{ + template + result_type operator()(Vector_d const&v, Tag_ t)const{ return CVI(this->kernel())(v,t); } diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 94e99dda802..5c7370ee97e 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -41,16 +41,16 @@ namespace CGAL { templatestruct Convert_ttag {}; template struct map_functor_type { typedef Misc_tag type; }; - template struct Typedef_tag_type; - //template struct Read_tag_type {}; + template struct Typedef_tag_type; + //template struct Read_tag_type {}; - template + template struct Provides_type - : Has_type_different_from, Null_type> {}; + : Has_type_different_from, Null_type> {}; - template + template struct Provides_functor - : Has_type_different_from, Null_functor> {}; + : Has_type_different_from, Null_functor> {}; template::type::value> struct Provides_functors : boost::mpl::and_ < @@ -67,25 +67,27 @@ namespace CGAL { struct Provides_types : boost::true_type {}; namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Type) } - template::value /* false */> struct Provides_type_i : boost::false_type {}; - template - struct Provides_type_i - : Has_type_different_from, Null_type> {}; + template + struct Provides_type_i + : Has_type_different_from, Null_type> {}; namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Functor) } - template::value /* false */> struct Provides_functor_i : boost::false_type {}; - template - struct Provides_functor_i - : Has_type_different_from, Null_type> {}; + template + struct Provides_functor_i + : Has_type_different_from, Null_type> {}; -#define DECL_OBJ(X) struct X##_tag {}; \ +#define DECL_OBJ_(X) \ template \ - struct Typedef_tag_type : Base { typedef Obj X; }; + struct Typedef_tag_type : Base { typedef Obj X; } +#define DECL_OBJ(X) struct X##_tag {}; \ + DECL_OBJ_(X) //namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } //template @@ -97,6 +99,14 @@ namespace CGAL { DECL_OBJ(FT); DECL_OBJ(RT); + //DECL_OBJ(Boolean); // FIXME: Boolean_tag is already taken, and is a template :-( + DECL_OBJ(Comparison_result); + DECL_OBJ(Sign); + DECL_OBJ(Orientation); // Note: duplicate with the functor tag! + DECL_OBJ(Oriented_side); + DECL_OBJ(Bounded_side); + DECL_OBJ(Angle); + DECL_OBJ(Vector); DECL_OBJ(Point); DECL_OBJ(Segment); @@ -108,6 +118,7 @@ namespace CGAL { DECL_OBJ(Iso_box); DECL_OBJ(Bbox); DECL_OBJ(Aff_transformation); +#undef DECL_OBJ_ #undef DECL_OBJ template struct is_NT_tag { enum { value = false }; }; @@ -140,7 +151,7 @@ namespace CGAL { typedef C##_tag container; \ }; \ template \ - struct Typedef_tag_type : Base { typedef Obj X; }; + struct Typedef_tag_type : Base { typedef Obj X; } //namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } //template @@ -187,8 +198,10 @@ namespace CGAL { #endif //FIXME: choose a convention: prefix with Predicate_ ? -#define DECL_PREDICATE(X) struct X##_tag {}; \ +#define DECL_PREDICATE_(X) \ template<>struct map_functor_type{typedef Predicate_tag type;} +#define DECL_PREDICATE(X) struct X##_tag {}; \ + DECL_PREDICATE_(X) DECL_PREDICATE(Less_point_cartesian_coordinate); DECL_PREDICATE(Compare_point_cartesian_coordinate); DECL_PREDICATE(Compare_distance); @@ -196,7 +209,7 @@ namespace CGAL { DECL_PREDICATE(Less_lexicographically); DECL_PREDICATE(Less_or_equal_lexicographically); DECL_PREDICATE(Equal_points); - DECL_PREDICATE(Orientation); + DECL_PREDICATE_(Orientation); // duplicate with the type DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_vectors); DECL_PREDICATE(Side_of_oriented_sphere); diff --git a/NewKernel_d/include/CGAL/is_iterator.h b/NewKernel_d/include/CGAL/is_iterator.h index 02cf09b0d14..591a26d86d6 100644 --- a/NewKernel_d/include/CGAL/is_iterator.h +++ b/NewKernel_d/include/CGAL/is_iterator.h @@ -48,8 +48,8 @@ template struct is_iterator_type_ : template struct is_iterator : internal::is_iterator_::type>::type> {}; -template struct is_iterator_type : - internal::is_iterator_type_::type>::type,Tag> {}; +template struct is_iterator_type : + internal::is_iterator_type_::type>::type,Tg> {}; template ::value> struct is_iterator_to { enum { value=false }; diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 38256545e8e..c825634d97a 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -231,14 +231,15 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) }; } +// TODO: make a Cartesian-only variant #define CGAL_STRIP_PAREN_(...) __VA_ARGS__ #define CGAL_STRIP_PAREN(...) CGAL_STRIP_PAREN_ __VA_ARGS__ // What to do with O? pass it down to other functors or drop it? -#define CGAL_KD_DEFAULT_FUNCTOR(Tag,Name,ReqTyp,ReqFun) \ +#define CGAL_KD_DEFAULT_FUNCTOR(Tg,Name,ReqTyp,ReqFun) \ template \ - struct Get_functor::value \ + Provides_functor_i::value \ || !Provides_types >::value \ || !Provides_functors >::value \ , int, void>::type> \ @@ -247,11 +248,11 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) } // Not used yet, may need some changes. -#define CGAL_KD_DEFAULT_TYPE(Tag,Name,ReqTyp,ReqFun) \ +#define CGAL_KD_DEFAULT_TYPE(Tg,Name,ReqTyp,ReqFun) \ template \ - struct Get_type::value \ + Provides_type_i::value \ || !Provides_types >::value \ || !Provides_functors >::value \ , int, void>::type> \ From 7445bb7f34f3032473dc6750e535ede4104b1cf3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 1 Jan 2013 16:42:35 +0100 Subject: [PATCH 171/210] More Get_type, replaces the nested RT, FT, Boolean, Comparison_result, etc. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 21 +---- .../CGAL/Kernel_d/Cartesian_LA_functors.h | 18 ++--- .../CGAL/Kernel_d/Cartesian_change_FT.h | 23 +----- .../CGAL/Kernel_d/Cartesian_complete.h | 6 +- .../CGAL/Kernel_d/Cartesian_filter_K.h | 2 +- .../CGAL/Kernel_d/Cartesian_filter_NT.h | 4 +- .../CGAL/Kernel_d/Cartesian_static_filters.h | 4 +- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 16 ++-- .../include/CGAL/Kernel_d/KernelD_converter.h | 4 +- .../CGAL/Kernel_d/Kernel_2_interface.h | 9 +++ .../CGAL/Kernel_d/Kernel_3_interface.h | 9 +++ .../CGAL/Kernel_d/Kernel_d_interface.h | 18 +++-- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 32 ++------ .../include/CGAL/Kernel_d/Types/Hyperplane.h | 6 +- .../include/CGAL/Kernel_d/Types/Iso_box.h | 4 +- .../include/CGAL/Kernel_d/Types/Line.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h | 2 +- .../include/CGAL/Kernel_d/Types/Segmentd.h | 2 +- .../include/CGAL/Kernel_d/Types/Sphere.h | 6 +- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 2 +- .../include/CGAL/Kernel_d/Wrapper/Point_d.h | 4 +- .../include/CGAL/Kernel_d/Wrapper/Segment_d.h | 6 +- .../include/CGAL/Kernel_d/Wrapper/Sphere_d.h | 6 +- .../include/CGAL/Kernel_d/Wrapper/Vector_d.h | 4 +- .../Kernel_d/function_objects_cartesian.h | 60 +++++++------- NewKernel_d/include/CGAL/Lazy.h | 8 +- NewKernel_d/include/CGAL/functor_tags.h | 81 ++++++++++++------- NewKernel_d/include/CGAL/marcutils.h | 12 +-- NewKernel_d/test/NewKernel_d/Makefile | 4 +- 29 files changed, 183 insertions(+), 192 deletions(-) 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 482a8912b07..b3f9800fbef 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -29,8 +29,6 @@ template < typename FT_, typename Dim_, /* Default LA to Vec or to LA_eigen? */ struct Cartesian_LA_base_d : public Dimension_base { - typedef FT_ FT; - typedef FT_ RT; typedef Cartesian_LA_base_d Self; typedef Cartesian_tag Rep_tag; typedef Cartesian_tag Kernel_tag; @@ -38,21 +36,6 @@ struct Cartesian_LA_base_d : public Dimension_base typedef Dim_ Max_ambient_dimension; typedef LA_ LA; - typedef typename Same_uncertainty_nt::type - Boolean; - typedef typename Same_uncertainty_nt::type - Sign; - typedef typename Same_uncertainty_nt::type - Comparison_result; - typedef typename Same_uncertainty_nt::type - Orientation; - typedef typename Same_uncertainty_nt::type - Oriented_side; - typedef typename Same_uncertainty_nt::type - Bounded_side; - typedef typename Same_uncertainty_nt::type - Angle; - typedef Vec_ LA_vector; typedef typename LA_vector::Vector Point; typedef typename LA_vector::Vector Vector; @@ -64,8 +47,8 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type {}; template struct Type< Point_tag, D> { typedef Vector_ type; }; template struct Type { typedef Vector_ type; }; - template struct Type< RT_tag, D> { typedef RT type; }; - template struct Type< FT_tag, D> { typedef FT type; }; + template struct Type< RT_tag, D> { typedef FT_ type; }; + template struct Type< FT_tag, D> { typedef FT_ type; }; typedef typeset ::add::type diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h index 0f26ab701fb..01756c203f4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_functors.h @@ -18,7 +18,7 @@ template struct Construct_LA_vector_ { }; #define CODE(Z,N,_) template struct Construct_LA_vector_ { \ typedef typename R::Constructor Constructor; \ - typedef typename R::RT RT; \ + typedef typename Get_type::type RT; \ typedef typename R::Vector_ result_type; \ result_type operator() \ (BOOST_PP_ENUM_PARAMS(N,RT const& t)) const { \ @@ -44,8 +44,8 @@ template struct Construct_LA_vector CGAL_FUNCTOR_INIT_STORE(Construct_LA_vector) typedef R_ R; typedef typename R::Constructor Constructor; - typedef typename R::RT RT; - typedef typename R::FT FT; + typedef typename Get_type::type RT; + typedef typename Get_type::type FT; typedef typename R::Vector_ result_type; typedef typename R_::Default_ambient_dimension Dimension; static const int static_dim=Dimension::value; @@ -147,7 +147,7 @@ template struct Construct_LA_vector template struct Compute_cartesian_coordinate { CGAL_FUNCTOR_INIT_IGNORE(Compute_cartesian_coordinate) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename R::Vector_ first_argument_type; typedef int second_argument_type; typedef Tag_true Is_exact; @@ -232,7 +232,7 @@ template struct Scalar_product { CGAL_FUNCTOR_INIT_IGNORE(Scalar_product) typedef R_ R; typedef typename R::LA_vector LA; - typedef typename R::RT result_type; + typedef typename Get_type::type result_type; typedef typename Get_type::type first_argument_type; typedef typename Get_type::type second_argument_type; @@ -245,7 +245,7 @@ template struct Squared_distance_to_origin_stored { CGAL_FUNCTOR_INIT_IGNORE(Squared_distance_to_origin_stored) typedef R_ R; typedef typename R::LA_vector LA; - typedef typename R::RT result_type; + typedef typename Get_type::type result_type; typedef typename Get_type::type argument_type; result_type operator()(argument_type const& a)const{ @@ -257,7 +257,7 @@ template struct Squared_distance_to_origin_via_dotprod { CGAL_FUNCTOR_INIT_IGNORE(Squared_distance_to_origin_via_dotprod) typedef R_ R; typedef typename R::LA_vector LA; - typedef typename R::RT result_type; + typedef typename Get_type::type result_type; typedef typename Get_type::type argument_type; result_type operator()(argument_type const& a)const{ @@ -270,7 +270,7 @@ template struct Orientation_of_vectors { typedef R_ R; typedef typename R::Vector_cartesian_const_iterator first_argument_type; typedef typename R::Vector_cartesian_const_iterator second_argument_type; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename R::LA_vector LA; template @@ -284,7 +284,7 @@ template struct Orientation_of_points { typedef R_ R; typedef typename R::Point_cartesian_const_iterator first_argument_type; typedef typename R::Point_cartesian_const_iterator second_argument_type; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename R::LA_vector LA; template 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 d9a05bb0dad..5c32b4a79b7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -17,26 +17,9 @@ struct Cartesian_change_FT_base : public typedef Cartesian_change_FT_base Self; typedef Base_ Kernel_base; - typedef FT_ RT; - typedef FT_ FT; typedef LA_ LA; - typedef typename Same_uncertainty_nt::type - Boolean; - typedef typename Same_uncertainty_nt::type - Sign; - typedef typename Same_uncertainty_nt::type - Comparison_result; - typedef typename Same_uncertainty_nt::type - Orientation; - typedef typename Same_uncertainty_nt::type - Oriented_side; - typedef typename Same_uncertainty_nt::type - Bounded_side; - typedef typename Same_uncertainty_nt::type - Angle; - - typedef NT_converter FT_converter; + typedef NT_converter::type,FT_> FT_converter; typedef transforming_iterator Point_cartesian_const_iterator; typedef transforming_iterator Vector_cartesian_const_iterator; //FIXME: use Iterator_list! @@ -73,14 +56,14 @@ struct Cartesian_change_FT_base : public Compute_cartesian_coordinate(){} Compute_cartesian_coordinate(Self const&r):f(r){} Functor_base f; - typedef FT result_type; + typedef FT_ result_type; template result_type operator()(Obj_ const& v,int i)const{ return FT_converter()(f(v,i)); } }; - template::type> struct Functor : + template::type> struct Functor : Get_functor { }; template struct Functor { typedef Null_functor type; }; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 4cefee0dfe8..552ba8fb02c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -80,7 +80,7 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; - template::type> struct Functor : + template::type> struct Functor : Get_functor {}; template struct Functor { typedef typename Get_functor::type Base_functor; @@ -102,7 +102,7 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; - template::type> struct Functor : + template::type> struct Functor : Get_functor {}; template struct Functor { typedef typename Get_functor::type Base_functor; @@ -121,7 +121,7 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; - template::type> struct Functor : + template::type> struct Functor : Get_functor {}; template struct Functor { typedef typename Get_functor::type Base_functor; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index 34bd69ee1e2..2c7123d4010 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -30,7 +30,7 @@ struct Cartesian_filter_K : public Base_, typedef KernelD_converter C2A; typedef KernelD_converter C2E; - template::type> struct Functor : + template::type> struct Functor : Get_functor {}; template struct Functor { typedef typename Get_functor::type AP; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h index 3b7f510fe67..8d423320348 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -14,10 +14,10 @@ struct Cartesian_filter_NT : public Base_ CGAL_CONSTEXPR Cartesian_filter_NT(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_change_FT K1; - typedef typename internal::Exact_type_selector::Type Exact_nt; + typedef typename internal::Exact_type_selector::type>::Type Exact_nt; typedef Cartesian_change_FT K2; - template::type> struct Functor : + template::type> struct Functor : Get_functor {}; template struct Functor { struct type { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index 77e34eb4c04..c813a488edf 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -12,8 +12,8 @@ namespace SFA { // static filter adapter template struct Orientation_of_points_2 : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_2); typedef typename Get_type::type Point; - typedef typename R_::Orientation result_type; - typedef typename R_::FT FT; + typedef typename Get_type::type result_type; + typedef typename Get_type::type FT; typedef typename Get_functor::type CC; typedef typename Get_functor::type Orientation_base; // TODO: Move this out for easy reuse diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 72bfc7128ba..800adccd0da 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -43,7 +43,7 @@ inline void debug_matrix(std::ostream& o, Mat const&mat) { template struct Construct_flat_orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_flat_orientation) typedef R_ R; - typedef typename R_::FT FT; + typedef typename Get_type::type FT; typedef typename Get_type::type Point; typedef typename Increment_dimension::type Dplusone; typedef typename R::LA::template Rebind_dimension::Other LA; @@ -96,9 +96,9 @@ template struct Construct_flat_orientation : private Store_kernel template struct Contained_in_affine_hull : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Contained_in_affine_hull) typedef R_ R; - typedef typename R_::FT FT; + typedef typename Get_type::type FT; typedef typename Get_type::type Point; - typedef typename R::Boolean result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor::type CCC; typedef typename Get_functor::type PD; //typedef typename Increment_dimension::type D1; @@ -155,9 +155,9 @@ template struct Contained_in_affine_hull : private Store_kernel { template struct In_flat_orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(In_flat_orientation) typedef R_ R; - typedef typename R_::FT FT; + typedef typename Get_type::type FT; typedef typename Get_type::type Point; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; typedef typename R::LA::template Rebind_dimension::Other LA; @@ -193,9 +193,9 @@ template struct In_flat_orientation : private Store_kernel { template struct In_flat_side_of_oriented_sphere : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(In_flat_side_of_oriented_sphere) typedef R_ R; - typedef typename R_::FT FT; + typedef typename Get_type::type FT; typedef typename Get_type::type Point; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; typedef typename R::LA::template Rebind_dimension::Other LA; @@ -239,6 +239,6 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel } -CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,CartesianDKernelFunctors::In_flat_orientation,(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); +CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation,(CartesianDKernelFunctors::In_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); } #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index 5a4b45bbf4c..3c894cd6d9a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -109,8 +109,8 @@ typename typeset_intersection Base; - typedef typename K1::FT FT1; - typedef typename K2::FT FT2; + typedef typename Get_type::type FT1; + typedef typename Get_type::type FT2; typedef NT_converter NTc; NTc c; // TODO: compressed storage as this is likely empty and the converter gets passed around (and stored in iterators) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h index 2f2251fd16c..fb44402e2b3 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -11,6 +11,15 @@ namespace CGAL { template struct Kernel_2_interface : public Base_ { typedef Base_ Base; typedef Kernel_2_interface Kernel; + typedef typename Get_type::type RT; + typedef typename Get_type::type FT; + typedef typename Get_type::type Boolean; + typedef typename Get_type::type Sign; + typedef typename Get_type::type Comparison_result; + typedef typename Get_type::type Orientation; + typedef typename Get_type::type Oriented_side; + typedef typename Get_type::type Bounded_side; + typedef typename Get_type::type Angle; typedef typename Get_type::type Point_2; typedef typename Get_type::type Vector_2; struct Segment_2 {}; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h index d8bd7db3ce8..1a523ee2213 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_3_interface.h @@ -11,6 +11,15 @@ namespace CGAL { template struct Kernel_3_interface : public Base_ { typedef Base_ Base; typedef Kernel_3_interface Kernel; + typedef typename Get_type::type RT; + typedef typename Get_type::type FT; + typedef typename Get_type::type Boolean; + typedef typename Get_type::type Sign; + typedef typename Get_type::type Comparison_result; + typedef typename Get_type::type Orientation; + typedef typename Get_type::type Oriented_side; + typedef typename Get_type::type Bounded_side; + typedef typename Get_type::type Angle; typedef typename Get_type::type Point_3; typedef typename Get_type::type Vector_3; typedef typename Get_type::type Segment_3; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 799708205b6..01d22443485 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -15,6 +15,15 @@ template struct Kernel_d_interface : public Base_ { typedef Base_ Base; typedef Kernel_d_interface Kernel; typedef Base_ R_; // for the macros + typedef typename Get_type::type RT; + typedef typename Get_type::type FT; + typedef typename Get_type::type Boolean; + typedef typename Get_type::type Sign; + typedef typename Get_type::type Comparison_result; + typedef typename Get_type::type Orientation; + typedef typename Get_type::type Oriented_side; + typedef typename Get_type::type Bounded_side; + typedef typename Get_type::type Angle; typedef typename Base::Flat_orientation Flat_orientation_d; typedef typename Get_type::type Point_d; typedef typename Get_type::type Vector_d; @@ -55,16 +64,13 @@ template struct Kernel_d_interface : public Base_ { typedef typename Get_functor::type Midpoint_d; struct Component_accessor_d : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Component_accessor_d) - typedef typename Get_type::type Point; - typedef typename Base::RT RT; - typedef typename Base::FT FT; - int dimension(Point const&p){ + int dimension(Point_d const&p){ return this->kernel().point_dimension_d_object()(p); } - FT cartesian(Point const&p, int i){ + FT cartesian(Point_d const&p, int i){ return this->kernel().compute_coordinate_d_object()(p); } - RT homogeneous(Point const&p, int i){ + RT homogeneous(Point_d const&p, int i){ throw "not implemented yet"; return 0; // FIXME diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 795388f3e0d..d55f7438a82 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -54,17 +54,16 @@ struct Lazy_cartesian_types typename EK_::Iterator_list >::type Iterator_list; - template struct Type { + template ::type> struct Type {}; + template struct Type { typedef Lazy< typename Get_type::type, typename Get_type::type, - typename EK_::FT, E2A_> type; + typename Get_type::type, + E2A_> type; }; - template struct Type { - typedef CGAL::Lazy_exact_nt type; - }; - template struct Type { - typedef CGAL::Lazy_exact_nt type; + template struct Type { + typedef CGAL::Lazy_exact_nt::type> type; }; template struct Iterator { @@ -108,8 +107,6 @@ struct Lazy_cartesian : Dimension_base, typedef E2A_ E2A; typedef Approx_converter C2A; typedef Exact_converter C2E; - typedef CGAL::Lazy_exact_nt FT; - typedef CGAL::Lazy_exact_nt RT; typedef typename Exact_kernel::Rep_tag Rep_tag; typedef typename Exact_kernel::Kernel_tag Kernel_tag; @@ -118,22 +115,7 @@ struct Lazy_cartesian : Dimension_base, typedef typename Exact_kernel::Flat_orientation Flat_orientation; // Check that Approximate_kernel agrees with all that... - typedef typename Same_uncertainty_nt::type - Boolean; - typedef typename Same_uncertainty_nt::type - Sign; - typedef typename Same_uncertainty_nt::type - Comparison_result; - typedef typename Same_uncertainty_nt::type - Orientation; - typedef typename Same_uncertainty_nt::type - Oriented_side; - typedef typename Same_uncertainty_nt::type - Bounded_side; - typedef typename Same_uncertainty_nt::type - Angle; - - template::type> struct Functor { + template::type> struct Functor { typedef Null_functor type; }; //FIXME: what do we do with D here? diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h index 464432f07b6..8f83718759c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h @@ -3,7 +3,7 @@ #include namespace CGAL { template class Hyperplane { - typedef typename R_::FT FT_; + typedef typename Get_type::type FT_; typedef typename Get_type::type Point_; typedef typename Get_type::type Vector_; Vector_ v_; @@ -22,7 +22,7 @@ template struct Construct_hyperplane : Store_kernel { typedef typename Get_type::type result_type; typedef typename Get_type::type Point; typedef typename Get_type::type Vector; - typedef typename R_::FT FT; + typedef typename Get_type::type FT; typedef typename R_::LA LA; result_type operator()(Vector const&a, FT const&b)const{ return result_type(a,b); @@ -43,7 +43,7 @@ template struct Orthogonal_vector { template struct Hyperplane_translation { CGAL_FUNCTOR_INIT_IGNORE(Hyperplane_translation) typedef typename Get_type::type Hyperplane; - typedef typename R_::FT result_type; + typedef typename Get_type::type result_type; // TODO: Is_exact? result_type operator()(Hyperplane const&s)const{ return s.translation(); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h index 3cf982f1281..669e16697c7 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h @@ -7,7 +7,7 @@ #include namespace CGAL { template class Iso_box { - typedef typename R_::FT FT_; + typedef typename Get_type::type FT_; typedef typename Get_type::type Point_; typedef std::pair Data_; Data_ data; @@ -25,7 +25,7 @@ namespace CartesianDKernelFunctors { template struct Construct_iso_box : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_iso_box) typedef typename Get_type::type result_type; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Point; typedef typename Get_type::type Vector; typedef typename Get_functor >::type Cp_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h index 3c84429d7ed..7b984b038d1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h @@ -5,7 +5,7 @@ #include namespace CGAL { template class Line { - typedef typename R_::FT FT_; + typedef typename Get_type::type FT_; typedef typename Get_type::type Point_; typedef std::pair Data_; Data_ data; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h index 591c4641fa5..49652020d57 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h @@ -5,7 +5,7 @@ #include namespace CGAL { template class Ray { - typedef typename R_::FT FT_; + typedef typename Get_type::type FT_; typedef typename Get_type::type Point_; typedef typename Get_type::type Vector_; typedef std::pair Data_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h index b8ae5b29253..8693e0f8478 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h @@ -4,7 +4,7 @@ #include namespace CGAL { template class Segment { - typedef typename R_::FT FT_; + typedef typename Get_type::type FT_; typedef typename Get_type::type Point_; //typedef typename R_::Vector Vector_; //typedef typename Get_functor >::type Cv_; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h index a5e20cf568c..7982f86936c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h @@ -3,7 +3,7 @@ #include namespace CGAL { template class Sphere { - typedef typename R_::FT FT_; + typedef typename Get_type::type FT_; typedef typename Get_type::type Point_; Point_ c_; FT_ r2_; @@ -20,7 +20,7 @@ template struct Construct_sphere : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_sphere) typedef typename Get_type::type result_type; typedef typename Get_type::type Point; - typedef typename R_::FT FT; + typedef typename Get_type::type FT; typedef typename R_::LA LA; result_type operator()(Point const&a, FT const&b)const{ return result_type(a,b); @@ -41,7 +41,7 @@ template struct Center_of_sphere { template struct Squared_radius { CGAL_FUNCTOR_INIT_IGNORE(Squared_radius) typedef typename Get_type::type Sphere; - typedef typename R_::FT result_type; + typedef typename Get_type::type result_type; // TODO: Is_exact? result_type operator()(Sphere const&s)const{ return s.squared_radius(); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index e0ff344805f..bd5dcbea306 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -95,7 +95,7 @@ struct Cartesian_wrap : public Base_ #include //Translate the arguments - template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { + template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { typedef typename Get_functor::type B; struct type { B b; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h index 8c92c77f2f8..7a1adc87fa0 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_d.h @@ -20,8 +20,8 @@ class Point_d : public Get_type::type // Deriving won't work if the point is just a __m256d. // Test boost/std::is_class for instance { - typedef typename R_::RT RT_; - typedef typename R_::FT FT_; + typedef typename Get_type::type RT_; + typedef typename Get_type::type FT_; typedef typename R_::Kernel_base Kbase; typedef typename Get_type::type Vector_; typedef typename Get_functor >::type CPBase; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h index 10dc1d5829c..45834171060 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Segment_d.h @@ -18,9 +18,9 @@ namespace CGAL { template class Segment_d : public Get_type::type { - typedef typename R_::RT RT_; - typedef typename R_::FT FT_; - typedef typename R_::Kernel_base Kbase; + typedef typename Get_type::type RT_; + typedef typename Get_type::type FT_; + typedef typename R_::Kernel_base Kbase; typedef typename Get_type::type Point_; typedef typename Get_functor >::type CPBase; typedef typename Get_functor >::type CSBase; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h index b8f8be38534..43af2a834bd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Sphere_d.h @@ -14,9 +14,9 @@ namespace CGAL { template -class Sphere_d : public R_::Kernel_base::Sphere +class Sphere_d : public Get_type::type { - typedef typename R_::FT FT_; + typedef typename Get_type::type FT_; typedef typename R_::Kernel_base Kbase; typedef typename Get_type::type Point_; typedef typename Get_functor >::type CSBase; @@ -24,7 +24,7 @@ class Sphere_d : public R_::Kernel_base::Sphere typedef typename Get_functor::type SRBase; typedef Sphere_d Self; - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::value)); public: diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h index 845575baf8a..bced5b751a8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_d.h @@ -18,8 +18,8 @@ namespace CGAL { template class Vector_d : public Get_type::type { - typedef typename R_::RT RT_; - typedef typename R_::FT FT_; + typedef typename Get_type::type RT_; + typedef typename Get_type::type FT_; typedef typename R_::Kernel_base Kbase; typedef typename Get_type::type Point_; typedef typename Get_functor >::type CVBase; 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 c59dba6f279..c28af8c41f1 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -30,7 +30,7 @@ template::type Point; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename R::LA::Square_matrix Matrix; template @@ -88,7 +88,7 @@ template struct Orientation_of_points,true> CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; typedef typename Get_type::type Point; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; templatestruct Help; templatestruct Help > { template result_type operator()(C const&c,P const&x,T&&t)const{ @@ -124,9 +124,9 @@ template struct Orientation_of_points,true> template struct Orientation_of_points,true> : private Store_kernel { \ CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) \ typedef R_ R; \ - typedef typename R_::RT RT; \ + typedef typename Get_type::type RT; \ typedef typename Get_type::type Point; \ - typedef typename R::Orientation result_type; \ + typedef typename Get_type::type result_type; \ result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ typename Get_functor::type c(this->kernel()); \ BOOST_PP_REPEAT(N,VAR4,) \ @@ -154,7 +154,7 @@ template struct Orientation_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) typedef R_ R; typedef typename Get_type::type Vector; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename R::LA::Square_matrix Matrix; template @@ -197,7 +197,7 @@ template::v typedef R_ R; typedef typename Get_type::type Vector; typedef typename Get_type::type Point; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor::type OP; typedef typename Get_functor::type OV; @@ -221,7 +221,7 @@ template struct Orientation : private Store_kernel { typedef R_ R; typedef typename Get_type::type Vector; typedef typename Get_type::type Point; - typedef typename R::Orientation result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor::type OP; typedef typename Get_functor::type OV; typedef typename R::LA::Square_matrix Matrix; @@ -246,9 +246,9 @@ template struct Orientation : private Store_kernel { template struct Side_of_oriented_sphere : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Point; - typedef typename R::Oriented_side result_type; + typedef typename Get_type::type result_type; typedef typename Increment_dimension::type D1; typedef typename Increment_dimension::type D2; typedef typename R::LA::template Rebind_dimension::Other LA; @@ -305,7 +305,7 @@ template struct Side_of_oriented_sphere : private Store_kernel { template struct Point_to_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Point_to_vector) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Vector; typedef typename Get_type::type Point; typedef typename Get_functor >::type CV; @@ -321,7 +321,7 @@ template struct Point_to_vector : private Store_kernel { template struct Vector_to_point : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Vector_to_point) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Vector; typedef typename Get_type::type Point; typedef typename Get_functor >::type CV; @@ -337,7 +337,7 @@ template struct Vector_to_point : private Store_kernel { template struct Opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Opposite_vector) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; @@ -352,7 +352,7 @@ template struct Opposite_vector : private Store_kernel { template struct Scaled_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Scaled_vector) typedef R_ R; - typedef typename R_::FT FT; + typedef typename Get_type::type FT; typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; @@ -368,7 +368,7 @@ template struct Scaled_vector : private Store_kernel { template struct Sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; @@ -384,7 +384,7 @@ template struct Sum_of_vectors : private Store_kernel { template struct Difference_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_vectors) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; typedef typename Get_functor >::type CI; @@ -400,7 +400,7 @@ template struct Difference_of_vectors : private Store_kernel { template struct Translated_point : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Translated_point) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Vector; typedef typename Get_type::type Point; typedef typename Get_functor >::type CP; @@ -419,7 +419,7 @@ template struct Translated_point : private Store_kernel { template struct Difference_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_points) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Point; typedef typename Get_type::type Vector; typedef typename Get_functor >::type CV; @@ -436,8 +436,8 @@ template struct Difference_of_points : private Store_kernel { template struct Midpoint : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Midpoint) typedef R_ R; - typedef typename R_::FT FT; - typedef typename R_::RT RT; + typedef typename Get_type::type FT; + typedef typename Get_type::type RT; typedef typename Get_type::type Point; typedef typename Get_functor >::type CP; typedef typename Get_functor >::type CI; @@ -461,7 +461,7 @@ template struct Midpoint : private Store_kernel { template struct Squared_length : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_length) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Vector; typedef typename Get_functor >::type CI; typedef RT result_type; @@ -477,7 +477,7 @@ template struct Squared_length : private Store_kernel { template struct Squared_distance_to_origin : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_distance_to_origin) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Point; typedef typename Get_functor >::type CI; typedef RT result_type; @@ -493,7 +493,7 @@ template struct Squared_distance_to_origin : private Store_kernel template struct Squared_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_distance) typedef R_ R; - typedef typename R_::RT RT; + typedef typename Get_type::type RT; typedef typename Get_type::type Point; typedef typename Get_functor >::type CI; typedef RT result_type; @@ -517,7 +517,7 @@ template struct Compare_distance : private Store_kernel { typedef R_ R; typedef typename Get_type::type Point; typedef typename Get_functor::type CSD; - typedef typename R_::Comparison_result result_type; + typedef typename Get_type::type result_type; typedef Point first_argument_type; typedef Point second_argument_type; typedef Point third_argument_type; // why am I doing this already? @@ -535,7 +535,7 @@ template struct Compare_distance : private Store_kernel { template struct Less_point_cartesian_coordinate : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_point_cartesian_coordinate) typedef R_ R; - typedef typename R::Boolean result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor::type Cc; // TODO: This is_exact thing should be reengineered. // the goal is to have a way to tell: don't filter this @@ -551,7 +551,7 @@ template struct Less_point_cartesian_coordinate : private Store_kernel template struct Compare_point_cartesian_coordinate : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_point_cartesian_coordinate) typedef R_ R; - typedef typename R::Comparison_result result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor::type Cc; // TODO: This is_exact thing should be reengineered. // the goal is to have a way to tell: don't filter this @@ -567,7 +567,7 @@ template struct Compare_point_cartesian_coordinate : private Store_ker template struct Compare_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_lexicographically) typedef R_ R; - typedef typename R::Comparison_result result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor >::type CI; // TODO: This is_exact thing should be reengineered. // the goal is to have a way to tell: don't filter this @@ -596,7 +596,7 @@ template struct Compare_lexicographically : private Store_kernel { template struct Less_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_lexicographically) typedef R_ R; - typedef typename R::Boolean result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor::type CL; typedef typename CGAL::Is_exact Is_exact; @@ -610,7 +610,7 @@ template struct Less_lexicographically : private Store_kernel { template struct Less_or_equal_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_or_equal_lexicographically) typedef R_ R; - typedef typename R::Boolean result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor::type CL; typedef typename CGAL::Is_exact Is_exact; @@ -622,13 +622,13 @@ template struct Less_or_equal_lexicographically : private Store_kernel }; } -CGAL_KD_DEFAULT_FUNCTOR(Less_or_equal_lexicographically_tag,CartesianDKernelFunctors::Less_or_equal_lexicographically,(),(Compare_lexicographically_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Less_or_equal_lexicographically,(CartesianDKernelFunctors::Less_or_equal_lexicographically),(),(Compare_lexicographically_tag)); namespace CartesianDKernelFunctors { template struct Equal_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Equal_points) typedef R_ R; - typedef typename R::Boolean result_type; + typedef typename Get_type::type result_type; typedef typename Get_functor >::type CI; // TODO: This is_exact thing should be reengineered. // the goal is to have a way to tell: don't filter this diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index 3dbd7cc275d..9a352f5d359 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -1569,7 +1569,7 @@ struct Lazy_functor_2_2 typedef void result_type; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; + typedef typename Get_type::type EFT; typedef typename LK::E2A E2A; AC ac; @@ -1611,7 +1611,7 @@ struct Lazy_intersect_with_iterators static const bool Protection = true; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; + typedef typename Get_type::type EFT; typedef typename LK::E2A E2A; typedef void result_type; typedef Lazy Lazy_object; @@ -1690,7 +1690,7 @@ struct Lazy_construction_object typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; + typedef typename Get_type::type EFT; typedef typename LK::E2A E2A; typedef typename AC::result_type AT; typedef typename EC::result_type ET; @@ -1783,7 +1783,7 @@ struct Lazy_construction typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; + typedef typename Get_type::type EFT; typedef typename Default::Get::type E2A; typedef typename decay::type AT; typedef typename decay::type ET; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 5c7370ee97e..5a048d86da0 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -40,7 +40,7 @@ namespace CGAL { templatestruct Construct_ttag {}; templatestruct Convert_ttag {}; - template struct map_functor_type { typedef Misc_tag type; }; + template struct Get_functor_category { typedef Misc_tag type; }; template struct Typedef_tag_type; //template struct Read_tag_type {}; @@ -82,12 +82,18 @@ namespace CGAL { struct Provides_functor_i : Has_type_different_from, Null_type> {}; + struct Number_tag {}; + struct Discrete_tag {}; + struct Object_tag {}; + template struct Get_type_category; -#define DECL_OBJ_(X) \ +#define DECL_OBJ_(X,Y) \ template \ - struct Typedef_tag_type : Base { typedef Obj X; } -#define DECL_OBJ(X) struct X##_tag {}; \ - DECL_OBJ_(X) + struct Typedef_tag_type : Base { typedef Obj X; }; \ + template \ + struct Get_type_category { typedef Y##_tag type; } +#define DECL_OBJ(X,Y) struct X##_tag {}; \ + DECL_OBJ_(X,Y) //namespace has_object { BOOST_MPL_HAS_XXX_TRAIT_DEF(X) } //template @@ -96,31 +102,43 @@ namespace CGAL { //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(FT, Number); + DECL_OBJ(RT, Number); - //DECL_OBJ(Boolean); // FIXME: Boolean_tag is already taken, and is a template :-( - DECL_OBJ(Comparison_result); - DECL_OBJ(Sign); - DECL_OBJ(Orientation); // Note: duplicate with the functor tag! - DECL_OBJ(Oriented_side); - DECL_OBJ(Bounded_side); - DECL_OBJ(Angle); + DECL_OBJ(Bool, Discrete); // Boolean_tag is already taken, and is a template :-( + DECL_OBJ(Comparison_result, Discrete); + DECL_OBJ(Sign, Discrete); + DECL_OBJ(Orientation, Discrete); // Note: duplicate with the functor tag! + DECL_OBJ(Oriented_side, Discrete); + DECL_OBJ(Bounded_side, Discrete); + DECL_OBJ(Angle, Discrete); - DECL_OBJ(Vector); - DECL_OBJ(Point); - DECL_OBJ(Segment); - DECL_OBJ(Sphere); - DECL_OBJ(Line); - DECL_OBJ(Direction); - DECL_OBJ(Hyperplane); - DECL_OBJ(Ray); - DECL_OBJ(Iso_box); - DECL_OBJ(Bbox); - DECL_OBJ(Aff_transformation); + DECL_OBJ(Vector, Object); + DECL_OBJ(Point, Object); + DECL_OBJ(Segment, Object); + DECL_OBJ(Sphere, Object); + DECL_OBJ(Line, Object); + DECL_OBJ(Direction, Object); + DECL_OBJ(Hyperplane, Object); + DECL_OBJ(Ray, Object); + DECL_OBJ(Iso_box, Object); + DECL_OBJ(Bbox, Object); + DECL_OBJ(Aff_transformation, Object); #undef DECL_OBJ_ #undef DECL_OBJ +#define SMURF2(A,B) CGAL_KD_DEFAULT_TYPE(A,(typename Same_uncertainty_nt::type>::type),(RT_tag),()) +#define SMURF1(A) SMURF2(A,CGAL::A) + SMURF2(Bool, bool); + SMURF1(Sign); + SMURF1(Comparison_result); + SMURF1(Orientation); + SMURF1(Oriented_side); + SMURF1(Bounded_side); + SMURF1(Angle); +#undef SMURF1 +#undef SMURF2 + template struct is_NT_tag { enum { value = false }; }; template<> struct is_NT_tag { enum { value = true }; }; template<> struct is_NT_tag { enum { value = true }; }; @@ -131,7 +149,7 @@ namespace CGAL { }; #define DECL_COMPUTE(X) struct X##_tag {}; \ - template<>struct map_functor_type{typedef Compute_tag type;} + templatestruct Get_functor_category{typedef Compute_tag type;} DECL_COMPUTE(Compute_point_cartesian_coordinate); DECL_COMPUTE(Compute_vector_cartesian_coordinate); DECL_COMPUTE(Compute_homogeneous_coordinate); @@ -166,15 +184,16 @@ namespace CGAL { templatestruct map_result_tag{typedef Null_type type;}; templatestruct map_result_tag >{typedef T type;}; - templatestruct map_functor_type > : + templatestruct Get_functor_category,B,C> : BOOSTD conditional::is_iterator, Construct_iterator_tag, Construct_tag> {}; - templatestruct map_functor_type >{typedef Misc_tag type;}; + // Really? + templatestruct Get_functor_category,B,C>{typedef Misc_tag type;}; #define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ template<>struct map_result_tag{typedef Y##_tag type;}; \ - template<>struct map_functor_type{typedef Construct_tag type;} + templatestruct Get_functor_category{typedef Construct_tag type;} DECL_CONSTRUCT(Midpoint,Point); DECL_CONSTRUCT(Center_of_sphere,Point); DECL_CONSTRUCT(Segment_extremity,Point); @@ -199,7 +218,7 @@ namespace CGAL { //FIXME: choose a convention: prefix with Predicate_ ? #define DECL_PREDICATE_(X) \ - template<>struct map_functor_type{typedef Predicate_tag type;} + templatestruct Get_functor_category{typedef Predicate_tag type;} #define DECL_PREDICATE(X) struct X##_tag {}; \ DECL_PREDICATE_(X) DECL_PREDICATE(Less_point_cartesian_coordinate); @@ -220,7 +239,7 @@ namespace CGAL { #undef DECL_PREDICATE #define DECL_MISC(X) struct X##_tag {}; \ - template<>struct map_functor_type{typedef Misc_tag type;} + templatestruct Get_functor_category{typedef Misc_tag type;} //TODO: split into _begin and _end ? //DECL_MISC(Construct_point_cartesian_const_iterator); //DECL_MISC(Construct_vector_cartesian_const_iterator); diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index c825634d97a..2acd2ba93e8 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -237,27 +237,27 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) // What to do with O? pass it down to other functors or drop it? #define CGAL_KD_DEFAULT_FUNCTOR(Tg,Name,ReqTyp,ReqFun) \ template \ - struct Get_functor::value \ + Provides_functor_i::value \ || !Provides_types >::value \ || !Provides_functors >::value \ , int, void>::type> \ { \ - typedef Name type; \ + typedef CGAL_STRIP_PAREN_ Name type; \ } // Not used yet, may need some changes. #define CGAL_KD_DEFAULT_TYPE(Tg,Name,ReqTyp,ReqFun) \ template \ - struct Get_type::value \ + Provides_type_i::value \ || !Provides_types >::value \ || !Provides_functors >::value \ , int, void>::type> \ { \ - typedef Name type; \ + typedef CGAL_STRIP_PAREN_ Name type; \ } diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 3cfabe8b3b2..9f4ab5eec41 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -9,7 +9,7 @@ normal: ./a.out cxx0x: - g++ -std=c++0x -O2 test.cpp -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include ${EIGEN_INC} ${CGAL_INC} - ./a.out + g++ -std=c++0x -O2 test.cpp -lCGAL -lboost_thread -frounding-math -Wall -Wextra -I. -lmpfr -lgmp -DCGAL_CXX0X -I../../include ${EIGEN_INC} ${CGAL_INC} -o b.out + ./b.out #-DBOOST_RESULT_OF_USE_DECLTYPE From 3639c6db61c145073abdea01d2b96b06eb7a287e Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 1 Jan 2013 22:48:11 +0100 Subject: [PATCH 172/210] Move more stuff out of interface_macros.h (should disappear soon). --- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 2 +- .../include/CGAL/Kernel_d/Types/Hyperplane.h | 9 +- .../Kernel_d/function_objects_cartesian.h | 93 ++++++++++++++++-- .../include/CGAL/Kernel_d/interface_macros.h | 94 +++++++++---------- NewKernel_d/include/CGAL/functor_tags.h | 2 +- NewKernel_d/include/CGAL/marcutils.h | 8 +- 6 files changed, 146 insertions(+), 62 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 800adccd0da..8a5747021bf 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -239,6 +239,6 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel } -CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation,(CartesianDKernelFunctors::In_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); +CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,(CartesianDKernelFunctors::In_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); } #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h index 8f83718759c..2d23d4c88b8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h @@ -4,7 +4,6 @@ namespace CGAL { template class Hyperplane { typedef typename Get_type::type FT_; - typedef typename Get_type::type Point_; typedef typename Get_type::type Vector_; Vector_ v_; FT_ s_; @@ -20,7 +19,6 @@ namespace CartesianDKernelFunctors { template struct Construct_hyperplane : Store_kernel { CGAL_FUNCTOR_INIT_STORE(Construct_hyperplane) typedef typename Get_type::type result_type; - typedef typename Get_type::type Point; typedef typename Get_type::type Vector; typedef typename Get_type::type FT; typedef typename R_::LA LA; @@ -35,7 +33,7 @@ template struct Construct_hyperplane : Store_kernel { template struct Orthogonal_vector { CGAL_FUNCTOR_INIT_IGNORE(Orthogonal_vector) typedef typename Get_type::type Hyperplane; - typedef typename Get_type::type result_type; + typedef typename Get_type::type result_type; result_type operator()(Hyperplane const&s)const{ return s.orthogonal_vector(); } @@ -50,5 +48,10 @@ template struct Hyperplane_translation { } }; } +//TODO: Add a condition that the hyperplane type is the one from this file. +CGAL_KD_DEFAULT_TYPE(Hyperplane_tag,(CGAL::Hyperplane),(Vector_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_hyperplane),(Vector_tag,Hyperplane_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Orthogonal_vector_tag,(CartesianDKernelFunctors::Orthogonal_vector),(Vector_tag,Hyperplane_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Hyperplane_translation_tag,(CartesianDKernelFunctors::Hyperplane_translation),(Hyperplane_tag),()); } // namespace CGAL #endif 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 c28af8c41f1..c6f671cb3b9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #ifdef CGAL_CXX0X #include @@ -147,9 +148,11 @@ template struct Orientation_of_points,true> : priv #undef VAR #endif +} +CGAL_KD_DEFAULT_FUNCTOR(Orientation_of_points_tag,(CartesianDKernelFunctors::Orientation_of_points),(Point_tag),(Point_dimension_tag,Compute_point_cartesian_coordinate_tag)); - +namespace CartesianDKernelFunctors { template struct Orientation_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_vectors) typedef R_ R; @@ -161,6 +164,7 @@ template struct Orientation_of_vectors : private Store_kernel { result_type operator()(Iter f, Iter e)const{ typename Get_functor::type c(this->kernel()); typename Get_functor::type vd(this->kernel()); + // FIXME: Uh? Using it on a vector ?! Vector const& v0=*f; int d=vd(v0); Matrix m(d,d); @@ -190,7 +194,11 @@ template struct Orientation_of_vectors : private Store_kernel { //TODO #endif }; +} +CGAL_KD_DEFAULT_FUNCTOR(Orientation_of_vectors_tag,(CartesianDKernelFunctors::Orientation_of_vectors),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); + +namespace CartesianDKernelFunctors { #if 0 template::value> struct Orientation : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation) @@ -301,7 +309,11 @@ template struct Side_of_oriented_sphere : private Store_kernel { //TODO #endif }; +} +CGAL_KD_DEFAULT_FUNCTOR(Side_of_oriented_sphere_tag,(CartesianDKernelFunctors::Side_of_oriented_sphere),(Point_tag),(Point_dimension_tag,Squared_distance_to_origin_tag,Compute_point_cartesian_coordinate_tag)); + +namespace CartesianDKernelFunctors { template struct Point_to_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Point_to_vector) typedef R_ R; @@ -317,7 +329,11 @@ template struct Point_to_vector : private Store_kernel { return CV(this->kernel())(ci(v,Begin_tag(),ci(v,End_tag()))); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Point_to_vector_tag,(CartesianDKernelFunctors::Point_to_vector),(Point_tag,Vector_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Vector_to_point : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Vector_to_point) typedef R_ R; @@ -333,7 +349,11 @@ template struct Vector_to_point : private Store_kernel { return CV(this->kernel())(ci(v,Begin_tag(),ci(v,End_tag()))); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Vector_to_point_tag,(CartesianDKernelFunctors::Vector_to_point),(Point_tag,Vector_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Opposite_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Opposite_vector) typedef R_ R; @@ -348,7 +368,11 @@ template struct Opposite_vector : private Store_kernel { return CV(this->kernel())(make_transforming_iterator(ci(v,Begin_tag()),std::negate()),make_transforming_iterator(ci(v,End_tag()),std::negate())); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Opposite_vector_tag,(CartesianDKernelFunctors::Opposite_vector),(Vector_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Scaled_vector : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Scaled_vector) typedef R_ R; @@ -364,7 +388,11 @@ template struct Scaled_vector : private Store_kernel { return CV(this->kernel())(make_transforming_iterator(ci(v,Begin_tag()),Scale(s)),make_transforming_iterator(ci(v,End_tag()),Scale(s))); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Scaled_vector_tag,(CartesianDKernelFunctors::Scaled_vector),(Vector_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Sum_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Sum_of_vectors) typedef R_ R; @@ -380,7 +408,11 @@ template struct Sum_of_vectors : private Store_kernel { return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::plus())); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Sum_of_vectors_tag,(CartesianDKernelFunctors::Sum_of_vectors),(Vector_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Difference_of_vectors : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_vectors) typedef R_ R; @@ -396,7 +428,11 @@ template struct Difference_of_vectors : private Store_kernel { return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Difference_of_vectors_tag,(CartesianDKernelFunctors::Difference_of_vectors),(Vector_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Translated_point : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Translated_point) typedef R_ R; @@ -415,7 +451,11 @@ template struct Translated_point : private Store_kernel { return CP(this->kernel())(make_transforming_pair_iterator(cpi(a,Begin_tag()),cvi(b,Begin_tag()),std::plus()),make_transforming_pair_iterator(cpi(a,End_tag()),cvi(b,End_tag()),std::plus())); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Translated_point_tag,(CartesianDKernelFunctors::Translated_point),(Point_tag, Vector_tag),(Construct_ttag, Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Difference_of_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Difference_of_points) typedef R_ R; @@ -432,7 +472,11 @@ template struct Difference_of_points : private Store_kernel { return CV(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),std::minus()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),std::minus())); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Difference_of_points_tag,(CartesianDKernelFunctors::Difference_of_points),(Point_tag, Vector_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Midpoint : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Midpoint) typedef R_ R; @@ -457,7 +501,11 @@ template struct Midpoint : private Store_kernel { return CP(this->kernel())(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),Average()),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),Average())); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Midpoint_tag,(CartesianDKernelFunctors::Midpoint),(Point_tag),(Construct_ttag, Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Squared_length : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_length) typedef R_ R; @@ -473,7 +521,11 @@ template struct Squared_length : private Store_kernel { return std::accumulate(make_transforming_iterator(ci(a,Begin_tag()),f),make_transforming_iterator(ci(a,End_tag()),f),RT(0)); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Squared_length_tag,(CartesianDKernelFunctors::Squared_length),(Vector_tag),(Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Squared_distance_to_origin : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_distance_to_origin) typedef R_ R; @@ -489,7 +541,11 @@ template struct Squared_distance_to_origin : private Store_kernel return std::accumulate(make_transforming_iterator(ci(a,Begin_tag()),f),make_transforming_iterator(ci(a,End_tag()),f),RT(0)); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Squared_distance_to_origin_tag,(CartesianDKernelFunctors::Squared_distance_to_origin),(Point_tag),(Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Squared_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Squared_distance) typedef R_ R; @@ -511,7 +567,11 @@ template struct Squared_distance : private Store_kernel { return std::accumulate(make_transforming_pair_iterator(ci(a,Begin_tag()),ci(b,Begin_tag()),f),make_transforming_pair_iterator(ci(a,End_tag()),ci(b,End_tag()),f),RT(0)); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Squared_distance_tag,(CartesianDKernelFunctors::Squared_distance),(Point_tag),(Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Compare_distance : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_distance) typedef R_ R; @@ -531,7 +591,11 @@ template struct Compare_distance : private Store_kernel { return CGAL_NTS compare(csd(a,b),csd(c,d)); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Compare_distance_tag,(CartesianDKernelFunctors::Compare_distance),(Point_tag),(Squared_distance_tag)); + +namespace CartesianDKernelFunctors { template struct Less_point_cartesian_coordinate : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_point_cartesian_coordinate) typedef R_ R; @@ -547,7 +611,11 @@ template struct Less_point_cartesian_coordinate : private Store_kernel return c(a,i)),(),(Compute_point_cartesian_coordinate_tag)); + +namespace CartesianDKernelFunctors { template struct Compare_point_cartesian_coordinate : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_point_cartesian_coordinate) typedef R_ R; @@ -563,7 +631,11 @@ template struct Compare_point_cartesian_coordinate : private Store_ker return CGAL_NTS compare(c(a,i),c(b,i)); } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Compare_point_cartesian_coordinate_tag,(CartesianDKernelFunctors::Compare_point_cartesian_coordinate),(),(Compute_point_cartesian_coordinate_tag)); + +namespace CartesianDKernelFunctors { template struct Compare_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Compare_lexicographically) typedef R_ R; @@ -592,7 +664,11 @@ template struct Compare_lexicographically : private Store_kernel { return res; } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Compare_lexicographically_tag,(CartesianDKernelFunctors::Compare_lexicographically),(),(Construct_ttag)); + +namespace CartesianDKernelFunctors { template struct Less_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_lexicographically) typedef R_ R; @@ -606,7 +682,11 @@ template struct Less_lexicographically : private Store_kernel { return c(a,b) < 0; } }; +} +CGAL_KD_DEFAULT_FUNCTOR(Less_lexicographically_tag,(CartesianDKernelFunctors::Less_lexicographically),(),(Compare_lexicographically_tag)); + +namespace CartesianDKernelFunctors { template struct Less_or_equal_lexicographically : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Less_or_equal_lexicographically) typedef R_ R; @@ -620,11 +700,11 @@ template struct Less_or_equal_lexicographically : private Store_kernel return c(a,b) <= 0; } }; - } -CGAL_KD_DEFAULT_FUNCTOR(Less_or_equal_lexicographically,(CartesianDKernelFunctors::Less_or_equal_lexicographically),(),(Compare_lexicographically_tag)); -namespace CartesianDKernelFunctors { +CGAL_KD_DEFAULT_FUNCTOR(Less_or_equal_lexicographically_tag,(CartesianDKernelFunctors::Less_or_equal_lexicographically),(),(Compare_lexicographically_tag)); + +namespace CartesianDKernelFunctors { template struct Equal_points : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Equal_points) typedef R_ R; @@ -652,9 +732,10 @@ template struct Equal_points : private Store_kernel { return res; } }; - - } + +CGAL_KD_DEFAULT_FUNCTOR(Equal_points_tag,(CartesianDKernelFunctors::Equal_points),(),(Construct_ttag)); + } #include #endif // CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index daa95585852..b0df215a817 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -41,7 +41,7 @@ CGAL_Kernel_obj2(Segment,segment) CGAL_Kernel_obj2(Sphere,sphere) CGAL_Kernel_obj3(Line,line) CGAL_Kernel_obj3(Ray,ray) -CGAL_Kernel_obj3(Hyperplane,hyperplane) +//CGAL_Kernel_obj3(Hyperplane,hyperplane) CGAL_Kernel_obj3(Aff_transformation,aff_transformation) CGAL_Kernel_obj3(Iso_box,iso_box) @@ -49,28 +49,28 @@ CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, construct_point_cartesian_const_iterator_object) CGAL_Kernel_cons1(Construct_vector_cartesian_const_iterator, construct_vector_cartesian_const_iterator_object) -CGAL_Kernel_cons2(Sum_of_vectors, - sum_of_vectors_object) -CGAL_Kernel_cons2(Difference_of_vectors, - difference_of_vectors_object) -CGAL_Kernel_cons2(Translated_point, - translated_point_object) -CGAL_Kernel_cons2(Opposite_vector, - opposite_vector_object) -CGAL_Kernel_cons2(Scaled_vector, - scaled_vector_object) -CGAL_Kernel_cons2(Difference_of_points, - difference_of_points_object) -CGAL_Kernel_cons2(Vector_to_point, - vector_to_point_object) -CGAL_Kernel_cons2(Point_to_vector, - point_to_vector_object) -CGAL_Kernel_cons2(Midpoint, - midpoint_object) -CGAL_Kernel_cons2(Orthogonal_vector, - orthogonal_vector_object) -CGAL_Kernel_cons2(Hyperplane_translation, - hyperplane_translation_object) +//CGAL_Kernel_cons2(Sum_of_vectors, +// sum_of_vectors_object) +//CGAL_Kernel_cons2(Difference_of_vectors, +// difference_of_vectors_object) +//CGAL_Kernel_cons2(Translated_point, +// translated_point_object) +//CGAL_Kernel_cons2(Opposite_vector, +// opposite_vector_object) +//CGAL_Kernel_cons2(Scaled_vector, +// scaled_vector_object) +//CGAL_Kernel_cons2(Difference_of_points, +// difference_of_points_object) +//CGAL_Kernel_cons2(Vector_to_point, +// vector_to_point_object) +//CGAL_Kernel_cons2(Point_to_vector, +// point_to_vector_object) +//CGAL_Kernel_cons2(Midpoint, +// midpoint_object) +//CGAL_Kernel_cons2(Orthogonal_vector, +// orthogonal_vector_object) +//CGAL_Kernel_cons2(Hyperplane_translation, +// hyperplane_translation_object) //CGAL_Kernel_cons2(Construct_segment, // construct_segment_object) CGAL_Kernel_cons2(Segment_extremity, @@ -80,35 +80,35 @@ CGAL_Kernel_comp1(Compute_point_cartesian_coordinate, compute_point_cartesian_coordinate_object) CGAL_Kernel_comp1(Compute_vector_cartesian_coordinate, compute_vector_cartesian_coordinate_object) -CGAL_Kernel_comp2(Squared_length, - squared_length_object) -CGAL_Kernel_comp2(Squared_distance, - squared_distance_object) -CGAL_Kernel_comp2(Squared_distance_to_origin, - squared_distance_to_origin_object) +//CGAL_Kernel_comp2(Squared_length, +// squared_length_object) +//CGAL_Kernel_comp2(Squared_distance, +// squared_distance_object) +//CGAL_Kernel_comp2(Squared_distance_to_origin, +// squared_distance_to_origin_object) #if 0 CGAL_Kernel_pred(Orientation, orientation_object) #endif -CGAL_Kernel_pred(Orientation_of_points, - orientation_of_points_object) -CGAL_Kernel_pred(Orientation_of_vectors, - orientation_of_vectors_object) -CGAL_Kernel_pred(Side_of_oriented_sphere, - side_of_oriented_sphere_object) -CGAL_Kernel_pred(Less_point_cartesian_coordinate, - less_point_cartesian_coordinate_object) -CGAL_Kernel_pred(Compare_point_cartesian_coordinate, - compare_point_cartesian_coordinate_object) -CGAL_Kernel_pred(Compare_distance, - compare_distance_object) -CGAL_Kernel_pred(Compare_lexicographically, - compare_lexicographically_object) -CGAL_Kernel_pred(Less_lexicographically, - less_lexicographically_object) -CGAL_Kernel_pred(Equal_points, - equal_points_object) +//CGAL_Kernel_pred(Orientation_of_points, +// orientation_of_points_object) +//CGAL_Kernel_pred(Orientation_of_vectors, +// orientation_of_vectors_object) +//CGAL_Kernel_pred(Side_of_oriented_sphere, +// side_of_oriented_sphere_object) +//CGAL_Kernel_pred(Less_point_cartesian_coordinate, +// less_point_cartesian_coordinate_object) +//CGAL_Kernel_pred(Compare_point_cartesian_coordinate, +// compare_point_cartesian_coordinate_object) +//CGAL_Kernel_pred(Compare_distance, +// compare_distance_object) +//CGAL_Kernel_pred(Compare_lexicographically, +// compare_lexicographically_object) +//CGAL_Kernel_pred(Less_lexicographically, +// less_lexicographically_object) +//CGAL_Kernel_pred(Equal_points, +// equal_points_object) //CGAL_Kernel_pred(Less_or_equal_lexicographically, // less_or_equal_lexicographically_object) CGAL_Kernel_pred(Contained_in_affine_hull, diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 5a048d86da0..7e9d50b8614 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -127,7 +127,7 @@ namespace CGAL { #undef DECL_OBJ_ #undef DECL_OBJ -#define SMURF2(A,B) CGAL_KD_DEFAULT_TYPE(A,(typename Same_uncertainty_nt::type>::type),(RT_tag),()) +#define SMURF2(A,B) CGAL_KD_DEFAULT_TYPE(A##_tag,(typename Same_uncertainty_nt::type>::type),(RT_tag),()) #define SMURF1(A) SMURF2(A,CGAL::A) SMURF2(Bool, bool); SMURF1(Sign); diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 2acd2ba93e8..6709b84598e 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -237,9 +237,9 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) // What to do with O? pass it down to other functors or drop it? #define CGAL_KD_DEFAULT_FUNCTOR(Tg,Name,ReqTyp,ReqFun) \ template \ - struct Get_functor::value \ + Provides_functor_i::value \ || !Provides_types >::value \ || !Provides_functors >::value \ , int, void>::type> \ @@ -250,9 +250,9 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) // Not used yet, may need some changes. #define CGAL_KD_DEFAULT_TYPE(Tg,Name,ReqTyp,ReqFun) \ template \ - struct Get_type::value \ + Provides_type_i::value \ || !Provides_types >::value \ || !Provides_functors >::value \ , int, void>::type> \ From 0892dad33e75a0db6c669c9da4247878a6467fb8 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 1 Jan 2013 23:33:10 +0100 Subject: [PATCH 173/210] Continue moving stuff out of interface_macros. If no RT is specified, default to FT. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 1 - NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 3 +++ NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h | 4 ++++ .../include/CGAL/Kernel_d/interface_macros.h | 14 +++++++------- NewKernel_d/include/CGAL/functor_tags.h | 3 +++ 5 files changed, 17 insertions(+), 8 deletions(-) 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 b3f9800fbef..870a08e912a 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -47,7 +47,6 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type {}; template struct Type< Point_tag, D> { typedef Vector_ type; }; template struct Type { typedef Vector_ type; }; - template struct Type< RT_tag, D> { typedef FT_ type; }; template struct Type< FT_tag, D> { typedef FT_ type; }; typedef typeset diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 8a5747021bf..d5397f3dab0 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -240,5 +240,8 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel } CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,(CartesianDKernelFunctors::In_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); +CGAL_KD_DEFAULT_FUNCTOR(In_flat_side_of_oriented_sphere_tag,(CartesianDKernelFunctors::In_flat_side_of_oriented_sphere),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Construct_flat_orientation_tag,(CartesianDKernelFunctors::Construct_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Contained_in_affine_hull_tag,(CartesianDKernelFunctors::Contained_in_affine_hull),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); } #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h index 7982f86936c..cc9c163b58b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h @@ -48,5 +48,9 @@ template struct Squared_radius { } }; } +CGAL_KD_DEFAULT_TYPE(Sphere_tag,(CGAL::Sphere),(Point_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_sphere),(Sphere_tag,Point_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Center_of_sphere_tag,(CartesianDKernelFunctors::Center_of_sphere),(Sphere_tag,Point_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Squared_radius_tag,(CartesianDKernelFunctors::Squared_radius),(Sphere_tag),()); } // namespace CGAL #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index b0df215a817..0893bdde511 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -38,7 +38,7 @@ CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) CGAL_Kernel_obj2(Segment,segment) -CGAL_Kernel_obj2(Sphere,sphere) +//CGAL_Kernel_obj2(Sphere,sphere) CGAL_Kernel_obj3(Line,line) CGAL_Kernel_obj3(Ray,ray) //CGAL_Kernel_obj3(Hyperplane,hyperplane) @@ -111,14 +111,14 @@ CGAL_Kernel_pred(Orientation, // equal_points_object) //CGAL_Kernel_pred(Less_or_equal_lexicographically, // less_or_equal_lexicographically_object) -CGAL_Kernel_pred(Contained_in_affine_hull, - contained_in_affine_hull_object) +//CGAL_Kernel_pred(Contained_in_affine_hull, +// contained_in_affine_hull_object) //CGAL_Kernel_pred(In_flat_orientation, // in_flat_orientation_object) -CGAL_Kernel_pred(In_flat_side_of_oriented_sphere, - in_flat_side_of_oriented_sphere_object) -CGAL_Kernel_pred(Construct_flat_orientation, - construct_flat_orientation_object) +//CGAL_Kernel_pred(In_flat_side_of_oriented_sphere, +// in_flat_side_of_oriented_sphere_object) +//CGAL_Kernel_pred(Construct_flat_orientation, +// construct_flat_orientation_object) #undef CGAL_Kernel_pred #undef CGAL_Kernel_comp diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 7e9d50b8614..f5fbd00358e 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -127,6 +127,8 @@ namespace CGAL { #undef DECL_OBJ_ #undef DECL_OBJ + CGAL_KD_DEFAULT_TYPE(RT_tag,(typename Get_type::type),(FT_tag),()); + #define SMURF2(A,B) CGAL_KD_DEFAULT_TYPE(A##_tag,(typename Same_uncertainty_nt::type>::type),(RT_tag),()) #define SMURF1(A) SMURF2(A,CGAL::A) SMURF2(Bool, bool); @@ -139,6 +141,7 @@ namespace CGAL { #undef SMURF1 #undef SMURF2 + // TODO: replace with Get_type_category template struct is_NT_tag { enum { value = false }; }; template<> struct is_NT_tag { enum { value = true }; }; template<> struct is_NT_tag { enum { value = true }; }; From 02516c9e5e7bc932022244b9570d5baf67d7e51b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 2 Jan 2013 00:40:14 +0100 Subject: [PATCH 174/210] If FT is not provided, use Quotient (for a future homogeneous?). Avoid circular references :-/ --- NewKernel_d/include/CGAL/functor_tags.h | 3 ++- NewKernel_d/include/CGAL/marcutils.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index f5fbd00358e..53d3a794289 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -127,7 +127,8 @@ namespace CGAL { #undef DECL_OBJ_ #undef DECL_OBJ - CGAL_KD_DEFAULT_TYPE(RT_tag,(typename Get_type::type),(FT_tag),()); + CGAL_KD_DEFAULT_TYPE(RT_tag,(typename Get_type::type),(),()); + CGAL_KD_DEFAULT_TYPE(FT_tag,(CGAL::Quotient::type>),(),()); #define SMURF2(A,B) CGAL_KD_DEFAULT_TYPE(A##_tag,(typename Same_uncertainty_nt::type>::type),(RT_tag),()) #define SMURF1(A) SMURF2(A,CGAL::A) diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 6709b84598e..8daa2323ef5 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -232,6 +232,7 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) } // TODO: make a Cartesian-only variant +// WARNING: do not use the Req* parameters too much, they can cause circular instanciations and are only useful for dispatching. #define CGAL_STRIP_PAREN_(...) __VA_ARGS__ #define CGAL_STRIP_PAREN(...) CGAL_STRIP_PAREN_ __VA_ARGS__ // What to do with O? pass it down to other functors or drop it? From 76c8258107c10e052ffb6dc5bdaf8ec3955ac8a4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 2 Jan 2013 16:05:23 +0100 Subject: [PATCH 175/210] Use a single wrapper for reference counted objects. --- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 10 +- .../CGAL/Kernel_d/Wrapper/Point_rc_d.h | 104 ------------------ .../CGAL/Kernel_d/Wrapper/Ref_count_obj.h | 101 +++++++++++++++++ .../CGAL/Kernel_d/Wrapper/Vector_rc_d.h | 98 ----------------- 4 files changed, 105 insertions(+), 208 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h create mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Ref_count_obj.h delete mode 100644 NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index bd5dcbea306..2c457be3412 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -9,8 +9,7 @@ #include #include -#include -#include +#include #include @@ -160,12 +159,11 @@ struct Cartesian_refcount : public Base_ typedef Base_ Kernel_base; typedef Cartesian_refcount Self; - //FIXME: Use object_list (or a list passed as argument) - //TODO: A generic object wrapper should work just fine, no need to have a different one for each type. + // FIXME: Use object_list, or a list passed as argument, or anything + // automatic. template struct Type : Get_type {}; #define CGAL_Kernel_obj(X,Y) \ - template struct Type { typedef X##_rc_d type; }; \ - typedef X##_rc_d X; + template struct Type { typedef Ref_count_obj type; }; CGAL_Kernel_obj(Point,point) CGAL_Kernel_obj(Vector,vector) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h deleted file mode 100644 index 7a07ad0a036..00000000000 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Point_rc_d.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef CGAL_WRAPPER_POINT_RC_D_H -#define CGAL_WRAPPER_POINT_RC_D_H - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef CGAL_CXX0X -#include -#endif -#include - -// no need for a fancy interface here, people can use the Point_d wrapper on -// top. - -// I don't remember why this type even exists, why it isn't just Handle_for (or something similar because of limitations in the interface of Handle_for) - -namespace CGAL { - -template -class Point_rc_d -{ - typedef typename R_::Kernel_base Kbase; - typedef typename Get_functor >::type CPBase; - typedef typename Get_functor::type CCBase; - - typedef Point_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::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 R_::Point_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Get_type::type Rep; - typedef Handle_for Data; - -private: - Data data; -public: - - const Rep& rep() const - { - return CGAL::get(data); - } - -#ifdef CGAL_CXX0X - template::type...>,std::tuple >::value>::type> explicit Point_rc_d(U&&...u) - : data(Eval_functor(),CPBase(),std::forward(u)...){} - - template explicit Point_rc_d(Eval_functor&&,F&&f,U&&...u) - : data(Eval_functor(),std::forward(f),std::forward(u)...){} - - // try not to use these - Point_rc_d(Rep const& v) : data(v) {} - Point_rc_d(Rep& v) : data(static_cast(v)) {} - Point_rc_d(Rep&& v) : data(std::move(v)) {} - - // this one should be implicit - Point_rc_d(Origin const& v) - : data(Eval_functor(),CPBase(),v) {} - Point_rc_d(Origin& v) - : data(Eval_functor(),CPBase(),v) {} - Point_rc_d(Origin&& v) - : data(Eval_functor(),CPBase(),std::move(v)) {} - -#else - - Point_rc_d() : data(Eval_functor(),CPBase()) {} - - Point_rc_d(Rep const& v) : data(v) {} // try not to use it - -#define CODE(Z,N,_) template \ - explicit Point_rc_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : data(Eval_functor(),CPBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ - \ - template \ - Point_rc_d(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,CODE,_) -#undef CODE - template - Point_rc_d(Eval_functor,F const& f) - : data(Eval_functor(),f) {} - - // this one should be implicit - Point_rc_d(Origin const& o) - : data(Eval_functor(),CPBase(),o) {} - -#endif - -}; - -} //namespace CGAL - -#endif // CGAL_WRAPPER_POINT_RC_D_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Ref_count_obj.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Ref_count_obj.h new file mode 100644 index 00000000000..ec87fffed54 --- /dev/null +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Ref_count_obj.h @@ -0,0 +1,101 @@ +#ifndef CGAL_WRAPPER_REF_COUNT_OBJ_H +#define CGAL_WRAPPER_REF_COUNT_OBJ_H + +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef CGAL_CXX0X +#include +#endif +#include + +// no need for a fancy interface here, people can use the Point_d wrapper on +// top. + +namespace CGAL { + +template +class Ref_count_obj +{ + typedef typename R_::Kernel_base Kbase; + typedef typename Get_functor >::type CBase; + + typedef Ref_count_obj Self; + BOOST_STATIC_ASSERT((boost::is_same::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::type Rep; + typedef Handle_for Data; + +private: + Data data; +public: + + const Rep& rep() const + { + return CGAL::get(data); + } + +#ifdef CGAL_CXX0X + template::type...>,std::tuple >::value>::type> explicit Ref_count_obj(U&&...u) + : data(Eval_functor(),CBase(),std::forward(u)...){} + + template explicit Ref_count_obj(Eval_functor&&,F&&f,U&&...u) + : data(Eval_functor(),std::forward(f),std::forward(u)...){} + + // try not to use these + Ref_count_obj(Rep const& v) : data(v) {} + Ref_count_obj(Rep& v) : data(static_cast(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 CODE(Z,N,_) template \ + explicit Ref_count_obj(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ + : data(Eval_functor(),CBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ + \ + template \ + 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,CODE,_) +#undef CODE + template + 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/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h deleted file mode 100644 index 1f044fd937f..00000000000 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Vector_rc_d.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef CGAL_WRAPPER_VECTOR_RC_D_H -#define CGAL_WRAPPER_VECTOR_RC_D_H - -#include -#include -#include -#include -#include -#include -#include -#ifndef CGAL_CXX0X -#include -#endif -#include - -// no need for a fancy interface here, people can use the Vector_d wrapper on -// top. - -namespace CGAL { - -template -class Vector_rc_d -{ - typedef typename R_::Kernel_base Kbase; - typedef typename Get_functor >::type CVBase; - typedef typename Get_functor::type CCBase; - - typedef Vector_rc_d Self; - BOOST_STATIC_ASSERT((boost::is_same::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 R_::Vector_cartesian_const_iterator Cartesian_const_iterator; - typedef typename Get_type::type Rep; - typedef Handle_for Data; - -private: - Data data; -public: - - const Rep& rep() const - { - return CGAL::get(data); - } - -#ifdef CGAL_CXX0X - template::type...>,std::tuple >::value>::type> explicit Vector_rc_d(U&&...u) - : data(Eval_functor(),CVBase(),std::forward(u)...){} - - template explicit Vector_rc_d(Eval_functor&&,F&&f,U&&...u) - : data(Eval_functor(),std::forward(f),std::forward(u)...){} - - // try not to use these - Vector_rc_d(Rep const& v) : data(v) {} - Vector_rc_d(Rep& v) : data(static_cast(v)) {} - Vector_rc_d(Rep&& v) : data(std::move(v)) {} - - // this one should be implicit - Vector_rc_d(Null_vector const& v) - : data(Eval_functor(),CVBase(),v) {} - Vector_rc_d(Null_vector& v) - : data(Eval_functor(),CVBase(),v) {} - Vector_rc_d(Null_vector&& v) - : data(Eval_functor(),CVBase(),std::move(v)) {} - -#else - - Vector_rc_d() : data(Eval_functor(),CVBase()) {} - - Vector_rc_d(Rep const& v) : data(v) {} // try not to use it - -#define CODE(Z,N,_) template \ - explicit Vector_rc_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : data(Eval_functor(),CVBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ - \ - template \ - Vector_rc_d(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,CODE,_) -#undef CODE - - // this one should be implicit - Vector_rc_d(Null_vector const& v) - : data(Eval_functor(),CVBase(),v) {} - -#endif - -}; - -} //namespace CGAL - -#endif // CGAL_WRAPPER_VECTOR_RC_D_H From 382591aa025340b7692981904df4e35f0f20b68a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 4 Jan 2013 18:29:58 +0100 Subject: [PATCH 176/210] More types and functors under Get_*. --- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 1 + NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 2 +- .../include/CGAL/Kernel_d/Types/Aff_transformation.h | 5 ++++- NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h | 3 ++- NewKernel_d/include/CGAL/Kernel_d/Types/Line.h | 2 ++ NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h | 2 ++ .../include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 1 + NewKernel_d/include/CGAL/Kernel_d/interface_macros.h | 8 ++++---- NewKernel_d/include/CGAL/functor_tags.h | 1 + 11 files changed, 20 insertions(+), 9 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index d5397f3dab0..86470a98271 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -239,6 +239,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel } +CGAL_KD_DEFAULT_TYPE(Flat_orientation_tag,(CGAL::CartesianDKernelFunctors::Flat_orientation),(),()); CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,(CartesianDKernelFunctors::In_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); CGAL_KD_DEFAULT_FUNCTOR(In_flat_side_of_oriented_sphere_tag,(CartesianDKernelFunctors::In_flat_side_of_oriented_sphere),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); CGAL_KD_DEFAULT_FUNCTOR(Construct_flat_orientation_tag,(CartesianDKernelFunctors::Construct_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index 3c894cd6d9a..5bc5dbe7cf5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -138,7 +138,7 @@ typename typeset_intersection::Type const&x)const{return cr(x);} - typename K2::Flat_orientation const& operator()(typename K1::Flat_orientation const&o)const{return o;} // Both kernels should have the same, returning a reference should warn if not. + //typename K2::Flat_orientation const& operator()(typename K1::Flat_orientation const&o)const{return o;} // Both kernels should have the same, returning a reference should warn if not. template transforming_iterator,It>::type> diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 01d22443485..afd14fd5be6 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -24,7 +24,7 @@ template struct Kernel_d_interface : public Base_ { typedef typename Get_type::type Oriented_side; typedef typename Get_type::type Bounded_side; typedef typename Get_type::type Angle; - typedef typename Base::Flat_orientation Flat_orientation_d; + typedef typename Get_type::type Flat_orientation_d; typedef typename Get_type::type Point_d; typedef typename Get_type::type Vector_d; typedef typename Get_type::type Segment_d; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index d55f7438a82..07a79c0f07d 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -112,7 +112,7 @@ struct Lazy_cartesian : Dimension_base, typedef typename Exact_kernel::Kernel_tag Kernel_tag; typedef typename Exact_kernel::Default_ambient_dimension Default_ambient_dimension; typedef typename Exact_kernel::Max_ambient_dimension Max_ambient_dimension; - typedef typename Exact_kernel::Flat_orientation Flat_orientation; + //typedef typename Exact_kernel::Flat_orientation Flat_orientation; // Check that Approximate_kernel agrees with all that... template::type> struct Functor { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h index 836862666c9..27f01671e2b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Aff_transformation.h @@ -14,7 +14,7 @@ namespace CartesianDKernelFunctors { template struct Construct_aff_transformation { CGAL_FUNCTOR_INIT_IGNORE(Construct_aff_transformation) typedef R_ R; - typedef typename R::Aff_transformation result_type; + typedef typename Get_type::type result_type; #ifdef CGAL_CXX0X template result_type operator()(T&&...)const{return result_type();} @@ -32,5 +32,8 @@ template struct Construct_aff_transformation { #endif }; } +CGAL_KD_DEFAULT_TYPE(Aff_transformation_tag,(CGAL::Aff_transformation),(),()); +CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_aff_transformation),(Aff_transformation_tag),()); + } #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h index 669e16697c7..8559ed39af8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Iso_box.h @@ -27,7 +27,6 @@ namespace CartesianDKernelFunctors { typedef typename Get_type::type result_type; typedef typename Get_type::type RT; typedef typename Get_type::type Point; - typedef typename Get_type::type Vector; typedef typename Get_functor >::type Cp_; typedef typename Get_functor >::type Ci_; result_type operator()(Point const&a, Point const&b)const{ @@ -42,6 +41,8 @@ namespace CartesianDKernelFunctors { } }; } +CGAL_KD_DEFAULT_TYPE(Iso_box_tag,(CGAL::Iso_box),(Point_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_iso_box),(Iso_box_tag,Point_tag),(Construct_ttag,Construct_ttag)); } // namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h index 7b984b038d1..338bdd00b46 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Line.h @@ -39,6 +39,8 @@ namespace CartesianDKernelFunctors { } }; } +CGAL_KD_DEFAULT_TYPE(Line_tag,(CGAL::Line),(Point_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_line),(Line_tag,Point_tag,Vector_tag),(Translated_point_tag)); } // namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h index 49652020d57..2dfcf2b2ba4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Ray.h @@ -39,6 +39,8 @@ namespace CartesianDKernelFunctors { } }; } +CGAL_KD_DEFAULT_TYPE(Ray_tag,(CGAL::Ray),(Point_tag,Vector_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_ray),(Point_tag,Ray_tag,Vector_tag),(Difference_of_points_tag)); } // namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 2c457be3412..b0a5a5773d9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -123,6 +123,7 @@ struct Cartesian_wrap : public Base_ typedef Null_functor type; }; + // FIXME: only when the return type is wrapped! See refcount, which does it better. template struct Functor { typedef typename Get_functor::type B; struct type { diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 0893bdde511..82cff999880 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -39,11 +39,11 @@ CGAL_Kernel_obj1(Vector,vector) CGAL_Kernel_obj1(Point,point) CGAL_Kernel_obj2(Segment,segment) //CGAL_Kernel_obj2(Sphere,sphere) -CGAL_Kernel_obj3(Line,line) -CGAL_Kernel_obj3(Ray,ray) +//CGAL_Kernel_obj3(Line,line) +//CGAL_Kernel_obj3(Ray,ray) //CGAL_Kernel_obj3(Hyperplane,hyperplane) -CGAL_Kernel_obj3(Aff_transformation,aff_transformation) -CGAL_Kernel_obj3(Iso_box,iso_box) +//CGAL_Kernel_obj3(Aff_transformation,aff_transformation) +//CGAL_Kernel_obj3(Iso_box,iso_box) CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, construct_point_cartesian_const_iterator_object) diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 53d3a794289..dbd74e931ca 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -112,6 +112,7 @@ namespace CGAL { DECL_OBJ(Oriented_side, Discrete); DECL_OBJ(Bounded_side, Discrete); DECL_OBJ(Angle, Discrete); + DECL_OBJ(Flat_orientation, Discrete); DECL_OBJ(Vector, Object); DECL_OBJ(Point, Object); From 816eea66b077501b237d61ddf961be33f15fdfba Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 4 Jan 2013 19:28:07 +0100 Subject: [PATCH 177/210] Comment out some unused stuff (so it is visible that it is not used). --- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 3 +-- .../include/CGAL/Kernel_d/interface_macros.h | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index b0a5a5773d9..43fb4df34f4 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -85,8 +85,7 @@ struct Cartesian_wrap : public Base_ template struct Type : Get_type {}; #define CGAL_Kernel_obj(X,Y) \ - template struct Type { typedef X##_d type; }; \ - typedef X##_d X; + template struct Type { typedef X##_d type; }; #define CGAL_Kernel_obj3(X,Y) //CGAL_Kernel_obj(Segment,segment) diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index 82cff999880..fa1fd9bc7d5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -45,10 +45,10 @@ CGAL_Kernel_obj2(Segment,segment) //CGAL_Kernel_obj3(Aff_transformation,aff_transformation) //CGAL_Kernel_obj3(Iso_box,iso_box) -CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, - construct_point_cartesian_const_iterator_object) -CGAL_Kernel_cons1(Construct_vector_cartesian_const_iterator, - construct_vector_cartesian_const_iterator_object) +//CGAL_Kernel_cons1(Construct_point_cartesian_const_iterator, +// construct_point_cartesian_const_iterator_object) +//CGAL_Kernel_cons1(Construct_vector_cartesian_const_iterator, +// construct_vector_cartesian_const_iterator_object) //CGAL_Kernel_cons2(Sum_of_vectors, // sum_of_vectors_object) //CGAL_Kernel_cons2(Difference_of_vectors, @@ -76,10 +76,10 @@ CGAL_Kernel_cons1(Construct_vector_cartesian_const_iterator, CGAL_Kernel_cons2(Segment_extremity, segment_extremity_object) -CGAL_Kernel_comp1(Compute_point_cartesian_coordinate, - compute_point_cartesian_coordinate_object) -CGAL_Kernel_comp1(Compute_vector_cartesian_coordinate, - compute_vector_cartesian_coordinate_object) +//CGAL_Kernel_comp1(Compute_point_cartesian_coordinate, +// compute_point_cartesian_coordinate_object) +//CGAL_Kernel_comp1(Compute_vector_cartesian_coordinate, +// compute_vector_cartesian_coordinate_object) //CGAL_Kernel_comp2(Squared_length, // squared_length_object) //CGAL_Kernel_comp2(Squared_distance, From 85b47f490eefb7f3b3ccb0eecd39198940c0528d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 4 Jan 2013 20:16:12 +0100 Subject: [PATCH 178/210] Cleanup Cartesian_wrap a bit. --- .../CGAL/Kernel_d/Wrapper/Cartesian_wrap.h | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h index 43fb4df34f4..daeb376495e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Wrapper/Cartesian_wrap.h @@ -12,6 +12,8 @@ #include #include +#include +#include //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. @@ -71,6 +73,19 @@ template transforming_iterator::value> +struct Map_wrapping_type : Get_type {}; +#define CGAL_REGISTER_OBJECT_WRAPPER(X) \ + template \ + struct Map_wrapping_type { \ + typedef X##_d type; \ + } +CGAL_REGISTER_OBJECT_WRAPPER(Point); +CGAL_REGISTER_OBJECT_WRAPPER(Vector); +CGAL_REGISTER_OBJECT_WRAPPER(Segment); +CGAL_REGISTER_OBJECT_WRAPPER(Sphere); +#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. @@ -82,18 +97,18 @@ struct Cartesian_wrap : public Base_ typedef Base_ Kernel_base; typedef Cartesian_wrap Self; typedef typename Default::Get::type Derived; + // FIXME: The list doesn't belong here. + typedef boost::mpl::vector Wrapped_list; - template struct Type : Get_type {}; -#define CGAL_Kernel_obj(X,Y) \ - template struct Type { typedef X##_d type; }; -#define CGAL_Kernel_obj3(X,Y) - - //CGAL_Kernel_obj(Segment,segment) - //TODO: use Object_list, intersected with the list of objects that do have a wrapper available. -#include + template + struct Type : Map_wrapping_type {}; //Translate the arguments - template::type,bool=boost::is_same::type,Null_functor>::value> struct Functor { + template ::type, + bool=Provides_functor::value, + bool=boost::mpl::contains::type>::type::value> + struct Functor { typedef typename Get_functor::type B; struct type { B b; @@ -117,13 +132,14 @@ struct Cartesian_wrap : public Base_ }; }; - //Translate both the arguments and the result - template struct Functor { - typedef Null_functor type; - }; + // Preserve the difference between Null_functor and nothing. + template + struct Functor + : Get_functor {}; - // FIXME: only when the return type is wrapped! See refcount, which does it better. - template struct Functor { + //Translate both the arguments and the result + //TODO: Check Is_wrapper instead of relying on map_result_tag? + template struct Functor { typedef typename Get_functor::type B; struct type { B b; From 7dcb68314efc0cc9595ae0dae14759bb3b0cd09d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 4 Jan 2013 20:35:00 +0100 Subject: [PATCH 179/210] Remove more unused code. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 1 + .../include/CGAL/Kernel_d/Cartesian_complete.h | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) 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 870a08e912a..ab7c0b3d277 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -48,6 +48,7 @@ struct Cartesian_LA_base_d : public Dimension_base template struct Type< Point_tag, D> { typedef Vector_ type; }; template struct Type { typedef Vector_ type; }; template struct Type< FT_tag, D> { typedef FT_ type; }; + template struct Type< RT_tag, D> { typedef FT_ type; }; typedef typeset ::add::type diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 552ba8fb02c..42453664abe 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -16,12 +16,6 @@ namespace CGAL { -namespace internal { -BOOST_MPL_HAS_XXX_TRAIT_DEF(Segment) -BOOST_MPL_HAS_XXX_TRAIT_DEF(Ray) -BOOST_MPL_HAS_XXX_TRAIT_DEF(Direction) -BOOST_MPL_HAS_XXX_TRAIT_DEF(Line) -} template struct Cartesian_define_all_functors_ : public R_ @@ -39,8 +33,8 @@ template struct Cartesian_define_all_functors_ template struct Functor ,D> { \ typedef CartesianDKernelFunctors::Construct_##Y type; \ }; -#define CGAL_Kernel_pred(F,f) CGAL_Kernel_cons2(F,f) -#define CGAL_Kernel_comp2(F,f) CGAL_Kernel_cons2(F,f) +//#define CGAL_Kernel_pred(F,f) CGAL_Kernel_cons2(F,f) +//#define CGAL_Kernel_comp2(F,f) CGAL_Kernel_cons2(F,f) #include @@ -64,8 +58,7 @@ template struct Cartesian_com Provides_type::value; \ typedef Get_type B_; \ typedef typename boost::mpl::if_c >,B_>::type::type type; \ - }; \ - typedef CGAL::X X; + }; //Implement by chaining things like Define_segment? //FIXME: needs to be conditional!!! #include From 82482cf97116f1a84375ca2d17900a09e1bd94e4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 4 Jan 2013 20:40:25 +0100 Subject: [PATCH 180/210] Unused --- NewKernel_d/include/CGAL/Kernel_d/interface_macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h index fa1fd9bc7d5..4760e400c97 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h +++ b/NewKernel_d/include/CGAL/Kernel_d/interface_macros.h @@ -35,8 +35,8 @@ # define CGAL_Kernel_obj3(X,Y) CGAL_Kernel_obj2(X,Y) #endif -CGAL_Kernel_obj1(Vector,vector) -CGAL_Kernel_obj1(Point,point) +//CGAL_Kernel_obj1(Vector,vector) +//CGAL_Kernel_obj1(Point,point) CGAL_Kernel_obj2(Segment,segment) //CGAL_Kernel_obj2(Sphere,sphere) //CGAL_Kernel_obj3(Line,line) From 5d32399e1b5fb8ce14f934407194e0773ad9e064 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Jan 2013 14:24:06 +0100 Subject: [PATCH 181/210] BOOST_MPL_HAS_XXX_TEMPLATE_DEF doesn't work, that took me forever to track down... --- .../include/CGAL/Kernel_d/Cartesian_filter_K.h | 3 +++ .../include/CGAL/Kernel_d/KernelD_converter.h | 5 ++++- .../include/CGAL/Kernel_d/Kernel_d_interface.h | 4 ++-- NewKernel_d/include/CGAL/functor_tags.h | 12 ++++++++---- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index 2c7123d4010..afc722a7f83 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -30,6 +30,9 @@ struct Cartesian_filter_K : public Base_, typedef KernelD_converter C2A; typedef KernelD_converter C2E; + template struct Type : + Get_type {}; + template::type> struct Functor : Get_functor {}; template struct Functor { diff --git a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h index 5bc5dbe7cf5..7028ea68899 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/Kernel_d/KernelD_converter.h @@ -138,7 +138,10 @@ typename typeset_intersection::Type const&x)const{return cr(x);} - //typename K2::Flat_orientation const& operator()(typename K1::Flat_orientation const&o)const{return o;} // Both kernels should have the same, returning a reference should warn if not. + + typename Get_type::type const& + operator()(typename Get_type::type const&o)const + { return o; } // Both kernels should have the same, returning a reference should warn if not. template transforming_iterator,It>::type> diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index afd14fd5be6..b63e708cb07 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -90,7 +90,7 @@ template struct Kernel_d_interface : public Base_ { return CPI(this->kernel())(p,t); } template - result_type operator()(Vector_d const&v, Tag_ t)const{ + result_type operator()(typename First_if_different::Type const&v, Tag_ t)const{ return CVI(this->kernel())(v,t); } @@ -101,7 +101,7 @@ template struct Kernel_d_interface : public Base_ { result_type operator()(Point_d const&p, int)const{ return operator()(p, End_tag()); } - result_type operator()(Vector_d const&v, int)const{ + result_type operator()(typename First_if_different::Type const&v, int)const{ return operator()(v, End_tag()); } }; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index dbd74e931ca..1cd9602315a 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -66,7 +66,7 @@ namespace CGAL { template struct Provides_types : boost::true_type {}; - namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Type) } + namespace internal { BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_Type,template Type,false) } template::value /* false */> struct Provides_type_i : boost::false_type {}; @@ -74,18 +74,22 @@ namespace CGAL { struct Provides_type_i : Has_type_different_from, Null_type> {}; - namespace internal { BOOST_MPL_HAS_XXX_TEMPLATE_DEF(Functor) } + namespace internal { BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_Functor,template Functor,false) } template::value /* false */> struct Provides_functor_i : boost::false_type {}; template struct Provides_functor_i - : Has_type_different_from, Null_type> {}; + : Has_type_different_from, Null_functor> {}; struct Number_tag {}; struct Discrete_tag {}; struct Object_tag {}; - template struct Get_type_category; + template struct Get_type_category { + // The lazy kernel uses it too eagerly, + // so it currently needs a default. + typedef Null_tag type; + }; #define DECL_OBJ_(X,Y) \ template \ From 183f6fec8683cc5c96b2a6207ebcff79dae28f51 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Jan 2013 15:01:56 +0100 Subject: [PATCH 182/210] Unused --- NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index 42453664abe..cfad616cfbb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -90,9 +90,6 @@ template struct Cartesian_com CGAL_CONSTEXPR Cartesian_complete_predicates(){} CGAL_CONSTEXPR Cartesian_complete_predicates(int d):R_(d){} - // TODO: this doesn't look like the right place for this typedef... - typedef CartesianDKernelFunctors::Flat_orientation Flat_orientation; - typedef R_ Kernel_base; typedef typename Default::Get::type Derived; template::type> struct Functor : From 6e11857e6a1274187e4a52a375567b1e9ec8d625 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Jan 2013 20:44:18 +0100 Subject: [PATCH 183/210] Use default functors less eagerly. Prepare for removal of Cartesian_complete. --- .../CGAL/Kernel_d/Cartesian_complete.h | 77 ++++++------------- .../CGAL/Kernel_d/Cartesian_filter_K.h | 5 +- .../CGAL/Kernel_d/Cartesian_filter_NT.h | 2 +- .../CGAL/Kernel_d/Cartesian_static_filters.h | 2 +- .../include/CGAL/Kernel_d/Define_segment.h | 4 +- NewKernel_d/include/CGAL/functor_tags.h | 14 ++++ NewKernel_d/include/CGAL/marcutils.h | 2 + 7 files changed, 45 insertions(+), 61 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index cfad616cfbb..ccc3e303620 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -22,21 +22,14 @@ template struct Cartesian_define_all_functors_ { typedef R_ Kernel_base; template struct Functor - : Get_functor + : Inherit_functor { }; -#define CGAL_Kernel_cons2(F,f) \ - template struct Functor { \ - typedef CartesianDKernelFunctors::F type; \ + template struct Functor { + typedef CartesianDKernelFunctors::Segment_extremity type; }; - //type f() const { return type(); } -#define CGAL_Kernel_obj2(X,Y) \ - template struct Functor ,D> { \ - typedef CartesianDKernelFunctors::Construct_##Y type; \ + template struct Functor ,D> { + typedef CartesianDKernelFunctors::Construct_segment type; }; -//#define CGAL_Kernel_pred(F,f) CGAL_Kernel_cons2(F,f) -//#define CGAL_Kernel_comp2(F,f) CGAL_Kernel_cons2(F,f) - -#include }; @@ -51,17 +44,13 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; - template struct Type : Get_type {}; -#define CGAL_Kernel_obj2(X,Y) \ - template struct Type { \ - static const bool inbase = \ - Provides_type::value; \ - typedef Get_type B_; \ - typedef typename boost::mpl::if_c >,B_>::type::type type; \ + template struct Type : Inherit_type {}; + template struct Type { + static const bool inbase = + Provides_type::value; + typedef Get_type B_; + typedef typename boost::mpl::if_c >,B_>::type::type type; }; - //Implement by chaining things like Define_segment? - //FIXME: needs to be conditional!!! -#include }; @@ -73,13 +62,19 @@ template struct Cartesian_com typedef R_ Kernel_base; typedef typename Default::Get::type Derived; - template::type> struct Functor : - Get_functor {}; - template struct Functor { - typedef typename Get_functor::type Base_functor; - typedef typename boost::mpl::if_c::value, - typename Get_functor, F>::type, - Base_functor>::type type; + template struct Functor : + Inherit_functor {}; + template struct Functor,D> { + typedef typename Get_functor >::type Base_functor; + typedef typename boost::mpl::if_c::value, + typename Get_functor, Construct_ttag >::type, + Base_functor>::type type; + }; + template struct Functor { + typedef typename Get_functor::type Base_functor; + typedef typename boost::mpl::if_c::value, + typename Get_functor, Segment_extremity_tag>::type, + Base_functor>::type type; }; }; @@ -89,18 +84,6 @@ template struct Cartesian_com { CGAL_CONSTEXPR Cartesian_complete_predicates(){} CGAL_CONSTEXPR Cartesian_complete_predicates(int d):R_(d){} - - typedef R_ Kernel_base; - typedef typename Default::Get::type Derived; - template::type> struct Functor : - Get_functor {}; - template struct Functor { - typedef typename Get_functor::type Base_functor; - typedef typename boost::mpl::if_c::value, - typename Get_functor, F>::type, - Base_functor>::type type; - }; - }; template struct Cartesian_complete_computes @@ -108,18 +91,6 @@ template struct Cartesian_com { CGAL_CONSTEXPR Cartesian_complete_computes(){} CGAL_CONSTEXPR Cartesian_complete_computes(int d):R_(d){} - - typedef R_ Kernel_base; - typedef typename Default::Get::type Derived; - template::type> struct Functor : - Get_functor {}; - template struct Functor { - typedef typename Get_functor::type Base_functor; - typedef typename boost::mpl::if_c::value, - typename Get_functor, F>::type, - Base_functor>::type type; - }; - }; } diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index afc722a7f83..c490f9b0ce5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -30,11 +30,8 @@ struct Cartesian_filter_K : public Base_, typedef KernelD_converter C2A; typedef KernelD_converter C2E; - template struct Type : - Get_type {}; - template::type> struct Functor : - Get_functor {}; + Inherit_functor {}; template struct Functor { typedef typename Get_functor::type AP; typedef typename Get_functor::type EP; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h index 8d423320348..adb8a8073cf 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -18,7 +18,7 @@ struct Cartesian_filter_NT : public Base_ typedef Cartesian_change_FT K2; template::type> struct Functor : - Get_functor {}; + Inherit_functor {}; template struct Functor { struct type { //TODO: use compression (derive from a compressed_pair?) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h index c813a488edf..d33820cd844 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_static_filters.h @@ -59,7 +59,7 @@ struct Cartesian_static_filters, R_, Derived_> : public R_ { CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} typedef Cartesian_static_filters, R_, Derived_> Self; typedef typename Default::Get::type Derived; - template struct Functor : Get_functor {}; + template struct Functor : Inherit_functor {}; template struct Functor { typedef //typename boost::conditional< diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index d71e51f4d4f..05e3b4a5936 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -59,13 +59,13 @@ struct Define_segment : public Base_ { typedef CGAL::Segment Segment; typedef typename Base::Object_list::template add::type Object_list; - template struct Type : Get_type {}; + template struct Type : Inherit_type {}; template struct Type { typedef CGAL::Segment type; }; // TODO: forward the second Functor argument (like fast, no_filter) - template struct Functor : Get_functor {}; + template struct Functor : Inherit_functor {}; template struct Functor,D> { typedef CartesianDKernelFunctors::Construct_segment type; diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 1cd9602315a..92ecb43359d 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -82,6 +82,20 @@ namespace CGAL { struct Provides_functor_i : Has_type_different_from, Null_functor> {}; + // TODO: Refine this a bit. + template ::value, + //bool=Provides_functor_i::value, + bool=internal::has_Functor::value> + struct Inherit_functor : K::template Functor {}; + template + struct Inherit_functor {}; + + template ::value> + struct Inherit_type : K::template Type {}; + template + struct Inherit_type {}; + struct Number_tag {}; struct Discrete_tag {}; struct Object_tag {}; diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index 8daa2323ef5..c3bc8e6467c 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -246,6 +246,7 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) , int, void>::type> \ { \ typedef CGAL_STRIP_PAREN_ Name type; \ + typedef K Bound_kernel; \ } // Not used yet, may need some changes. @@ -259,6 +260,7 @@ BOOST_PP_REPEAT_FROM_TO(1, 8, CODE, _ ) , int, void>::type> \ { \ typedef CGAL_STRIP_PAREN_ Name type; \ + typedef K Bound_kernel; \ } From 7aa00b76aa0fccd0bb2d00038cd1eae874f0846a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Jan 2013 23:20:14 +0100 Subject: [PATCH 184/210] Use Get_* for segments too. Disable Cartesian_complete, now useless. --- .../include/CGAL/Kernel_d/Cartesian_LA_base.h | 2 + .../include/CGAL/Kernel_d/Cartesian_base.h | 12 +---- .../CGAL/Kernel_d/Cartesian_complete.h | 49 ------------------- .../include/CGAL/Kernel_d/Define_segment.h | 4 ++ .../include/CGAL/Kernel_d/Types/Segmentd.h | 1 + NewKernel_d/test/NewKernel_d/test.cpp | 6 +-- 6 files changed, 11 insertions(+), 63 deletions(-) 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 ab7c0b3d277..73ea8612bd9 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_LA_base.h @@ -52,6 +52,8 @@ struct Cartesian_LA_base_d : public Dimension_base typedef typeset ::add::type + // FIXME: Segment has nothing to do here. + ::add::type Object_list; typedef typeset< Point_cartesian_const_iterator_tag>::type diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h index f97e6e015d3..f5ef884ac76 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_base.h @@ -7,17 +7,7 @@ namespace CGAL { #define CGAL_BASE \ -Cartesian_complete_predicates< \ -Cartesian_complete_constructors< \ -Cartesian_complete_computes< \ -Cartesian_complete_types< \ -Cartesian_LA_base_d< \ - FT_, Dim_ \ ->, false, typename Default::Get >::type \ ->, false, typename Default::Get >::type \ ->, false, typename Default::Get >::type \ ->, false, typename Default::Get >::type \ -> + Cartesian_LA_base_d< FT_, Dim_ > template < typename FT_, typename Dim_, typename Derived_=Default> struct Cartesian_base_d : public CGAL_BASE { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index ccc3e303620..e1691596d91 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -16,67 +16,18 @@ namespace CGAL { - -template struct Cartesian_define_all_functors_ -: public R_ -{ - typedef R_ Kernel_base; - template struct Functor - : Inherit_functor - { }; - template struct Functor { - typedef CartesianDKernelFunctors::Segment_extremity type; - }; - template struct Functor ,D> { - typedef CartesianDKernelFunctors::Construct_segment type; - }; - -}; - -template struct Cartesian_define_all_functors -: public Cartesian_per_dimension,Derived_> {}; - template struct Cartesian_complete_types : public R_ { CGAL_CONSTEXPR Cartesian_complete_types(){} CGAL_CONSTEXPR Cartesian_complete_types(int d):R_(d){} - - typedef R_ Kernel_base; - typedef typename Default::Get::type Derived; - template struct Type : Inherit_type {}; - template struct Type { - static const bool inbase = - Provides_type::value; - typedef Get_type B_; - typedef typename boost::mpl::if_c >,B_>::type::type type; - }; }; - template struct Cartesian_complete_constructors : public R_ { CGAL_CONSTEXPR Cartesian_complete_constructors(){} CGAL_CONSTEXPR Cartesian_complete_constructors(int d):R_(d){} - - typedef R_ Kernel_base; - typedef typename Default::Get::type Derived; - template struct Functor : - Inherit_functor {}; - template struct Functor,D> { - typedef typename Get_functor >::type Base_functor; - typedef typename boost::mpl::if_c::value, - typename Get_functor, Construct_ttag >::type, - Base_functor>::type type; - }; - template struct Functor { - typedef typename Get_functor::type Base_functor; - typedef typename boost::mpl::if_c::value, - typename Get_functor, Segment_extremity_tag>::type, - Base_functor>::type type; - }; - }; template struct Cartesian_complete_predicates diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h index 05e3b4a5936..f2654fe116b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h @@ -50,9 +50,12 @@ template struct Segment_extremity { #endif }; } // CartesianDKernelFunctors +CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_segment),(Segment_tag,Point_tag),(Construct_ttag)); +CGAL_KD_DEFAULT_FUNCTOR(Segment_extremity_tag,(CartesianDKernelFunctors::Segment_extremity),(Segment_tag,Point_tag),()); template struct Define_segment : public Base_ { +#if 0 typedef Base_ Base; typedef Define_segment Self; typedef typename Default::Get::type Derived; @@ -73,6 +76,7 @@ struct Define_segment : public Base_ { template struct Functor { typedef CartesianDKernelFunctors::Segment_extremity type; }; +#endif }; } #endif diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h index 8693e0f8478..e464951718b 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h @@ -41,6 +41,7 @@ template class Segment { // return Csd_()(data.first,data.second); // } }; +CGAL_KD_DEFAULT_TYPE(Segment_tag,(CGAL::Segment),(Point_tag),()); } // namespace CGAL diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 072238147c9..07e45058255 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -19,8 +19,8 @@ templatevoid marc_use(){} //typedef CGAL::Cartesian_base_d > K0; //typedef CGAL::Cartesian_base_d > KA; -struct KA : CGAL::Cartesian_static_filters, CGAL::Define_segment,KA>, KA>, KA> {}; -typedef CGAL::Define_segment > > KE; +struct KA : CGAL::Cartesian_static_filters, CGAL::Cartesian_base_d, KA>, KA> {}; +typedef CGAL::Cartesian_base_d > KE; struct RC: public CGAL::Cartesian_static_filters, // Yes, it is silly to put it there. @@ -41,7 +41,7 @@ CGAL::Cartesian_LA_base_d > RC(int){} }; -typedef CGAL::Define_segment K0; +struct K0 : RC {}; #if 0 From 8c2c86ae45873b55b5f4aeb4e6213d1fe626f5e7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 5 Jan 2013 23:31:07 +0100 Subject: [PATCH 185/210] Move all segment-related code in the same file, as is already the case for sphere and others. --- .../CGAL/Kernel_d/Cartesian_complete.h | 2 +- .../{Define_segment.h => Types/Segment.h} | 76 +++++++++++-------- .../include/CGAL/Kernel_d/Types/Segmentd.h | 48 ------------ NewKernel_d/test/NewKernel_d/test.cpp | 2 - 4 files changed, 46 insertions(+), 82 deletions(-) rename NewKernel_d/include/CGAL/Kernel_d/{Define_segment.h => Types/Segment.h} (55%) delete mode 100644 NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index e1691596d91..e24a3ae77dd 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include diff --git a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segment.h similarity index 55% rename from NewKernel_d/include/CGAL/Kernel_d/Define_segment.h rename to NewKernel_d/include/CGAL/Kernel_d/Types/Segment.h index f2654fe116b..0f617ed4494 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Define_segment.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Segment.h @@ -1,11 +1,47 @@ -#ifndef CGAL_KD_DEFINE_SEGMENT_H -#define CGAL_KD_DEFINE_SEGMENT_H +#ifndef CGAL_KERNELD_SEGMENTD_H +#define CGAL_KERNELD_SEGMENTD_H #include -#include #include -#include - namespace CGAL { +template class Segment { + typedef typename Get_type::type FT_; + typedef typename Get_type::type Point_; + //typedef typename R_::Vector Vector_; + //typedef typename Get_functor >::type Cv_; +// typedef typename R_::Squared_distance Csd_; + typedef std::pair Data_; + Data_ data; + public: + //typedef Segmentd Segment; +#ifdef CGAL_CXX0X + //FIXME: don't forward directly, piecewise_constuct should call the point construction functor (I guess? or is it unnecessary?) + template::type...>,std::tuple>::value>::type> + Segment(U&&...u):data(std::forward(u)...){} +#else + Segment(){} + Segment(Point_ const&a, Point_ const&b): data(a,b) {} + //template + //Segment(A const&,T1 const&t1,T2 const&t2) +#endif + Point_ source()const{return data.first;} + Point_ target()const{return data.second;} + Point_ operator[](int i)const{ + if((i%2)==0) + return source(); + else + return target(); + } + Segment opposite()const{ + return Segment(target(),source()); + } + //Vector_ vector()const{ + // return Cv_()(data.first,data.second); + //} +// FT_ squared_length()const{ +// return Csd_()(data.first,data.second); +// } +}; + namespace CartesianDKernelFunctors { template struct Construct_segment { @@ -50,33 +86,11 @@ template struct Segment_extremity { #endif }; } // CartesianDKernelFunctors + +CGAL_KD_DEFAULT_TYPE(Segment_tag,(CGAL::Segment),(Point_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_segment),(Segment_tag,Point_tag),(Construct_ttag)); CGAL_KD_DEFAULT_FUNCTOR(Segment_extremity_tag,(CartesianDKernelFunctors::Segment_extremity),(Segment_tag,Point_tag),()); -template -struct Define_segment : public Base_ { -#if 0 - typedef Base_ Base; - typedef Define_segment Self; - typedef typename Default::Get::type Derived; +} // namespace CGAL - typedef CGAL::Segment Segment; - typedef typename Base::Object_list::template add::type Object_list; - template struct Type : Inherit_type {}; - template struct Type { - typedef CGAL::Segment type; - }; - - // TODO: forward the second Functor argument (like fast, no_filter) - template struct Functor : Inherit_functor {}; - - template struct Functor,D> { - typedef CartesianDKernelFunctors::Construct_segment type; - }; - template struct Functor { - typedef CartesianDKernelFunctors::Segment_extremity type; - }; -#endif -}; -} -#endif +#endif // CGAL_KERNELD_SEGMENTD_H diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h deleted file mode 100644 index e464951718b..00000000000 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Segmentd.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef CGAL_KERNELD_SEGMENTD_H -#define CGAL_KERNELD_SEGMENTD_H -#include -#include -namespace CGAL { -template class Segment { - typedef typename Get_type::type FT_; - typedef typename Get_type::type Point_; - //typedef typename R_::Vector Vector_; - //typedef typename Get_functor >::type Cv_; -// typedef typename R_::Squared_distance Csd_; - typedef std::pair Data_; - Data_ data; - public: - //typedef Segmentd Segment; -#ifdef CGAL_CXX0X - //FIXME: don't forward directly, piecewise_constuct should call the point construction functor (I guess? or is it unnecessary?) - template::type...>,std::tuple>::value>::type> - Segment(U&&...u):data(std::forward(u)...){} -#else - Segment(){} - Segment(Point_ const&a, Point_ const&b): data(a,b) {} - //template - //Segment(A const&,T1 const&t1,T2 const&t2) -#endif - Point_ source()const{return data.first;} - Point_ target()const{return data.second;} - Point_ operator[](int i)const{ - if((i%2)==0) - return source(); - else - return target(); - } - Segment opposite()const{ - return Segment(target(),source()); - } - //Vector_ vector()const{ - // return Cv_()(data.first,data.second); - //} -// FT_ squared_length()const{ -// return Csd_()(data.first,data.second); -// } -}; -CGAL_KD_DEFAULT_TYPE(Segment_tag,(CGAL::Segment),(Point_tag),()); - -} // namespace CGAL - -#endif // CGAL_KERNELD_SEGMENTD_H diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 07e45058255..319d022becd 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -6,8 +6,6 @@ #include #include #include -#include -#include #include #include #include From a2fc0a4a85e31a0132156e55ee769cb88789694c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 6 Jan 2013 00:16:45 +0100 Subject: [PATCH 186/210] Fix change_FT, remove dead complete_* code. --- .../CGAL/Kernel_d/Cartesian_change_FT.h | 16 ++++----- .../CGAL/Kernel_d/Cartesian_complete.h | 35 ------------------- NewKernel_d/test/NewKernel_d/test.cpp | 14 ++------ 3 files changed, 10 insertions(+), 55 deletions(-) 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 5c32b4a79b7..ba2d44dc904 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_change_FT.h @@ -19,6 +19,10 @@ struct Cartesian_change_FT_base : public typedef Base_ Kernel_base; typedef LA_ LA; + template struct Type : Inherit_type {}; + template struct Type { typedef FT_ type; }; + template struct Type { typedef FT_ type; }; + typedef NT_converter::type,FT_> FT_converter; typedef transforming_iterator Point_cartesian_const_iterator; typedef transforming_iterator Vector_cartesian_const_iterator; @@ -64,11 +68,9 @@ struct Cartesian_change_FT_base : public }; template::type> struct Functor : - Get_functor { }; - template struct Functor - { typedef Null_functor type; }; - template struct Functor - { typedef Null_functor type; }; + Inherit_functor { }; + template struct Functor { }; + template struct Functor { }; template struct Functor { typedef Compute_cartesian_coordinate type; }; @@ -85,11 +87,7 @@ struct Cartesian_change_FT_base : public template < typename Base_, typename FT_> struct Cartesian_change_FT : public -Cartesian_complete_predicates< -Cartesian_complete_computes< Cartesian_change_FT_base -, true, Cartesian_change_FT > -, true, Cartesian_change_FT > { CGAL_CONSTEXPR Cartesian_change_FT(){} CGAL_CONSTEXPR Cartesian_change_FT(int d):Cartesian_change_FT_base(d){} diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h index e24a3ae77dd..b78a96a0e7c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_complete.h @@ -10,40 +10,5 @@ #include #include #include -#include -#include -#include - - -namespace CGAL { -template struct Cartesian_complete_types -: public R_ -{ - CGAL_CONSTEXPR Cartesian_complete_types(){} - CGAL_CONSTEXPR Cartesian_complete_types(int d):R_(d){} -}; - -template struct Cartesian_complete_constructors -: public R_ -{ - CGAL_CONSTEXPR Cartesian_complete_constructors(){} - CGAL_CONSTEXPR Cartesian_complete_constructors(int d):R_(d){} -}; - -template struct Cartesian_complete_predicates -: public R_ -{ - CGAL_CONSTEXPR Cartesian_complete_predicates(){} - CGAL_CONSTEXPR Cartesian_complete_predicates(int d):R_(d){} -}; - -template struct Cartesian_complete_computes -: public R_ -{ - CGAL_CONSTEXPR Cartesian_complete_computes(){} - CGAL_CONSTEXPR Cartesian_complete_computes(int d):R_(d){} -}; - -} #endif // CGAL_KERNEL_D_CARTESIAN_COMPLETE_H diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 319d022becd..e8130defd28 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -22,17 +22,9 @@ typedef CGAL::Cartesian_base_d > KE; struct RC: public CGAL::Cartesian_static_filters, // Yes, it is silly to put it there. -CGAL::Cartesian_complete_predicates< -CGAL::Cartesian_complete_constructors< -CGAL::Cartesian_complete_computes< -CGAL::Cartesian_complete_types< -CGAL::Cartesian_refcount< -CGAL::Cartesian_LA_base_d > -> ->, false, RC ->, false, RC ->, false, RC ->, RC + CGAL::Cartesian_refcount< + CGAL::Cartesian_LA_base_d > + >, RC > { RC(){} From 380b394e7b9b671aad600c3ed8b44d59d5189d3f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 23 Feb 2013 10:39:27 +0100 Subject: [PATCH 187/210] Spheres are called circles in 2D. --- NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h index fb44402e2b3..aed4ebbc645 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_2_interface.h @@ -22,7 +22,7 @@ template struct Kernel_2_interface : public Base_ { typedef typename Get_type::type Angle; typedef typename Get_type::type Point_2; typedef typename Get_type::type Vector_2; - struct Segment_2 {}; + typedef typename Get_type::type Segment_2; typedef cpp0x::tuple Triangle_2; // triangulation insists... template struct Help_2p_i { typedef typename Get_functor::type LT; @@ -61,11 +61,11 @@ template struct Kernel_2_interface : public Base_ { } }; - struct Side_of_oriented_sphere_2 { + struct Side_of_oriented_circle_2 { typedef typename Get_functor::type SOS; typedef typename SOS::result_type result_type; SOS sos; - Side_of_oriented_sphere_2(Kernel const&k):sos(k){} + Side_of_oriented_circle_2(Kernel const&k):sos(k){} result_type operator()(Point_2 const&a, Point_2 const&b, Point_2 const&c, Point_2 const&d) { //return sos(a,b,c,d); Point_2 const* t[4]={&a,&b,&c,&d}; @@ -78,7 +78,7 @@ template struct Kernel_2_interface : public Base_ { Compare_y_2 compare_y_2_object()const{ return Compare_y_2(*this); } Compare_distance_2 compare_distance_2_object()const{ return Compare_distance_2(*this); } Orientation_2 orientation_2_object()const{ return Orientation_2(*this); } - Side_of_oriented_sphere_2 side_of_oriented_sphere_2_object()const{ return Side_of_oriented_sphere_2(*this); } + Side_of_oriented_circle_2 side_of_oriented_circle_2_object()const{ return Side_of_oriented_circle_2(*this); } }; } From 096c04c794c9eedb4806b8af0c13d5662123af3d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 19 Jul 2013 11:36:40 +0200 Subject: [PATCH 188/210] Minor update for newer CGAL. Remove unused file. --- .../CGAL/Kernel_d/Cartesian_filter_NT.h | 2 +- NewKernel_d/include/CGAL/marcutils.h | 3 +- NewKernel_d/include/CGAL/myeigen.h | 43 ------------------- 3 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/myeigen.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h index adb8a8073cf..33b136a5385 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_NT.h @@ -14,7 +14,7 @@ struct Cartesian_filter_NT : public Base_ CGAL_CONSTEXPR Cartesian_filter_NT(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_change_FT K1; - typedef typename internal::Exact_type_selector::type>::Type Exact_nt; + typedef typename internal::Exact_field_selector::type>::Type Exact_nt; typedef Cartesian_change_FT K2; template::type> struct Functor : diff --git a/NewKernel_d/include/CGAL/marcutils.h b/NewKernel_d/include/CGAL/marcutils.h index c3bc8e6467c..90ea434792a 100644 --- a/NewKernel_d/include/CGAL/marcutils.h +++ b/NewKernel_d/include/CGAL/marcutils.h @@ -14,14 +14,13 @@ #define CGAL_MOVE(t) t #define CGAL_CONSTEXPR #endif -#include #include #include #include #include #include #include -#include +#include #ifdef CGAL_CXX0X #define BOOSTD std:: diff --git a/NewKernel_d/include/CGAL/myeigen.h b/NewKernel_d/include/CGAL/myeigen.h deleted file mode 100644 index c8f2af8fa63..00000000000 --- a/NewKernel_d/include/CGAL/myeigen.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef myeigen_h -#define myeigen_h -#include -#include -#include - -namespace Eigen { - - template<> struct NumTraits - { - typedef CGAL::Gmpq Real; - typedef CGAL::Gmpq NonInteger; - typedef CGAL::Gmpq Nested; - - enum { - IsComplex = 0, - IsInteger = 0, - IsSigned, - ReadCost = 10, - AddCost = 100, - MulCost = 1000 - }; - }; - - template<> struct NumTraits - { - typedef CGAL::Interval_nt_advanced Real; - typedef CGAL::Interval_nt_advanced NonInteger; - typedef CGAL::Interval_nt_advanced Nested; - - enum { - IsComplex = 0, - IsInteger = 0, - IsSigned, - ReadCost = 2, - AddCost = 2, - MulCost = 10 - }; - }; - -} - -#endif From a5b9e12a7ce791f8b5f9b72c1fb71969f7f7f482 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 19 Jul 2013 18:57:33 +0200 Subject: [PATCH 189/210] Copy the doc to doxygen (haven't tried to compile yet). --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 54 ++++++++++++++++++++ Kernel_d/doc/Kernel_d/Kernel_d.txt | 13 +++++ Kernel_d/doc/Kernel_d/PackageDescription.txt | 3 +- NewKernel_d/test/NewKernel_d/Makefile | 2 +- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 Kernel_d/doc/Kernel_d/CGAL/Epick_d.h diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h new file mode 100644 index 00000000000..3fb578728a2 --- /dev/null +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -0,0 +1,54 @@ + +namespace CGAL { + +/*! +\ingroup PkgKernelDKernels + +A model for `Kernel_d` that uses %Cartesian coordinates to represent the +geometric objects. The parameter `Dimension` is the dimension of the +ambient Euclidean space. It may be either `Dimension_tag` or +`Dynamic_dimension_tag`. It supports construction of points from `double` +Cartesian coordinates. It provides exact geometric predicates, but +inexact geometric constructions. The geometric predicates are made exact +without sacrificing speed thanks to the use of filters. + +This kernel is default constructible and copyable. It does not carry any +state so it is possible to use objects created by one instance with +functors created by another one. + +Note that this kernel does not completely conform to the `Kernel_d` +concept: it is missing the constructions `Lift_to_paraboloid_d` and +`Project_along_d_axis_d` which do not make sense with a single fixed +dimension. + + +\cgalModels `Kernel_d` +\cgalModels `DelaunayTriangulationTraits` + +\sa `CGAL::Epick_d::Point_d` +\sa `CGAL::Cartesian_d` +\sa `CGAL::Homogeneous_d` + +*/ +template< typename Dimension > +class Epick_d { +public: +/*! +represents a point in the Euclidean space +\cgalModels `DefaultConstructible` +\cgalModels `Copyable` +\cgalModels `Assignable` +*/ +class Point_d { +public: +/*! introduces a point with coordinates (x0, x1, ...). */ +Point_d(double x0, double x1, ...); + +/*! returns the i'th coordinate of a point.r + \pre `i` is non-negative and less than the dimension */ +double operator[](int i)const; +} +/// @} + +}; /* end Epick_d */ +} /* end namespace CGAL */ diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 40bbed39524..a161871a0e2 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -205,6 +205,19 @@ circumvented. With `Homogeneous_d`, `Homogeneous_d::%LA` is mapped to the type `LinearAlgebra`. +\subsection Epick_d Kernel + +The kernel `Epick_d`, short for Exact Predicates Inexact +Constructions Kernel is a kernel particularly useful when the dimension of +the space is known at compile-time. It uses a Cartesian representation and +supports construction of points from `double` coordinates. It provides exact +geometric predicates, but inexact geometric constructions. + +Note that it provides few interfaces in addition to those documented in the +`Kernel_d` concept. In particular, the type of a point is only available as +`Epick_d::Point_d`, not `Point_d>`. + + \subsection Kernel_dNamingconventions Naming conventions The use of representation classes not only avoids problems, it also diff --git a/Kernel_d/doc/Kernel_d/PackageDescription.txt b/Kernel_d/doc/Kernel_d/PackageDescription.txt index 9ec3f820ce0..58aa707ed80 100644 --- a/Kernel_d/doc/Kernel_d/PackageDescription.txt +++ b/Kernel_d/doc/Kernel_d/PackageDescription.txt @@ -47,7 +47,8 @@ ## Kernels ## - `CGAL::Cartesian_d` -- `CGAL::Homogeneous` +- `CGAL::Homogeneous_d` +- `CGAL::Epick_d` ## %Kernel Objects ## - `CGAL::Point_d` diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index 9f4ab5eec41..c7aea1ec399 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -1,6 +1,6 @@ all: normal cxx0x -CGAL_INC = -I/home/glisse/repos/cgal/master/Algebraic_foundations/include -I/home/glisse/repos/cgal/master/STL_Extension/include -I/home/glisse/repos/cgal/master/Number_types/include -I/data/repos/cgal/master/Algebraic_foundations/include -I/data/repos/cgal/master/STL_Extension/include -I/data/repos/cgal/master/Number_types/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK +CGAL_INC = -I../../../Algebraic_foundations/include -I../../../STL_Extension/include -I../../../Number_types/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_EIGEN3_ENABLED From 4c4318ee6bfebbc93c7584584fc6cc680dc3468f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 19 Jul 2013 19:22:54 +0200 Subject: [PATCH 190/210] Minor fixes. doxygen complains a lot (for the whole cgal) and outputs duplicated functions for Point_d, but the information is there. --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 5 ++--- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 3fb578728a2..314c8a421c8 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -8,7 +8,7 @@ A model for `Kernel_d` that uses %Cartesian coordinates to represent the geometric objects. The parameter `Dimension` is the dimension of the ambient Euclidean space. It may be either `Dimension_tag` or `Dynamic_dimension_tag`. It supports construction of points from `double` -Cartesian coordinates. It provides exact geometric predicates, but +%Cartesian coordinates. It provides exact geometric predicates, but inexact geometric constructions. The geometric predicates are made exact without sacrificing speed thanks to the use of filters. @@ -25,7 +25,6 @@ dimension. \cgalModels `Kernel_d` \cgalModels `DelaunayTriangulationTraits` -\sa `CGAL::Epick_d::Point_d` \sa `CGAL::Cartesian_d` \sa `CGAL::Homogeneous_d` @@ -44,7 +43,7 @@ public: /*! introduces a point with coordinates (x0, x1, ...). */ Point_d(double x0, double x1, ...); -/*! returns the i'th coordinate of a point.r +/*! returns the i'th coordinate of a point. \pre `i` is non-negative and less than the dimension */ double operator[](int i)const; } diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index a161871a0e2..4a30f145d91 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -205,7 +205,7 @@ circumvented. With `Homogeneous_d`, `Homogeneous_d::%LA` is mapped to the type `LinearAlgebra`. -\subsection Epick_d Kernel +\subsection Kernel_dEpickKernel Epick_d Kernel The kernel `Epick_d`, short for Exact Predicates Inexact Constructions Kernel is a kernel particularly useful when the dimension of From 71c9e2b42707ceedce76a94ac52dfc25f9efa4ce Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 19 Jul 2013 19:50:55 +0200 Subject: [PATCH 191/210] Follow some reviewer comments. Untested (the more I rebuild the doc, the longer it takes...). --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 9 ++++++--- Kernel_d/doc/Kernel_d/Kernel_d.txt | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 314c8a421c8..4230517c605 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -9,8 +9,9 @@ geometric objects. The parameter `Dimension` is the dimension of the ambient Euclidean space. It may be either `Dimension_tag` or `Dynamic_dimension_tag`. It supports construction of points from `double` %Cartesian coordinates. It provides exact geometric predicates, but -inexact geometric constructions. The geometric predicates are made exact -without sacrificing speed thanks to the use of filters. +the geometric constructions are not guaranteed to be exact. The geometric +predicates are made exact without sacrificing speed thanks to the use of +filters. This kernel is default constructible and copyable. It does not carry any state so it is possible to use objects created by one instance with @@ -40,7 +41,9 @@ represents a point in the Euclidean space */ class Point_d { public: -/*! introduces a point with coordinates (x0, x1, ...). */ +/*! introduces a point with coordinates (x0, x1, ...) where the number of + coordinates matches the dimension. + \pre `Dimension` is a fixed dimension, not `Dynamic_dimension_tag` */ Point_d(double x0, double x1, ...); /*! returns the i'th coordinate of a point. diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 4a30f145d91..11abcacbc37 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -211,7 +211,8 @@ The kernel `Epick_d`, short for Exact Predicates Inexact Constructions Kernel is a kernel particularly useful when the dimension of the space is known at compile-time. It uses a Cartesian representation and supports construction of points from `double` coordinates. It provides exact -geometric predicates, but inexact geometric constructions. +geometric predicates, but the geometric constructions are not guaranteed to +be exact. Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as From 95c6e3526dc8e3fd082a1e39b093dfc2ac7344fc Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 19 Jul 2013 20:16:23 +0200 Subject: [PATCH 192/210] More doc that only applies to Cartesian_d and Homogeneous_d. --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 11abcacbc37..b49d99bdef2 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -109,17 +109,19 @@ argument for this parameter must fulfill certain requirements on syntax and semantics. The list of requirements defines an abstract kernel concept. In \cgal such a kernel concept is often also called a representation class and denoted by `R`. A representation -class provides the actual implementations of the kernel objects. For -all kernel objects `Kernel_object`, the types -`CGAL::Kernel_object` and `R::Kernel_object` are identical. +class provides the actual implementations of the kernel objects. +For all kernel objects `Kernel_object` of a representation class `R` based +on `Cartesian_d` or `Homogeneous_d`, the types `CGAL::Kernel_object` and +`R::Kernel_object` are identical. -\cgal offers two families of concrete models for the concept -representation class, one based on the %Cartesian + +\cgal offers three families of concrete models for the concept +representation class, two based on the %Cartesian representation of points and one based on the homogeneous representation of points. The interface of the kernel objects is designed such that it works well with both %Cartesian and homogeneous representation, for -example, points have a constructor with a range of coordinates plus a +example, points have a `Construct_point_d` functor that takes a range of coordinates plus a common denominator (the \f$ d+1\f$ homogeneous coordinates of the point). The common interfaces parameterized with a representation class allow one to develop code independent of the chosen representation. We said From dafdb457867335d1287c7b8c6f01eb2864069fb4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 19 Jul 2013 21:55:34 +0200 Subject: [PATCH 193/210] Move is_iterator changes back to the original file. --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 3 + NewKernel_d/include/CGAL/is_iterator.h | 64 ------------------- STL_Extension/include/CGAL/is_iterator.h | 7 ++ .../test/STL_Extension/test_is_iterator.cpp | 15 +++++ 4 files changed, 25 insertions(+), 64 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/is_iterator.h diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 4230517c605..fe78662f1e7 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -22,6 +22,9 @@ concept: it is missing the constructions `Lift_to_paraboloid_d` and `Project_along_d_axis_d` which do not make sense with a single fixed dimension. +Only the interfaces specific to this class are listed here, refer to the +concepts for the rest. + \cgalModels `Kernel_d` \cgalModels `DelaunayTriangulationTraits` diff --git a/NewKernel_d/include/CGAL/is_iterator.h b/NewKernel_d/include/CGAL/is_iterator.h deleted file mode 100644 index 591a26d86d6..00000000000 --- a/NewKernel_d/include/CGAL/is_iterator.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2011 INRIA Saclay Ile-de-France (France). -// All rights reserved. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// 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; version 2.1 of the License. -// See the file LICENSE.LGPL distributed with CGAL. -// -// 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_IS_ITERATOR_H -#define CGAL_IS_ITERATOR_H - -#include -#include -#include - -namespace CGAL { -namespace internal { -BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category) -template struct is_iterator_ { - enum { value = has_iterator_category::value - || boost::is_pointer::value }; -}; -template ::value> -struct is_iterator_type_ { - enum { value=false }; -}; -template struct is_iterator_type_ : - //boost::is_base_of::iterator_category> - boost::is_convertible::iterator_category,U> - {}; - -} - -// NOTE: we don't want the real std::decay or functions are included -template struct is_iterator : - internal::is_iterator_::type>::type> {}; - -template struct is_iterator_type : - internal::is_iterator_type_::type>::type,Tg> {}; - -template ::value> struct is_iterator_to { - enum { value=false }; -}; -template struct is_iterator_to : - boost::is_convertible::value_type,U> -{ }; - - -} - -#endif // CGAL_IS_ITERATOR_H diff --git a/STL_Extension/include/CGAL/is_iterator.h b/STL_Extension/include/CGAL/is_iterator.h index 5043515a8e8..6b1e4884c91 100644 --- a/STL_Extension/include/CGAL/is_iterator.h +++ b/STL_Extension/include/CGAL/is_iterator.h @@ -67,6 +67,13 @@ template struct is_iterator : template struct is_iterator_type : internal::is_iterator_type_::type>::type,Tag> {}; +template ::value> struct is_iterator_to { + enum { value=false }; +}; +template struct is_iterator_to : + boost::is_convertible::value_type,U> +{ }; + } #endif // CGAL_IS_ITERATOR_H diff --git a/STL_Extension/test/STL_Extension/test_is_iterator.cpp b/STL_Extension/test/STL_Extension/test_is_iterator.cpp index 31aaf66957f..ffe3f0ad35d 100644 --- a/STL_Extension/test/STL_Extension/test_is_iterator.cpp +++ b/STL_Extension/test/STL_Extension/test_is_iterator.cpp @@ -2,14 +2,29 @@ #include #include #include +#include + +struct A { }; int main() { typedef std::vector::const_iterator vector_it; + typedef std::list::const_iterator list_it; typedef int* int_p; using CGAL::is_iterator; + using CGAL::is_iterator_type; + using CGAL::is_iterator_to; CGAL_static_assertion(is_iterator::value); + CGAL_static_assertion(is_iterator::value); CGAL_static_assertion(!is_iterator::value); CGAL_static_assertion(!is_iterator::value); CGAL_static_assertion(is_iterator::value); + + CGAL_static_assertion((is_iterator_type::value)); + CGAL_static_assertion((!is_iterator_type::value)); + CGAL_static_assertion((!is_iterator_type::value)); + + CGAL_static_assertion((is_iterator_to::value)); + CGAL_static_assertion((!is_iterator_to::value)); + CGAL_static_assertion((!is_iterator_to::value)); } From 92bbb4cb6c196c2614f392e7928803c0b236fedf Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 19 Jul 2013 22:20:29 +0200 Subject: [PATCH 194/210] Move back long_long.h changes to the original file. --- NewKernel_d/include/CGAL/long_long.h | 93 --------------------------- Number_types/include/CGAL/long_long.h | 44 +++++++++++++ 2 files changed, 44 insertions(+), 93 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/long_long.h diff --git a/NewKernel_d/include/CGAL/long_long.h b/NewKernel_d/include/CGAL/long_long.h deleted file mode 100644 index ec5727a0baf..00000000000 --- a/NewKernel_d/include/CGAL/long_long.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 1999,2001,2007 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). All rights reserved. -// -// 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) : Stefan Schirra, Michael Hemmer - -// ISO C++ does not support `long long', but ISO C does, which means the next -// revision of ISO C++ probably will too. However, currently, g++ -pedantic -// produces a warning so we don't include this file by default. - -#ifndef CGAL_LONG_LONG_H -#define CGAL_LONG_LONG_H - -#include - -namespace CGAL { - -template<> class Algebraic_structure_traits< long long int > - : public Algebraic_structure_traits_base< long long int, - Euclidean_ring_tag > { - - public: - typedef Tag_true Is_exact; - typedef Tag_false Is_numerical_sensitive; - - typedef INTERN_AST::Div_per_operator< Type > Div; - typedef INTERN_AST::Mod_per_operator< Type > Mod; - - class Is_square - : public std::binary_function< Type, Type&, - bool > { - public: - bool operator()( const Type& x, - Type& y ) const { - y = (Type) std::sqrt( (double)x ); - return x == y * y; - } - bool operator()( const Type& x) const { - Type y - = (Type) std::sqrt( (double)x ); - return x == y * y; - } - }; -}; - -template <> class Real_embeddable_traits< long long int > - : public INTERN_RET::Real_embeddable_traits_base< long long int , CGAL::Tag_true > { - public: - - class To_interval - : public std::unary_function< Type, std::pair< double, double > > { - public: - std::pair operator()( const Type& x ) const { - Protect_FPU_rounding P(CGAL_FE_TONEAREST); - Interval_nt approx ((double) x); - FPU_set_cw(CGAL_FE_UPWARD); - approx += Interval_nt::smallest(); - return approx.pair(); - } - }; -}; - -#ifdef __SIZEOF_INT128__ -template <> class Real_embeddable_traits< __int128 > - : public INTERN_RET::Real_embeddable_traits_base< __int128 , CGAL::Tag_true > {}; - -template <> class Real_embeddable_traits< unsigned __int128 > - : public INTERN_RET::Real_embeddable_traits_base< unsigned __int128 , CGAL::Tag_true > {}; -#endif - -} //namespace CGAL - -#include - -#endif // CGAL_LONG_LONG_H diff --git a/Number_types/include/CGAL/long_long.h b/Number_types/include/CGAL/long_long.h index 6f6c9001292..6135f76323b 100644 --- a/Number_types/include/CGAL/long_long.h +++ b/Number_types/include/CGAL/long_long.h @@ -88,6 +88,50 @@ template <> class Real_embeddable_traits< unsigned long long > }; }; +#ifdef __SIZEOF_INT128__ +// __int128 +template<> class Algebraic_structure_traits< __int128 > + : public Algebraic_structure_traits_base< __int128, + Euclidean_ring_tag > { + + public: + typedef Tag_true Is_exact; + typedef Tag_false Is_numerical_sensitive; + + typedef INTERN_AST::Div_per_operator< Type > Div; + typedef INTERN_AST::Mod_per_operator< Type > Mod; + +}; + +template <> class Real_embeddable_traits< __int128 > + : public INTERN_RET::Real_embeddable_traits_base< __int128 , CGAL::Tag_true > { + public: + + class To_interval + : public std::unary_function< Type, std::pair< double, double > > { + public: + std::pair operator()( const Type& x ) const { + return (Interval_nt<>((double)x)+Interval_nt<>::smallest()).pair(); + } + }; +}; + +// unsigned __int128 +template <> class Real_embeddable_traits< unsigned __int128 > + : public INTERN_RET::Real_embeddable_traits_base< unsigned __int128 , CGAL::Tag_true > { + public: + + class To_interval + : public std::unary_function< Type, std::pair< double, double > > { + public: + std::pair operator()( const Type& x ) const { + return (Interval_nt<>((double)x)+Interval_nt<>::smallest()).pair(); + } + }; +}; +#endif + + } //namespace CGAL #include From 4d6d5e685b0c177e23f8c40e2a9c25de932243ce Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 21 Jul 2013 15:31:57 +0200 Subject: [PATCH 195/210] Reviewers asked that Epick_d take a type argument for the dimension instead of an int. --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- NewKernel_d/include/CGAL/Epick_d.h | 12 +++++------- NewKernel_d/test/NewKernel_d/test.cpp | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index b49d99bdef2..cb1621093f7 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -121,7 +121,7 @@ representation of points and one based on the homogeneous representation of points. The interface of the kernel objects is designed such that it works well with both %Cartesian and homogeneous representation, for -example, points have a `Construct_point_d` functor that takes a range of coordinates plus a +example, points have a constructor with a range of coordinates plus a common denominator (the \f$ d+1\f$ homogeneous coordinates of the point). The common interfaces parameterized with a representation class allow one to develop code independent of the chosen representation. We said diff --git a/NewKernel_d/include/CGAL/Epick_d.h b/NewKernel_d/include/CGAL/Epick_d.h index a289c55e373..38b20bafc1a 100644 --- a/NewKernel_d/include/CGAL/Epick_d.h +++ b/NewKernel_d/include/CGAL/Epick_d.h @@ -35,13 +35,11 @@ struct Epick_d_help2 }; #undef CGAL_BASE #define CGAL_BASE \ - Kernel_d_interface< Cartesian_wrap< Epick_d_help2< \ - typename boost::conditional< d_==UNKNOWN_DIMENSION, \ - Dynamic_dimension_tag, \ - Dimension_tag \ - >::type \ - >, Epick_d > > -template + Kernel_d_interface< \ + Cartesian_wrap< \ + Epick_d_help2, \ + Epick_d > > +template struct Epick_d : CGAL_BASE { diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index e8130defd28..1570c7157a6 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -234,7 +234,7 @@ void test3(){ int main(){ test2 >(); - test2 >(); - test3 >(); - test3 >(); + test2 > >(); + test3 > >(); + test3 >(); } From 61d12905058e038205346ac14403b83e10f3583c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 21 Jul 2013 16:32:26 +0200 Subject: [PATCH 196/210] Missing functor --- .../CGAL/Kernel_d/Kernel_d_interface.h | 4 +- .../include/CGAL/Kernel_d/Types/Sphere.h | 42 +++++++++++++++++-- NewKernel_d/include/CGAL/functor_tags.h | 2 + 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index b63e708cb07..2ba2dcf6732 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -117,9 +117,9 @@ template struct Kernel_d_interface : public Base_ { //typedef typename Get_functor::type Oriented_side_d; //typedef typename Get_functor::type Side_of_bounded_sphere_d; - //typedef typename Get_functor::type Center_of_sphere_d; + typedef typename Get_functor::type Center_of_sphere_d; //typedef typename Get_functor::type Value_at_d; - //typedef typename Get_functor::type Point_of_sphere_d; + typedef typename Get_functor::type Point_of_sphere_d; typedef typename Get_functor::type Orthogonal_vector_d; //typedef typename Get_functor::type Linear_base_d; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h index cc9c163b58b..dabae71f8cb 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Sphere.h @@ -1,6 +1,7 @@ #ifndef CGAL_KD_TYPE_SPHERE_H #define CGAL_KD_TYPE_SPHERE_H #include +#include namespace CGAL { template class Sphere { typedef typename Get_type::type FT_; @@ -12,8 +13,8 @@ template class Sphere { Sphere(Point_ const&p, FT_ const&r2): c_(p), r2_(r2) {} // TODO: Add a piecewise constructor? - Point_ center()const{return c_;} - FT_ squared_radius()const{return r2_;} + Point_ const& center()const{return c_;} + FT_ const& squared_radius()const{return r2_;} }; namespace CartesianDKernelFunctors { template struct Construct_sphere : Store_kernel { @@ -33,7 +34,7 @@ template struct Construct_sphere : Store_kernel { template struct Center_of_sphere { CGAL_FUNCTOR_INIT_IGNORE(Center_of_sphere) typedef typename Get_type::type Sphere; - typedef typename Get_type::type result_type; + typedef typename Get_type::type const& result_type; result_type operator()(Sphere const&s)const{ return s.center(); } @@ -41,16 +42,49 @@ template struct Center_of_sphere { template struct Squared_radius { CGAL_FUNCTOR_INIT_IGNORE(Squared_radius) typedef typename Get_type::type Sphere; - typedef typename Get_type::type result_type; + typedef typename Get_type::type const& result_type; // TODO: Is_exact? result_type operator()(Sphere const&s)const{ return s.squared_radius(); } }; +// FIXME: Move it to the generic functors, using the two above and conditional to the existence of sqrt(FT) +template struct Point_of_sphere : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Point_of_sphere) + typedef R_ R; + typedef typename Get_type::type FT; + typedef typename Get_type::type RT; + typedef typename Get_type::type Point; + typedef typename Get_type::type Sphere; + typedef typename Get_functor >::type CP; + typedef typename Get_functor >::type CI; + typedef typename Get_functor::type PD; + typedef Point result_type; + typedef Sphere first_argument_type; + typedef int second_argument_type; + struct Trans : std::binary_function { + FT const& r_; int idx; bool sgn; + Trans (int n, FT const& r, bool b) : r_(r), idx(n), sgn(b) {} + FT operator()(FT const&x, int i)const{ + return (i == idx) ? sgn ? x + r_ : x - r_ : x; + } + }; + result_type operator()(Sphere const&s, int i)const{ + CI ci(this->kernel()); + PD pd(this->kernel()); + typedef boost::counting_iterator Count; + Point const&c = s.center(); + int d=pd(c); + bool last = (i == d); + Trans t(last ? 0 : i, sqrt(s.radius()), !last); + return CP(this->kernel())(make_transforming_pair_iterator(ci(c,Begin_tag()),Count(0),t),make_transforming_pair_iterator(ci(c,End_tag()),Count(d+1),t)); + } +}; } CGAL_KD_DEFAULT_TYPE(Sphere_tag,(CGAL::Sphere),(Point_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_sphere),(Sphere_tag,Point_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Center_of_sphere_tag,(CartesianDKernelFunctors::Center_of_sphere),(Sphere_tag,Point_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Squared_radius_tag,(CartesianDKernelFunctors::Squared_radius),(Sphere_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Point_of_sphere_tag,(CartesianDKernelFunctors::Point_of_sphere),(Sphere_tag,Point_tag),(Construct_ttag, Construct_ttag)); } // namespace CGAL #endif diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 92ecb43359d..e29397eb4ad 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -214,11 +214,13 @@ namespace CGAL { // Really? templatestruct Get_functor_category,B,C>{typedef Misc_tag type;}; + #define DECL_CONSTRUCT(X,Y) struct X##_tag {}; \ template<>struct map_result_tag{typedef Y##_tag type;}; \ templatestruct Get_functor_category{typedef Construct_tag type;} DECL_CONSTRUCT(Midpoint,Point); DECL_CONSTRUCT(Center_of_sphere,Point); + DECL_CONSTRUCT(Point_of_sphere,Point); DECL_CONSTRUCT(Segment_extremity,Point); DECL_CONSTRUCT(Sum_of_vectors,Vector); DECL_CONSTRUCT(Difference_of_vectors,Vector); From 7c574d3dd806b8ea996c6960cf876e8cdd0429f9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 22 Jul 2013 14:23:08 +0200 Subject: [PATCH 197/210] Rename Filtered_predicate since it isn't compatible with the old version. --- NewKernel_d/include/CGAL/Filtered_predicate.h | 357 ++---------------- .../CGAL/Kernel_d/Cartesian_filter_K.h | 2 +- .../include/CGAL/Kernel_d/Lazy_cartesian.h | 2 +- STL_Extension/include/CGAL/tags.h | 4 + 4 files changed, 43 insertions(+), 322 deletions(-) diff --git a/NewKernel_d/include/CGAL/Filtered_predicate.h b/NewKernel_d/include/CGAL/Filtered_predicate.h index c4608c2d3cf..06e13ca42f1 100644 --- a/NewKernel_d/include/CGAL/Filtered_predicate.h +++ b/NewKernel_d/include/CGAL/Filtered_predicate.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include namespace CGAL { @@ -47,7 +49,7 @@ namespace CGAL { template -class Filtered_predicate +class Filtered_predicate2 { //TODO: pack (at least use a tuple) //FIXME: is it better to store those, or just store enough to recreate them @@ -66,100 +68,30 @@ public: typedef C2E To_exact_converter; typedef C2A To_approximate_converter; + // FIXME: should use result_of, see emails by Nico typedef typename EP::result_type result_type; // AP::result_type must be convertible to EP::result_type. - Filtered_predicate() + Filtered_predicate2() {} template - Filtered_predicate(const K& k) + Filtered_predicate2(const K& k) : ep(k.exact_kernel()), ap(k.approximate_kernel()), c2e(k,k.exact_kernel()), c2a(k,k.approximate_kernel()) {} - template - Filtered_predicate(const K& k,const EK& ek,const AK& ak) - : ep(ek), ap(ak), c2e(k,ek), c2a(k,ak) - {} - - -#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES +#ifdef CGAL_CXX0X template result_type - operator()(const Args&... args) const; -#else - - template - result_type - operator()(const A1 &a1) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, - const A9 &a9) const; - - template - result_type - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, - const A9 &a9, const A10 &a10) const; - - // Idem for more than 10 arguments. Do it on demand. - -#endif -}; - -#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const Args&... args) const -{ + operator()(Args&&... args) const + { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); // Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG { Protect_FPU_rounding p; try { + // No forward here, the arguments may still be needed Ares res = ap(c2a(args)...); if (is_certain(res)) return get_certain(res); @@ -168,252 +100,37 @@ Filtered_predicate:: } CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(args)...); -} - + return ep(c2e(std::forward(args))...); + } #else -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - - Ares res = ap(c2a(a1)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), - c2a(a7)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), - c2a(a7), c2a(a8)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7), - c2e(a8)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, - const A9 &a9) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), - c2a(a7), c2a(a8), c2a(a9)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7), - c2e(a8), c2e(a9)); -} - -template - template -typename Filtered_predicate::result_type -Filtered_predicate:: - operator()(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, - const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, - const A9 &a9, const A10 &a10) const -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding p; - try - { - Ares res = ap(c2a(a1), c2a(a2), c2a(a3), c2a(a4), c2a(a5), c2a(a6), - c2a(a7), c2a(a8), c2a(a9), c2a(a10)); - if (is_certain(res)) - return get_certain(res); - } - catch (Uncertain_conversion_exception) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding p(CGAL_FE_TONEAREST); - return ep(c2e(a1), c2e(a2), c2e(a3), c2e(a4), c2e(a5), c2e(a6), c2e(a7), - c2e(a8), c2e(a9), c2e(a10)); -} +#define VAR(Z,N,C) C(a##N) +#define CODE(Z,N,_) \ + template \ + result_type \ + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a)) const \ + { \ + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ + { \ + Protect_FPU_rounding p; \ + try \ + { \ + Ares res = ap(BOOST_PP_ENUM(N,VAR,c2a)); \ + if (is_certain(res)) \ + return get_certain(res); \ + } \ + catch (Uncertain_conversion_exception) {} \ + } \ + CGAL_BRANCH_PROFILER_BRANCH(tmp); \ + Protect_FPU_rounding p(CGAL_FE_TONEAREST); \ + return ep(BOOST_PP_ENUM(N,VAR,c2e)); \ + } + BOOST_PP_REPEAT_FROM_TO(1, 10, CODE, _ ) +#undef CODE +#undef VAR #endif +}; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index c490f9b0ce5..c853cc125f2 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -35,7 +35,7 @@ struct Cartesian_filter_K : public Base_, template struct Functor { typedef typename Get_functor::type AP; typedef typename Get_functor::type EP; - typedef Filtered_predicate type; + typedef Filtered_predicate2 type; }; // TODO: // template struct Functor : diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 07a79c0f07d..44743047d5f 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -122,7 +122,7 @@ struct Lazy_cartesian : Dimension_base, template struct Functor { typedef typename Get_functor::type FA; typedef typename Get_functor::type FE; - typedef Filtered_predicate type; + typedef Filtered_predicate2 type; }; template struct Functor { typedef typename Get_functor::type FA; diff --git a/STL_Extension/include/CGAL/tags.h b/STL_Extension/include/CGAL/tags.h index 8bf81c78a83..9e5c943d0a2 100644 --- a/STL_Extension/include/CGAL/tags.h +++ b/STL_Extension/include/CGAL/tags.h @@ -39,6 +39,10 @@ template struct Boolean_tag { static const bool value = b; }; +/* In C++11, try: +template +using Boolean_tag = std::integral_constant; +*/ typedef Boolean_tag Tag_true; typedef Boolean_tag Tag_false; From 40119cb6ea407bfc794e7193310eba7b83d5a3df Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 22 Jul 2013 14:28:03 +0200 Subject: [PATCH 198/210] and rename the file, to match the class. --- .../CGAL/{Filtered_predicate.h => Filtered_predicate2.h} | 0 NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h | 2 +- NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename NewKernel_d/include/CGAL/{Filtered_predicate.h => Filtered_predicate2.h} (100%) diff --git a/NewKernel_d/include/CGAL/Filtered_predicate.h b/NewKernel_d/include/CGAL/Filtered_predicate2.h similarity index 100% rename from NewKernel_d/include/CGAL/Filtered_predicate.h rename to NewKernel_d/include/CGAL/Filtered_predicate2.h diff --git a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h index c853cc125f2..4e08e39d4ff 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Cartesian_filter_K.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include namespace CGAL { diff --git a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h index 44743047d5f..059e2a74fe5 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Lazy_cartesian.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include From 0d67d54bf3ce7c498cc584334ea7a29748cbfab3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 22 Jul 2013 15:11:38 +0200 Subject: [PATCH 199/210] I was starting to reduce the diff between master's Lazy.h and mine, but it is too large, I guess I'll have to start again from the one in master. IIRC it needed work anyway and is not useful for Epick_d so it can wait. --- NewKernel_d/include/CGAL/Lazy.h | 78 +++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 19 deletions(-) diff --git a/NewKernel_d/include/CGAL/Lazy.h b/NewKernel_d/include/CGAL/Lazy.h index 9a352f5d359..e62d45917f6 100644 --- a/NewKernel_d/include/CGAL/Lazy.h +++ b/NewKernel_d/include/CGAL/Lazy.h @@ -3,8 +3,8 @@ // // 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; version 2.1 of the License. -// See the file LICENSE.LGPL distributed with CGAL. +// 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. @@ -35,12 +35,23 @@ #include #include #include -#include #ifdef CGAL_HAS_THREADS # include #endif +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + namespace CGAL { namespace internal { BOOST_MPL_HAS_XXX_TRAIT_DEF(AT) @@ -89,17 +100,30 @@ depth(const Lazy& l) } +template +inline T const & approx(T const& d) { return d; }; +template +inline T const & exact (T const& d) { return d; }; +template +inline unsigned depth (T const& ) { return 0; }; /* #define CGAL_LAZY_FORWARD(T) \ - inline T const & approx(T const& d) { return d; } \ - inline T const & exact (T const& d) { return d; } \ - inline unsigned depth (T const& ) { return 0; } + inline const T & approx(const T& d) { return d; } \ + inline const T & exact (const T& d) { return d; } \ + inline unsigned depth (const T& ) { return 0; } +CGAL_LAZY_FORWARD(long double) CGAL_LAZY_FORWARD(double) CGAL_LAZY_FORWARD(float) CGAL_LAZY_FORWARD(int) -CGAL_LAZY_FORWARD(unsigned) +CGAL_LAZY_FORWARD(unsigned int) +CGAL_LAZY_FORWARD(long) +CGAL_LAZY_FORWARD(unsigned long) +#ifdef CGAL_USE_LONG_LONG +CGAL_LAZY_FORWARD(long long) +CGAL_LAZY_FORWARD(unsigned long long) +#endif CGAL_LAZY_FORWARD(Return_base_tag) CGAL_LAZY_FORWARD(Null_vector) CGAL_LAZY_FORWARD(Origin) @@ -107,13 +131,7 @@ CGAL_LAZY_FORWARD(Orientation) CGAL_LAZY_FORWARD(Bbox_2) CGAL_LAZY_FORWARD(Bbox_3) */ -template -inline T const & approx(T const& d) { return d; }; -template -inline T const & exact (T const& d) { return d; }; -template -inline unsigned depth (T const& ) { return 0; }; - +#undef CGAL_LAZY_FORWARD #ifdef CGAL_LAZY_KERNEL_DEBUG template @@ -164,7 +182,7 @@ print_dag(double d, std::ostream& os, int level) inline void -msg(std::ostream& os, int level, char* s) +msg(std::ostream& os, int level, const char* s) { for(int i = 0; i < level; i++) os << " "; @@ -173,7 +191,7 @@ msg(std::ostream& os, int level, char* s) inline void -print_dag(const Null_vector& nv, std::ostream& os, int level) +print_dag(const Null_vector&, std::ostream& os, int level) { for(int i = 0; i < level; i++) os << " "; @@ -182,12 +200,21 @@ print_dag(const Null_vector& nv, std::ostream& os, int level) inline void -print_dag(const Origin& nv, std::ostream& os, int level) +print_dag(const Origin&, std::ostream& os, int level) { for(int i = 0; i < level; i++) os << " "; os << "Origin" << std::endl; } + +inline +void +print_dag(const Return_base_tag&, std::ostream& os, int level) +{ + for(int i = 0; i < level; i++) + os << " "; + os << "Return_base_tag" << std::endl; +} #endif @@ -223,10 +250,10 @@ public: mutable ET *et; Lazy_rep () - : at(), et(NULL) {} + : at(), et(NULL){} Lazy_rep (const AT& a) - : at(a), et(NULL) {} + : at(a), et(NULL){} Lazy_rep (const AT& a, const ET& e) : at(a), et(new ET(e)) {} @@ -271,6 +298,12 @@ public: os << "Exact: "; print_at(os, *et); os << std::endl; +#ifdef CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID + for(int i = 0; i < level; i++){ + os << " "; + } + os << " (type: " << typeid(*et).name() << ")" << std::endl; +#endif // CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID } } @@ -352,12 +385,19 @@ public: this->set_depth(CGAL::depth(l1_) + 1); } +#ifdef CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID +# define CGAL_LAZY_PRINT_TYPEID CGAL::msg(os, level, typeid(AC).name()); +#else // not CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID +# define CGAL_LAZY_PRINT_TYPEID +#endif // not CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID + #ifdef CGAL_LAZY_KERNEL_DEBUG void print_dag(std::ostream& os, int level) const { this->print_at_et(os, level); if(this->is_lazy()){ + CGAL_LAZY_PRINT_TYPEID CGAL::msg(os, level, "DAG with one child node:"); CGAL::print_dag(l1_, os, level+1); } From 14d2073dd2fda21f1dec7916838186b27d010ea0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 22 Jul 2013 15:44:50 +0200 Subject: [PATCH 200/210] Move Dimension.h back to its place. --- Kernel_23/include/CGAL/Dimension.h | 61 +++++++++++- NewKernel_d/include/CGAL/Dimension.h | 130 -------------------------- NewKernel_d/test/NewKernel_d/Makefile | 2 +- 3 files changed, 61 insertions(+), 132 deletions(-) delete mode 100644 NewKernel_d/include/CGAL/Dimension.h diff --git a/Kernel_23/include/CGAL/Dimension.h b/Kernel_23/include/CGAL/Dimension.h index aab513f36ae..3070af031e3 100644 --- a/Kernel_23/include/CGAL/Dimension.h +++ b/Kernel_23/include/CGAL/Dimension.h @@ -23,9 +23,33 @@ #include #include #include +#include +#ifdef CGAL_EIGEN3_ENABLED +#include +#endif namespace CGAL { +#ifdef CGAL_EIGEN3_ENABLED +const int UNKNOWN_DIMENSION=Eigen::Dynamic; +#else +const int UNKNOWN_DIMENSION=std::numeric_limits::max(); +#endif + +// Check that dimension d1 is fine for a kernel of dimension d2. +// If d2 is unknown, any d1 is fine. +inline bool check_dimension_lt(int d1, int d2){ + //return (d2==UNKNOWN_DIMENSION)||(d1 @@ -34,7 +58,9 @@ struct Dimension_tag static const int value = dim; }; -struct Dynamic_dimension_tag {}; +struct Dynamic_dimension_tag { + static const int value = UNKNOWN_DIMENSION; +}; namespace internal { @@ -69,6 +95,39 @@ struct Feature_dimension typedef typename K::template Feature_dimension::type type; }; +// Change the dimension +templatestruct Increment_dimension { + typedef Dynamic_dimension_tag type; +}; +templatestruct Increment_dimension,i> { + typedef Dimension_tag type; +}; + +templatestruct Product_dimension { + typedef Dynamic_dimension_tag type; +}; +templatestruct Product_dimension,Dimension_tag > { + typedef Dimension_tag type; +}; + +#ifdef CGAL_EIGEN3_ENABLED +// Convert to Eigen's notion of dimension +template struct Eigen_dimension { + enum { value=Eigen::Dynamic }; +}; +template struct Eigen_dimension > { + enum { value=d }; +}; + +// and convert back +template struct Dimension_eigen { + typedef Dimension_tag type; +}; +template <> struct Dimension_eigen { + typedef Dynamic_dimension_tag type; +}; +#endif + } //namespace CGAL #endif // CGAL_DIMENSION_H diff --git a/NewKernel_d/include/CGAL/Dimension.h b/NewKernel_d/include/CGAL/Dimension.h deleted file mode 100644 index c89f1d96db1..00000000000 --- a/NewKernel_d/include/CGAL/Dimension.h +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2008 INRIA Sophia-Antipolis (France). -// Aviv University (Israel). All rights reserved. -// -// 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; version 2.1 of the License. -// See the file LICENSE.LGPL distributed with CGAL. -// -// 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) : Sylvain Pion - -#ifndef CGAL_DIMENSION_H -#define CGAL_DIMENSION_H - -#include -#include -#include -#ifdef CGAL_EIGEN3_ENABLED -#include -#endif - -namespace CGAL { - -#ifdef CGAL_EIGEN3_ENABLED -const int UNKNOWN_DIMENSION=Eigen::Dynamic; -#else -const int UNKNOWN_DIMENSION=std::numeric_limits::max(); -#endif - -inline bool check_dimension_lt(int d1, int d2){ - //return (d2==UNKNOWN_DIMENSION)||(d1 -struct Dimension_tag -{ - static const int value = dim; -}; - -struct Dynamic_dimension_tag { - static const int value = UNKNOWN_DIMENSION; -}; - - -namespace internal { - - template < typename D > - struct Dim_value { - static const int value = D::value; - }; - - template <> - struct Dim_value {}; - -} // namespace internal - - -// Ambient_dimension gives access to the dimension of the ambient space of an object. - -template < typename T, typename K = typename Kernel_traits::Kernel > -struct Ambient_dimension - : public internal::Dim_value< typename K::template Ambient_dimension::type > -{ - typedef typename K::template Ambient_dimension::type type; -}; - - -// Feature_dimension gives access to the dimension of an object. - -template < typename T, typename K = typename Kernel_traits::Kernel > -struct Feature_dimension - : public internal::Dim_value< typename K::template Feature_dimension::type > -{ - typedef typename K::template Feature_dimension::type type; -}; - -// Change the dimension -templatestruct Increment_dimension { - typedef Dynamic_dimension_tag type; -}; -templatestruct Increment_dimension,i> { - typedef Dimension_tag type; -}; - -templatestruct Product_dimension { - typedef Dynamic_dimension_tag type; -}; -templatestruct Product_dimension,Dimension_tag > { - typedef Dimension_tag type; -}; - -#ifdef CGAL_EIGEN3_ENABLED -// Convert to Eigen's notion of dimension -template struct Eigen_dimension { - enum { value=Eigen::Dynamic }; -}; -template struct Eigen_dimension > { - enum { value=d }; -}; - -// and convert back -template struct Dimension_eigen { - typedef Dimension_tag type; -}; -template <> struct Dimension_eigen { - typedef Dynamic_dimension_tag type; -}; -#endif - -} //namespace CGAL - -#endif // CGAL_DIMENSION_H diff --git a/NewKernel_d/test/NewKernel_d/Makefile b/NewKernel_d/test/NewKernel_d/Makefile index c7aea1ec399..0a6cbe80189 100644 --- a/NewKernel_d/test/NewKernel_d/Makefile +++ b/NewKernel_d/test/NewKernel_d/Makefile @@ -1,6 +1,6 @@ all: normal cxx0x -CGAL_INC = -I../../../Algebraic_foundations/include -I../../../STL_Extension/include -I../../../Number_types/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK +CGAL_INC = -I../../../Algebraic_foundations/include -I../../../STL_Extension/include -I../../../Number_types/include -I../../../Kernel_23/include -DCGAL_DISABLE_ROUNDING_MATH_CHECK EIGEN_INC = `pkg-config --cflags eigen3|sed -e 's/-I/-isystem/g'` -DCGAL_EIGEN3_ENABLED From 2a7b549d5e27147f8c64832cd73b6bbb638b6497 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 26 Jul 2013 18:10:10 +0200 Subject: [PATCH 201/210] A few more updates to the user manual for Epick_d. --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index cb1621093f7..c7a11b3ca3d 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -67,7 +67,7 @@ unordered set of elements of the corresponding tuple. This extends the syntax of random access iterators to input iterators. If we index the tuple as above then we require that -\f$ ++^{(d+1)}\mathit{first} = \mathit{last}\f$. +\f$ ++^{(d)}\mathit{first} = \mathit{last}\f$. \section Kernel_dKernel Kernel Representations @@ -142,7 +142,7 @@ strictly speaking, the built-in type `int` does not fulfill the requirements on a field type, since `int`s correspond to elements of a ring rather than a field, especially operation \f$ /\f$ is not the inverse of \f$ *\f$. The requirements on the type `R::RT` are -weaker. This type must fulfill the requirements on what is called an +weaker. This type must fulfill the requirements on what is called a Euclidean ring type in \cgal. This roughly means that `R::RT` is a type for which operations \f$ +\f$, \f$ -\f$, \f$ *\f$ are defined with semantics (approximately) corresponding to those of a @@ -224,7 +224,8 @@ Note that it provides few interfaces in addition to those documented in the \subsection Kernel_dNamingconventions Naming conventions The use of representation classes not only avoids problems, it also -makes all \cgal classes very uniform. They always consist of: +makes all \cgal classes very uniform. Like `Cartesian_d::Point_d`, +they always consist of:

  1. The capitalized base name of the geometric object, such as @@ -232,9 +233,9 @@ makes all \cgal classes very uniform. They always consist of:
  2. Followed by `_d`. -
  3. A representation class as parameter, which itself is -parameterized with a number type, such as -`Cartesian_d` or `Homogeneous_d`. +
  4. A representation class, which itself may be parameterized with a +number type, such as `Cartesian_d` or `Homogeneous_d`, +where the type can be found.
\subsection Kernel_dKernelasaTraitsClass Kernel as a Traits Class @@ -247,7 +248,7 @@ library you can use a kernel as a traits class. For some algorithms you even do not have to specify the kernel; it is detected automatically using the types of the geometric objects passed to the algorithm. In some other cases, the algorithms or data structures -needs more than is provided by a kernel. In these cases, a kernel can +need more than is provided by a kernel. In these cases, a kernel can not be used as a traits class. \subsection Kernel_dChoosingaKernel Choosing a Kernel @@ -282,6 +283,11 @@ they need speed and can live with approximate results, or even algorithms that, from time to time, crash or compute incorrect results due to accumulated rounding errors. +The `Epick_d` kernel provides a compromise using `double` coordinates. It +evaluates predicates exactly, which is slower than plain `double` +computations, but still faster than using an exact number type thanks to +filtering techniques. Constructions are inexact, computed with `double`. + \subsection Kernel_dInclusionofHeaderFiles Inclusion of Header Files You need just to include a representation class to obtain the From 4dc6fa5d2aeea1317957b9bb03010ab8da1d9d45 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 28 Jul 2013 19:08:31 +0200 Subject: [PATCH 202/210] Uglify private typedef in Handle_for for C++03 compilers. Add functor Value_at. --- NewKernel_d/include/CGAL/Handle_for.h | 6 ++--- .../CGAL/Kernel_d/Kernel_d_interface.h | 2 +- .../include/CGAL/Kernel_d/Types/Hyperplane.h | 22 +++++++++++++++++++ NewKernel_d/include/CGAL/functor_tags.h | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/NewKernel_d/include/CGAL/Handle_for.h b/NewKernel_d/include/CGAL/Handle_for.h index 047a6657fab..63a3fc39683 100644 --- a/NewKernel_d/include/CGAL/Handle_for.h +++ b/NewKernel_d/include/CGAL/Handle_for.h @@ -47,10 +47,10 @@ class Handle_for }; typedef typename Alloc::template rebind::other Allocator; - typedef typename Allocator::pointer pointer; + typedef typename Allocator::pointer pointer_; static Allocator allocator; - pointer ptr_; + pointer_ ptr_; public: @@ -255,7 +255,7 @@ protected: { if ( is_shared() ) { - pointer tmp_ptr = allocator.allocate(1); + pointer_ tmp_ptr = allocator.allocate(1); new (&(tmp_ptr->t)) element_type(ptr_->t); tmp_ptr->count = 1; --(ptr_->count); diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 2ba2dcf6732..1aa9d6a3b57 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -118,7 +118,7 @@ template struct Kernel_d_interface : public Base_ { //typedef typename Get_functor::type Side_of_bounded_sphere_d; typedef typename Get_functor::type Center_of_sphere_d; - //typedef typename Get_functor::type Value_at_d; + typedef typename Get_functor::type Value_at_d; typedef typename Get_functor::type Point_of_sphere_d; typedef typename Get_functor::type Orthogonal_vector_d; //typedef typename Get_functor::type Linear_base_d; diff --git a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h index 2d23d4c88b8..b35c9f91abc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Types/Hyperplane.h @@ -47,11 +47,33 @@ template struct Hyperplane_translation { return s.translation(); } }; +template struct Value_at : Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Value_at) + typedef typename Get_type::type Hyperplane; + typedef typename Get_type::type Vector; + typedef typename Get_type::type Point; + typedef typename Get_type::type FT; + typedef FT result_type; + typedef typename Get_functor::type Dot; + typedef typename Get_functor::type P2V; + result_type operator()(Hyperplane const&h, Point const&p)const{ + Dot dot(this->kernel()); + P2V p2v(this->kernel()); + return dot(h.orthogonal_vector(),p2v(p)); + // Use Orthogonal_vector to make it generic? + // Copy the code from Scalar_product to avoid p2v? + } + template + result_type operator()(Iter f, Iter e)const{ + throw "not implemented yet!"; + } +}; } //TODO: Add a condition that the hyperplane type is the one from this file. CGAL_KD_DEFAULT_TYPE(Hyperplane_tag,(CGAL::Hyperplane),(Vector_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Construct_ttag,(CartesianDKernelFunctors::Construct_hyperplane),(Vector_tag,Hyperplane_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Orthogonal_vector_tag,(CartesianDKernelFunctors::Orthogonal_vector),(Vector_tag,Hyperplane_tag),()); CGAL_KD_DEFAULT_FUNCTOR(Hyperplane_translation_tag,(CartesianDKernelFunctors::Hyperplane_translation),(Hyperplane_tag),()); +CGAL_KD_DEFAULT_FUNCTOR(Value_at_tag,(CartesianDKernelFunctors::Value_at),(Point_tag,Vector_tag,Hyperplane_tag),(Scalar_product_tag,Point_to_vector_tag)); } // namespace CGAL #endif diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index e29397eb4ad..8b43d802fa1 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -182,6 +182,7 @@ namespace CGAL { DECL_COMPUTE(Squared_radius); DECL_COMPUTE(Scalar_product); DECL_COMPUTE(Hyperplane_translation); + DECL_COMPUTE(Value_at); #undef DECL_COMPUTE #define DECL_ITER_OBJ(X,Y,Z,C) struct X##_tag {}; \ From 83443126779a3d69d59c1cbf08d3b36f862a4dce Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 28 Jul 2013 20:21:39 +0200 Subject: [PATCH 203/210] Oriented_side_d --- .../CGAL/Kernel_d/Kernel_d_interface.h | 2 +- .../Kernel_d/function_objects_cartesian.h | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index 1aa9d6a3b57..de0a5334a43 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -114,7 +114,7 @@ template struct Kernel_d_interface : public Base_ { //typedef typename Get_functor::type Has_on_positive_side_d; //typedef typename Get_functor::type Linear_rank_d; //typedef typename Get_functor::type Linearly_independent_d; - //typedef typename Get_functor::type Oriented_side_d; + typedef typename Get_functor::type Oriented_side_d; //typedef typename Get_functor::type Side_of_bounded_sphere_d; typedef typename Get_functor::type Center_of_sphere_d; 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 c6f671cb3b9..8d197daaee8 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -736,6 +736,36 @@ template struct Equal_points : private Store_kernel { CGAL_KD_DEFAULT_FUNCTOR(Equal_points_tag,(CartesianDKernelFunctors::Equal_points),(),(Construct_ttag)); +namespace CartesianDKernelFunctors { +template struct Oriented_side : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Oriented_side) + typedef R_ R; + typedef typename Get_type::type result_type; + typedef typename Get_type::type Point; + typedef typename Get_type::type Hyperplane; + typedef typename Get_type::type Sphere; + typedef typename Get_functor::type VA; + typedef typename Get_functor::type HT; + typedef typename Get_functor::type SD; + typedef typename Get_functor::type SR; + typedef typename Get_functor::type CS; + + result_type operator()(Hyperplane const&h, Point const&p)const{ + HT ht(this->kernel()); + VA va(this->kernel()); + return CGAL::compare(va(h,p),ht(h)); + } + result_type operator()(Sphere const&s, Point const&p)const{ + SD sd(this->kernel()); + SR sr(this->kernel()); + CS cs(this->kernel()); + return CGAL::compare(sd(cs(s),p),sr(s)); + } +}; +} + +CGAL_KD_DEFAULT_FUNCTOR(Oriented_side_tag,(CartesianDKernelFunctors::Oriented_side),(Point_tag,Sphere_tag,Hyperplane_tag),(Value_at_tag,Hyperplane_translation_tag,Squared_distance_tag,Squared_radius_tag,Center_of_sphere_tag)); + } #include #endif // CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H From 29fefc1a2295d06070d68c43a5497708f3f0679d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 28 Jul 2013 20:45:54 +0200 Subject: [PATCH 204/210] Has_on_positive_side_d --- .../include/CGAL/Kernel_d/Kernel_d_interface.h | 2 +- .../CGAL/Kernel_d/function_objects_cartesian.h | 17 +++++++++++++++++ NewKernel_d/include/CGAL/functor_tags.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h index de0a5334a43..ffc102e1a25 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Kernel_d_interface.h @@ -111,7 +111,7 @@ template struct Kernel_d_interface : public Base_ { //typedef typename Get_functor::type Affinely_independent_d; //typedef typename Get_functor::type Contained_in_linear_hull_d; //typedef typename Get_functor::type Contained_in_simplex_d; - //typedef typename Get_functor::type Has_on_positive_side_d; + typedef typename Get_functor::type Has_on_positive_side_d; //typedef typename Get_functor::type Linear_rank_d; //typedef typename Get_functor::type Linearly_independent_d; typedef typename Get_functor::type Oriented_side_d; 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 8d197daaee8..8aae038d11e 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -766,6 +766,23 @@ template struct Oriented_side : private Store_kernel { CGAL_KD_DEFAULT_FUNCTOR(Oriented_side_tag,(CartesianDKernelFunctors::Oriented_side),(Point_tag,Sphere_tag,Hyperplane_tag),(Value_at_tag,Hyperplane_translation_tag,Squared_distance_tag,Squared_radius_tag,Center_of_sphere_tag)); +namespace CartesianDKernelFunctors { +template struct Has_on_positive_side : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Has_on_positive_side) + typedef R_ R; + typedef typename Get_type::type result_type; + typedef typename Get_functor::type OS; + + template + result_type operator()(Obj const&o, Pt const&p)const{ + OS os(this->kernel()); + return os(o,p) == ON_POSITIVE_SIDE; + } +}; +} + +CGAL_KD_DEFAULT_FUNCTOR(Has_on_positive_side_tag,(CartesianDKernelFunctors::Has_on_positive_side),(),(Oriented_side_tag)); + } #include #endif // CGAL_KERNEL_D_FUNCTION_OBJECTS_CARTESIAN_H diff --git a/NewKernel_d/include/CGAL/functor_tags.h b/NewKernel_d/include/CGAL/functor_tags.h index 8b43d802fa1..5fb34472835 100644 --- a/NewKernel_d/include/CGAL/functor_tags.h +++ b/NewKernel_d/include/CGAL/functor_tags.h @@ -254,7 +254,9 @@ namespace CGAL { DECL_PREDICATE(Less_lexicographically); DECL_PREDICATE(Less_or_equal_lexicographically); DECL_PREDICATE(Equal_points); + DECL_PREDICATE(Has_on_positive_side); DECL_PREDICATE_(Orientation); // duplicate with the type + DECL_PREDICATE_(Oriented_side); // duplicate with the type DECL_PREDICATE(Orientation_of_points); DECL_PREDICATE(Orientation_of_vectors); DECL_PREDICATE(Side_of_oriented_sphere); From 2fd3af8408735769d4ec897d6b0eecbaaaa5710d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 9 Oct 2013 17:52:58 +0200 Subject: [PATCH 205/210] Bogus sign in side_of_oriented_sphere. The definition is not so intuitive. --- NewKernel_d/include/CGAL/Kernel_d/Coaffine.h | 2 +- .../Kernel_d/function_objects_cartesian.h | 12 ++++++-- NewKernel_d/test/NewKernel_d/test.cpp | 28 ++++++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h index 86470a98271..ffc81ae6ecc 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/Kernel_d/Coaffine.h @@ -233,7 +233,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel m(d+1,d+1)+=CGAL_NTS square(m(d+1,j+1)); } - return LA::sign_of_determinant(CGAL_MOVE(m)); + return -LA::sign_of_determinant(CGAL_MOVE(m)); } }; 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 8aae038d11e..ce10ca8b10c 100644 --- a/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/Kernel_d/function_objects_cartesian.h @@ -264,11 +264,16 @@ template struct Side_of_oriented_sphere : private Store_kernel { template result_type operator()(Iter f, Iter const& e)const{ + Point const& p0=*f++; // *--e ? + return this->operator()(f,e,p0); + } + + template + result_type operator()(Iter f, Iter const& e, Point const& p0) const { typedef typename Get_functor::type Sqdo; typename Get_functor::type c(this->kernel()); typename Get_functor::type pd(this->kernel()); - Point const& p0=*f++; int d=pd(p0); Matrix m(d+1,d+1); if(CGAL::Is_stored::value) { @@ -292,7 +297,10 @@ template struct Side_of_oriented_sphere : private Store_kernel { } } } - return LA::sign_of_determinant(CGAL_MOVE(m)); + if(d%2) + return -LA::sign_of_determinant(CGAL_MOVE(m)); + else + return LA::sign_of_determinant(CGAL_MOVE(m)); } #ifdef CGAL_CXX0X diff --git a/NewKernel_d/test/NewKernel_d/test.cpp b/NewKernel_d/test/NewKernel_d/test.cpp index 1570c7157a6..74042308c19 100644 --- a/NewKernel_d/test/NewKernel_d/test.cpp +++ b/NewKernel_d/test/NewKernel_d/test.cpp @@ -1,4 +1,4 @@ -#define BOOST_RESULT_OF_USE_DECLTYPE 1 +//#define BOOST_RESULT_OF_USE_DECLTYPE 1 #include #include #include @@ -120,6 +120,20 @@ void test2(){ P tab[]={a,b,c,d}; std::cout << po (&tab[0],tab+3) << std::endl; std::cout << sos(&tab[0],tab+4) << std::endl; + P x1=cp(0,1); + P x2=cp(-1,-1); + P x3=cp(1,-1); + P x4=cp(0,0); + P x5=cp(0,-1); + P tab2[]={x1,x2,x3,x4}; + assert(po(tab2+0,tab2+3)==CGAL::COUNTERCLOCKWISE); + assert(sos(tab2+0,tab2+3,x4)==CGAL::ON_POSITIVE_SIDE); +#if 0 + // Doesn't compile with Lazy yet. + FO fo=cfo(tab2+1,tab2+3); + assert(ifo(fo,tab2+1,tab2+3)==CGAL::POSITIVE); + assert(ifsos(fo,tab2+1,tab2+3,x5)==CGAL::ON_POSITIVE_SIDE); +#endif } template struct Construct_point3_helper { @@ -230,6 +244,18 @@ void test3(){ assert(!cah(y+0,y+3,buf[0])); assert(cl(a,a)==CGAL::EQUAL); assert(cl(a,b)==CGAL::LARGER); + P x1=cp(0,1,-1); + P x2=cp(-1,-1,-1); + P x3=cp(1,-1,-1); + P x4=cp(0,0,1); + P x5=cp(0,0,0); + P x6=cp(0,0,-1); + P tab2[]={x1,x2,x3,x4,x5}; + assert(po(tab2+0,tab2+4)==CGAL::POSITIVE); + assert(sos(tab2+0,tab2+4,x5)==CGAL::ON_POSITIVE_SIDE); + FO fo4=cfo(tab2+0,tab2+3); + assert(ifo(fo4,tab2+0,tab2+3)==CGAL::POSITIVE); + assert(ifsos(fo4,tab2+0,tab2+3,x6)==CGAL::ON_POSITIVE_SIDE); } int main(){ From 9165a9f965d61d6ab52d11bf624d5a28667aaf2a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 18 Nov 2013 18:09:33 +0100 Subject: [PATCH 206/210] Use consistent notations. --- Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h index 769617412d5..cfb79c066a2 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h @@ -14,8 +14,8 @@ public: /*! returns \f$ p = (x_0,\ldots,x_{d-1})\f$ lifted to the paraboloid of -revolution which is the point \f$ (p_0, \ldots,p_{d-1},\sum_{0 \le i < -d}p_i^2)\f$ in \f$ (d+1)\f$-space. +revolution which is the point \f$ (x_0, \ldots,x_{d-1},\sum_{0 \le i < +d}x_i^2)\f$ in \f$ (d+1)\f$-space. */ Kernel_d::Point_d operator()(const Kernel_d::Point_d& p); From 8aa03c152cd489e38dd239dc7cb87319a3b1e6e1 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 18 Nov 2013 18:18:01 +0100 Subject: [PATCH 207/210] Rename parameter of Epick_d to DimensionTag. --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 9 +++++---- Kernel_d/doc/Kernel_d/Kernel_d.txt | 4 ++-- Kernel_d/doc/Kernel_d/PackageDescription.txt | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index fe78662f1e7..df510e91567 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -5,8 +5,9 @@ namespace CGAL { \ingroup PkgKernelDKernels A model for `Kernel_d` that uses %Cartesian coordinates to represent the -geometric objects. The parameter `Dimension` is the dimension of the -ambient Euclidean space. It may be either `Dimension_tag` or +geometric objects. The parameter `DimensionTag` is the dimension of the +ambient Euclidean space. It may be either `Dimension_tag` where `d` is +an integer or `Dynamic_dimension_tag`. It supports construction of points from `double` %Cartesian coordinates. It provides exact geometric predicates, but the geometric constructions are not guaranteed to be exact. The geometric @@ -33,7 +34,7 @@ concepts for the rest. \sa `CGAL::Homogeneous_d` */ -template< typename Dimension > +template< typename DimensionTag > class Epick_d { public: /*! @@ -46,7 +47,7 @@ class Point_d { public: /*! introduces a point with coordinates (x0, x1, ...) where the number of coordinates matches the dimension. - \pre `Dimension` is a fixed dimension, not `Dynamic_dimension_tag` */ + \pre `DimensionTag` is a fixed dimension, not `Dynamic_dimension_tag` */ Point_d(double x0, double x1, ...); /*! returns the i'th coordinate of a point. diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index c7a11b3ca3d..ffbb743a80d 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -209,7 +209,7 @@ type `LinearAlgebra`. \subsection Kernel_dEpickKernel Epick_d Kernel -The kernel `Epick_d`, short for Exact Predicates Inexact +The kernel `Epick_d`, short for Exact Predicates Inexact Constructions Kernel is a kernel particularly useful when the dimension of the space is known at compile-time. It uses a Cartesian representation and supports construction of points from `double` coordinates. It provides exact @@ -218,7 +218,7 @@ be exact. Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as -`Epick_d::Point_d`, not `Point_d>`. +`Epick_d::Point_d`, not `Point_d>`. \subsection Kernel_dNamingconventions Naming conventions diff --git a/Kernel_d/doc/Kernel_d/PackageDescription.txt b/Kernel_d/doc/Kernel_d/PackageDescription.txt index 58aa707ed80..fac0bbea0cb 100644 --- a/Kernel_d/doc/Kernel_d/PackageDescription.txt +++ b/Kernel_d/doc/Kernel_d/PackageDescription.txt @@ -48,7 +48,7 @@ ## Kernels ## - `CGAL::Cartesian_d` - `CGAL::Homogeneous_d` -- `CGAL::Epick_d` +- `CGAL::Epick_d` ## %Kernel Objects ## - `CGAL::Point_d` From 5d6c4c207b6fb05c2e66b52e406fed79ba45be9d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 18 Nov 2013 19:35:11 +0100 Subject: [PATCH 208/210] Explain DimensionTag in the user manual. --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index ffbb743a80d..7d5138d4a71 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -211,7 +211,9 @@ type `LinearAlgebra`. The kernel `Epick_d`, short for Exact Predicates Inexact Constructions Kernel is a kernel particularly useful when the dimension of -the space is known at compile-time. It uses a Cartesian representation and +the space is known at compile-time; `DimensionTag` is then +`Dimension_tag` where `d` is an integer representing the dimension. +It uses a Cartesian representation and supports construction of points from `double` coordinates. It provides exact geometric predicates, but the geometric constructions are not guaranteed to be exact. From 569aa80b0acb964809950aa9a1037f2abfb066fd Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 22 Nov 2013 01:27:13 +0100 Subject: [PATCH 209/210] Say a few more words about Dynamic_dimension_tag, document a few more functions for Point_d. Doc may not compile (didn't check). --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 22 +++++++++++++++++----- Kernel_d/doc/Kernel_d/Kernel_d.txt | 9 ++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index df510e91567..57eb9284c8e 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -6,9 +6,9 @@ namespace CGAL { A model for `Kernel_d` that uses %Cartesian coordinates to represent the geometric objects. The parameter `DimensionTag` is the dimension of the -ambient Euclidean space. It may be either `Dimension_tag` where `d` is -an integer or -`Dynamic_dimension_tag`. It supports construction of points from `double` +ambient Euclidean space. It may be either `Dimension_tag` \cgalModifBegin where `d` is +an integer \cgalModifEnd or +`Dynamic_dimension_tag`. \cgalModifBegin In the later case, the dimension of the space is specified for each point when it is constructed, so it doesn't need to be known at compile-time. \cgalModifEnd This kernel supports construction of points from `double` %Cartesian coordinates. It provides exact geometric predicates, but the geometric constructions are not guaranteed to be exact. The geometric predicates are made exact without sacrificing speed thanks to the use of @@ -47,12 +47,24 @@ class Point_d { public: /*! introduces a point with coordinates (x0, x1, ...) where the number of coordinates matches the dimension. - \pre `DimensionTag` is a fixed dimension, not `Dynamic_dimension_tag` */ + \pre `DimensionTag` is a fixed dimension, not `Dynamic_dimension_tag`. */ Point_d(double x0, double x1, ...); +/*! \cgalModifBegin introduces a point with coordinate set `[first,end)`. + \pre If `DimensionTag` is a fixed dimension, it matches `distance(first,end)`. + \cgalRequires The value type of `InputIterator` is convertible to `FT`.\cgalModifEnd + */ +template +Point_d(InputIterator first, InputIterator end); + /*! returns the i'th coordinate of a point. - \pre `i` is non-negative and less than the dimension */ + \pre `i` is non-negative and less than the dimension. */ double operator[](int i)const; + +/*! \cgalModifBegin returns an iterator pointing to the zeroth Cartesian coordinate.\cgalModifEnd */ +Cartesian_const_iterator_d cartesian_begin()const; +/*! \cgalModifBegin returns an iterator pointing beyond the last Cartesian coordinate.\cgalModifEnd */ +Cartesian_const_iterator_d cartesian_end()const; } /// @} diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 7d5138d4a71..d8772a62b4a 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -211,8 +211,10 @@ type `LinearAlgebra`. The kernel `Epick_d`, short for Exact Predicates Inexact Constructions Kernel is a kernel particularly useful when the dimension of -the space is known at compile-time; `DimensionTag` is then -`Dimension_tag` where `d` is an integer representing the dimension. +the space is known at compile-time; \cgalModifBegin `DimensionTag` is then +`Dimension_tag` where `d` is an integer representing the dimension. It +may also be used with parameter `Dynamic_dimension_tag`, in which case the +dimension does not need to be known at compile-time.\cgalModifEnd It uses a Cartesian representation and supports construction of points from `double` coordinates. It provides exact geometric predicates, but the geometric constructions are not guaranteed to @@ -237,7 +239,8 @@ they always consist of:
  • A representation class, which itself may be parameterized with a number type, such as `Cartesian_d` or `Homogeneous_d`, -where the type can be found. +where the type can be found, \cgalModifBegin except for `Epick_d` where the +number type is implicitly `double`\cgalModifEnd . \subsection Kernel_dKernelasaTraitsClass Kernel as a Traits Class From e6008198207ada6c2b58c4e1f7c2e4af15378d76 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 23 Nov 2013 12:25:33 +0100 Subject: [PATCH 210/210] Split the lifting and projection predicates into a refinement of Kernel_d. --- Kernel_d/doc/Kernel_d/CGAL/Cartesian_d.h | 4 +- Kernel_d/doc/Kernel_d/CGAL/Homogeneous_d.h | 4 +- .../Concepts/Kernel--Lift_to_paraboloid_d.h | 4 +- .../Concepts/Kernel--Project_along_d_axis_d.h | 4 +- .../Kernel_d/Concepts/KernelWithLifting_d.h | 50 +++++++++++++++++++ Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h | 1 + Kernel_d/doc/Kernel_d/Kernel_d.txt | 4 ++ 7 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 Kernel_d/doc/Kernel_d/Concepts/KernelWithLifting_d.h diff --git a/Kernel_d/doc/Kernel_d/CGAL/Cartesian_d.h b/Kernel_d/doc/Kernel_d/CGAL/Cartesian_d.h index a9136ed3072..dc5a473b70c 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Cartesian_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Cartesian_d.h @@ -4,7 +4,7 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels -A model for `Kernel_d` that uses %Cartesian coordinates to represent the +A model for `Kernel_d` (and even `KernelWithLifting_d`) that uses %Cartesian coordinates to represent the geometric objects. In order for `Cartesian_d` to model Euclidean geometry in \f$ E^d\f$ , for some mathematical field \f$ E\f$ (e.g., the rationals \f$\mathbb{Q}\f$ or the reals \f$\mathbb{R}\f$), the template parameter `FieldNumberType` @@ -14,7 +14,7 @@ type provided as a model for `FieldNumberType` is only an approximation of a field (such as the built-in type `double`), then the geometry provided by the kernel is only an approximation of Euclidean geometry. -\cgalModels `Kernel_d` +\cgalModels `KernelWithLifting_d` \sa `CGAL::Homogeneous_d` diff --git a/Kernel_d/doc/Kernel_d/CGAL/Homogeneous_d.h b/Kernel_d/doc/Kernel_d/CGAL/Homogeneous_d.h index ef224f2df35..71d57228738 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Homogeneous_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Homogeneous_d.h @@ -4,7 +4,7 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels -A model for a `Kernel_d` using homogeneous coordinates to represent the +A model for a `Kernel_d` (and even `KernelWithLifting_d`) using homogeneous coordinates to represent the geometric objects. In order for `Homogeneous` to model Euclidean geometry in \f$ E^d\f$, for some mathematical ring \f$ E\f$ (e.g., the integers \f$\mathbb{Z}\f$ or the rationals \f$\mathbb{Q}\f$), the template parameter `RT` @@ -14,7 +14,7 @@ type provided as a model for `RingNumberType` is only an approximation of a ring (such as the built-in type `double`), then the geometry provided by the kernel is only an approximation of Euclidean geometry. -\cgalModels `Kernel_d` +\cgalModels `KernelWithLifting_d` \sa `CGAL::Cartesian_d` diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h index cfb79c066a2..d6d2eddfd6e 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Lift_to_paraboloid_d.h @@ -5,7 +5,7 @@ */ -class Kernel_d::Lift_to_paraboloid_d { +class KernelWithLifting_d::Lift_to_paraboloid_d { public: /// \name Operations @@ -22,5 +22,5 @@ p); /// @} -}; /* end Kernel_d::Lift_to_paraboloid_d */ +}; /* end KernelWithLifting_d::Lift_to_paraboloid_d */ diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Project_along_d_axis_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Project_along_d_axis_d.h index 314374e0fc9..32b81ff5aa0 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel--Project_along_d_axis_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel--Project_along_d_axis_d.h @@ -5,7 +5,7 @@ */ -class Kernel_d::Project_along_d_axis_d { +class KernelWithLifting_d::Project_along_d_axis_d { public: /// \name Operations @@ -20,5 +20,5 @@ Kernel_d::Point_d operator()(const Kernel_d::Point_d& p); /// @} -}; /* end Kernel_d::Project_along_d_axis_d */ +}; /* end KernelWithLifting_d::Project_along_d_axis_d */ diff --git a/Kernel_d/doc/Kernel_d/Concepts/KernelWithLifting_d.h b/Kernel_d/doc/Kernel_d/Concepts/KernelWithLifting_d.h new file mode 100644 index 00000000000..65a6fe54a3f --- /dev/null +++ b/Kernel_d/doc/Kernel_d/Concepts/KernelWithLifting_d.h @@ -0,0 +1,50 @@ + +/*! +\ingroup PkgKernelDKernelConcept +\cgalConcept + +The concept of a kernel with lifting is a small refinement of the +general kernel concept. It adds 2 functors, the meaning of which would be +unclear in kernels of fixed dimension. + +\cgalRefines `Kernel_d` +\cgalHasModel `CGAL::Cartesian_d` +\cgalHasModel `CGAL::Homogeneous_d` +*/ +class KernelWithLifting_d { +public: + +/// \name Constructions +/// @{ + +/*! +a model of `KernelWithLifting_d::Lift_to_paraboloid_d` +*/ +typedef unspecified_type Lift_to_paraboloid_d; + +/*! +a model of `KernelWithLifting_d::Project_along_d_axis_d` +*/ +typedef unspecified_type Project_along_d_axis_d; + +/// @} + +/// \name Operations +/// The following member functions return function objects of the +/// types listed above. +/// @{ + +/*! + +*/ +Kernel_d::Lift_to_paraboloid_d lift_to_paraboloid_d_object() const; + +/*! + +*/ +Kernel_d::Project_along_d_axis_d project_along_d_axis_d_object() const; + +/// @} + +}; /* end KernelWithLifting_d */ + diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h index d93fad26e3d..09951afe72e 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h @@ -20,6 +20,7 @@ replacing operators, especially for equality testing. \cgalHasModel `CGAL::Cartesian_d` \cgalHasModel `CGAL::Homogeneous_d` +\cgalHasModel `CGAL::Epick_d` */ class Kernel_d { public: diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index d8772a62b4a..bed006c0da6 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -543,6 +543,10 @@ Stefan Schirra. This work was supported by ESPRIT IV Long Term Research Projects No. 21957 (CGAL) and No. 28155 (GALIA). +The Epick_d kernel was partially supported by the IST Programme of the EU +(FET Open) Project under Contract No IST-25582 – (CGL - Computational +Geometric Learning). + */ } /* namespace CGAL */