2014-02-10 18:57:46 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//
|
|
|
|
// Copyright 2014 Sandia Corporation.
|
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-05-21 12:09:22 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2014-02-10 18:57:46 +00:00
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
2014-10-07 23:27:31 +00:00
|
|
|
#ifndef vtk_m_VecTraits_h
|
|
|
|
#define vtk_m_VecTraits_h
|
2014-02-10 18:57:46 +00:00
|
|
|
|
|
|
|
#include <vtkm/Types.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
2014-02-10 18:57:46 +00:00
|
|
|
|
|
|
|
/// A tag for vectors that are "true" vectors (i.e. have more than one
|
|
|
|
/// component).
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct VecTraitsTagMultipleComponents
|
|
|
|
{
|
|
|
|
};
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2014-10-07 23:27:31 +00:00
|
|
|
/// A tag for vectors that are really just scalars (i.e. have only one
|
|
|
|
/// component)
|
2014-02-10 18:57:46 +00:00
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct VecTraitsTagSingleComponent
|
|
|
|
{
|
|
|
|
};
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2015-08-07 23:58:52 +00:00
|
|
|
/// A tag for vectors where the number of components are known at compile time.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct VecTraitsTagSizeStatic
|
|
|
|
{
|
|
|
|
};
|
2015-08-07 23:58:52 +00:00
|
|
|
|
|
|
|
/// A tag for vectors where the number of components are not determined until
|
|
|
|
/// run time.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
struct VecTraitsTagSizeVariable
|
|
|
|
{
|
|
|
|
};
|
2015-08-07 23:58:52 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace internal
|
|
|
|
{
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent numComponents>
|
2014-10-07 23:27:31 +00:00
|
|
|
struct VecTraitsMultipleComponentChooser
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2014-10-07 23:27:31 +00:00
|
|
|
typedef VecTraitsTagMultipleComponents Type;
|
2014-02-10 18:57:46 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <>
|
2014-10-07 23:27:31 +00:00
|
|
|
struct VecTraitsMultipleComponentChooser<1>
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2014-10-07 23:27:31 +00:00
|
|
|
typedef VecTraitsTagSingleComponent Type;
|
2014-02-10 18:57:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
2014-10-07 23:27:31 +00:00
|
|
|
/// The VecTraits class gives several static members that define how
|
2014-02-10 18:57:46 +00:00
|
|
|
/// to use a given type as a vector.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <class VecType>
|
2014-10-07 23:27:31 +00:00
|
|
|
struct VecTraits
|
2014-02-10 18:57:46 +00:00
|
|
|
#ifdef VTKM_DOXYGEN_ONLY
|
|
|
|
{
|
|
|
|
/// Type of the components in the vector.
|
|
|
|
///
|
2014-10-07 23:27:31 +00:00
|
|
|
typedef typename VecType::ComponentType ComponentType;
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2015-08-20 12:50:19 +00:00
|
|
|
/// \brief Number of components in the vector.
|
|
|
|
///
|
|
|
|
/// This is only defined for vectors of a static size.
|
2014-02-10 18:57:46 +00:00
|
|
|
///
|
2014-10-07 23:27:31 +00:00
|
|
|
static const vtkm::IdComponent NUM_COMPONENTS = VecType::NUM_COMPONENTS;
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2015-08-07 23:58:52 +00:00
|
|
|
/// Number of components in the given vector.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
static vtkm::IdComponent GetNumberOfComponents(const VecType& vec);
|
2015-08-07 23:58:52 +00:00
|
|
|
|
2015-08-20 12:50:19 +00:00
|
|
|
/// \brief A tag specifying whether this vector has multiple components (i.e. is a "real" vector).
|
|
|
|
///
|
|
|
|
/// This tag can be useful for creating specialized functions when a vector
|
|
|
|
/// is really just a scalar.
|
2014-02-10 18:57:46 +00:00
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
typedef typename internal::VecTraitsMultipleComponentChooser<NUM_COMPONENTS>::Type
|
|
|
|
HasMultipleComponents;
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2015-08-20 12:50:19 +00:00
|
|
|
/// \brief A tag specifying whether the size of this vector is known at compile time.
|
|
|
|
///
|
|
|
|
/// If set to \c VecTraitsTagSizeStatic, then \c NUM_COMPONENTS is set. If
|
|
|
|
/// set to \c VecTraitsTagSizeVariable, then the number of components is not
|
|
|
|
/// known at compile time and must be queried with \c GetNumberOfComponents.
|
2015-08-07 23:58:52 +00:00
|
|
|
///
|
|
|
|
typedef vtkm::VecTraitsTagSizeStatic IsSizeStatic;
|
|
|
|
|
2014-02-10 18:57:46 +00:00
|
|
|
/// Returns the value in a given component of the vector.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_EXEC_CONT static const ComponentType& GetComponent(
|
2017-05-26 17:53:28 +00:00
|
|
|
const typename std::remove_const<VecType>::type& vector,
|
|
|
|
vtkm::IdComponent component);
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_EXEC_CONT static ComponentType& GetComponent(
|
2017-05-26 17:53:28 +00:00
|
|
|
typename std::remove_const<VecType>::type& vector,
|
|
|
|
vtkm::IdComponent component);
|
2014-02-10 18:57:46 +00:00
|
|
|
|
|
|
|
/// Changes the value in a given component of the vector.
|
|
|
|
///
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_EXEC_CONT static void SetComponent(VecType& vector,
|
|
|
|
vtkm::IdComponent component,
|
2017-05-18 14:29:41 +00:00
|
|
|
ComponentType value);
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2015-08-13 22:53:34 +00:00
|
|
|
/// Copies the components in the given vector into a given Vec object.
|
2014-02-10 18:57:46 +00:00
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vktm::IdComponent destSize>
|
|
|
|
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest);
|
2014-02-10 18:57:46 +00:00
|
|
|
};
|
2017-05-18 14:29:41 +00:00
|
|
|
#else // VTKM_DOXYGEN_ONLY
|
|
|
|
;
|
2014-02-10 18:57:46 +00:00
|
|
|
#endif // VTKM_DOXYGEN_ONLY
|
|
|
|
|
|
|
|
// This partial specialization allows you to define a non-const version of
|
2014-10-07 23:27:31 +00:00
|
|
|
// VecTraits and have it still work for const version.
|
2014-02-10 18:57:46 +00:00
|
|
|
//
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
2014-10-07 23:27:31 +00:00
|
|
|
struct VecTraits<const T> : VecTraits<T>
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
};
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, vtkm::IdComponent Size>
|
|
|
|
struct VecTraits<vtkm::Vec<T, Size>>
|
2014-02-10 18:57:46 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
typedef vtkm::Vec<T, Size> VecType;
|
2014-02-10 18:57:46 +00:00
|
|
|
|
|
|
|
/// Type of the components in the vector.
|
|
|
|
///
|
2014-10-07 23:27:31 +00:00
|
|
|
typedef typename VecType::ComponentType ComponentType;
|
2014-02-10 18:57:46 +00:00
|
|
|
|
|
|
|
/// Number of components in the vector.
|
|
|
|
///
|
2014-10-07 23:27:31 +00:00
|
|
|
static const vtkm::IdComponent NUM_COMPONENTS = VecType::NUM_COMPONENTS;
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2015-08-07 23:58:52 +00:00
|
|
|
/// Number of components in the given vector.
|
|
|
|
///
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static vtkm::IdComponent GetNumberOfComponents(const VecType&) { return NUM_COMPONENTS; }
|
2015-08-07 23:58:52 +00:00
|
|
|
|
2014-02-10 18:57:46 +00:00
|
|
|
/// A tag specifying whether this vector has multiple components (i.e. is a
|
|
|
|
/// "real" vector). This tag can be useful for creating specialized functions
|
|
|
|
/// when a vector is really just a scalar.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
typedef typename internal::VecTraitsMultipleComponentChooser<NUM_COMPONENTS>::Type
|
|
|
|
HasMultipleComponents;
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2015-08-07 23:58:52 +00:00
|
|
|
/// A tag specifying whether the size of this vector is known at compile
|
|
|
|
/// time. If set to \c VecTraitsTagSizeStatic, then \c NUM_COMPONENTS is set.
|
|
|
|
/// If set to \c VecTraitsTagSizeVariable, then the number of components is
|
|
|
|
/// not known at compile time and must be queried with \c
|
|
|
|
/// GetNumberOfComponents.
|
|
|
|
///
|
|
|
|
typedef vtkm::VecTraitsTagSizeStatic IsSizeStatic;
|
|
|
|
|
2014-02-10 18:57:46 +00:00
|
|
|
/// Returns the value in a given component of the vector.
|
|
|
|
///
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static const ComponentType& GetComponent(const VecType& vector, vtkm::IdComponent component)
|
2014-02-10 18:57:46 +00:00
|
|
|
{
|
|
|
|
return vector[component];
|
|
|
|
}
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static ComponentType& GetComponent(VecType& vector, vtkm::IdComponent component)
|
|
|
|
{
|
2014-02-10 18:57:46 +00:00
|
|
|
return vector[component];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Changes the value in a given component of the vector.
|
|
|
|
///
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_EXEC_CONT static void SetComponent(VecType& vector,
|
|
|
|
vtkm::IdComponent component,
|
2017-05-18 14:29:41 +00:00
|
|
|
ComponentType value)
|
|
|
|
{
|
2014-02-10 18:57:46 +00:00
|
|
|
vector[component] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent destSize>
|
|
|
|
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
2014-02-10 18:57:46 +00:00
|
|
|
{
|
2015-08-07 23:58:52 +00:00
|
|
|
src.CopyInto(dest);
|
2014-02-10 18:57:46 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
struct VecTraits<vtkm::VecC<T>>
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
using VecType = vtkm::VecC<T>;
|
|
|
|
|
|
|
|
/// Type of the components in the vector.
|
|
|
|
///
|
|
|
|
using ComponentType = typename VecType::ComponentType;
|
|
|
|
|
|
|
|
/// Number of components in the given vector.
|
|
|
|
///
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static vtkm::IdComponent GetNumberOfComponents(const VecType& vector)
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
return vector.GetNumberOfComponents();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A tag specifying whether this vector has multiple components (i.e. is a
|
|
|
|
/// "real" vector). This tag can be useful for creating specialized functions
|
|
|
|
/// when a vector is really just a scalar.
|
|
|
|
///
|
|
|
|
/// The size of a \c VecC is not known until runtime and can always
|
|
|
|
/// potentially have multiple components, this is always set to \c
|
|
|
|
/// HasMultipleComponents.
|
|
|
|
///
|
|
|
|
using HasMultipleComponents = vtkm::VecTraitsTagMultipleComponents;
|
|
|
|
|
|
|
|
/// A tag specifying whether the size of this vector is known at compile
|
|
|
|
/// time. If set to \c VecTraitsTagSizeStatic, then \c NUM_COMPONENTS is set.
|
|
|
|
/// If set to \c VecTraitsTagSizeVariable, then the number of components is
|
|
|
|
/// not known at compile time and must be queried with \c
|
|
|
|
/// GetNumberOfComponents.
|
|
|
|
///
|
|
|
|
using IsSizeStatic = vtkm::VecTraitsTagSizeVariable;
|
|
|
|
|
|
|
|
/// Returns the value in a given component of the vector.
|
|
|
|
///
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static const ComponentType& GetComponent(const VecType& vector, vtkm::IdComponent component)
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
return vector[component];
|
|
|
|
}
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static ComponentType& GetComponent(VecType& vector, vtkm::IdComponent component)
|
|
|
|
{
|
2016-11-30 22:03:30 +00:00
|
|
|
return vector[component];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Changes the value in a given component of the vector.
|
|
|
|
///
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static void SetComponent(VecType& vector, vtkm::IdComponent component, ComponentType value)
|
|
|
|
{
|
2016-11-30 22:03:30 +00:00
|
|
|
vector[component] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent destSize>
|
|
|
|
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
src.CopyInto(dest);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
struct VecTraits<vtkm::VecCConst<T>>
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
using VecType = vtkm::VecCConst<T>;
|
|
|
|
|
|
|
|
/// Type of the components in the vector.
|
|
|
|
///
|
|
|
|
using ComponentType = typename VecType::ComponentType;
|
|
|
|
|
|
|
|
/// Number of components in the given vector.
|
|
|
|
///
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static vtkm::IdComponent GetNumberOfComponents(const VecType& vector)
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
return vector.GetNumberOfComponents();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A tag specifying whether this vector has multiple components (i.e. is a
|
|
|
|
/// "real" vector). This tag can be useful for creating specialized functions
|
|
|
|
/// when a vector is really just a scalar.
|
|
|
|
///
|
|
|
|
/// The size of a \c VecCConst is not known until runtime and can always
|
|
|
|
/// potentially have multiple components, this is always set to \c
|
|
|
|
/// HasMultipleComponents.
|
|
|
|
///
|
|
|
|
using HasMultipleComponents = vtkm::VecTraitsTagMultipleComponents;
|
|
|
|
|
|
|
|
/// A tag specifying whether the size of this vector is known at compile
|
|
|
|
/// time. If set to \c VecTraitsTagSizeStatic, then \c NUM_COMPONENTS is set.
|
|
|
|
/// If set to \c VecTraitsTagSizeVariable, then the number of components is
|
|
|
|
/// not known at compile time and must be queried with \c
|
|
|
|
/// GetNumberOfComponents.
|
|
|
|
///
|
|
|
|
using IsSizeStatic = vtkm::VecTraitsTagSizeVariable;
|
|
|
|
|
|
|
|
/// Returns the value in a given component of the vector.
|
|
|
|
///
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static const ComponentType& GetComponent(const VecType& vector, vtkm::IdComponent component)
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
return vector[component];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Changes the value in a given component of the vector.
|
|
|
|
///
|
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static void SetComponent(VecType& vector, vtkm::IdComponent component, ComponentType value)
|
|
|
|
{
|
2016-11-30 22:03:30 +00:00
|
|
|
vector[component] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Converts whatever type this vector is into the standard VTKm Tuple.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent destSize>
|
|
|
|
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
|
2016-11-30 22:03:30 +00:00
|
|
|
{
|
|
|
|
src.CopyInto(dest);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace internal
|
|
|
|
{
|
2014-10-07 23:27:31 +00:00
|
|
|
/// Used for overriding VecTraits for basic scalar types.
|
2014-02-10 18:57:46 +00:00
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ScalarType>
|
|
|
|
struct VecTraitsBasic
|
|
|
|
{
|
2014-02-10 18:57:46 +00:00
|
|
|
typedef ScalarType ComponentType;
|
2014-10-07 16:59:34 +00:00
|
|
|
static const vtkm::IdComponent NUM_COMPONENTS = 1;
|
2014-10-07 23:27:31 +00:00
|
|
|
typedef VecTraitsTagSingleComponent HasMultipleComponents;
|
2015-08-07 23:58:52 +00:00
|
|
|
typedef vtkm::VecTraitsTagSizeStatic IsSizeStatic;
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static vtkm::IdComponent GetNumberOfComponents(const ScalarType&) { return 1; }
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static const ComponentType& GetComponent(const ScalarType& vector, vtkm::IdComponent)
|
|
|
|
{
|
2014-02-10 18:57:46 +00:00
|
|
|
return vector;
|
|
|
|
}
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
static ComponentType& GetComponent(ScalarType& vector, vtkm::IdComponent) { return vector; }
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_EXEC_CONT static void SetComponent(ScalarType& vector,
|
|
|
|
vtkm::IdComponent,
|
2017-05-18 14:29:41 +00:00
|
|
|
ComponentType value)
|
|
|
|
{
|
2014-02-10 18:57:46 +00:00
|
|
|
vector = value;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent destSize>
|
|
|
|
VTKM_EXEC_CONT static void CopyInto(const ScalarType& src, vtkm::Vec<ScalarType, destSize>& dest)
|
2014-02-10 18:57:46 +00:00
|
|
|
{
|
2015-08-07 23:58:52 +00:00
|
|
|
dest[0] = src;
|
2014-02-10 18:57:46 +00:00
|
|
|
}
|
|
|
|
};
|
2015-05-07 22:34:06 +00:00
|
|
|
} // namespace internal
|
|
|
|
|
2015-09-20 06:01:04 +00:00
|
|
|
/// \brief VecTraits for Pair types
|
|
|
|
///
|
|
|
|
/// Although a pair woudl seem better as a size-2 vector, we treat it as a
|
|
|
|
/// scalar. This is because a \c Vec is assumed to have the same type for
|
|
|
|
/// every component, and a pair in general has a different type for each
|
|
|
|
/// component. Thus we treat a pair as a "scalar" unit.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename U>
|
|
|
|
struct VecTraits<vtkm::Pair<T, U>> : public vtkm::internal::VecTraitsBasic<vtkm::Pair<T, U>>
|
2015-09-20 06:01:04 +00:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2015-05-07 22:34:06 +00:00
|
|
|
} // anonymous namespace
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
#define VTKM_BASIC_TYPE_VECTOR(type) \
|
|
|
|
namespace vtkm \
|
|
|
|
{ \
|
|
|
|
template <> \
|
|
|
|
struct VecTraits<type> : public vtkm::internal::VecTraitsBasic<type> \
|
|
|
|
{ \
|
|
|
|
}; \
|
2015-05-07 22:34:06 +00:00
|
|
|
}
|
2014-02-10 18:57:46 +00:00
|
|
|
|
|
|
|
/// Allows you to treat basic types as if they were vectors.
|
|
|
|
|
2016-02-12 21:31:00 +00:00
|
|
|
VTKM_BASIC_TYPE_VECTOR(float)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(double)
|
|
|
|
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(char)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(signed char)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(unsigned char)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(short)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(unsigned short)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(int)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(unsigned int)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(long)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(unsigned long)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(long long)
|
|
|
|
VTKM_BASIC_TYPE_VECTOR(unsigned long long)
|
|
|
|
|
2015-05-07 22:34:06 +00:00
|
|
|
//#undef VTKM_BASIC_TYPE_VECTOR
|
2014-02-10 18:57:46 +00:00
|
|
|
|
2014-10-07 23:27:31 +00:00
|
|
|
#endif //vtk_m_VecTraits_h
|