Commit 181d5f9f authored by Robert Maynard's avatar Robert Maynard
Browse files

ArrayHandleZip now gracefully handles writes to implicit handles.

parent 2a8f7ec4
......@@ -22,6 +22,7 @@
#include <vtkm/Pair.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/internal/ArrayPortalHelpers.h>
namespace vtkm
......@@ -37,6 +38,9 @@ class ArrayPortalZip
using ValueType = ValueType_;
using T = typename ValueType::FirstType;
using U = typename ValueType::SecondType;
using IteratorType = ValueType_;
using PortalTypeFirst = PortalTypeFirst_;
using PortalTypeSecond = PortalTypeSecond_;
......@@ -73,14 +77,20 @@ public:
ValueType Get(vtkm::Id index) const
return vtkm::make_Pair(this->PortalFirst.Get(index), this->PortalSecond.Get(index));
using call_supported_t1 = typename vtkm::internal::PortalSupportsGets<PortalTypeFirst>::type;
using call_supported_t2 = typename vtkm::internal::PortalSupportsGets<PortalTypeSecond>::type;
return vtkm::make_Pair(this->GetFirst(call_supported_t1(), index),
this->GetSecond(call_supported_t2(), index));
void Set(vtkm::Id index, const ValueType& value) const
this->PortalFirst.Set(index, value.first);
this->PortalSecond.Set(index, value.second);
using call_supported_t1 = typename vtkm::internal::PortalSupportsSets<PortalTypeFirst>::type;
using call_supported_t2 = typename vtkm::internal::PortalSupportsSets<PortalTypeSecond>::type;
this->SetFirst(call_supported_t1(), index, value.first);
this->SetSecond(call_supported_t2(), index, value.second);
......@@ -90,6 +100,28 @@ public:
const PortalTypeSecond& GetSecondPortal() const { return this->PortalSecond; }
VTKM_EXEC inline T GetFirst(std::true_type, vtkm::Id index) const noexcept
return this->PortalFirst.Get(index);
VTKM_EXEC inline T GetFirst(std::false_type, vtkm::Id) const noexcept { return T{}; }
VTKM_EXEC inline U GetSecond(std::true_type, vtkm::Id index) const noexcept
return this->PortalSecond.Get(index);
VTKM_EXEC inline U GetSecond(std::false_type, vtkm::Id) const noexcept { return U{}; }
VTKM_EXEC inline void SetFirst(std::true_type, vtkm::Id index, const T& value) const noexcept
this->PortalFirst.Set(index, value);
VTKM_EXEC inline void SetFirst(std::false_type, vtkm::Id, const T&) const noexcept {}
VTKM_EXEC inline void SetSecond(std::true_type, vtkm::Id index, const U& value) const noexcept
this->PortalSecond.Set(index, value);
VTKM_EXEC inline void SetSecond(std::false_type, vtkm::Id, const U&) const noexcept {}
PortalTypeFirst PortalFirst;
PortalTypeSecond PortalSecond;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment