2015-09-28 23:19:38 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-09-28 23:19:38 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_cont_ArrayHandleGroupVec_h
|
|
|
|
#define vtk_m_cont_ArrayHandleGroupVec_h
|
|
|
|
|
2020-09-10 23:54:12 +00:00
|
|
|
#include <vtkm/cont/ArrayExtractComponent.h>
|
2015-09-28 23:19:38 +00:00
|
|
|
#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 internal
|
|
|
|
{
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2019-02-28 20:08:08 +00:00
|
|
|
template <typename PortalType, vtkm::IdComponent N_COMPONENTS>
|
2016-12-19 19:39:17 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT ArrayPortalGroupVec
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2019-09-13 15:42:33 +00:00
|
|
|
using Writable = vtkm::internal::PortalSupportsSets<PortalType>;
|
|
|
|
|
2015-09-28 23:19:38 +00:00
|
|
|
public:
|
2019-02-28 20:08:08 +00:00
|
|
|
static constexpr vtkm::IdComponent NUM_COMPONENTS = N_COMPONENTS;
|
2020-11-17 17:13:14 +00:00
|
|
|
using ComponentsPortalType = PortalType;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2020-11-17 17:13:14 +00:00
|
|
|
using ComponentType = typename std::remove_const<typename ComponentsPortalType::ValueType>::type;
|
2017-08-16 15:34:21 +00:00
|
|
|
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()
|
2020-11-17 17:13:14 +00:00
|
|
|
: ComponentsPortal()
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2020-11-17 17:13:14 +00:00
|
|
|
ArrayPortalGroupVec(const ComponentsPortalType& componentsPortal)
|
|
|
|
: ComponentsPortal(componentsPortal)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
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
|
2020-11-17 17:13:14 +00:00
|
|
|
template <typename OtherComponentsPortalType>
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_EXEC_CONT ArrayPortalGroupVec(
|
2020-11-17 17:13:14 +00:00
|
|
|
const ArrayPortalGroupVec<OtherComponentsPortalType, NUM_COMPONENTS>& src)
|
|
|
|
: ComponentsPortal(src.GetPortal())
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
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
|
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
return this->ComponentsPortal.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;
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkm::Id componentsIndex = index * NUM_COMPONENTS;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
result[componentIndex] = this->ComponentsPortal.Get(componentsIndex);
|
|
|
|
componentsIndex++;
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2019-09-13 15:42:33 +00:00
|
|
|
template <typename Writable_ = Writable,
|
|
|
|
typename = typename std::enable_if<Writable_::value>::type>
|
|
|
|
VTKM_EXEC_CONT void Set(vtkm::Id index, const ValueType& value) const
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkm::Id componentsIndex = index * NUM_COMPONENTS;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; componentIndex++)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
this->ComponentsPortal.Set(componentsIndex, value[componentIndex]);
|
|
|
|
componentsIndex++;
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2020-11-17 17:13:14 +00:00
|
|
|
const ComponentsPortalType& GetPortal() const { return this->ComponentsPortal; }
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
private:
|
2020-11-17 17:13:14 +00:00
|
|
|
ComponentsPortalType ComponentsPortal;
|
2015-09-28 23:19:38 +00:00
|
|
|
};
|
2016-08-02 15:26:29 +00:00
|
|
|
}
|
2020-11-17 17:13:14 +00:00
|
|
|
} // namespace vtkm::internal
|
2016-08-02 15:26:29 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2016-08-02 15:26:29 +00:00
|
|
|
|
2020-11-17 17:13:14 +00:00
|
|
|
template <typename ComponentsStorageTag, vtkm::IdComponent NUM_COMPONENTS>
|
2017-05-18 14:29:41 +00:00
|
|
|
struct VTKM_ALWAYS_EXPORT StorageTagGroupVec
|
|
|
|
{
|
|
|
|
};
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2019-12-30 22:20:44 +00:00
|
|
|
namespace internal
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2019-12-30 22:20:44 +00:00
|
|
|
|
2020-11-17 17:13:14 +00:00
|
|
|
template <typename ComponentType, vtkm::IdComponent NUM_COMPONENTS, typename ComponentsStorageTag>
|
2019-12-30 22:20:44 +00:00
|
|
|
class Storage<vtkm::Vec<ComponentType, NUM_COMPONENTS>,
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkm::cont::StorageTagGroupVec<ComponentsStorageTag, NUM_COMPONENTS>>
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
using ComponentsStorage = vtkm::cont::internal::Storage<ComponentType, ComponentsStorageTag>;
|
2017-08-16 15:34:21 +00:00
|
|
|
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
public:
|
2020-11-17 17:13:14 +00:00
|
|
|
using ReadPortalType =
|
|
|
|
vtkm::internal::ArrayPortalGroupVec<typename ComponentsStorage::ReadPortalType, NUM_COMPONENTS>;
|
|
|
|
using WritePortalType =
|
|
|
|
vtkm::internal::ArrayPortalGroupVec<typename ComponentsStorage::WritePortalType,
|
|
|
|
NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2022-06-28 20:26:38 +00:00
|
|
|
VTKM_CONT static std::vector<vtkm::cont::internal::Buffer> CreateBuffers()
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
2022-06-28 20:26:38 +00:00
|
|
|
return ComponentsStorage::CreateBuffers();
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2020-11-17 17:13:14 +00:00
|
|
|
VTKM_CONT static void ResizeBuffers(vtkm::Id numValues,
|
2022-06-28 20:26:38 +00:00
|
|
|
const std::vector<vtkm::cont::internal::Buffer>& buffers,
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkm::CopyFlag preserve,
|
|
|
|
vtkm::cont::Token& token)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
ComponentsStorage::ResizeBuffers(NUM_COMPONENTS * numValues, buffers, preserve, token);
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2023-10-03 14:31:38 +00:00
|
|
|
VTKM_CONT static vtkm::IdComponent GetNumberOfComponentsFlat(
|
|
|
|
const std::vector<vtkm::cont::internal::Buffer>& buffers)
|
|
|
|
{
|
|
|
|
return ComponentsStorage::GetNumberOfComponentsFlat(buffers) * NUM_COMPONENTS;
|
|
|
|
}
|
|
|
|
|
2022-06-28 20:26:38 +00:00
|
|
|
VTKM_CONT static vtkm::Id GetNumberOfValues(
|
|
|
|
const std::vector<vtkm::cont::internal::Buffer>& buffers)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkm::Id componentsSize = ComponentsStorage::GetNumberOfValues(buffers);
|
|
|
|
return componentsSize / NUM_COMPONENTS;
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 20:26:38 +00:00
|
|
|
VTKM_CONT static void Fill(const std::vector<vtkm::cont::internal::Buffer>&,
|
2022-01-04 16:29:12 +00:00
|
|
|
const ValueType&,
|
|
|
|
vtkm::Id,
|
2022-01-11 14:15:41 +00:00
|
|
|
vtkm::Id,
|
2022-01-04 16:29:12 +00:00
|
|
|
vtkm::cont::Token&)
|
|
|
|
{
|
|
|
|
throw vtkm::cont::ErrorBadType("Fill not supported for ArrayHandleGroupVec.");
|
|
|
|
}
|
|
|
|
|
2022-06-28 20:26:38 +00:00
|
|
|
VTKM_CONT static ReadPortalType CreateReadPortal(
|
|
|
|
const std::vector<vtkm::cont::internal::Buffer>& buffers,
|
|
|
|
vtkm::cont::DeviceAdapterId device,
|
|
|
|
vtkm::cont::Token& token)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-18 18:15:50 +00:00
|
|
|
if ((ComponentsStorage::GetNumberOfValues(buffers) % NUM_COMPONENTS) != 0)
|
|
|
|
{
|
|
|
|
VTKM_LOG_S(vtkm::cont::LogLevel::Warn,
|
|
|
|
"ArrayHandleGroupVec's components array does not divide evenly into Vecs.");
|
|
|
|
}
|
2020-11-17 17:13:14 +00:00
|
|
|
return ReadPortalType(ComponentsStorage::CreateReadPortal(buffers, device, token));
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 20:26:38 +00:00
|
|
|
VTKM_CONT static WritePortalType CreateWritePortal(
|
|
|
|
const std::vector<vtkm::cont::internal::Buffer>& buffers,
|
|
|
|
vtkm::cont::DeviceAdapterId device,
|
|
|
|
vtkm::cont::Token& token)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-18 18:15:50 +00:00
|
|
|
if ((ComponentsStorage::GetNumberOfValues(buffers) % NUM_COMPONENTS) != 0)
|
|
|
|
{
|
|
|
|
VTKM_LOG_S(vtkm::cont::LogLevel::Warn,
|
|
|
|
"ArrayHandleGroupVec's components array does not divide evenly into Vecs.");
|
|
|
|
}
|
2020-11-17 17:13:14 +00:00
|
|
|
return WritePortalType(ComponentsStorage::CreateWritePortal(buffers, device, token));
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
2024-05-31 14:41:44 +00:00
|
|
|
/// @brief Fancy array handle that groups values into vectors.
|
2015-09-28 23:19:38 +00:00
|
|
|
///
|
|
|
|
/// 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
|
2024-05-31 14:41:44 +00:00
|
|
|
/// stored in a `vtkm::Vec`.
|
2015-09-28 23:19:38 +00:00
|
|
|
///
|
|
|
|
/// For example, if you have an array handle with the six values 0,1,2,3,4,5
|
2024-05-31 14:41:44 +00:00
|
|
|
/// and give it to a `ArrayHandleGroupVec` with the number of components set
|
|
|
|
/// to 3, you get an array that looks like it contains two values of `vtkm::Vec`
|
|
|
|
/// of size 3 with the data [0,1,2], [3,4,5].
|
2015-09-28 23:19:38 +00:00
|
|
|
///
|
2020-11-18 18:15:50 +00:00
|
|
|
/// The array of components should have a number of values that divides evenly
|
2024-05-31 14:41:44 +00:00
|
|
|
/// with the size of the `vtkm::Vec`. If the components array does not divide evenly
|
|
|
|
/// into `vtkm::Vec`s, then a warning will be logged and the extra component values
|
2020-11-18 18:15:50 +00:00
|
|
|
/// will be ignored.
|
|
|
|
///
|
2020-11-17 17:13:14 +00:00
|
|
|
template <typename ComponentsArrayHandleType, 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<
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkm::Vec<typename ComponentsArrayHandleType::ValueType, NUM_COMPONENTS>,
|
|
|
|
vtkm::cont::StorageTagGroupVec<typename ComponentsArrayHandleType::StorageTag,
|
|
|
|
NUM_COMPONENTS>>
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
VTKM_IS_ARRAY_HANDLE(ComponentsArrayHandleType);
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
public:
|
2015-10-21 19:36:27 +00:00
|
|
|
VTKM_ARRAY_HANDLE_SUBCLASS(
|
2017-05-26 17:53:28 +00:00
|
|
|
ArrayHandleGroupVec,
|
2020-11-17 17:13:14 +00:00
|
|
|
(ArrayHandleGroupVec<ComponentsArrayHandleType, NUM_COMPONENTS>),
|
2017-05-18 14:29:41 +00:00
|
|
|
(vtkm::cont::ArrayHandle<
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkm::Vec<typename ComponentsArrayHandleType::ValueType, NUM_COMPONENTS>,
|
|
|
|
vtkm::cont::StorageTagGroupVec<typename ComponentsArrayHandleType::StorageTag,
|
|
|
|
NUM_COMPONENTS>>));
|
2015-10-21 19:36:27 +00:00
|
|
|
|
2020-11-17 17:13:14 +00:00
|
|
|
using ComponentType = typename ComponentsArrayHandleType::ValueType;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2024-05-31 14:41:44 +00:00
|
|
|
/// Construct an `ArrayHandleGroupVec` with a provided components array.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2020-11-17 17:13:14 +00:00
|
|
|
ArrayHandleGroupVec(const ComponentsArrayHandleType& componentsArray)
|
|
|
|
: Superclass(componentsArray.GetBuffers())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-05-31 14:41:44 +00:00
|
|
|
/// Retrieve the components array being grouped.
|
2020-11-17 17:13:14 +00:00
|
|
|
VTKM_CONT ComponentsArrayHandleType GetComponentsArray() const
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
return ComponentsArrayHandleType(this->GetBuffers());
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
};
|
|
|
|
|
2024-05-31 14:41:44 +00:00
|
|
|
/// `make_ArrayHandleGroupVec` is convenience function to generate an
|
2015-09-29 13:16:22 +00:00
|
|
|
/// 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
|
|
|
}
|
2020-09-10 23:54:12 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------
|
|
|
|
// Specialization of ArrayExtractComponent
|
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
|
2022-01-19 21:59:27 +00:00
|
|
|
// Superclass will inherit the ArrayExtractComponentImplInefficient property if
|
|
|
|
// the sub-storage is inefficient (thus making everything inefficient).
|
2020-09-10 23:54:12 +00:00
|
|
|
template <typename ComponentsStorageTag, vtkm::IdComponent NUM_COMPONENTS>
|
|
|
|
struct ArrayExtractComponentImpl<
|
|
|
|
vtkm::cont::StorageTagGroupVec<ComponentsStorageTag, NUM_COMPONENTS>>
|
2022-01-19 21:59:27 +00:00
|
|
|
: vtkm::cont::internal::ArrayExtractComponentImpl<ComponentsStorageTag>
|
2020-09-10 23:54:12 +00:00
|
|
|
{
|
|
|
|
template <typename T>
|
|
|
|
vtkm::cont::ArrayHandleStride<typename vtkm::VecTraits<T>::BaseComponentType> operator()(
|
|
|
|
const vtkm::cont::ArrayHandle<
|
|
|
|
vtkm::Vec<T, NUM_COMPONENTS>,
|
|
|
|
vtkm::cont::StorageTagGroupVec<ComponentsStorageTag, NUM_COMPONENTS>>& src,
|
|
|
|
vtkm::IdComponent componentIndex,
|
|
|
|
vtkm::CopyFlag allowCopy) const
|
|
|
|
{
|
|
|
|
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<T, ComponentsStorageTag>,
|
|
|
|
NUM_COMPONENTS>
|
|
|
|
srcArray(src);
|
|
|
|
constexpr vtkm::IdComponent NUM_SUB_COMPONENTS = vtkm::VecFlat<T>::NUM_COMPONENTS;
|
|
|
|
vtkm::cont::ArrayHandleStride<typename vtkm::VecTraits<T>::BaseComponentType> dest =
|
|
|
|
ArrayExtractComponentImpl<ComponentsStorageTag>{}(
|
|
|
|
srcArray.GetComponentsArray(), componentIndex % NUM_SUB_COMPONENTS, allowCopy);
|
|
|
|
|
|
|
|
// Adjust stride and offset to expectations of grouped values
|
|
|
|
return vtkm::cont::ArrayHandleStride<typename vtkm::VecTraits<T>::BaseComponentType>(
|
|
|
|
dest.GetBasicArray(),
|
|
|
|
dest.GetNumberOfValues() / NUM_COMPONENTS,
|
|
|
|
dest.GetStride() * NUM_COMPONENTS,
|
|
|
|
dest.GetOffset() + (dest.GetStride() * (componentIndex / NUM_SUB_COMPONENTS)),
|
|
|
|
dest.GetModulo(),
|
|
|
|
dest.GetDivisor());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
2015-09-28 23:19:38 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
2018-06-08 15:56:40 +00:00
|
|
|
//=============================================================================
|
|
|
|
// Specializations of serialization related classes
|
2019-09-12 21:19:36 +00:00
|
|
|
/// @cond SERIALIZATION
|
2018-06-08 15:56:40 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
|
|
|
template <typename AH, vtkm::IdComponent NUM_COMPS>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString<vtkm::cont::ArrayHandleGroupVec<AH, NUM_COMPS>>
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name =
|
2019-02-28 18:15:27 +00:00
|
|
|
"AH_GroupVec<" + SerializableTypeString<AH>::Get() + "," + std::to_string(NUM_COMPS) + ">";
|
2018-06-08 15:56:40 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-30 22:20:44 +00:00
|
|
|
template <typename T, vtkm::IdComponent NUM_COMPS, typename ST>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString<
|
2019-12-30 22:20:44 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec<T, NUM_COMPS>, vtkm::cont::StorageTagGroupVec<ST, NUM_COMPS>>>
|
|
|
|
: SerializableTypeString<
|
|
|
|
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<T, ST>, NUM_COMPS>>
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // vtkm::cont
|
|
|
|
|
2019-02-05 16:02:29 +00:00
|
|
|
namespace mangled_diy_namespace
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
template <typename AH, vtkm::IdComponent NUM_COMPS>
|
|
|
|
struct Serialization<vtkm::cont::ArrayHandleGroupVec<AH, NUM_COMPS>>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
using Type = vtkm::cont::ArrayHandleGroupVec<AH, NUM_COMPS>;
|
|
|
|
using BaseType = vtkm::cont::ArrayHandle<typename Type::ValueType, typename Type::StorageTag>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static VTKM_CONT void save(BinaryBuffer& bb, const BaseType& obj)
|
|
|
|
{
|
2020-11-17 17:13:14 +00:00
|
|
|
vtkmdiy::save(bb, Type(obj).GetComponentsArray());
|
2018-06-08 15:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static VTKM_CONT void load(BinaryBuffer& bb, BaseType& obj)
|
|
|
|
{
|
|
|
|
AH array;
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::load(bb, array);
|
2018-06-08 15:56:40 +00:00
|
|
|
|
|
|
|
obj = vtkm::cont::make_ArrayHandleGroupVec<NUM_COMPS>(array);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-30 22:20:44 +00:00
|
|
|
template <typename T, vtkm::IdComponent NUM_COMPS, typename ST>
|
2018-06-08 15:56:40 +00:00
|
|
|
struct Serialization<
|
2019-12-30 22:20:44 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec<T, NUM_COMPS>, vtkm::cont::StorageTagGroupVec<ST, NUM_COMPS>>>
|
|
|
|
: Serialization<vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<T, ST>, NUM_COMPS>>
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
} // diy
|
2019-09-12 21:19:36 +00:00
|
|
|
/// @endcond SERIALIZATION
|
2018-06-08 15:56:40 +00:00
|
|
|
|
2015-09-28 23:19:38 +00:00
|
|
|
#endif //vtk_m_cont_ArrayHandleGroupVec_h
|