VTK-m  2.0
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<tt>is 6 (3 * 2). The[]operator takes an index between 0 and 5 and returns a value of typevtkm::Id<tt>. The indices are explored in depth-first order. SoflatVec[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::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::make_VecFlat
VTKM_EXEC_CONT vtkm::VecFlat< T > make_VecFlat(const T &vec)
Converts a Vec-like object to a VecFlat.
Definition: VecFlat.h:281