// Copyright (c) 2014 // INRIA Saclay-Ile de France (France) // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // Author(s) : Marc Glisse #ifndef CGAL_KD_KO_CONVERTER_H #define CGAL_KD_KO_CONVERTER_H #include #include #include // First_if_different #include 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. namespace internal { template struct Point_converter_help { 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); typename Get_functor >::type cp(k2); return cp(conv(i(p,Begin_tag())),conv(i(p,End_tag()))); } }; #ifdef CGAL_CXX11 // 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 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); typename Get_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 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 // typedef typename K1:: Point K1_Point; // typedef typename First_if_different::Type argument_type; typedef K1_Vector 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& v) const { typename Get_functor >::type i(k1); typename Get_functor >::type cp(k2); return cp(conv(i(v,Begin_tag())),conv(i(v,End_tag()))); } }; template struct KO_converter{ 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); typename Get_functor >::type cs(k2); return cs(conv(f(s,0)),conv(f(s,1))); } }; template struct KO_converter{ 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& h) const { typename Get_functor::type ov(k1); typename Get_functor::type ht(k1); typename Get_functor >::type ch(k2); return ch(conv(ov(h)),conv(ht(h))); } }; template struct KO_converter{ 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 cos(k1); typename Get_functor::type sr(k1); typename Get_functor >::type cs(k2); return cs(conv(cos(s)),conv(sr(s))); } }; template struct KO_converter{ 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 pdw(k1); typename Get_functor::type pw(k1); typename Get_functor >::type cwp(k2); return cwp(conv(pdw(s)),conv(pw(s))); } }; } #endif