3#include <Core/Containers/AlignedStdVector.hpp>
4#include <Core/RaCore.hpp>
5#include <Core/Utils/ContainerIntrospectionInterface.hpp>
15template <
typename V,
bool isArithmetic,
bool isEigen>
25 std::is_arithmetic<V>::value || std::is_enum<V>::value,
26 std::is_base_of<typename Eigen::MatrixBase<V>, V>::value> {};
40 static constexpr int NumberOfComponents = TypeHelper::NumberOfComponents;
47 using Matrix = Eigen::Matrix<component_type, TypeHelper::NumberOfComponents, Eigen::Dynamic>;
48 using MatrixMap = Eigen::Map<Matrix>;
49 using ConstMatrixMap = Eigen::Map<const Matrix>;
59 int getStride()
const override {
return sizeof( V ); }
69 template <
int N = NumberOfComponents>
70 std::enable_if_t<( N > 0 ), MatrixMap>
getMap() {
71 CORE_ASSERT( !this->
empty(),
"Cannot map an empty vector " );
72 return MatrixMap( TypeHelper::getData(
this ),
73 TypeHelper::NumberOfComponents,
74 Eigen::Index( this->
size() ) );
78 template <
int N = NumberOfComponents>
79 std::enable_if_t<( N > 0 ), ConstMatrixMap>
getMap()
const {
80 CORE_ASSERT( !this->
empty(),
"Cannot map an empty vector " );
81 return ConstMatrixMap( TypeHelper::getConstData(
this ),
82 TypeHelper::NumberOfComponents,
83 Eigen::Index( this->
size() ) );
90 using component_type = V;
91 static constexpr int NumberOfComponents = 1;
93 static inline const component_type* getConstData(
const VectorArray<V>* v ) {
99struct VectorArrayTypeHelperInternal<V, false, true> {
100 using component_type =
typename V::Scalar;
101 static constexpr int NumberOfComponents = V::RowsAtCompileTime;
102 static inline component_type* getData( VectorArray<V>* v ) {
return v->data()->data(); }
103 static inline const component_type* getConstData(
const VectorArray<V>* v ) {
104 return v->data()->data();
109struct VectorArrayTypeHelperInternal<V, false, false> {
110 using component_type = V;
111 static constexpr int NumberOfComponents = 0;
112 static inline component_type* getData( VectorArray<V>* v ) {
return v->data(); }
113 static inline const component_type* getConstData(
const VectorArray<V>* v ) {
119using Vector1Array = VectorArray<Scalar>;
120#define DEFINE_CONVENIENCE_MATRIX_ALIAS( NAME, TYPE, DIM ) \
121 using NAME = VectorArray<Eigen::Matrix<TYPE, DIM, 1>>;
122DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector2Array, Scalar, 2 )
123DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector3Array, Scalar, 3 )
124DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector4Array, Scalar, 4 )
125DEFINE_CONVENIENCE_MATRIX_ALIAS( VectorNArray, Scalar, Eigen::Dynamic )
126DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector1iArray,
int, 1 )
127DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector2iArray,
int, 2 )
128DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector3iArray,
int, 3 )
129DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector4iArray,
int, 4 )
130DEFINE_CONVENIENCE_MATRIX_ALIAS( VectorNiArray,
int, Eigen::Dynamic )
131DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector1uArray, uint, 1 )
132DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector2uArray, uint, 2 )
133DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector3uArray, uint, 3 )
134DEFINE_CONVENIENCE_MATRIX_ALIAS( Vector4uArray, uint, 4 )
135DEFINE_CONVENIENCE_MATRIX_ALIAS( VectorNuArray, uint, Eigen::Dynamic )
136#undef DEFINE_CONVENIENCE_MATRIX_ALIAS
This class defines the introspection interface a container need to implement.
This class implements ContainerIntrospectionInterface for AlignedStdVector.
std::enable_if_t<(N > 0), MatrixMap > getMap()
const void * dataPtr() const override
typename TypeHelper::component_type component_type
size_t getNumberOfComponents() const override
int getStride() const override
size_t getSize() const override
size_t getBufferSize() const override
std::enable_if_t<(N > 0), ConstMatrixMap > getMap() const
std::vector< T, Eigen::aligned_allocator< T > > AlignedStdVector
hepler function to manage enum as underlying types in VariableSet