10 #ifndef vtk_m_cont_ArrayHandleSwizzle_h 
   11 #define vtk_m_cont_ArrayHandleSwizzle_h 
   17 #include <vtkmstd/integer_sequence.h> 
   24 template <
typename InType, 
typename OutType>
 
   37   using IndexList = vtkmstd::make_integer_sequence<vtkm::IdComponent, NUM_OUT_COMPONENTS>;
 
   42   VTKM_CONT SwizzleFunctor(
const MapType& map)
 
   51     return this->Swizzle(vec, IndexList{});
 
   54   VTKM_CONT static MapType InitMap() { 
return IndexListAsMap(IndexList{}); }
 
   58   VTKM_CONT static MapType IndexListAsMap(IndexSequence<Is...>)
 
   64   VTKM_EXEC_CONT OutType Swizzle(
const InType& vec, IndexSequence<Is...>)
 const 
   69   MapType Map = InitMap();
 
   75 template <
typename InType, 
typename OutType, 
typename Invertible>
 
   76 struct GetInverseSwizzleImpl;
 
   78 template <
typename InType, 
typename OutType>
 
   79 struct GetInverseSwizzleImpl<InType, OutType, std::true_type>
 
   81   using Type = vtkm::internal::SwizzleFunctor<OutType, InType>;
 
   82   template <
typename ForwardMapType>
 
   83   VTKM_CONT static Type Value(
const ForwardMapType& forwardMap)
 
   88     using InverseMapType = 
typename Type::MapType;
 
   89     InverseMapType inverseMap = Type::InitMap();
 
   90     for (
vtkm::IdComponent inIndex = 0; inIndex < ForwardMapType::NUM_COMPONENTS; ++inIndex)
 
   92       inverseMap[forwardMap[inIndex]] = inIndex;
 
   95     return Type(inverseMap);
 
   99 template <
typename InType, 
typename OutType>
 
  100 struct GetInverseSwizzleImpl<InType, OutType, std::false_type>
 
  102   using Type = vtkm::cont::internal::NullFunctorType;
 
  103   template <
typename ForwardMapType>
 
  104   VTKM_CONT static Type Value(
const ForwardMapType&)
 
  110 template <
typename InType, 
typename OutType>
 
  111 using SwizzleInvertible = std::integral_constant<bool,
 
  117 template <
typename InType, 
typename OutType>
 
  118 VTKM_CONT vtkm::internal::SwizzleFunctor<InType, OutType> GetSwizzleFunctor(
 
  121   return vtkm::internal::SwizzleFunctor<InType, OutType>(forwardMap);
 
  124 template <
typename InType, 
typename OutType>
 
  125 using InverseSwizzleType = 
typename detail::
 
  126   GetInverseSwizzleImpl<InType, OutType, detail::SwizzleInvertible<InType, OutType>>::Type;
 
  128 template <
typename InType, 
typename OutType>
 
  129 VTKM_CONT InverseSwizzleType<InType, OutType> GetInverseSwizzleFunctor(
 
  133     GetInverseSwizzleImpl<InType, OutType, detail::SwizzleInvertible<InType, OutType>>::Value(
 
  148 template <
typename ArrayHandleType, vtkm::IdComponent OutSize>
 
  149 struct ArrayHandleSwizzleTraits
 
  153   using InType = 
typename ArrayHandleType::ValueType;
 
  155   using SwizzleFunctor = vtkm::internal::SwizzleFunctor<InType, OutType>;
 
  156   using InverseSwizzleFunctor = vtkm::internal::InverseSwizzleType<InType, OutType>;
 
  157   using MapType = 
typename SwizzleFunctor::MapType;
 
  159   static SwizzleFunctor GetFunctor(
const MapType& forwardMap)
 
  161     return vtkm::internal::GetSwizzleFunctor<InType, OutType>(forwardMap);
 
  164   static InverseSwizzleFunctor GetInverseFunctor(
const MapType& forwardMap)
 
  166     return vtkm::internal::GetInverseSwizzleFunctor<InType, OutType>(forwardMap);
 
  192 template <
typename ArrayHandleType, vtkm::IdComponent OutSize>
 
  194   : 
public detail::ArrayHandleSwizzleTraits<ArrayHandleType, OutSize>::Superclass
 
  198   using Traits = detail::ArrayHandleSwizzleTraits<ArrayHandleType, OutSize>;
 
  213 template <
typename ArrayHandleType, vtkm::IdComponent OutSize>
 
  215   const ArrayHandleType& array,
 
  221 template <
typename ArrayHandleType, 
typename... SwizzleIndexTypes>
 
  225                         SwizzleIndexTypes... swizzleIndices)
 
  240 template <
typename InType, 
typename OutType>
 
  241 struct SerializableTypeString<
vtkm::internal::SwizzleFunctor<InType, OutType>>
 
  251 template <
typename AH, vtkm::IdComponent NComps>
 
  252 struct SerializableTypeString<
vtkm::cont::ArrayHandleSwizzle<AH, NComps>>
 
  253   : SerializableTypeString<typename vtkm::cont::ArrayHandleSwizzle<AH, NComps>::Superclass>
 
  262 template <
typename AH, vtkm::IdComponent NComps>
 
  263 struct Serialization<
vtkm::cont::ArrayHandleSwizzle<AH, NComps>>
 
  264   : Serialization<typename vtkm::cont::ArrayHandleSwizzle<AH, NComps>::Superclass>
 
  271 #endif // vtk_m_cont_ArrayHandleSwizzle_h