Viskores  1.0
viskores::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 viskores::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 viskores::Vec<viskores::Vec<viskores::Id, 2>, 3>& nestedVec)
{
auto flatVec = viskores::make_VecFlat(nestedVec);

flatVec is now of type viskores::VecFlat<viskores::Vec<viskores::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 viskores::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 viskores::VecTraitsTagSizeStatic (that is, the NUM_COMPONENTS constant is defined).


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