mirror of https://github.com/CGAL/cgal
Untested LA experiment.
This commit is contained in:
parent
9ab9754a1b
commit
26e611e450
|
|
@ -13,6 +13,8 @@ namespace CGAL {
|
|||
// In that case, we should store the real dim next to the array.
|
||||
template<class NT_,class Dim_,class Max_dim_=Dim_> 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;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
#ifndef CGAL_VECTOR_DETPTS_H
|
||||
#define CGAL_VECTOR_DETPTS_H
|
||||
#include <CGAL/functor_tags.h>
|
||||
#include <CGAL/Dimension.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class LA, class Dim_=LA::Dimension, class Max_dim_=LA::Max_dimension,
|
||||
bool = LA::template Property<Has_determinant_of_points_tag>::value,
|
||||
bool = LA::template Property<Has_determinant_of_vectors_tag>::value
|
||||
&& LA::template Property<Has_plus_minus_tag>::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<D2,D3> LA2;
|
||||
typedef Add_determinant_of_vectors_small_dim<LA2> Other;
|
||||
};
|
||||
};
|
||||
|
||||
//FIXME: Use variadics and boost so it works in any dimension.
|
||||
template <class LA, class Max_dim_>
|
||||
struct Add_determinant_of_points_from_vectors_and_minus
|
||||
<LA, Dimension_tag<2>, Max_dim_, false, true> : LA {
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
typedef typename LA::template Rebind_dimension<D2,D3> LA2;
|
||||
typedef Add_determinant_of_points_from_vectors_and_minus<LA2> Other;
|
||||
};
|
||||
template<class P,class=void> struct Property : LA::template Property<P> {};
|
||||
template<class D> struct Property<Has_determinant_of_points_tag, D> :
|
||||
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 <class LA, class Max_dim_>
|
||||
struct Add_determinant_of_points_from_vectors_and_minus
|
||||
<LA, Dimension_tag<3>, Max_dim_, false, true> : LA {
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
typedef typename LA::template Rebind_dimension<D2,D3> LA2;
|
||||
typedef Add_determinant_of_points_from_vectors_and_minus<LA2> Other;
|
||||
};
|
||||
template<class P,class=void> struct Property : LA::template Property<P> {};
|
||||
template<class D> struct Property<Has_determinant_of_points_tag, D> :
|
||||
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 <class LA, class Max_dim_>
|
||||
struct Add_determinant_of_points_from_vectors_and_minus
|
||||
<LA, Dimension_tag<4>, Max_dim_, false, true> : LA {
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
typedef typename LA::template Rebind_dimension<D2,D3> LA2;
|
||||
typedef Add_determinant_of_points_from_vectors_and_minus<LA2> Other;
|
||||
};
|
||||
template<class P,class=void> struct Property : LA::template Property<P> {};
|
||||
template<class D> struct Property<Has_determinant_of_points_tag, D> :
|
||||
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
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
#ifndef CGAL_VECTOR_DETVEC_SMALL_H
|
||||
#define CGAL_VECTOR_DETVEC_SMALL_H
|
||||
#include <CGAL/functor_tags.h>
|
||||
#include <CGAL/Dimension.h>
|
||||
#include <CGAL/determinant.h>
|
||||
#include <CGAL/predicates/sign_of_determinant.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <class LA, class Dim_=LA::Dimension, class Max_dim_=LA::Max_dimension,
|
||||
bool=LA::template Property<Has_determinant_of_vectors_tag>::value>
|
||||
struct Add_determinant_of_vectors_small_dim : LA {
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
typedef typename LA::template Rebind_dimension<D2,D3> LA2;
|
||||
typedef Add_determinant_of_vectors_small_dim<LA2> Other;
|
||||
};
|
||||
};
|
||||
|
||||
template <class LA, class Max_dim_>
|
||||
struct Add_determinant_of_vectors_small_dim
|
||||
<LA, Dimension_tag<2>, Max_dim_, false> : LA {
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
typedef typename LA::template Rebind_dimension<D2,D3> LA2;
|
||||
typedef Add_determinant_of_vectors_small_dim<LA2> Other;
|
||||
};
|
||||
template<class P,class=void> struct Property : LA::template Property<P> {};
|
||||
template<class D> struct Property<Has_determinant_of_vectors_tag, D> :
|
||||
boost::true_type {};
|
||||
|
||||
template <class V1, class V2>
|
||||
static NT determinant_of_vectors(V1 const&a, V2 const&b){
|
||||
return determinant(a[0],a[1],b[0],b[1]);
|
||||
}
|
||||
template <class V1, class V2>
|
||||
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 <class LA, class Max_dim_>
|
||||
struct Add_determinant_of_vectors_small_dim
|
||||
<LA, Dimension_tag<3>, Max_dim_, false> : LA {
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
typedef typename LA::template Rebind_dimension<D2,D3> LA2;
|
||||
typedef Add_determinant_of_vectors_small_dim<LA2> Other;
|
||||
};
|
||||
template<class P,class=void> struct Property : LA::template Property<P> {};
|
||||
template<class D> struct Property<Has_determinant_of_vectors_tag, D> :
|
||||
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 <class LA, class Max_dim_>
|
||||
struct Add_determinant_of_vectors_small_dim
|
||||
<LA, Dimension_tag<4>, Max_dim_, false> : LA {
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
typedef typename LA::template Rebind_dimension<D2,D3> LA2;
|
||||
typedef Add_determinant_of_vectors_small_dim<LA2> Other;
|
||||
};
|
||||
template<class P,class=void> struct Property : LA::template Property<P> {};
|
||||
template<class D> struct Property<Has_determinant_of_vectors_tag, D> :
|
||||
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
|
||||
|
|
@ -12,6 +12,8 @@ namespace CGAL {
|
|||
//Derive from a class that doesn't depend on Dim, or still use Dim for checking?
|
||||
template<class NT_,class Dim_,class Max_dim_=Dim_> struct Vector_vector {
|
||||
typedef NT_ NT;
|
||||
typedef Dim_ Dimension;
|
||||
typedef Max_dim_ Max_dimension;
|
||||
typedef std::vector<NT> Vector;
|
||||
template< class D2, class D3=D2 >
|
||||
struct Rebind_dimension {
|
||||
|
|
|
|||
Loading…
Reference in New Issue