Commit 4f1506d9 authored by Robert Maynard's avatar Robert Maynard

vtkmlib PortalTraits has traits for scalar,vec, and vec of vec.

This way other code can easily see if the T type being passed
in is a scalar, a vtkm::Vec or a vtkm::Vec<vtkm::Vec>. This
is important when converting to and from vtk-m.
parent 47a5b53a
......@@ -26,9 +26,14 @@
namespace tovtkm {
struct vtkPortalOfVecOfVecValues;
struct vtkPortalOfVecOfValues;
struct vtkPortalOfScalarValues;
template<typename T>
struct vtkPortalTraits
{
using TagType = vtkPortalOfScalarValues;
using ComponentType = typename std::remove_const<T>::type;
using Type = ComponentType;
static constexpr vtkm::IdComponent NUM_COMPONENTS = 1;
......@@ -47,6 +52,7 @@ struct vtkPortalTraits
template<typename T, int N>
struct vtkPortalTraits< vtkm::Vec<T,N> >
{
using TagType = vtkPortalOfVecOfValues;
using ComponentType = typename std::remove_const<T>::type;
using Type = vtkm::Vec<T,N>;
static constexpr vtkm::IdComponent NUM_COMPONENTS = N;
......@@ -69,6 +75,7 @@ struct vtkPortalTraits< vtkm::Vec<T,N> >
template<typename T, int N>
struct vtkPortalTraits< const vtkm::Vec<T,N> >
{
using TagType = vtkPortalOfVecOfValues;
using ComponentType = typename std::remove_const<T>::type;
using Type = vtkm::Vec<T,N>;
static constexpr vtkm::IdComponent NUM_COMPONENTS = N;
......@@ -91,10 +98,14 @@ struct vtkPortalTraits< const vtkm::Vec<T,N> >
template<typename T, int N, int M>
struct vtkPortalTraits<vtkm::Vec< vtkm::Vec<T,N>, M> >
{
using TagType = vtkPortalOfVecOfVecValues;
using ComponentType = typename std::remove_const<T>::type;
using Type = vtkm::Vec< vtkm::Vec<T,N>, M>;
static constexpr vtkm::IdComponent NUM_COMPONENTS = N*M;
static constexpr vtkm::IdComponent NUM_COMPONENTS_OUTER = M;
static constexpr vtkm::IdComponent NUM_COMPONENTS_INNER = N;
static inline
void SetComponent(Type& t, vtkm::IdComponent i, const ComponentType& v)
{
......@@ -117,10 +128,15 @@ struct vtkPortalTraits<vtkm::Vec< vtkm::Vec<T,N>, M> >
template<typename T, int N, int M>
struct vtkPortalTraits< const vtkm::Vec< vtkm::Vec<T,N>, M> >
{
using TagType = vtkPortalOfVecOfVecValues;
using ComponentType = typename std::remove_const<T>::type;
using Type = vtkm::Vec< vtkm::Vec<T,N>, M>;
static constexpr vtkm::IdComponent NUM_COMPONENTS = N*M;
static constexpr vtkm::IdComponent NUM_COMPONENTS_OUTER = M;
static constexpr vtkm::IdComponent NUM_COMPONENTS_INNER = N;
static inline
void SetComponent(Type& t, vtkm::IdComponent i, const ComponentType& v)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment