mirror of https://github.com/CGAL/cgal
Use cpp11::array and std::vector instead of eigen to store objects,
because of alignment issues (fingers crossed for C++17...). This showed a bug in the way I was conditionally enabling some functors, good thing there are more than 2 integers.
This commit is contained in:
parent
bb4cf33b5e
commit
6f7814bf5d
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/basic.h>
|
||||||
#include <CGAL/Origin.h>
|
#include <CGAL/Origin.h>
|
||||||
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
#include <CGAL/representation_tags.h>
|
#include <CGAL/representation_tags.h>
|
||||||
#include <CGAL/NewKernel_d/functor_tags.h>
|
#include <CGAL/NewKernel_d/functor_tags.h>
|
||||||
#include <CGAL/Uncertain.h>
|
#include <CGAL/Uncertain.h>
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
#include <CGAL/NewKernel_d/Dimension_base.h>
|
#include <CGAL/NewKernel_d/Dimension_base.h>
|
||||||
#include <CGAL/NewKernel_d/Cartesian_LA_functors.h>
|
#include <CGAL/NewKernel_d/Cartesian_LA_functors.h>
|
||||||
#include <CGAL/NewKernel_d/Vector/array.h>
|
#include <CGAL/NewKernel_d/Vector/array.h>
|
||||||
|
#include <CGAL/NewKernel_d/Vector/vector.h>
|
||||||
|
#include <CGAL/NewKernel_d/Vector/mix.h>
|
||||||
#ifdef CGAL_EIGEN3_ENABLED
|
#ifdef CGAL_EIGEN3_ENABLED
|
||||||
#include <CGAL/NewKernel_d/LA_eigen/LA.h>
|
#include <CGAL/NewKernel_d/LA_eigen/LA.h>
|
||||||
#else
|
#else
|
||||||
|
|
@ -21,9 +23,16 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
template < typename FT_, typename Dim_,
|
template < typename FT_, typename Dim_,
|
||||||
#if 0
|
#if 1
|
||||||
|
typename Vec_=Mix_vector<Array_vector<FT_, Dim_>,
|
||||||
|
Vector_vector<FT_, Dim_>,
|
||||||
|
FT_, Dim_>,
|
||||||
|
#elif 0
|
||||||
typename Vec_=Array_vector<FT_, Dim_>,
|
typename Vec_=Array_vector<FT_, Dim_>,
|
||||||
|
#elif 0
|
||||||
|
typename Vec_=Vector_vector<FT_, Dim_>,
|
||||||
#else
|
#else
|
||||||
|
// Dangerous because of alignment. Ok on x86_64 without AVX.
|
||||||
typename Vec_=LA_eigen<FT_, Dim_>,
|
typename Vec_=LA_eigen<FT_, Dim_>,
|
||||||
#endif
|
#endif
|
||||||
typename LA_=LA_eigen<FT_,Dim_> >
|
typename LA_=LA_eigen<FT_,Dim_> >
|
||||||
|
|
@ -61,7 +70,7 @@ struct Cartesian_LA_base_d : public Dimension_base<Dim_>
|
||||||
::add<Vector_cartesian_const_iterator_tag>::type
|
::add<Vector_cartesian_const_iterator_tag>::type
|
||||||
Iterator_list;
|
Iterator_list;
|
||||||
|
|
||||||
template<class, class=void, class=Tag_true> struct Functor {
|
template<class, class=void, class=boost::integral_constant<int,0> > struct Functor {
|
||||||
typedef Null_functor type;
|
typedef Null_functor type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Construct_ttag<Vector_tag>,D> {
|
template<class D> struct Functor<Construct_ttag<Vector_tag>,D> {
|
||||||
|
|
@ -77,20 +86,21 @@ struct Cartesian_LA_base_d : public Dimension_base<Dim_>
|
||||||
typedef CartesianDVectorBase::Construct_cartesian_const_iterator<Self> type;
|
typedef CartesianDVectorBase::Construct_cartesian_const_iterator<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Sum_of_vectors_tag,D,
|
template<class D> struct Functor<Sum_of_vectors_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Has_vector_plus_minus_tag>::value> > {
|
boost::integral_constant<int,!LA_vector::template Property<Has_vector_plus_minus_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Sum_of_vectors<Self> type;
|
typedef CartesianDVectorBase::Sum_of_vectors<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Difference_of_vectors_tag,D,
|
template<class D> struct Functor<Difference_of_vectors_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Has_vector_plus_minus_tag>::value> > {
|
boost::integral_constant<int,!LA_vector::template Property<Has_vector_plus_minus_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Difference_of_vectors<Self> type;
|
typedef CartesianDVectorBase::Difference_of_vectors<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Opposite_vector_tag,D,
|
template<class D> struct Functor<Opposite_vector_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Has_vector_plus_minus_tag>::value> > {
|
boost::integral_constant<int,!LA_vector::template Property<Has_vector_plus_minus_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Opposite_vector<Self> type;
|
typedef CartesianDVectorBase::Opposite_vector<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Midpoint_tag,D,
|
template<class D> struct Functor<Midpoint_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Has_vector_plus_minus_tag>::value
|
boost::integral_constant<int,
|
||||||
&& LA_vector::template Property<Has_vector_scalar_ops_tag>::value> > {
|
!LA_vector::template Property<Has_vector_plus_minus_tag>::value
|
||||||
|
|| !LA_vector::template Property<Has_vector_scalar_ops_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Midpoint<Self> type;
|
typedef CartesianDVectorBase::Midpoint<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Compute_point_cartesian_coordinate_tag,D> {
|
template<class D> struct Functor<Compute_point_cartesian_coordinate_tag,D> {
|
||||||
|
|
@ -106,24 +116,26 @@ struct Cartesian_LA_base_d : public Dimension_base<Dim_>
|
||||||
typedef CartesianDVectorBase::PV_dimension<Self> type;
|
typedef CartesianDVectorBase::PV_dimension<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Orientation_of_vectors_tag,D,
|
template<class D> struct Functor<Orientation_of_vectors_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Has_determinant_of_iterator_to_vectors_tag>::value> > {
|
boost::integral_constant<int,!LA_vector::template Property<Has_determinant_of_iterator_to_vectors_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Orientation_of_vectors<Self> type;
|
typedef CartesianDVectorBase::Orientation_of_vectors<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Orientation_of_points_tag,D,
|
template<class D> struct Functor<Orientation_of_points_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Has_determinant_of_iterator_to_points_tag>::value> > {
|
boost::integral_constant<int,!LA_vector::template Property<Has_determinant_of_iterator_to_points_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Orientation_of_points<Self> type;
|
typedef CartesianDVectorBase::Orientation_of_points<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Scalar_product_tag,D,
|
template<class D> struct Functor<Scalar_product_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Has_dot_product_tag>::value> > {
|
boost::integral_constant<int,!LA_vector::template Property<Has_dot_product_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Scalar_product<Self> type;
|
typedef CartesianDVectorBase::Scalar_product<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Squared_distance_to_origin_tag,D,
|
template<class D> struct Functor<Squared_distance_to_origin_tag,D,
|
||||||
Boolean_tag<LA_vector::template Property<Stores_squared_norm_tag>::value> > {
|
boost::integral_constant<int,!LA_vector::template Property<Stores_squared_norm_tag>::value> > {
|
||||||
typedef CartesianDVectorBase::Squared_distance_to_origin_stored<Self> type;
|
typedef CartesianDVectorBase::Squared_distance_to_origin_stored<Self> type;
|
||||||
};
|
};
|
||||||
|
// Use integral_constant<int,2> in case of failure, to distinguish from the previous one.
|
||||||
template<class D> struct Functor<Squared_distance_to_origin_tag,D,
|
template<class D> struct Functor<Squared_distance_to_origin_tag,D,
|
||||||
Boolean_tag<!LA_vector::template Property<Stores_squared_norm_tag>::value
|
boost::integral_constant<int,
|
||||||
&& LA_vector::template Property<Has_dot_product_tag>::value> > {
|
(LA_vector::template Property<Stores_squared_norm_tag>::value
|
||||||
|
|| !LA_vector::template Property<Has_dot_product_tag>::value)*2> > {
|
||||||
typedef CartesianDVectorBase::Squared_distance_to_origin_via_dotprod<Self> type;
|
typedef CartesianDVectorBase::Squared_distance_to_origin_via_dotprod<Self> type;
|
||||||
};
|
};
|
||||||
template<class D> struct Functor<Point_to_vector_tag,D> {
|
template<class D> struct Functor<Point_to_vector_tag,D> {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef CGAL_KD_MIX_VECTOR_H
|
||||||
|
#define CGAL_KD_MIX_VECTOR_H
|
||||||
|
#include <CGAL/Dimension.h>
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
template <class Static_, class Dynamic_, class NT_ ,class Dim_, class Max_dim_ = Dim_>
|
||||||
|
struct Mix_vector
|
||||||
|
: Dynamic_::template Rebind_dimension<Dim_, Max_dim_>::Other
|
||||||
|
{
|
||||||
|
template <class D2, class D3 = D2>
|
||||||
|
struct Rebind_dimension {
|
||||||
|
typedef Mix_vector<Static_, Dynamic_, NT_, D2, D3> Other;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Static_, class Dynamic_, class NT_, int d, class Max_dim_>
|
||||||
|
struct Mix_vector<Static_, Dynamic_, NT_, Dimension_tag<d>, Max_dim_>
|
||||||
|
: Static_::template Rebind_dimension<Dimension_tag<d>, Max_dim_>::Other
|
||||||
|
{
|
||||||
|
template <class D2, class D3 = D2>
|
||||||
|
struct Rebind_dimension {
|
||||||
|
typedef Mix_vector<Static_, Dynamic_, NT_, D2, D3> Other;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Loading…
Reference in New Issue