Felt  3.1
Deformable surface library.
Felt::Impl::Mixin::Grid::Index< TDerived > Class Template Reference

#include <GridMixin.hpp>

Inherited by Felt::Impl::Mixin::Grid::Access::ByRef< TDerived > [protected], and Felt::Impl::Mixin::Grid::Access::ByValue< TDerived > [protected].

Protected Member Functions

PosIdx index (const VecDi &pos_) const
 Get index in data array of position vector. More...
 
VecDi index (const PosIdx idx_) const
 Get position of index. More...
 

Member Function Documentation

◆ index() [1/2]

template<class TDerived >
PosIdx Felt::Impl::Mixin::Grid::Index< TDerived >::index ( const VecDi &  pos_) const
inlineprotected

Get index in data array of position vector.

The grid is packed in a 1D array, so this method is required to get the index in that array of the D-dimensional position.

THEN("the index of a point in the data array is reported correctly")
{
CHECK(Felt::index<3>(Vec3i(1, 0, -1), size, offset) == 613);
CHECK(grid.index(Vec3i(1, 0, -1)) == 613);
}
THEN("the point represented by an index in the data array is reported correctly")
{
CHECK(grid.index(613) == Vec3i(1, 0, -1));
CHECK(Felt::index<3>(613, size, offset) == Vec3i(1, 0, -1));
}
Parameters
pos_position in grid to query.
Returns
index in internal data array of this grid position.

◆ index() [2/2]

template<class TDerived >
VecDi Felt::Impl::Mixin::Grid::Index< TDerived >::index ( const PosIdx  idx_) const
inlineprotected

Get position of index.

Given an index in the 1D grid data array, calculate the position vector that it pertains to.

THEN("the index of a point in the data array is reported correctly")
{
CHECK(Felt::index<3>(Vec3i(1, 0, -1), size, offset) == 613);
CHECK(grid.index(Vec3i(1, 0, -1)) == 613);
}
THEN("the point represented by an index in the data array is reported correctly")
{
CHECK(grid.index(613) == Vec3i(1, 0, -1));
CHECK(Felt::index<3>(613, size, offset) == Vec3i(1, 0, -1));
}
Parameters
idx_index in internal data array to query.
Returns
the position in the grid represented in the data array at given index.

The documentation for this class was generated from the following file: