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],