2017-07-28 18:55:37 +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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2017-07-28 18:55:37 +00:00
|
|
|
// Copyright 2017 UT-Battelle, LLC.
|
|
|
|
// Copyright 2017 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2017-07-28 18:55:37 +00:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//=============================================================================
|
|
|
|
#ifndef vtk_m_cont_ArrayHandleSwizzle_h
|
|
|
|
#define vtk_m_cont_ArrayHandleSwizzle_h
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
#include <vtkm/StaticAssert.h>
|
|
|
|
#include <vtkm/Types.h>
|
2017-07-28 18:55:37 +00:00
|
|
|
#include <vtkm/VecTraits.h>
|
2018-05-10 16:37:05 +00:00
|
|
|
|
2017-07-28 18:55:37 +00:00
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
2018-05-10 16:37:05 +00:00
|
|
|
#include <vtkm/cont/ErrorBadValue.h>
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
#include <sstream>
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename InVecType, vtkm::IdComponent OutVecSize>
|
|
|
|
struct ResizeVectorType
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
private:
|
|
|
|
using ComponentType = typename vtkm::VecTraits<InVecType>::ComponentType;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
public:
|
|
|
|
using Type = vtkm::Vec<ComponentType, OutVecSize>;
|
2017-07-28 18:55:37 +00:00
|
|
|
};
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename ArrayHandleType, vtkm::IdComponent OutVecSize>
|
|
|
|
class StorageTagSwizzle
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
namespace internal
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename ArrayHandleType, vtkm::IdComponent OutputSize>
|
|
|
|
struct ArrayHandleSwizzleTraits;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename V, vtkm::IdComponent C, typename S, vtkm::IdComponent OutSize>
|
|
|
|
struct ArrayHandleSwizzleTraits<vtkm::cont::ArrayHandle<vtkm::Vec<V, C>, S>, OutSize>
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
using ComponentType = V;
|
|
|
|
static constexpr vtkm::IdComponent InVecSize = C;
|
|
|
|
static constexpr vtkm::IdComponent OutVecSize = OutSize;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
VTKM_STATIC_ASSERT(OutVecSize <= InVecSize);
|
|
|
|
static constexpr bool AllCompsUsed = (InVecSize == OutVecSize);
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
using InValueType = vtkm::Vec<ComponentType, InVecSize>;
|
|
|
|
using OutValueType = vtkm::Vec<ComponentType, OutVecSize>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
using InStorageTag = S;
|
|
|
|
using InArrayHandleType = vtkm::cont::ArrayHandle<InValueType, InStorageTag>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
using OutStorageTag = vtkm::cont::StorageTagSwizzle<InArrayHandleType, OutVecSize>;
|
|
|
|
using OutArrayHandleType = vtkm::cont::ArrayHandle<OutValueType, OutStorageTag>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
using InStorageType = vtkm::cont::internal::Storage<InValueType, InStorageTag>;
|
|
|
|
using OutStorageType = vtkm::cont::internal::Storage<OutValueType, OutStorageTag>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
using MapType = vtkm::Vec<vtkm::IdComponent, OutVecSize>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
VTKM_CONT
|
|
|
|
static void ValidateMap(const MapType& map)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < OutVecSize; ++i)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
if (map[i] < 0 || map[i] >= InVecSize)
|
|
|
|
{
|
|
|
|
std::ostringstream error;
|
|
|
|
error << "Invalid swizzle map: Element " << i << " (" << map[i]
|
|
|
|
<< ") outside valid range [0, " << InVecSize << ").";
|
|
|
|
throw vtkm::cont::ErrorBadValue(error.str());
|
|
|
|
}
|
|
|
|
for (vtkm::IdComponent j = i + 1; j < OutVecSize; ++j)
|
|
|
|
{
|
|
|
|
if (map[i] == map[j])
|
|
|
|
{
|
|
|
|
std::ostringstream error;
|
|
|
|
error << "Invalid swizzle map: Repeated element (" << map[i] << ")"
|
|
|
|
<< " at indices " << i << " and " << j << ".";
|
|
|
|
throw vtkm::cont::ErrorBadValue(error.str());
|
|
|
|
}
|
|
|
|
}
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
VTKM_EXEC_CONT
|
|
|
|
static void Swizzle(const InValueType& in, OutValueType& out, const MapType& map)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < OutSize; ++i)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
out[i] = in[map[i]];
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
2018-05-10 16:37:05 +00:00
|
|
|
}
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
VTKM_EXEC_CONT
|
|
|
|
static void UnSwizzle(const OutValueType& out, InValueType& in, const MapType& map)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < OutSize; ++i)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
in[map[i]] = out[i];
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename PortalType, typename ArrayHandleType, vtkm::IdComponent OutSize>
|
2017-07-28 18:55:37 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT ArrayPortalSwizzle
|
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
using Traits = internal::ArrayHandleSwizzleTraits<ArrayHandleType, OutSize>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
public:
|
2018-05-10 16:37:05 +00:00
|
|
|
using MapType = typename Traits::MapType;
|
|
|
|
using ValueType = typename Traits::OutValueType;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
ArrayPortalSwizzle()
|
|
|
|
: Portal()
|
2018-05-10 16:37:05 +00:00
|
|
|
, Map()
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
2018-05-10 16:37:05 +00:00
|
|
|
ArrayPortalSwizzle(const PortalType& portal, const MapType& map)
|
2017-07-28 18:55:37 +00:00
|
|
|
: Portal(portal)
|
2018-05-10 16:37:05 +00:00
|
|
|
, Map(map)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy constructor
|
2018-05-10 16:37:05 +00:00
|
|
|
VTKM_EXEC_CONT ArrayPortalSwizzle(const ArrayPortalSwizzle& src)
|
2017-07-28 18:55:37 +00:00
|
|
|
: Portal(src.GetPortal())
|
2018-05-10 16:37:05 +00:00
|
|
|
, Map(src.GetMap())
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
vtkm::Id GetNumberOfValues() const { return this->Portal.GetNumberOfValues(); }
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
ValueType Get(vtkm::Id index) const
|
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
ValueType result;
|
|
|
|
Traits::Swizzle(this->Portal.Get(index), result, this->Map);
|
2017-07-28 18:55:37 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
void Set(vtkm::Id index, const ValueType& value) const
|
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
if (Traits::AllCompsUsed)
|
|
|
|
{ // No need to prefetch the value, all values overwritten
|
|
|
|
typename Traits::InValueType tmp;
|
|
|
|
Traits::UnSwizzle(value, tmp, this->Map);
|
|
|
|
this->Portal.Set(index, tmp);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
2018-05-10 16:37:05 +00:00
|
|
|
else
|
|
|
|
{ // Not all values used -- need to initialize the vector
|
|
|
|
typename Traits::InValueType tmp = this->Portal.Get(index);
|
|
|
|
Traits::UnSwizzle(value, tmp, this->Map);
|
|
|
|
this->Portal.Set(index, tmp);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
2018-05-10 16:37:05 +00:00
|
|
|
}
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
const PortalType& GetPortal() const { return this->Portal; }
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
VTKM_EXEC_CONT
|
|
|
|
const MapType& GetMap() const { return this->Map; }
|
|
|
|
|
2017-07-28 18:55:37 +00:00
|
|
|
private:
|
|
|
|
PortalType Portal;
|
2018-05-10 16:37:05 +00:00
|
|
|
MapType Map;
|
2017-07-28 18:55:37 +00:00
|
|
|
};
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename ArrayHandleType, vtkm::IdComponent OutSize>
|
|
|
|
class Storage<typename ResizeVectorType<typename ArrayHandleType::ValueType, OutSize>::Type,
|
|
|
|
vtkm::cont::StorageTagSwizzle<ArrayHandleType, OutSize>>
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
using Traits = internal::ArrayHandleSwizzleTraits<ArrayHandleType, OutSize>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
public:
|
2018-05-10 16:37:05 +00:00
|
|
|
using PortalType =
|
|
|
|
ArrayPortalSwizzle<typename ArrayHandleType::PortalControl, ArrayHandleType, OutSize>;
|
2017-07-28 18:55:37 +00:00
|
|
|
using PortalConstType =
|
2018-05-10 16:37:05 +00:00
|
|
|
ArrayPortalSwizzle<typename ArrayHandleType::PortalConstControl, ArrayHandleType, OutSize>;
|
|
|
|
using MapType = typename Traits::MapType;
|
|
|
|
using ValueType = typename Traits::OutValueType;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
Storage()
|
|
|
|
: Valid(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
2018-05-10 16:37:05 +00:00
|
|
|
Storage(const ArrayHandleType& array, const MapType& map)
|
2017-07-28 18:55:37 +00:00
|
|
|
: Array(array)
|
2018-05-10 16:37:05 +00:00
|
|
|
, Map(map)
|
2017-07-28 18:55:37 +00:00
|
|
|
, Valid(true)
|
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
Traits::ValidateMap(this->Map);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
PortalConstType GetPortalConst() const
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
2018-05-10 16:37:05 +00:00
|
|
|
return PortalConstType(this->Array.GetPortalConstControl(), this->Map);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
PortalType GetPortal()
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
2018-05-10 16:37:05 +00:00
|
|
|
return PortalType(this->Array.GetPortalControl(), this->Map);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Id GetNumberOfValues() const
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
|
|
|
return this->Array.GetNumberOfValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void Allocate(vtkm::Id numberOfValues)
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
|
|
|
this->Array.Allocate(numberOfValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void Shrink(vtkm::Id numberOfValues)
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
|
|
|
this->Array.Shrink(numberOfValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void ReleaseResources()
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
|
|
|
this->Array.ReleaseResources();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
const ArrayHandleType& GetArray() const
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
|
|
|
return this->Array;
|
|
|
|
}
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
VTKM_CONT
|
|
|
|
const MapType& GetMap() const
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->Valid);
|
|
|
|
return this->Map;
|
|
|
|
}
|
|
|
|
|
2017-07-28 18:55:37 +00:00
|
|
|
private:
|
|
|
|
ArrayHandleType Array;
|
2018-05-10 16:37:05 +00:00
|
|
|
MapType Map;
|
2017-07-28 18:55:37 +00:00
|
|
|
bool Valid;
|
2018-05-10 16:37:05 +00:00
|
|
|
};
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename ArrayHandleType, vtkm::IdComponent OutSize, typename DeviceTag>
|
|
|
|
class ArrayTransfer<typename ResizeVectorType<typename ArrayHandleType::ValueType, OutSize>::Type,
|
|
|
|
vtkm::cont::StorageTagSwizzle<ArrayHandleType, OutSize>,
|
|
|
|
DeviceTag>
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
using InExecTypes = typename ArrayHandleType::template ExecutionTypes<DeviceTag>;
|
|
|
|
using Traits = ArrayHandleSwizzleTraits<ArrayHandleType, OutSize>;
|
|
|
|
using StorageType = typename Traits::OutStorageType;
|
|
|
|
using MapType = typename Traits::MapType;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename InPortalT>
|
|
|
|
using OutExecType = ArrayPortalSwizzle<InPortalT, ArrayHandleType, OutSize>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
public:
|
2018-05-10 16:37:05 +00:00
|
|
|
using ValueType = typename Traits::OutValueType;
|
2017-07-28 18:55:37 +00:00
|
|
|
using PortalControl = typename StorageType::PortalType;
|
|
|
|
using PortalConstControl = typename StorageType::PortalConstType;
|
2018-05-10 16:37:05 +00:00
|
|
|
using PortalExecution = OutExecType<typename InExecTypes::Portal>;
|
|
|
|
using PortalConstExecution = OutExecType<typename InExecTypes::PortalConst>;
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
ArrayTransfer(StorageType* storage)
|
|
|
|
: Array(storage->GetArray())
|
2018-05-10 16:37:05 +00:00
|
|
|
, Map(storage->GetMap())
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
vtkm::Id GetNumberOfValues() const { return this->Array.GetNumberOfValues(); }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
return PortalConstExecution(this->Array.PrepareForInput(DeviceTag()), this->Map);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
|
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
return PortalExecution(this->Array.PrepareForInPlace(DeviceTag()), this->Map);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
|
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
return PortalExecution(this->Array.PrepareForOutput(numberOfValues, DeviceTag()), this->Map);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
|
|
|
{
|
|
|
|
// Implementation of this method should be unnecessary. The internal
|
|
|
|
// array handle should automatically retrieve the output data as
|
|
|
|
// necessary.
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void Shrink(vtkm::Id numberOfValues) { this->Array.Shrink(numberOfValues); }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void ReleaseResources() { this->Array.ReleaseResourcesExecution(); }
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
|
2017-07-28 18:55:37 +00:00
|
|
|
private:
|
|
|
|
ArrayHandleType Array;
|
2018-05-10 16:37:05 +00:00
|
|
|
MapType Map;
|
2017-07-28 18:55:37 +00:00
|
|
|
};
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
} // end namespace internal
|
2017-07-28 18:55:37 +00:00
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename ArrayHandleType, vtkm::IdComponent OutSize>
|
|
|
|
class ArrayHandleSwizzle
|
|
|
|
: public ArrayHandle<
|
|
|
|
typename ResizeVectorType<typename ArrayHandleType::ValueType, OutSize>::Type,
|
|
|
|
vtkm::cont::StorageTagSwizzle<ArrayHandleType, OutSize>>
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-05-10 16:37:05 +00:00
|
|
|
using SwizzleTraits = internal::ArrayHandleSwizzleTraits<ArrayHandleType, OutSize>;
|
|
|
|
using StorageType = typename SwizzleTraits::OutStorageType;
|
|
|
|
using MapType = typename SwizzleTraits::MapType;
|
|
|
|
|
2017-07-28 18:55:37 +00:00
|
|
|
VTKM_ARRAY_HANDLE_SUBCLASS(
|
|
|
|
ArrayHandleSwizzle,
|
2018-05-10 16:37:05 +00:00
|
|
|
(ArrayHandleSwizzle<ArrayHandleType, OutSize>),
|
|
|
|
(ArrayHandle<typename ResizeVectorType<typename ArrayHandleType::ValueType, OutSize>::Type,
|
|
|
|
vtkm::cont::StorageTagSwizzle<ArrayHandleType, OutSize>>));
|
2017-07-28 18:55:37 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
2018-05-10 16:37:05 +00:00
|
|
|
ArrayHandleSwizzle(const ArrayHandleType& array, const MapType& map)
|
|
|
|
: Superclass(StorageType(array, map))
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-10 16:37:05 +00:00
|
|
|
template <typename ArrayHandleType, vtkm::IdComponent OutSize>
|
|
|
|
VTKM_CONT ArrayHandleSwizzle<ArrayHandleType, OutSize> make_ArrayHandleSwizzle(
|
|
|
|
const ArrayHandleType& array,
|
|
|
|
const vtkm::Vec<vtkm::IdComponent, OutSize>& map)
|
2017-07-28 18:55:37 +00:00
|
|
|
{
|
2018-05-10 16:37:05 +00:00
|
|
|
return ArrayHandleSwizzle<ArrayHandleType, OutSize>(array, map);
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
2018-05-30 23:07:06 +00:00
|
|
|
|
|
|
|
template <typename ArrayHandleType, typename... SwizzleIndexTypes>
|
2018-06-18 18:44:35 +00:00
|
|
|
VTKM_CONT ArrayHandleSwizzle<ArrayHandleType, vtkm::IdComponent(sizeof...(SwizzleIndexTypes) + 1)>
|
2018-05-30 23:07:06 +00:00
|
|
|
make_ArrayHandleSwizzle(const ArrayHandleType& array,
|
|
|
|
vtkm::IdComponent swizzleIndex0,
|
|
|
|
SwizzleIndexTypes... swizzleIndices)
|
|
|
|
{
|
|
|
|
return make_ArrayHandleSwizzle(array, vtkm::make_Vec(swizzleIndex0, swizzleIndices...));
|
|
|
|
}
|
2017-07-28 18:55:37 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
|
|
|
#endif // vtk_m_cont_ArrayHandleSwizzle_h
|