VTK-m  2.2
vtkm::VecFlat< T, bool > Class Template Reference

Treat a Vec or Vec-like object as a flat Vec. More...

#include <VecFlat.h>

Detailed Description

template<typename T, bool = internal::IsFlatVec<T>::value>
class vtkm::VecFlat< T, bool >

Treat a Vec or Vec-like object as a flat Vec.

The VecFlat template wraps around another object that is a nested Vec object (that is, a vector of vectors) and treats it like a flat, 1 dimensional Vec. For example, let's say that you have a Vec of size 3 holding Vecs of size 2.

void Foo(const vtkm::Vec<vtkm::Vec<vtkm::Id, 2>, 3>& nestedVec)
{
auto flatVec = vtkm::make_VecFlat(nestedVec);

flatVec is now of type vtkm::VecFlat<vtkm::Vec<vtkm::Vec<T, 2>, 3>. flatVec::NUM_COMPONENTS is 6 (3 * 2). The [] operator takes an index between 0 and 5 and returns a value of type vtkm::Id. The indices are explored in depth-first order. So flatVec[0] == nestedVec[0][0], flatVec[1] == nestedVec[0][1], flatVec[2] == nestedVec[1][0], and so on.

Note that flatVec only works with types that have VecTraits defined where the IsSizeStatic field is vtkm::VecTraitsTagSizeStatic (that is, the NUM_COMPONENTS constant is defined).


The documentation for this class was generated from the following file:
vtkm::make_VecFlat
vtkm::VecFlat< T > make_VecFlat(const T &vec)
Converts a Vec-like object to a VecFlat.
Definition: VecFlat.h:281
vtkm::Vec
A short fixed-length array.
Definition: Types.h:357