2015-09-28 23:19:38 +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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2015-09-28 23:19:38 +00:00
|
|
|
// Copyright 2015 UT-Battelle, LLC.
|
|
|
|
// Copyright 2015 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2015-09-28 23:19:38 +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_ArrayHandleGroupVec_h
|
|
|
|
#define vtk_m_cont_ArrayHandleGroupVec_h
|
|
|
|
|
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
|
|
|
#include <vtkm/cont/ArrayPortal.h>
|
2017-01-09 21:15:32 +00:00
|
|
|
#include <vtkm/cont/ErrorBadValue.h>
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace exec
|
|
|
|
{
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace internal
|
|
|
|
{
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename _SourcePortalType, vtkm::IdComponent _NUM_COMPONENTS>
|
2016-12-19 19:39:17 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT ArrayPortalGroupVec
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-02-27 14:25:25 +00:00
|
|
|
static constexpr vtkm::IdComponent NUM_COMPONENTS = _NUM_COMPONENTS;
|
2017-08-16 15:34:21 +00:00
|
|
|
using SourcePortalType = _SourcePortalType;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename std::remove_const<typename SourcePortalType::ValueType>::type;
|
|
|
|
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ArrayPortalGroupVec()
|
|
|
|
: SourcePortal()
|
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ArrayPortalGroupVec(const SourcePortalType& sourcePortal)
|
|
|
|
: SourcePortal(sourcePortal)
|
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
/// Copy constructor for any other ArrayPortalConcatenate with a portal type
|
|
|
|
/// that can be copied to this portal type. This allows us to do any type
|
|
|
|
/// casting that the portals do (like the non-const to const cast).
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename OtherSourcePortalType>
|
|
|
|
VTKM_EXEC_CONT ArrayPortalGroupVec(
|
|
|
|
const ArrayPortalGroupVec<OtherSourcePortalType, NUM_COMPONENTS>& src)
|
|
|
|
: SourcePortal(src.GetPortal())
|
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
vtkm::Id GetNumberOfValues() const
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
return this->SourcePortal.GetNumberOfValues() / NUM_COMPONENTS;
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
ValueType Get(vtkm::Id index) const
|
|
|
|
{
|
|
|
|
ValueType result;
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id sourceIndex = index * NUM_COMPONENTS;
|
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
result[componentIndex] = this->SourcePortal.Get(sourceIndex);
|
|
|
|
sourceIndex++;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void Set(vtkm::Id index, const ValueType& value) const
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id sourceIndex = index * NUM_COMPONENTS;
|
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
this->SourcePortal.Set(sourceIndex, value[componentIndex]);
|
|
|
|
sourceIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const SourcePortalType& GetPortal() const { return this->SourcePortal; }
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SourcePortalType SourcePortal;
|
|
|
|
};
|
2016-08-02 15:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::exec::internal
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2016-08-02 15:26:29 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace internal
|
|
|
|
{
|
2016-08-02 15:26:29 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
|
|
|
|
struct VTKM_ALWAYS_EXPORT StorageTagGroupVec
|
|
|
|
{
|
|
|
|
};
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
|
|
|
|
class Storage<vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
|
|
|
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>>
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename SourceArrayHandleType::ValueType;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
public:
|
2017-08-16 15:34:21 +00:00
|
|
|
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using PortalType =
|
|
|
|
vtkm::exec::internal::ArrayPortalGroupVec<typename SourceArrayHandleType::PortalControl,
|
|
|
|
NUM_COMPONENTS>;
|
|
|
|
using PortalConstType =
|
|
|
|
vtkm::exec::internal::ArrayPortalGroupVec<typename SourceArrayHandleType::PortalConstControl,
|
|
|
|
NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
Storage()
|
|
|
|
: Valid(false)
|
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
Storage(const SourceArrayHandleType& sourceArray)
|
|
|
|
: SourceArray(sourceArray)
|
|
|
|
, Valid(true)
|
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
PortalType GetPortal()
|
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Valid);
|
2015-09-28 23:19:38 +00:00
|
|
|
return PortalType(this->SourceArray.GetPortalControl());
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
PortalConstType GetPortalConst() const
|
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Valid);
|
2015-09-28 23:19:38 +00:00
|
|
|
return PortalConstType(this->SourceArray.GetPortalConstControl());
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
vtkm::Id GetNumberOfValues() const
|
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Valid);
|
2015-09-28 23:19:38 +00:00
|
|
|
vtkm::Id sourceSize = this->SourceArray.GetNumberOfValues();
|
2017-05-18 14:29:41 +00:00
|
|
|
if (sourceSize % NUM_COMPONENTS != 0)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-01-09 21:15:32 +00:00
|
|
|
throw vtkm::cont::ErrorBadValue(
|
2017-05-18 14:29:41 +00:00
|
|
|
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
return sourceSize / NUM_COMPONENTS;
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
void Allocate(vtkm::Id numberOfValues)
|
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Valid);
|
2017-05-18 14:29:41 +00:00
|
|
|
this->SourceArray.Allocate(numberOfValues * NUM_COMPONENTS);
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
void Shrink(vtkm::Id numberOfValues)
|
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Valid);
|
2017-05-18 14:29:41 +00:00
|
|
|
this->SourceArray.Shrink(numberOfValues * NUM_COMPONENTS);
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
void ReleaseResources()
|
|
|
|
{
|
|
|
|
if (this->Valid)
|
|
|
|
{
|
|
|
|
this->SourceArray.ReleaseResources();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Required for later use in ArrayTransfer class
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const SourceArrayHandleType& GetSourceArray() const
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Valid);
|
2015-09-28 23:19:38 +00:00
|
|
|
return this->SourceArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SourceArrayHandleType SourceArray;
|
|
|
|
bool Valid;
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS, typename Device>
|
|
|
|
class ArrayTransfer<vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
|
|
|
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>,
|
|
|
|
Device>
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename SourceArrayHandleType::ValueType;
|
|
|
|
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
private:
|
2017-08-16 15:34:21 +00:00
|
|
|
using StorageTag =
|
|
|
|
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>;
|
|
|
|
using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
public:
|
2017-08-16 15:34:21 +00:00
|
|
|
using PortalControl = typename StorageType::PortalType;
|
|
|
|
using PortalConstControl = typename StorageType::PortalConstType;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using PortalExecution = vtkm::exec::internal::ArrayPortalGroupVec<
|
2017-05-26 17:53:28 +00:00
|
|
|
typename SourceArrayHandleType::template ExecutionTypes<Device>::Portal,
|
2017-08-16 15:34:21 +00:00
|
|
|
NUM_COMPONENTS>;
|
|
|
|
using PortalConstExecution = vtkm::exec::internal::ArrayPortalGroupVec<
|
2017-05-26 17:53:28 +00:00
|
|
|
typename SourceArrayHandleType::template ExecutionTypes<Device>::PortalConst,
|
2017-08-16 15:34:21 +00:00
|
|
|
NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ArrayTransfer(StorageType* storage)
|
|
|
|
: SourceArray(storage->GetSourceArray())
|
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
vtkm::Id GetNumberOfValues() const
|
|
|
|
{
|
|
|
|
vtkm::Id sourceSize = this->SourceArray.GetNumberOfValues();
|
2017-05-18 14:29:41 +00:00
|
|
|
if (sourceSize % NUM_COMPONENTS != 0)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-01-09 21:15:32 +00:00
|
|
|
throw vtkm::cont::ErrorBadValue(
|
2017-05-18 14:29:41 +00:00
|
|
|
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
return sourceSize / NUM_COMPONENTS;
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
if (this->SourceArray.GetNumberOfValues() % NUM_COMPONENTS != 0)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-01-09 21:15:32 +00:00
|
|
|
throw vtkm::cont::ErrorBadValue(
|
2017-05-18 14:29:41 +00:00
|
|
|
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
return PortalConstExecution(this->SourceArray.PrepareForInput(Device()));
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
if (this->SourceArray.GetNumberOfValues() % NUM_COMPONENTS != 0)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-01-09 21:15:32 +00:00
|
|
|
throw vtkm::cont::ErrorBadValue(
|
2017-05-18 14:29:41 +00:00
|
|
|
"ArrayHandleGroupVec's source array does not divide evenly into Vecs.");
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
return PortalExecution(this->SourceArray.PrepareForInPlace(Device()));
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
return PortalExecution(
|
|
|
|
this->SourceArray.PrepareForOutput(numberOfValues * NUM_COMPONENTS, Device()));
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
// Implementation of this method should be unnecessary. The internal
|
|
|
|
// array handles should automatically retrieve the output data as
|
|
|
|
// necessary.
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2015-09-28 23:19:38 +00:00
|
|
|
void Shrink(vtkm::Id numberOfValues)
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
this->SourceArray.Shrink(numberOfValues * NUM_COMPONENTS);
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void ReleaseResources() { this->SourceArray.ReleaseResourcesExecution(); }
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SourceArrayHandleType SourceArray;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
/// \brief Fancy array handle that groups values into vectors.
|
|
|
|
///
|
|
|
|
/// It is sometimes the case that an array is stored such that consecutive
|
|
|
|
/// entries are meant to form a group. This fancy array handle takes an array
|
|
|
|
/// of values and a size of groups and then groups the consecutive values
|
|
|
|
/// stored in a \c Vec.
|
|
|
|
///
|
|
|
|
/// For example, if you have an array handle with the six values 0,1,2,3,4,5
|
|
|
|
/// and give it to a \c ArrayHandleGroupVec with the number of components set
|
|
|
|
/// to 3, you get an array that looks like it contains two values of \c Vec
|
|
|
|
/// values of size 3 with the data [0,1,2], [3,4,5].
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename SourceArrayHandleType, vtkm::IdComponent NUM_COMPONENTS>
|
2015-09-28 23:19:38 +00:00
|
|
|
class ArrayHandleGroupVec
|
2017-05-18 14:29:41 +00:00
|
|
|
: public vtkm::cont::ArrayHandle<
|
|
|
|
vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
|
|
|
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>>
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
VTKM_IS_ARRAY_HANDLE(SourceArrayHandleType);
|
|
|
|
|
|
|
|
public:
|
2015-10-21 19:36:27 +00:00
|
|
|
VTKM_ARRAY_HANDLE_SUBCLASS(
|
2017-05-26 17:53:28 +00:00
|
|
|
ArrayHandleGroupVec,
|
|
|
|
(ArrayHandleGroupVec<SourceArrayHandleType, NUM_COMPONENTS>),
|
2017-05-18 14:29:41 +00:00
|
|
|
(vtkm::cont::ArrayHandle<
|
|
|
|
vtkm::Vec<typename SourceArrayHandleType::ValueType, NUM_COMPONENTS>,
|
|
|
|
vtkm::cont::internal::StorageTagGroupVec<SourceArrayHandleType, NUM_COMPONENTS>>));
|
2015-10-21 19:36:27 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename SourceArrayHandleType::ValueType;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
private:
|
2017-08-16 15:34:21 +00:00
|
|
|
using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
public:
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ArrayHandleGroupVec(const SourceArrayHandleType& sourceArray)
|
|
|
|
: Superclass(StorageType(sourceArray))
|
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
};
|
|
|
|
|
2015-09-29 13:16:22 +00:00
|
|
|
/// \c make_ArrayHandleGroupVec is convenience function to generate an
|
|
|
|
/// ArrayHandleGroupVec. It takes in an ArrayHandle and the number of components
|
|
|
|
/// (as a specified template parameter), and returns an array handle with
|
|
|
|
/// consecutive entries grouped in a Vec.
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent NUM_COMPONENTS, typename ArrayHandleType>
|
|
|
|
VTKM_CONT vtkm::cont::ArrayHandleGroupVec<ArrayHandleType, NUM_COMPONENTS> make_ArrayHandleGroupVec(
|
|
|
|
const ArrayHandleType& array)
|
2015-09-29 13:16:22 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
return vtkm::cont::ArrayHandleGroupVec<ArrayHandleType, NUM_COMPONENTS>(array);
|
2015-09-29 13:16:22 +00:00
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
|
|
|
#endif //vtk_m_cont_ArrayHandleGroupVec_h
|