Merge topic 'deprecate-arrayhandlevirtualcoordinates'

c689a68c5 Suppress bad deprecation warnings in MSVC
a3f23a03b Do not cast to ArrayHandleVirtual in VariantArrayHandle::CastAndCall
f6b13df51 Support coordinates of both float32 and float64
453e31404 Deprecate ArrayHandleVirtualCoordinates
be7f06bbe CoordinateSystem data is VariantArrayHandle

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2177
This commit is contained in:
Kenneth Moreland 2020-07-16 21:25:37 +00:00 committed by Kitware Robot
commit 502c310cf8
79 changed files with 909 additions and 820 deletions

@ -0,0 +1,39 @@
# Deprecate ArrayHandleVirtualCoordinates
As we port VTK-m to more types of accelerator architectures, supporting
virtual methods is becoming more problematic. Thus, we are working to back
out of using virtual methods in the execution environment.
One of the most widespread users of virtual methods in the execution
environment is `ArrayHandleVirtual`. As a first step of deprecating this
class, we first deprecate the `ArrayHandleVirtualCoordinates` subclass.
Not surprisingly, `ArrayHandleVirtualCoordinates` is used directly by
`CoordinateSystem`. The biggest change necessary was that the `GetData`
method returned an `ArrayHandleVirtualCoordinates`, which obviously would
not work if that class is deprecated.
An oddness about this return type is that it is quite different from the
superclass's method of the same name. Rather, `Field` returns a
`VariantArrayHandle`. Since this had to be corrected anyway, it was decided
to change `CoordinateSystem`'s `GetData` to also return a
`VariantArrayHandle`, although its typelist is set to just `vtkm::Vec3f`.
To try to still support old code that expects the deprecated behavior of
returning an `ArrayHandleVirtualCoordinates`, `CoordinateSystem::GetData`
actually returns a "hidden" subclass of `VariantArrayHandle` that
automatically converts itself to an `ArrayHandleVirtualCoordinates`. (A
deprecation warning is given if this is done.)
This approach to support deprecated code is not perfect. The returned value
for `CoordinateSystem::GetData` can only be used as an `ArrayHandle` if a
method is directly called on it or if it is cast specifically to
`ArrayHandleVirtualCoordinates` or its superclass. For example, if passing
it to a method argument typed as `vtkm::cont::ArrayHandle<T, S>` where `T`
and `S` are template parameters, then the conversion will fail.
To continue to support ease of use, `CoordinateSystem` now has a method
named `GetDataAsMultiplexer` that returns the data as an
`ArrayHandleMultiplexer`. This can be employed to quickly use the
`CoordinateSystem` as an array without the overhead of a `CastAndCall`.

@ -42,7 +42,7 @@ vtkm::cont::DataSet make_test3DImageData(vtkm::Id3 dims)
vtkm::cont::ArrayHandle<vtkm::Vec3f> field;
vtkm::cont::Invoker invoke;
invoke(WaveField{}, ds.GetCoordinateSystem(), field);
invoke(WaveField{}, ds.GetCoordinateSystem().GetDataAsMultiplexer(), field);
ds.AddPointField("vec_field", field);
return ds;

@ -110,6 +110,39 @@ VTKM_CONT void ArrayCopy(const vtkm::cont::ArrayHandle<InValueType, InStorage>&
// Static dispatch cases 1 & 2
detail::ArrayCopyImpl(source, destination, JustCopyStorage{});
}
// Forward declaration
// Cannot include VariantArrayHandle.h here due to circular dependency.
template <typename TypeList>
class VariantArrayHandleBase;
namespace detail
{
struct ArrayCopyFunctor
{
template <typename InValueType, typename InStorage, typename OutValueType, typename OutStorage>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<InValueType, InStorage>& source,
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination) const
{
vtkm::cont::ArrayCopy(source, destination);
}
};
} // namespace detail
/// \brief Deep copies data in a `VariantArrayHandle` to an array of a known type.
///
/// This form of `ArrayCopy` can be used to copy data from an unknown array type to
/// an array of a known type. Note that regardless of the source type, the data will
/// be deep copied.
///
template <typename InTypeList, typename OutValueType, typename OutStorage>
VTKM_CONT void ArrayCopy(const vtkm::cont::VariantArrayHandleBase<InTypeList>& source,
vtkm::cont::ArrayHandle<OutValueType, OutStorage>& destination)
{
source.CastAndCall(detail::ArrayCopyFunctor{}, destination);
}
}
} // namespace vtkm::cont

@ -1409,8 +1409,8 @@ VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle(
vtkm::Id sz = array.GetNumberOfValues();
out << "valueType=" << vtkm::cont::TypeToString<T>()
<< " storageType=" << vtkm::cont::TypeToString<StorageT>() << sz << " values occupying "
<< (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
<< " storageType=" << vtkm::cont::TypeToString<StorageT>() << " " << sz
<< " values occupying " << (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
PortalType portal = array.ReadPortal();
if (full || sz <= 7)

@ -28,20 +28,24 @@ namespace cont
{
/// ArrayHandleVirtualCoordinates is a specialization of ArrayHandle.
class VTKM_ALWAYS_EXPORT ArrayHandleVirtualCoordinates final
: public vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>
class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Virtual ArrayHandles are being phased out.")
ArrayHandleVirtualCoordinates final : public vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>
{
public:
VTKM_ARRAY_HANDLE_SUBCLASS_NT(ArrayHandleVirtualCoordinates,
(vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>));
VTKM_DEPRECATED_SUPPRESS_BEGIN
template <typename T, typename S>
explicit ArrayHandleVirtualCoordinates(const vtkm::cont::ArrayHandle<T, S>& ah)
: vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>(vtkm::cont::make_ArrayHandleCast<ValueType>(ah))
{
}
VTKM_DEPRECATED_SUPPRESS_END
};
VTKM_DEPRECATED_SUPPRESS_BEGIN
template <typename Functor, typename... Args>
void CastAndCall(const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
Functor&& f,
@ -66,6 +70,8 @@ struct SerializableTypeString<vtkm::cont::ArrayHandleVirtualCoordinates>
static VTKM_CONT const std::string Get() { return "AH_VirtualCoordinates"; }
};
VTKM_DEPRECATED_SUPPRESS_END
} // namespace cont
} // namespace vtkm
@ -75,6 +81,8 @@ struct SerializableTypeString<vtkm::cont::ArrayHandleVirtualCoordinates>
namespace mangled_diy_namespace
{
VTKM_DEPRECATED_SUPPRESS_BEGIN
template <>
struct Serialization<vtkm::cont::ArrayHandleVirtualCoordinates>
{
@ -173,6 +181,8 @@ public:
}
};
VTKM_DEPRECATED_SUPPRESS_END
} // diy
/// @endcond SERIALIZATION

@ -16,7 +16,7 @@
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
#include <vtkm/cont/ArrayHandleCompositeVector.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
#include <vtkm/cont/ArrayHandleVirtual.h>
#include <vtkm/cont/DeviceAdapterTag.h>
namespace vtkm

@ -128,7 +128,6 @@ set(template_sources
CellSetExtrude.hxx
CellSetStructured.hxx
ColorTable.hxx
CoordinateSystem.hxx
FieldRangeCompute.hxx
FieldRangeGlobalCompute.hxx
StorageVirtual.hxx

@ -234,7 +234,7 @@ void CellLocatorBoundingIntervalHierarchy::Build()
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
vtkm::Id numCells = cellSet.GetNumberOfCells();
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
vtkm::cont::ArrayHandleVirtualCoordinates points = coords.GetData();
auto points = coords.GetDataAsMultiplexer();
//std::cout << "No of cells: " << numCells << "\n";
//std::cout.precision(3);
@ -457,7 +457,7 @@ struct CellLocatorBIHPrepareForExecutionFunctor
vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator>& bihExec,
const vtkm::cont::ArrayHandle<vtkm::exec::CellLocatorBoundingIntervalHierarchyNode>& nodes,
const vtkm::cont::ArrayHandle<vtkm::Id>& processedCellIds,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords) const
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coords) const
{
using ExecutionType =
vtkm::exec::CellLocatorBoundingIntervalHierarchyExec<DeviceAdapter, CellSetType>;
@ -501,7 +501,7 @@ const vtkm::exec::CellLocator* CellLocatorBoundingIntervalHierarchy::PrepareForE
this->ExecutionObjectHandle,
this->Nodes,
this->ProcessedCellIds,
this->GetCoordinates().GetData());
this->GetCoordinates().GetDataAsMultiplexer());
return this->ExecutionObjectHandle.PrepareForExecution(device, token);
;
}

@ -94,9 +94,9 @@ private:
using ArrayPortalConst =
typename vtkm::cont::ArrayHandle<T>::template ExecutionTypes<DeviceAdapter>::PortalConst;
using CoordsPortalType = decltype(vtkm::cont::ArrayHandleVirtualCoordinates{}.PrepareForInput(
DeviceAdapter{},
std::declval<vtkm::cont::Token&>()));
using CoordsPortalType =
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::ExecutionTypes<
DeviceAdapter>::PortalConst;
using CellSetP2CExecType =
decltype(std::declval<CellSetType>().PrepareForInput(DeviceAdapter{},
@ -150,7 +150,7 @@ public:
vtkm::TopologyElementTagCell{},
vtkm::TopologyElementTagPoint{},
token))
, Coords(coords.GetData().PrepareForInput(DeviceAdapter{}, token))
, Coords(coords.GetDataAsMultiplexer().PrepareForInput(DeviceAdapter{}, token))
{
}

@ -81,12 +81,10 @@ struct CellLocatorUniformGridPrepareForExecutionFunctor
template <typename DeviceAdapter, typename... Args>
VTKM_CONT bool operator()(DeviceAdapter,
vtkm::cont::VirtualObjectHandle<vtkm::exec::CellLocator>& execLocator,
vtkm::cont::Token& token,
Args&&... args) const
{
using ExecutionType = vtkm::exec::CellLocatorUniformGrid<DeviceAdapter, dimensions>;
ExecutionType* execObject =
new ExecutionType(std::forward<Args>(args)..., DeviceAdapter(), token);
ExecutionType* execObject = new ExecutionType(std::forward<Args>(args)..., DeviceAdapter());
execLocator.Reset(execObject);
return true;
}
@ -103,26 +101,22 @@ const vtkm::exec::CellLocator* CellLocatorUniformGrid::PrepareForExecution(
success = vtkm::cont::TryExecuteOnDevice(device,
CellLocatorUniformGridPrepareForExecutionFunctor<3>(),
this->ExecutionObjectHandle,
token,
this->CellDims,
this->PointDims,
this->Origin,
this->InvSpacing,
this->MaxPoint,
this->GetCoordinates().GetData());
this->MaxPoint);
}
else
{
success = vtkm::cont::TryExecuteOnDevice(device,
CellLocatorUniformGridPrepareForExecutionFunctor<2>(),
this->ExecutionObjectHandle,
token,
this->CellDims,
this->PointDims,
this->Origin,
this->InvSpacing,
this->MaxPoint,
this->GetCoordinates().GetData());
this->MaxPoint);
}
if (!success)
{

@ -10,22 +10,32 @@
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/CoordinateSystem.hxx>
namespace vtkm
{
namespace cont
{
namespace detail
{
VTKM_DEPRECATED_SUPPRESS_BEGIN
vtkm::cont::ArrayHandleVirtualCoordinates CoordDataDepWrapper::ToArray() const
{
return this->Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
}
VTKM_DEPRECATED_SUPPRESS_END
} // namespace detail
VTKM_CONT CoordinateSystem::CoordinateSystem()
: Superclass()
{
}
VTKM_CONT CoordinateSystem::CoordinateSystem(
std::string name,
const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& data)
: Superclass(name, Association::POINTS, data)
VTKM_CONT CoordinateSystem::CoordinateSystem(std::string name,
const vtkm::cont::VariantArrayHandleCommon& data)
: Superclass(name, Association::POINTS, vtkm::cont::VariantArrayHandle{ data })
{
}
@ -38,21 +48,19 @@ CoordinateSystem::CoordinateSystem(std::string name,
vtkm::Vec3f spacing)
: Superclass(name,
Association::POINTS,
vtkm::cont::ArrayHandleVirtualCoordinates(
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing)))
vtkm::cont::ArrayHandleUniformPointCoordinates(dimensions, origin, spacing))
{
}
VTKM_CONT
vtkm::cont::ArrayHandleVirtualCoordinates CoordinateSystem::GetData() const
VTKM_CONT vtkm::cont::detail::CoordDataDepWrapper CoordinateSystem::GetData() const
{
return this->Superclass::GetData().Cast<vtkm::cont::ArrayHandleVirtualCoordinates>();
return vtkm::cont::detail::CoordDataDepWrapper(this->Superclass::GetData());
}
VTKM_CONT
void CoordinateSystem::SetData(const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& newdata)
VTKM_CONT vtkm::cont::CoordinateSystem::MultiplexerArrayType
CoordinateSystem::GetDataAsMultiplexer() const
{
this->Superclass::SetData(newdata);
return this->GetData().AsMultiplexer<MultiplexerArrayType>();
}
VTKM_CONT
@ -103,14 +111,5 @@ template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>,
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>,
vtkm::cont::ArrayHandle<vtkm::Float64, vtkm::cont::StorageTagBasic>>::StorageTag>&);
template VTKM_CONT_EXPORT CoordinateSystem::CoordinateSystem(std::string name,
const vtkm::cont::VariantArrayHandle&);
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
const vtkm::cont::ArrayHandle<vtkm::Vec<float, 3>>&);
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(
const vtkm::cont::ArrayHandle<vtkm::Vec<double, 3>>&);
template VTKM_CONT_EXPORT void CoordinateSystem::SetData(const vtkm::cont::VariantArrayHandle&);
}
} // namespace vtkm::cont

@ -11,6 +11,7 @@
#define vtk_m_cont_CoordinateSystem_h
#include <vtkm/Bounds.h>
#include <vtkm/Deprecated.h>
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
@ -21,25 +22,116 @@ namespace vtkm
{
namespace cont
{
namespace detail
{
// CoordinateSystem::GetData used to return an ArrayHandleVirtualCoordinates.
// That behavior is deprecated, and CoordianteSystem::GetData now returns a
// VariantArrayHandle similar (although slightly different than) its superclass.
// This wrapper class supports the old deprecated behavior until it is no longer
// supported. Once the behavior is removed (probably when
// ArrayHandleVirtualCoordinates is removed), then this class should be removed.
class VTKM_ALWAYS_EXPORT CoordDataDepWrapper
: public vtkm::cont::VariantArrayHandleBase<vtkm::TypeListFieldVec3>
{
using Superclass = vtkm::cont::VariantArrayHandleBase<vtkm::TypeListFieldVec3>;
VTKM_DEPRECATED_SUPPRESS_BEGIN
VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates ToArray() const;
VTKM_DEPRECATED_SUPPRESS_END
public:
using Superclass::Superclass;
// Make the return also behave as ArrayHandleVirtualCoordiantes
VTKM_DEPRECATED_SUPPRESS_BEGIN
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
operator vtkm::cont::ArrayHandleVirtualCoordinates() const
{
return this->ToArray();
}
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
operator vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagVirtual>() const
{
return this->ToArray();
}
using ValueType VTKM_DEPRECATED(1.6,
"CoordinateSystem::GetData() now returns a VariantArrayHandle.") =
vtkm::Vec3f;
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
ArrayHandleVirtualCoordinates::ReadPortalType ReadPortal() const
{
return this->ToArray().ReadPortal();
}
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
ArrayHandleVirtualCoordinates::WritePortalType WritePortal() const
{
return this->ToArray().WritePortal();
}
template <typename Device>
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::PortalConst
PrepareForInput(Device device, vtkm::cont::Token& token) const
{
return this->ToArray().PrepareForInput(device, token);
}
template <typename Device>
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::Portal
PrepareForInPlace(Device device, vtkm::cont::Token& token) const
{
return this->ToArray().PrepareForInPlace(device, token);
}
template <typename Device>
VTKM_CONT VTKM_DEPRECATED(1.6, "CoordinateSystem::GetData() now returns a VariantArrayHandle.")
typename ArrayHandleVirtualCoordinates::ExecutionTypes<Device>::Portal
PrepareForOutput(vtkm::Id numberOfValues, Device device, vtkm::cont::Token& token) const
{
return this->ToArray().PrepareForOutput(numberOfValues, device, token);
}
VTKM_DEPRECATED_SUPPRESS_END
};
} // namespace detail
VTKM_DEPRECATED_SUPPRESS_BEGIN
VTKM_CONT VTKM_DEPRECATED(
1.6,
"CoordinateSystem::GetData() now returns a "
"VariantArrayHandle.") inline void printSummary_ArrayHandle(const detail::CoordDataDepWrapper&
array,
std::ostream& out,
bool full = false)
{
vtkm::cont::ArrayHandleVirtualCoordinates coordArray = array;
vtkm::cont::printSummary_ArrayHandle(coordArray, out, full);
}
VTKM_DEPRECATED_SUPPRESS_END
class VTKM_CONT_EXPORT CoordinateSystem : public vtkm::cont::Field
{
using Superclass = vtkm::cont::Field;
using CoordinatesTypeList = vtkm::List<vtkm::cont::ArrayHandleVirtualCoordinates::ValueType>;
using CoordinatesTypeList = vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>;
public:
VTKM_CONT
CoordinateSystem();
VTKM_CONT CoordinateSystem(std::string name,
const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& data);
template <typename TypeList>
VTKM_CONT CoordinateSystem(std::string name,
const vtkm::cont::VariantArrayHandleBase<TypeList>& data);
VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::VariantArrayHandleCommon& data);
template <typename T, typename Storage>
VTKM_CONT CoordinateSystem(std::string name, const ArrayHandle<T, Storage>& data)
: Superclass(name, Association::POINTS, vtkm::cont::ArrayHandleVirtualCoordinates(data))
: Superclass(name, Association::POINTS, data)
{
}
@ -54,17 +146,54 @@ public:
VTKM_CONT
vtkm::Id GetNumberOfPoints() const { return this->GetNumberOfValues(); }
VTKM_CONT
vtkm::cont::ArrayHandleVirtualCoordinates GetData() const;
VTKM_CONT detail::CoordDataDepWrapper GetData() const;
VTKM_CONT void SetData(const vtkm::cont::ArrayHandleVirtual<vtkm::Vec3f>& newdata);
private:
#ifdef VTKM_USE_DOUBLE_PRECISION
using FloatNonDefault = vtkm::Float32;
#else
using FloatNonDefault = vtkm::Float64;
#endif
using Vec3f_nd = vtkm::Vec<FloatNonDefault, 3>;
template <typename T, typename Storage>
VTKM_CONT void SetData(const vtkm::cont::ArrayHandle<T, Storage>& newdata);
struct StorageToArrayDefault
{
template <typename S>
using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<vtkm::Vec3f, S>;
VTKM_CONT
template <typename TypeList>
void SetData(const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata);
template <typename S>
using Transform = vtkm::cont::ArrayHandle<vtkm::Vec3f, S>;
};
struct StorageToArrayNonDefault
{
template <typename S>
using IsInvalid = vtkm::cont::internal::IsInvalidArrayHandle<Vec3f_nd, S>;
template <typename S>
using Transform =
vtkm::cont::ArrayHandleCast<vtkm::Vec3f, vtkm::cont::ArrayHandle<Vec3f_nd, S>>;
};
using ArraysFloatDefault = vtkm::ListTransform<
vtkm::ListRemoveIf<VTKM_DEFAULT_STORAGE_LIST, StorageToArrayDefault::IsInvalid>,
StorageToArrayDefault::Transform>;
using ArraysFloatNonDefault = vtkm::ListTransform<
vtkm::ListRemoveIf<VTKM_DEFAULT_STORAGE_LIST, StorageToArrayNonDefault::IsInvalid>,
StorageToArrayNonDefault::Transform>;
public:
using MultiplexerArrayType = //
vtkm::cont::ArrayHandleMultiplexerFromList<
vtkm::ListAppend<ArraysFloatDefault, ArraysFloatNonDefault>>;
/// \brief Returns the data for the coordinate system as an `ArrayHandleMultiplexer`.
///
/// This array will handle all potential types supported by CoordinateSystem, so all types can be
/// handled with one compile pass. However, using this precludes specialization for special
/// arrays such as `ArrayHandleUniformPointCoordinates` that could have optimized code paths
///
VTKM_CONT MultiplexerArrayType GetDataAsMultiplexer() const;
VTKM_CONT
void GetRange(vtkm::Range* range) const
@ -138,6 +267,12 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
};
template <>
struct DynamicTransformTraits<vtkm::cont::detail::CoordDataDepWrapper>
{
using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall;
};
} // namespace internal
} // namespace cont
} // namespace vtkm
@ -148,22 +283,32 @@ struct DynamicTransformTraits<vtkm::cont::CoordinateSystem>
namespace mangled_diy_namespace
{
template <>
struct Serialization<vtkm::cont::detail::CoordDataDepWrapper>
: public Serialization<
vtkm::cont::VariantArrayHandleBase<vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>>>
{
};
template <>
struct Serialization<vtkm::cont::CoordinateSystem>
{
using CoordinatesTypeList = vtkm::List<vtkm::Vec3f_32, vtkm::Vec3f_64>;
static VTKM_CONT void save(BinaryBuffer& bb, const vtkm::cont::CoordinateSystem& cs)
{
vtkmdiy::save(bb, cs.GetName());
vtkmdiy::save(bb, cs.GetData());
vtkmdiy::save(
bb, static_cast<vtkm::cont::VariantArrayHandleBase<CoordinatesTypeList>>(cs.GetData()));
}
static VTKM_CONT void load(BinaryBuffer& bb, vtkm::cont::CoordinateSystem& cs)
{
std::string name;
vtkmdiy::load(bb, name);
vtkm::cont::ArrayHandleVirtualCoordinates array;
vtkmdiy::load(bb, array);
cs = vtkm::cont::CoordinateSystem(name, array);
vtkm::cont::VariantArrayHandleBase<CoordinatesTypeList> data;
vtkmdiy::load(bb, data);
cs = vtkm::cont::CoordinateSystem(name, data);
}
};

@ -1,73 +0,0 @@
//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_cont_CoordinateSystem_hxx
#define vtk_m_cont_CoordinateSystem_hxx
#include <vtkm/cont/CoordinateSystem.h>
namespace vtkm
{
namespace cont
{
namespace detail
{
struct MakeArrayHandleVirtualCoordinatesFunctor
{
template <typename StorageTag>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, StorageTag>& array,
ArrayHandleVirtualCoordinates& output) const
{
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
}
template <typename StorageTag>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, StorageTag>& array,
ArrayHandleVirtualCoordinates& output) const
{
output = vtkm::cont::ArrayHandleVirtualCoordinates(array);
}
};
template <typename TypeList>
VTKM_CONT vtkm::cont::ArrayHandleVirtualCoordinates MakeArrayHandleVirtualCoordinates(
const vtkm::cont::VariantArrayHandleBase<TypeList>& array)
{
vtkm::cont::ArrayHandleVirtualCoordinates output;
vtkm::cont::CastAndCall(array.ResetTypes(vtkm::TypeListFieldVec3{}),
MakeArrayHandleVirtualCoordinatesFunctor{},
output);
return output;
}
} // namespace detail
template <typename TypeList>
VTKM_CONT CoordinateSystem::CoordinateSystem(
std::string name,
const vtkm::cont::VariantArrayHandleBase<TypeList>& data)
: Superclass(name, Association::POINTS, detail::MakeArrayHandleVirtualCoordinates(data))
{
}
template <typename T, typename Storage>
VTKM_CONT void CoordinateSystem::SetData(const vtkm::cont::ArrayHandle<T, Storage>& newdata)
{
this->SetData(vtkm::cont::ArrayHandleVirtualCoordinates(newdata));
}
template <typename TypeList>
VTKM_CONT void CoordinateSystem::SetData(
const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata)
{
this->SetData(detail::MakeArrayHandleVirtualCoordinates(newdata));
}
}
}
#endif

@ -69,19 +69,29 @@ public:
const std::string& coordsNm = "coords");
template <typename T>
VTKM_CONT static vtkm::cont::DataSet Create(
const vtkm::cont::ArrayHandle<T>& xVals,
const vtkm::cont::ArrayHandle<T>& yVals,
const vtkm::cont::ArrayHandle<T>& zVals,
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
const std::string& coordsNm = "coords")
VTKM_DEPRECATED(1.6,
"Combine point coordinate arrays using most appropriate array (e.g. "
"ArrayHandleCompositeVector, ArrayHandleSOA, ArrayHandleCartesianProduct")
VTKM_CONT static vtkm::cont::DataSet
Create(const vtkm::cont::ArrayHandle<T>& xVals,
const vtkm::cont::ArrayHandle<T>& yVals,
const vtkm::cont::ArrayHandle<T>& zVals,
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& numIndices,
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
const std::string& coordsNm = "coords")
{
VTKM_ASSERT(xVals.GetNumberOfValues() == yVals.GetNumberOfValues());
VTKM_ASSERT(xVals.GetNumberOfValues() == zVals.GetNumberOfValues());
auto offsets = vtkm::cont::ConvertNumIndicesToOffsets(numIndices);
return DataSetBuilderExplicit::BuildDataSet(
xVals, yVals, zVals, shapes, offsets, connectivity, coordsNm);
vtkm::cont::make_ArrayHandleCompositeVector(xVals, yVals, zVals),
shapes,
offsets,
connectivity,
coordsNm);
}
template <typename T>
@ -123,15 +133,6 @@ public:
}
private:
template <typename T>
static vtkm::cont::DataSet BuildDataSet(const vtkm::cont::ArrayHandle<T>& X,
const vtkm::cont::ArrayHandle<T>& Y,
const vtkm::cont::ArrayHandle<T>& Z,
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
const vtkm::cont::ArrayHandle<vtkm::Id>& offsets,
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
const std::string& coordsNm);
template <typename T>
VTKM_CONT static vtkm::cont::DataSet BuildDataSet(
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& coords,
@ -161,9 +162,16 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
{
VTKM_ASSERT(xVals.size() == yVals.size() && yVals.size() == zVals.size() && xVals.size() > 0);
auto xArray = vtkm::cont::make_ArrayHandle(xVals, vtkm::CopyFlag::On);
auto yArray = vtkm::cont::make_ArrayHandle(yVals, vtkm::CopyFlag::On);
auto zArray = vtkm::cont::make_ArrayHandle(zVals, vtkm::CopyFlag::On);
vtkm::cont::ArrayHandle<vtkm::Vec3f> coordsArray;
coordsArray.Allocate(static_cast<vtkm::Id>(xVals.size()));
auto coordsPortal = coordsArray.WritePortal();
for (std::size_t index = 0; index < xVals.size(); ++index)
{
coordsPortal.Set(static_cast<vtkm::Id>(index),
vtkm::make_Vec(static_cast<vtkm::FloatDefault>(xVals[index]),
static_cast<vtkm::FloatDefault>(yVals[index]),
static_cast<vtkm::FloatDefault>(zVals[index])));
}
auto shapesArray = vtkm::cont::make_ArrayHandle(shapes, vtkm::CopyFlag::On);
auto connArray = vtkm::cont::make_ArrayHandle(connectivity, vtkm::CopyFlag::On);
@ -172,33 +180,7 @@ inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::Create(
vtkm::cont::make_ArrayHandle(numIndices, vtkm::CopyFlag::Off));
return DataSetBuilderExplicit::BuildDataSet(
xArray, yArray, zArray, shapesArray, offsetsArray, connArray, coordsNm);
}
template <typename T>
inline VTKM_CONT vtkm::cont::DataSet DataSetBuilderExplicit::BuildDataSet(
const vtkm::cont::ArrayHandle<T>& X,
const vtkm::cont::ArrayHandle<T>& Y,
const vtkm::cont::ArrayHandle<T>& Z,
const vtkm::cont::ArrayHandle<vtkm::UInt8>& shapes,
const vtkm::cont::ArrayHandle<vtkm::Id>& offsets,
const vtkm::cont::ArrayHandle<vtkm::Id>& connectivity,
const std::string& coordsNm)
{
VTKM_ASSERT(X.GetNumberOfValues() == Y.GetNumberOfValues() &&
Y.GetNumberOfValues() == Z.GetNumberOfValues() && X.GetNumberOfValues() > 0 &&
shapes.GetNumberOfValues() + 1 == offsets.GetNumberOfValues());
vtkm::cont::DataSet dataSet;
dataSet.AddCoordinateSystem(
vtkm::cont::CoordinateSystem(coordsNm, make_ArrayHandleCompositeVector(X, Y, Z)));
vtkm::Id nPts = X.GetNumberOfValues();
vtkm::cont::CellSetExplicit<> cellSet;
cellSet.Fill(nPts, shapes, connectivity, offsets);
dataSet.SetCellSet(cellSet);
return dataSet;
coordsArray, shapesArray, offsetsArray, connArray, coordsNm);
}
template <typename T>

@ -126,10 +126,10 @@ public:
this->ModifiedFlag = true;
}
VTKM_CONT
void SetData(const vtkm::cont::VariantArrayHandle& newdata)
template <typename TypeList>
VTKM_CONT void SetData(const vtkm::cont::VariantArrayHandleBase<TypeList>& newdata)
{
this->Data = newdata;
this->Data = vtkm::cont::VariantArrayHandle(newdata);
this->ModifiedFlag = true;
}

@ -115,7 +115,7 @@ struct PointLocatorUniformGrid::PrepareExecutionObjectFunctor
rmin,
rmax,
self.Dims,
self.GetCoordinates().GetData().PrepareForInput(DeviceAdapter(), token),
self.GetCoordinates().GetDataAsMultiplexer().PrepareForInput(DeviceAdapter(), token),
self.PointIds.PrepareForInput(DeviceAdapter(), token),
self.CellLower.PrepareForInput(DeviceAdapter(), token),
self.CellUpper.PrepareForInput(DeviceAdapter(), token));

@ -84,7 +84,18 @@ public:
template <typename ArrayHandleType>
VTKM_CONT ArrayHandleType Cast() const
{
// MSVC will issue deprecation warnings if this templated method is instantiated with
// a deprecated class here even if the method is called from a section of code where
// deprecation warnings are suppressed. This is annoying behavior since this templated
// method has no control over what class it is used from. To get around it, we have to
// suppress all deprecation warnings here.
#ifdef VTKM_MSVC
VTKM_DEPRECATED_SUPPRESS_BEGIN
#endif
return internal::variant::Cast<ArrayHandleType>(this->ArrayContainer.get());
#ifdef VTKM_MSVC
VTKM_DEPRECATED_SUPPRESS_END
#endif
}
/// \brief Call a functor using the underlying array type.
@ -202,7 +213,7 @@ public:
/// \brief Holds an array handle without having to specify template parameters.
///
/// \c VariantArrayHandle holds an \c ArrayHandle or \c ArrayHandleVirtual
/// `VariantArrayHandle` holds an `ArrayHandle`
/// object using runtime polymorphism to manage different value types and
/// storage rather than compile-time templates. This adds a programming
/// convenience that helps avoid a proliferation of templates. It also provides
@ -210,24 +221,23 @@ public:
/// will not be known until runtime.
///
/// To interface between the runtime polymorphism and the templated algorithms
/// in VTK-m, \c VariantArrayHandle contains a method named \c CastAndCall that
/// will determine the correct type from some known list of types. It returns
/// an ArrayHandleVirtual which type erases the storage type by using polymorphism.
/// in VTK-m, `VariantArrayHandle` contains a method named `CastAndCall` that
/// will determine the correct type from some known list of types.
/// This mechanism is used internally by VTK-m's worklet invocation
/// mechanism to determine the type when running algorithms.
///
/// By default, \c VariantArrayHandle will assume that the value type in the
/// array matches one of the types specified by \c VTKM_DEFAULT_TYPE_LIST
/// This list can be changed by using the \c ResetTypes. It is
/// By default, `VariantArrayHandle` will assume that the value type in the
/// array matches one of the types specified by `VTKM_DEFAULT_TYPE_LIST`
/// This list can be changed by using the `ResetTypes`. It is
/// worthwhile to match these lists closely to the possible types that might be
/// used. If a type is missing you will get a runtime error. If there are more
/// types than necessary, then the template mechanism will create a lot of
/// object code that is never used, and keep in mind that the number of
/// combinations grows exponentially when using multiple \c VariantArrayHandle
/// combinations grows exponentially when using multiple `VariantArrayHandle`
/// objects.
///
/// The actual implementation of \c VariantArrayHandle is in a templated class
/// named \c VariantArrayHandleBase, which is templated on the list of
/// The actual implementation of `VariantArrayHandle` is in a templated class
/// named `VariantArrayHandleBase`, which is templated on the list of
/// component types.
///
template <typename TypeList>
@ -301,16 +311,12 @@ public:
/// `CastAndCall` attempts to cast the held array to a specific value type,
/// then call the given functor with the cast array. The types
/// tried in the cast are those in the lists defined by the TypeList.
/// By default \c VariantArrayHandle set this to \c VTKM_DEFAULT_TYPE_LIST.
/// By default `VariantArrayHandle` set this to `VTKM_DEFAULT_TYPE_LIST`.
///
/// In addition to the value type, an \c ArrayHandle also requires a storage tag.
/// By default, \c CastAndCall attempts to cast the array using the storage tags
/// listed in \c VTKM_DEFAULT_STORAGE_LIST. You can optionally give a custom
/// list of storage tags as the second argument. If the storage of the underlying
/// array does not match any of the storage tags given, then the array will
/// be cast to an \c ArrayHandleVirtual, which can hold any array given the
/// appropriate value type. To always use \c ArrayHandleVirtual, pass
/// \c vtkm::ListEmpty as thefirst argument.
/// In addition to the value type, an `ArrayHandle` also requires a storage tag.
/// By default, `CastAndCall` attempts to cast the array using the storage tags
/// listed in `VTKM_DEFAULT_STORAGE_LIST`. You can optionally give a custom
/// list of storage tags as the second argument.
///
/// As previous stated, if a storage tag list is provided, it is given in the
/// first argument. The functor to call with the cast array is given as the next
@ -318,7 +324,7 @@ public:
/// The remaning arguments, if any, are passed to the functor.
///
/// The functor will be called with the cast array as its first argument. Any
/// remaining arguments are passed from the arguments to \c CastAndCall.
/// remaining arguments are passed from the arguments to `CastAndCall`.
///
template <typename FunctorOrStorageList, typename... Args>
VTKM_CONT void CastAndCall(FunctorOrStorageList&& functorOrStorageList, Args&&... args) const
@ -423,35 +429,6 @@ struct VariantArrayHandleTry
}
};
struct VariantArrayHandleTryFallback
{
template <typename T, typename Functor, typename... Args>
void operator()(T,
Functor&& f,
bool& called,
const vtkm::cont::internal::VariantArrayHandleContainerBase& container,
Args&&... args) const
{
if (!called && vtkm::cont::internal::variant::IsValueType<T>(&container))
{
called = true;
const auto* derived =
static_cast<const vtkm::cont::internal::VariantArrayHandleContainer<T>*>(&container);
VTKM_LOG_CAST_SUCC(container, derived);
// If you get a compile error here, it means that you have called CastAndCall for a
// vtkm::cont::VariantArrayHandle and the arguments of the functor do not match those
// being passed. This is often because it is calling the functor with an ArrayHandle
// type that was not expected. Either add overloads to the functor to accept all
// possible array types or constrain the types tried for the CastAndCall. Note that
// the functor will be called with an array of type vtkm::cont::ArrayHandle<T, S>.
// Directly using a subclass of ArrayHandle (e.g. vtkm::cont::ArrayHandleConstant<T>)
// might not work.
f(derived->Array, std::forward<Args>(args)...);
}
}
};
template <typename T>
struct IsUndefinedStorage
{
@ -484,16 +461,6 @@ VTKM_CONT void VariantArrayHandleCommon::CastAndCall(Functor&& f, Args&&... args
ref,
std::forward<Args>(args)...);
if (!called)
{
// try to fall back to using ArrayHandleVirtual
vtkm::ListForEach(detail::VariantArrayHandleTryFallback{},
TypeList{},
std::forward<Functor>(f),
called,
ref,
std::forward<Args>(args)...);
}
if (!called)
{
// throw an exception
VTKM_LOG_CAST_FAIL(*this, TypeList);
@ -660,14 +627,14 @@ struct VariantArrayHandleSerializeFunctor
struct VariantArrayHandleDeserializeFunctor
{
template <typename T, typename TypeList>
void operator()(T,
template <typename T, typename S, typename TypeList>
void operator()(vtkm::List<T, S>,
vtkm::cont::VariantArrayHandleBase<TypeList>& dh,
const std::string& typeString,
bool& success,
BinaryBuffer& bb) const
{
using ArrayHandleType = vtkm::cont::ArrayHandleVirtual<T>;
using ArrayHandleType = vtkm::cont::ArrayHandle<T, S>;
if (!success && (typeString == vtkm::cont::SerializableTypeString<ArrayHandleType>::Get()))
{
@ -690,7 +657,7 @@ private:
public:
static VTKM_CONT void save(BinaryBuffer& bb, const Type& obj)
{
obj.CastAndCall(vtkm::ListEmpty(), internal::VariantArrayHandleSerializeFunctor{}, bb);
obj.CastAndCall(internal::VariantArrayHandleSerializeFunctor{}, bb);
}
static VTKM_CONT void load(BinaryBuffer& bb, Type& obj)
@ -699,8 +666,12 @@ public:
vtkmdiy::load(bb, typeString);
bool success = false;
vtkm::ListForEach(
internal::VariantArrayHandleDeserializeFunctor{}, TypeList{}, obj, typeString, success, bb);
vtkm::ListForEach(internal::VariantArrayHandleDeserializeFunctor{},
vtkm::cont::detail::ListDynamicTypes<TypeList, VTKM_DEFAULT_STORAGE_LIST>{},
obj,
typeString,
success,
bb);
if (!success)
{

@ -43,7 +43,7 @@ VTKM_CONT_EXPORT void ThrowCastAndCallException(
const std::type_info& type)
{
std::ostringstream out;
out << "Could not find appropriate cast for array in CastAndCall1.\n"
out << "Could not find appropriate cast for array in CastAndCall.\n"
"Array: ";
ref.PrintSummary(out);
out << "TypeList: " << type.name() << "\n";

@ -211,6 +211,14 @@ struct VTKM_ALWAYS_EXPORT Caster<T, vtkm::cont::StorageTagVirtual>
}
};
// MSVC will issue deprecation warnings here if this template is instantiated with
// a deprecated class even if the template is used from a section of code where
// deprecation warnings are suppressed. This is annoying behavior since this template
// has no control over what class it is used with. To get around it, we have to
// suppress all deprecation warnings here.
#ifdef VTKM_MSVC
VTKM_DEPRECATED_SUPPRESS_BEGIN
#endif
template <typename ArrayHandleType>
VTKM_CONT ArrayHandleType Cast(const VariantArrayHandleContainerBase* container)
{ //container could be nullptr
@ -220,6 +228,9 @@ VTKM_CONT ArrayHandleType Cast(const VariantArrayHandleContainerBase* container)
auto ret = Caster<Type, Storage>{}(container);
return ArrayHandleType(std::move(ret));
}
#ifdef VTKM_MSVC
VTKM_DEPRECATED_SUPPRESS_END
#endif
struct ForceCastToVirtual
{

@ -90,6 +90,21 @@ static void ComputeChunkSize(const vtkm::Id numVals,
valuesPerChunk = CeilDivide(pagesPerChunk * VTKM_PAGE_SIZE, bytesPerValue);
}
template <typename T>
struct CleanArrayRefImpl
{
using type = T;
};
template <typename PortalType>
struct CleanArrayRefImpl<vtkm::internal::ArrayPortalValueReference<PortalType>>
{
using type = typename PortalType::ValueType;
};
template <typename T>
using CleanArrayRef = typename CleanArrayRefImpl<T>::type;
template <typename T, typename U>
static void DoCopy(T src, U dst, vtkm::Id numVals, std::true_type)
{
@ -103,19 +118,24 @@ static void DoCopy(T src, U dst, vtkm::Id numVals, std::true_type)
template <typename InIterT, typename OutIterT>
static void DoCopy(InIterT inIter, OutIterT outIter, vtkm::Id numVals, std::false_type)
{
using ValueType = typename std::iterator_traits<OutIterT>::value_type;
using InValueType = CleanArrayRef<typename std::iterator_traits<InIterT>::value_type>;
using OutValueType = CleanArrayRef<typename std::iterator_traits<OutIterT>::value_type>;
for (vtkm::Id i = 0; i < numVals; ++i)
{
*(outIter++) = static_cast<ValueType>(*(inIter++));
// The conversion to InputType and then OutputType looks weird, but it is necessary.
// *inItr actually returns an ArrayPortalValueReference, which can automatically convert
// itself to InputType but not necessarily OutputType. Thus, we first convert to
// InputType, and then allow the conversion to OutputType.
*(outIter++) = static_cast<OutValueType>(static_cast<InValueType>(*(inIter++)));
}
}
template <typename InIterT, typename OutIterT>
static void DoCopy(InIterT inIter, OutIterT outIter, vtkm::Id numVals)
{
using InValueType = typename std::iterator_traits<InIterT>::value_type;
using OutValueType = typename std::iterator_traits<OutIterT>::value_type;
using InValueType = CleanArrayRef<typename std::iterator_traits<InIterT>::value_type>;
using OutValueType = CleanArrayRef<typename std::iterator_traits<OutIterT>::value_type>;
DoCopy(inIter, outIter, numVals, std::is_same<InValueType, OutValueType>());
}

@ -46,22 +46,32 @@ private:
// template calls std::copy if and only if the types match, otherwise falls
// back to a iterative casting approach. Since std::copy can only really
// optimize same-type copies, this shouldn't affect performance.
template <typename InIter, typename OutIter>
static void DoCopy(InIter src, InIter srcEnd, OutIter dst, std::false_type)
template <typename InPortal, typename OutPortal>
static void DoCopy(InPortal src,
OutPortal dst,
std::false_type,
vtkm::Id startIndex,
vtkm::Id numToCopy,
vtkm::Id outIndex)
{
using OutputType = typename std::iterator_traits<OutIter>::value_type;
while (src != srcEnd)
using OutputType = typename OutPortal::ValueType;
for (vtkm::Id index = 0; index < numToCopy; ++index)
{
*dst = static_cast<OutputType>(*src);
++src;
++dst;
dst.Set(index + startIndex, static_cast<OutputType>(src.Get(index + outIndex)));
}
}
template <typename InIter, typename OutIter>
static void DoCopy(InIter src, InIter srcEnd, OutIter dst, std::true_type)
template <typename InPortal, typename OutPortal>
static void DoCopy(InPortal src,
OutPortal dst,
std::true_type,
vtkm::Id startIndex,
vtkm::Id numToCopy,
vtkm::Id outIndex)
{
std::copy(src, srcEnd, dst);
std::copy(vtkm::cont::ArrayPortalToIteratorBegin(src) + startIndex,
vtkm::cont::ArrayPortalToIteratorBegin(src) + startIndex + numToCopy,
vtkm::cont::ArrayPortalToIteratorBegin(dst) + outIndex);
}
public:
@ -85,10 +95,7 @@ public:
using InputType = decltype(inputPortal.Get(0));
using OutputType = decltype(outputPortal.Get(0));
DoCopy(vtkm::cont::ArrayPortalToIteratorBegin(inputPortal),
vtkm::cont::ArrayPortalToIteratorEnd(inputPortal),
vtkm::cont::ArrayPortalToIteratorBegin(outputPortal),
std::is_same<InputType, OutputType>());
DoCopy(inputPortal, outputPortal, std::is_same<InputType, OutputType>{}, 0, inSize, 0);
}
template <typename T, typename U, class CIn, class CStencil, class COut>
@ -188,16 +195,16 @@ public:
vtkm::cont::Token token;
auto inputPortal = input.PrepareForInput(DeviceAdapterTagSerial(), token);
auto outputPortal = output.PrepareForInPlace(DeviceAdapterTagSerial(), token);
auto inIter = vtkm::cont::ArrayPortalToIteratorBegin(inputPortal);
auto outIter = vtkm::cont::ArrayPortalToIteratorBegin(outputPortal);
using InputType = decltype(inputPortal.Get(0));
using OutputType = decltype(outputPortal.Get(0));
DoCopy(inIter + inputStartIndex,
inIter + inputStartIndex + numberOfElementsToCopy,
outIter + outputIndex,
std::is_same<InputType, OutputType>());
DoCopy(inputPortal,
outputPortal,
std::is_same<InputType, OutputType>(),
inputStartIndex,
numberOfElementsToCopy,
outputIndex);
return true;
}

@ -107,10 +107,15 @@ struct CopyBody
template <typename InIter, typename OutIter>
void DoCopy(InIter src, InIter srcEnd, OutIter dst, std::false_type) const
{
using OutputType = typename std::iterator_traits<OutIter>::value_type;
using InputType = typename InputPortalType::ValueType;
using OutputType = typename OutputPortalType::ValueType;
while (src != srcEnd)
{
*dst = static_cast<OutputType>(*src);
// The conversion to InputType and then OutputType looks weird, but it is necessary.
// *src actually returns an ArrayPortalValueReference, which can automatically convert
// itself to InputType but not necessarily OutputType. Thus, we first convert to
// InputType, and then allow the conversion to OutputType.
*dst = static_cast<OutputType>(static_cast<InputType>(*src));
++src;
++dst;
}

@ -364,8 +364,10 @@ inline vtkm::cont::DataSet MakeTestDataSet::Make3DUniformDataSet3(const vtkm::Id
dataSet.AddPointField("pointvar", pointvar);
vtkm::Id numCells = (dims[0] - 1) * (dims[1] - 1) * (dims[2] - 1);
dataSet.AddCellField(
"cellvar", vtkm::cont::make_ArrayHandleCounting(vtkm::Float64(0), vtkm::Float64(1), numCells));
vtkm::cont::ArrayHandle<vtkm::Float64> cellvar;
vtkm::cont::ArrayCopy(
vtkm::cont::make_ArrayHandleCounting(vtkm::Float64(0), vtkm::Float64(1), numCells), cellvar);
dataSet.AddCellField("cellvar", cellvar);
return dataSet;
}

@ -10,6 +10,9 @@
#ifndef vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
#define vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h
// This is testing deprecated functionality. It is left to make sure that old code
// still works, but will be removed if ArrayHandleVirtualCoordinates is removed.
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
@ -17,6 +20,8 @@
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
VTKM_DEPRECATED_SUPPRESS_BEGIN
namespace vtkm
{
namespace cont
@ -142,5 +147,6 @@ public:
}
} // vtkm::cont::testing
VTKM_DEPRECATED_SUPPRESS_END
#endif // vtk_m_cont_testing_TestingArrayHandleVirtualCoordinates_h

@ -76,10 +76,6 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
vtkm::Vec<vtkm::FloatDefault, DIMENSIONS>(0.0f),
vtkm::Vec<vtkm::FloatDefault, DIMENSIONS>(1.0f));
// copy points
vtkm::cont::ArrayHandle<PointType> points;
vtkm::cont::ArrayCopy(uniformDs.GetCoordinateSystem().GetData(), points);
auto uniformCs =
uniformDs.GetCellSet().template Cast<vtkm::cont::CellSetStructured<DIMENSIONS>>();
@ -99,15 +95,21 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims)
// Warp the coordinates
std::uniform_real_distribution<vtkm::FloatDefault> warpFactor(-0.10f, 0.10f);
auto pointsPortal = points.WritePortal();
for (vtkm::Id i = 0; i < pointsPortal.GetNumberOfValues(); ++i)
auto inPointsPortal = uniformDs.GetCoordinateSystem()
.GetData()
.template Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>()
.ReadPortal();
vtkm::cont::ArrayHandle<PointType> points;
points.Allocate(inPointsPortal.GetNumberOfValues());
auto outPointsPortal = points.WritePortal();
for (vtkm::Id i = 0; i < outPointsPortal.GetNumberOfValues(); ++i)
{
PointType warpVec(0);
for (vtkm::IdComponent c = 0; c < DIMENSIONS; ++c)
{
warpVec[c] = warpFactor(RandomGenerator);
}
pointsPortal.Set(i, pointsPortal.Get(i) + warpVec);
outPointsPortal.Set(i, inPointsPortal.Get(i) + warpVec);
}
// build dataset
@ -152,7 +154,8 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates> dispatcher(
ParametricToWorldCoordinates::MakeScatter(cellIds));
dispatcher.Invoke(ds.GetCellSet(), ds.GetCoordinateSystem().GetData(), pcoords, wcoords);
dispatcher.Invoke(
ds.GetCellSet(), ds.GetCoordinateSystem().GetDataAsMultiplexer(), pcoords, wcoords);
}
class FindCellWorklet : public vtkm::worklet::WorkletMapField

@ -69,7 +69,7 @@ void EvaluateOnCoordinates(vtkm::cont::CoordinateSystem points,
EvaluateImplicitFunction eval(function.PrepareForExecution(device, token));
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(points, values, gradients);
dispatcher.Invoke(points.GetDataAsMultiplexer(), values, gradients);
}
template <typename ItemType, std::size_t N>

@ -61,7 +61,7 @@ vtkm::cont::DataSet MakeTestDataSetRectilinear()
vtkm::cont::DataSet MakeTestDataSetCurvilinear()
{
auto recti = MakeTestDataSetRectilinear();
auto coords = recti.GetCoordinateSystem().GetData();
auto coords = recti.GetCoordinateSystem().GetDataAsMultiplexer();
vtkm::cont::ArrayHandle<PointType> sheared;
sheared.Allocate(coords.GetNumberOfValues());
@ -140,7 +140,8 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates> dispatcher(
ParametricToWorldCoordinates::MakeScatter(cellIds));
dispatcher.Invoke(ds.GetCellSet(), ds.GetCoordinateSystem().GetData(), pcoords, wcoords);
dispatcher.Invoke(
ds.GetCellSet(), ds.GetCoordinateSystem().GetDataAsMultiplexer(), pcoords, wcoords);
}
//-----------------------------------------------------------------------------

@ -105,6 +105,9 @@ vtkm::cont::DataSet CreateDataSetArr(bool useSeparatedCoords,
{
std::vector<T> xvals(numPoints), yvals(numPoints), zvals(numPoints);
std::vector<T> varP(numPoints), varC(numCells);
std::vector<vtkm::UInt8> shapevals(numCells);
std::vector<vtkm::IdComponent> indicesvals(numCells);
std::vector<vtkm::Id> connvals(numConn);
for (std::size_t i = 0; i < numPoints; i++, f++)
{
xvals[i] = coords[i * 3 + 0];
@ -116,15 +119,18 @@ vtkm::cont::DataSet CreateDataSetArr(bool useSeparatedCoords,
for (std::size_t i = 0; i < numCells; i++, f++)
{
varC[i] = static_cast<T>(f * 1.1f);
shapevals[i] = shape[i];
indicesvals[i] = indices[i];
}
vtkm::cont::ArrayHandle<T> X, Y, Z, P, C;
DFA::Copy(vtkm::cont::make_ArrayHandle(xvals), X);
DFA::Copy(vtkm::cont::make_ArrayHandle(yvals), Y);
DFA::Copy(vtkm::cont::make_ArrayHandle(zvals), Z);
for (std::size_t i = 0; i < numConn; i++)
{
connvals[i] = conn[i];
}
dataSet = dsb.Create(xvals, yvals, zvals, shapevals, indicesvals, connvals);
vtkm::cont::ArrayHandle<T> P, C;
DFA::Copy(vtkm::cont::make_ArrayHandle(varP), P);
DFA::Copy(vtkm::cont::make_ArrayHandle(varC), C);
dataSet = dsb.Create(
X, Y, Z, createAH(numCells, shape), createAH(numCells, indices), createAH(numConn, conn));
dataSet.AddPointField("pointvar", P);
dataSet.AddCellField("cellvar", C);
return dataSet;
@ -229,7 +235,6 @@ vtkm::cont::DataSet CreateDataSetVec(bool useSeparatedCoords,
void TestDataSetBuilderExplicit()
{
vtkm::cont::DataSetBuilderExplicit dsb;
vtkm::cont::DataSet ds;
vtkm::Bounds bounds;

@ -141,7 +141,9 @@ void TestContDataTypesHaveMoveSemantics()
is_noexcept_movable<vtkm::cont::DataSet>();
is_noexcept_movable<vtkm::cont::Field>();
is_noexcept_movable<vtkm::cont::CoordinateSystem>();
VTKM_DEPRECATED_SUPPRESS_BEGIN
is_noexcept_movable<vtkm::cont::ArrayHandleVirtualCoordinates>();
VTKM_DEPRECATED_SUPPRESS_END
//verify the CellSetStructured, and CellSetExplicit
//have efficient storage in containers such as std::vector

@ -132,30 +132,6 @@ struct TestArrayHandleCast
}
};
struct TestArrayHandleCompositeVector
{
template <typename T>
void operator()(T) const
{
auto array = vtkm::cont::make_ArrayHandleCompositeVector(RandomArrayHandle<T>::Make(ArraySize),
RandomArrayHandle<T>::Make(ArraySize));
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
};
struct TestArrayHandleConcatenate
{
template <typename T>
void operator()(T) const
{
auto array = vtkm::cont::make_ArrayHandleConcatenate(RandomArrayHandle<T>::Make(ArraySize),
RandomArrayHandle<T>::Make(ArraySize));
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
};
struct TestArrayHandleConstant
{
template <typename T>
@ -181,19 +157,6 @@ struct TestArrayHandleCounting
}
};
struct TestArrayHandleExtractComponent
{
template <typename T>
void operator()(T) const
{
auto numComps = vtkm::VecTraits<T>::NUM_COMPONENTS;
auto array = vtkm::cont::make_ArrayHandleExtractComponent(
RandomArrayHandle<T>::Make(ArraySize), RandomValue<vtkm::IdComponent>::Make(0, numComps - 1));
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
};
struct TestArrayHandleGroupVec
{
template <typename T>
@ -253,37 +216,6 @@ struct TestArrayHandleGroupVecVariable
}
};
struct TestArrayHandleImplicit
{
template <typename T>
struct ImplicitFunctor
{
ImplicitFunctor() = default;
explicit ImplicitFunctor(const T& factor)
: Factor(factor)
{
}
VTKM_EXEC_CONT T operator()(vtkm::Id index) const
{
return static_cast<T>(this->Factor *
static_cast<typename vtkm::VecTraits<T>::ComponentType>(index));
}
T Factor;
};
template <typename T>
void operator()(T) const
{
ImplicitFunctor<T> functor(RandomValue<T>::Make(2, 9));
auto array = vtkm::cont::make_ArrayHandleImplicit(functor, ArraySize);
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
};
void TestArrayHandleIndex()
{
auto size = RandomValue<vtkm::Id>::Make(2, 10);
@ -321,86 +253,6 @@ struct TestArrayHandleReverse
}
};
struct TestArrayHandleSwizzle
{
template <typename T>
void operator()(T) const
{
static const vtkm::IdComponent2 map2s[6] = { { 0, 1 }, { 0, 2 }, { 1, 0 },
{ 1, 2 }, { 2, 0 }, { 2, 1 } };
static const vtkm::IdComponent3 map3s[6] = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 },
{ 1, 2, 0 }, { 2, 0, 1 }, { 2, 1, 0 } };
auto numOutComps = RandomValue<vtkm::IdComponent>::Make(2, 3);
switch (numOutComps)
{
case 2:
{
auto array = make_ArrayHandleSwizzle(RandomArrayHandle<vtkm::Vec<T, 3>>::Make(ArraySize),
map2s[RandomValue<int>::Make(0, 5)]);
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
break;
}
case 3:
default:
{
auto array = make_ArrayHandleSwizzle(RandomArrayHandle<vtkm::Vec<T, 3>>::Make(ArraySize),
map3s[RandomValue<int>::Make(0, 5)]);
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
break;
}
}
}
};
struct TestArrayHandleTransform
{
struct TransformFunctor
{
template <typename T>
VTKM_EXEC_CONT T operator()(const T& in) const
{
return static_cast<T>(in * T{ 2 });
}
};
struct InverseTransformFunctor
{
template <typename T>
VTKM_EXEC_CONT T operator()(const T& in) const
{
return static_cast<T>(in / T{ 2 });
}
};
template <typename T>
void TestType1() const
{
auto array = vtkm::cont::make_ArrayHandleTransform(RandomArrayHandle<T>::Make(ArraySize),
TransformFunctor{});
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
template <typename T>
void TestType2() const
{
auto array = vtkm::cont::make_ArrayHandleTransform(
RandomArrayHandle<T>::Make(ArraySize), TransformFunctor{}, InverseTransformFunctor{});
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
template <typename T>
void operator()(T) const
{
this->TestType1<T>();
this->TestType2<T>();
}
};
vtkm::cont::ArrayHandleUniformPointCoordinates MakeRandomArrayHandleUniformPointCoordinates()
{
@ -417,46 +269,6 @@ void TestArrayHandleUniformPointCoordinates()
RunTest(MakeTestVariantArrayHandle(array));
}
void TestArrayHandleVirtualCoordinates()
{
int type = RandomValue<int>::Make(0, 2);
vtkm::cont::ArrayHandleVirtualCoordinates array;
switch (type)
{
case 0:
array =
vtkm::cont::ArrayHandleVirtualCoordinates(MakeRandomArrayHandleUniformPointCoordinates());
break;
case 1:
array =
vtkm::cont::ArrayHandleVirtualCoordinates(vtkm::cont::make_ArrayHandleCartesianProduct(
RandomArrayHandle<vtkm::FloatDefault>::Make(ArraySize),
RandomArrayHandle<vtkm::FloatDefault>::Make(ArraySize),
RandomArrayHandle<vtkm::FloatDefault>::Make(ArraySize)));
break;
default:
array =
vtkm::cont::ArrayHandleVirtualCoordinates(RandomArrayHandle<vtkm::Vec3f>::Make(ArraySize));
break;
}
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
struct TestArrayHandleZip
{
template <typename T>
void operator()(T) const
{
auto array = vtkm::cont::make_ArrayHandleZip(RandomArrayHandle<T>::Make(ArraySize),
vtkm::cont::ArrayHandleIndex(ArraySize));
RunTest(array);
RunTest(MakeTestVariantArrayHandle(array));
}
};
//-----------------------------------------------------------------------------
void TestArrayHandleSerialization()
@ -464,62 +276,81 @@ void TestArrayHandleSerialization()
std::cout << "Testing ArrayHandleBasic\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleBasic(), TestTypesList());
std::cout << "Testing ArrayHandleSOA\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleSOA(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagSOA>::value)
{
std::cout << "Testing ArrayHandleSOA\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleSOA(), TestTypesList());
}
std::cout << "Testing ArrayHandleCartesianProduct\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleCartesianProduct(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
vtkm::cont::StorageTagCartesianProduct<vtkm::cont::StorageTagBasic,
vtkm::cont::StorageTagBasic,
vtkm::cont::StorageTagBasic>>::value)
{
std::cout << "Testing ArrayHandleCartesianProduct\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleCartesianProduct(), TestTypesList());
}
std::cout << "Testing TestArrayHandleCast\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleCast(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
vtkm::cont::StorageTagCast<vtkm::Int8, vtkm::cont::StorageTagBasic>>::value)
{
std::cout << "Testing TestArrayHandleCast\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleCast(), TestTypesList());
}
std::cout << "Testing ArrayHandleCompositeVector\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleCompositeVector(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagConstant>::value)
{
std::cout << "Testing ArrayHandleConstant\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleConstant(), TestTypesList());
}
std::cout << "Testing ArrayHandleConcatenate\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleConcatenate(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagCounting>::value)
{
std::cout << "Testing ArrayHandleCounting\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleCounting(), TestTypesList());
}
std::cout << "Testing ArrayHandleConstant\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleConstant(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
vtkm::cont::StorageTagGroupVec<vtkm::cont::StorageTagBasic, 3>>::value)
{
std::cout << "Testing ArrayHandleGroupVec\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVec(), TestTypesList());
}
std::cout << "Testing ArrayHandleCounting\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleCounting(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
vtkm::cont::StorageTagGroupVecVariable<vtkm::cont::StorageTagBasic,
vtkm::cont::StorageTagBasic>>::value)
{
std::cout << "Testing ArrayHandleGroupVecVariable\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVecVariable(), TestTypesList());
}
std::cout << "Testing ArrayHandleExtractComponent\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleExtractComponent(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagIndex>::value)
{
std::cout << "Testing ArrayHandleIndex\n";
TestArrayHandleIndex();
}
std::cout << "Testing ArrayHandleGroupVec\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVec(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
vtkm::cont::StorageTagPermutation<vtkm::cont::StorageTagBasic,
vtkm::cont::StorageTagBasic>>::value)
{
std::cout << "Testing ArrayHandlePermutation\n";
vtkm::testing::Testing::TryTypes(TestArrayHandlePermutation(), TestTypesList());
}
std::cout << "Testing ArrayHandleGroupVecVariable\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleGroupVecVariable(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST,
vtkm::cont::StorageTagReverse<vtkm::cont::StorageTagBasic>>::value)
{
std::cout << "Testing ArrayHandleReverse\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleReverse(), TestTypesList());
}
std::cout << "Testing ArrayHandleImplicit\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleImplicit(), TestTypesList());
std::cout << "Testing ArrayHandleIndex\n";
TestArrayHandleIndex();
std::cout << "Testing ArrayHandlePermutation\n";
vtkm::testing::Testing::TryTypes(TestArrayHandlePermutation(), TestTypesList());
std::cout << "Testing ArrayHandleReverse\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleReverse(), TestTypesList());
std::cout << "Testing ArrayHandleSwizzle\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleSwizzle(), TestTypesList());
std::cout << "Testing ArrayHandleTransform\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleTransform(), TestTypesList());
std::cout << "Testing ArrayHandleUniformPointCoordinates\n";
TestArrayHandleUniformPointCoordinates();
std::cout << "Testing ArrayHandleVirtualCoordinates\n";
TestArrayHandleVirtualCoordinates();
std::cout << "Testing ArrayHandleZip\n";
vtkm::testing::Testing::TryTypes(TestArrayHandleZip(), TestTypesList());
if (vtkm::ListHas<VTKM_DEFAULT_STORAGE_LIST, vtkm::cont::StorageTagUniformPoints>::value)
{
std::cout << "Testing ArrayHandleUniformPointCoordinates\n";
TestArrayHandleUniformPointCoordinates();
}
}
} // anonymous namespace
@ -540,37 +371,3 @@ int UnitTestSerializationArrayHandle(int argc, char* argv[])
return vtkm::cont::testing::Testing::Run(TestArrayHandleSerialization, argc, argv);
}
//-----------------------------------------------------------------------------
namespace vtkm
{
namespace cont
{
template <typename T>
struct SerializableTypeString<TestArrayHandleImplicit::ImplicitFunctor<T>>
{
static VTKM_CONT const std::string& Get()
{
static std::string name =
"TestArrayHandleImplicit::ImplicitFunctor<" + SerializableTypeString<T>::Get() + ">";
return name;
}
};
template <>
struct SerializableTypeString<TestArrayHandleTransform::TransformFunctor>
{
static VTKM_CONT const std::string Get() { return "TestArrayHandleTransform::TransformFunctor"; }
};
template <>
struct SerializableTypeString<TestArrayHandleTransform::InverseTransformFunctor>
{
static VTKM_CONT const std::string Get()
{
return "TestArrayHandleTransform::InverseTransformFunctor";
}
};
}
} // vtkm::cont

@ -187,6 +187,9 @@ void CheckArrayVariant(const vtkm::cont::VariantArrayHandleBase<TypeList>& array
VTKM_TEST_ASSERT(!calledUnusual, "The array somehow got cast to an unusual storage.");
}
#if 0
// Test disabled. CastAndCall no longer casts to ArrayHandleVirtual because
// that is getting deprecated.
std::cout << " CastAndCall with no storage" << std::endl;
calledBasic = false;
calledUnusual = false;
@ -197,6 +200,7 @@ void CheckArrayVariant(const vtkm::cont::VariantArrayHandleBase<TypeList>& array
"The functor was never called (and apparently a bad value exception not thrown).");
VTKM_TEST_ASSERT(!calledBasic, "The array somehow got cast to a basic storage.");
VTKM_TEST_ASSERT(!calledUnusual, "The array somehow got cast to an unusual storage.");
#endif
std::cout << " CastAndCall with extra storage" << std::endl;
calledBasic = false;
@ -469,6 +473,9 @@ void TryUnusualType()
std::cout << " Found type when type list was reset." << std::endl;
}
#if 0
// It is now requred to know the storage used (no longer wrapping in ArrayHandleVirtual),
// so disable this test.
void TryUnusualStorage()
{
vtkm::cont::VariantArrayHandle array = ArrayHandleWithUnusualStorage<vtkm::Id>();
@ -506,6 +513,7 @@ void TryUnusualTypeAndStorage()
VTKM_TEST_FAIL("CastAndCall with Variant failed to handle unusual storage.");
}
}
#endif
template <typename ArrayHandleType>
void TryCastToArrayHandle(const ArrayHandleType& array)
@ -586,11 +594,15 @@ void TestVariantArrayHandle()
std::cout << "Try unusual type." << std::endl;
TryUnusualType();
#if 0
// It is now requred to know the storage used (no longer wrapping in ArrayHandleVirtual),
// so disable this test.
std::cout << "Try unusual storage." << std::endl;
TryUnusualStorage();
std::cout << "Try unusual type in unusual storage." << std::endl;
TryUnusualTypeAndStorage();
#endif
std::cout << "Try CastToArrayHandle" << std::endl;
TryCastToArrayHandle();

@ -13,7 +13,7 @@
#include <vtkm/TopologyElementTag.h>
#include <vtkm/VecFromPortalPermute.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleVirtualCoordinates.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/exec/CellInside.h>
#include <vtkm/exec/CellLocator.h>
#include <vtkm/exec/ParametricCoordinates.h>
@ -74,12 +74,13 @@ public:
CellLocatorBoundingIntervalHierarchyExec() {}
VTKM_CONT
CellLocatorBoundingIntervalHierarchyExec(const NodeArrayHandle& nodes,
const CellIdArrayHandle& cellIds,
const CellSetType& cellSet,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
DeviceAdapter,
vtkm::cont::Token& token)
CellLocatorBoundingIntervalHierarchyExec(
const NodeArrayHandle& nodes,
const CellIdArrayHandle& cellIds,
const CellSetType& cellSet,
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coords,
DeviceAdapter,
vtkm::cont::Token& token)
: Nodes(nodes.PrepareForInput(DeviceAdapter(), token))
, CellIds(cellIds.PrepareForInput(DeviceAdapter(), token))
, CellSet(cellSet.PrepareForInput(DeviceAdapter(), VisitType(), IncidentType(), token))
@ -277,8 +278,9 @@ private:
using CellSetPortal = typename CellSetType::template ExecutionTypes<DeviceAdapter,
VisitType,
IncidentType>::ExecObjectType;
using CoordsPortal = typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
DeviceAdapter>::PortalConst;
using CoordsPortal =
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::template ExecutionTypes<
DeviceAdapter>::PortalConst;
NodePortal Nodes;
CellIdPortal CellIds;

@ -34,8 +34,6 @@ private:
using VisitType = vtkm::TopologyElementTagCell;
using IncidentType = vtkm::TopologyElementTagPoint;
using CellSetPortal = vtkm::exec::ConnectivityStructured<VisitType, IncidentType, dimensions>;
using CoordsPortal = typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
DeviceAdapter>::PortalConst;
public:
VTKM_CONT
@ -44,15 +42,12 @@ public:
const vtkm::Vec3f origin,
const vtkm::Vec3f invSpacing,
const vtkm::Vec3f maxPoint,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
DeviceAdapter,
vtkm::cont::Token& token)
DeviceAdapter)
: CellDims(cellDims)
, PointDims(pointDims)
, Origin(origin)
, InvSpacing(invSpacing)
, MaxPoint(maxPoint)
, Coords(coords.PrepareForInput(DeviceAdapter(), token))
{
}
@ -120,7 +115,6 @@ private:
vtkm::Vec3f Origin;
vtkm::Vec3f InvSpacing;
vtkm::Vec3f MaxPoint;
CoordsPortal Coords;
};
}
}

@ -10,6 +10,7 @@
#ifndef vtk_m_exec_PointLocatorUniformGrid_h
#define vtk_m_exec_PointLocatorUniformGrid_h
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/worklet/DispatcherMapField.h>
@ -29,7 +30,7 @@ class VTKM_ALWAYS_EXPORT PointLocatorUniformGrid final : public vtkm::exec::Poin
{
public:
using CoordPortalType =
typename vtkm::cont::ArrayHandleVirtualCoordinates::template ExecutionTypes<
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::template ExecutionTypes<
DeviceAdapter>::PortalConst;
using IdPortalType =
typename vtkm::cont::ArrayHandle<vtkm::Id>::template ExecutionTypes<DeviceAdapter>::PortalConst;

@ -35,7 +35,7 @@ public:
VTKM_CONT
CellMeasures();
/// Set/Get the name of the cell measure field. If empty, "measure" is used.
/// Set/Get the name of the cell measure field. If not set, "measure" is used.
void SetCellMeasureName(const std::string& name) { this->SetOutputFieldName(name); }
const std::string& GetCellMeasureName() const { return this->GetOutputFieldName(); }

@ -25,6 +25,7 @@ inline VTKM_CONT CellMeasures<IntegrationType>::CellMeasures()
: vtkm::filter::FilterCell<CellMeasures<IntegrationType>>()
{
this->SetUseCoordinateSystemAsField(true);
this->SetCellMeasureName("measure");
}
//-----------------------------------------------------------------------------

@ -108,6 +108,8 @@ VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithField);
}
} // namespace vtkm::filter
#ifndef vtk_m_filter_ClipWithField_hxx
#include <vtkm/filter/ClipWithField.hxx>
#endif
#endif // vtk_m_filter_ClipWithField_h

@ -11,6 +11,8 @@
#ifndef vtk_m_filter_ClipWithField_hxx
#define vtk_m_filter_ClipWithField_hxx
#include <vtkm/filter/ClipWithField.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/CoordinateSystem.h>
@ -21,6 +23,26 @@ namespace vtkm
{
namespace filter
{
namespace detail
{
struct ClipWithFieldProcessCoords
{
template <typename T, typename Storage>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
const std::string& coordsName,
const vtkm::worklet::Clip& worklet,
vtkm::cont::DataSet& output) const
{
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
output.AddCoordinateSystem(outCoords);
}
};
} // namespace detail
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
@ -37,9 +59,6 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
//get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& inputCoords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, this->ClipValue, this->Invert);
@ -48,9 +67,14 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
output.SetCellSet(outputCellSet);
// Compute the new boundary points and add them to the output:
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
output.AddCoordinateSystem(outputCoords);
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
++coordSystemId)
{
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
coords.GetData().CastAndCall(
detail::ClipWithFieldProcessCoords{}, coords.GetName(), this->Worklet, output);
}
return output;
}
}

@ -105,6 +105,8 @@ VTKM_FILTER_EXPORT_EXECUTE_METHOD(ClipWithImplicitFunction);
}
} // namespace vtkm::filter
#ifndef vtk_m_filter_ClipWithImplicitFunction_hxx
#include <vtkm/filter/ClipWithImplicitFunction.hxx>
#endif
#endif // vtk_m_filter_ClipWithImplicitFunction_h

@ -11,6 +11,8 @@
#ifndef vtk_m_filter_ClipWithImplicitFunction_hxx
#define vtk_m_filter_ClipWithImplicitFunction_hxx
#include <vtkm/filter/ClipWithImplicitFunction.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/DynamicCellSet.h>
@ -19,6 +21,26 @@ namespace vtkm
{
namespace filter
{
namespace detail
{
struct ClipWithImplicitFunctionProcessCoords
{
template <typename T, typename Storage>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>& inCoords,
const std::string& coordsName,
const vtkm::worklet::Clip& worklet,
vtkm::cont::DataSet& output) const
{
vtkm::cont::ArrayHandle<T> outArray = worklet.ProcessPointField(inCoords);
vtkm::cont::CoordinateSystem outCoords(coordsName, outArray);
output.AddCoordinateSystem(outCoords);
}
};
} // namespace detail
//-----------------------------------------------------------------------------
template <typename DerivedPolicy>
inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
@ -37,14 +59,18 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
inputCoords,
this->Invert);
// compute output coordinates
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
vtkm::cont::CoordinateSystem outputCoords(inputCoords.GetName(), outputCoordsArray);
//create the output data
vtkm::cont::DataSet output;
output.SetCellSet(outputCellSet);
output.AddCoordinateSystem(outputCoords);
// compute output coordinates
for (vtkm::IdComponent coordSystemId = 0; coordSystemId < input.GetNumberOfCoordinateSystems();
++coordSystemId)
{
vtkm::cont::CoordinateSystem coords = input.GetCoordinateSystem(coordSystemId);
coords.GetData().CastAndCall(
detail::ClipWithImplicitFunctionProcessCoords{}, coords.GetName(), this->Worklet, output);
}
return output;
}

@ -47,7 +47,7 @@ inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute(
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
this->FeatureAngle,
field,
input.GetCoordinateSystem().GetData(),
input.GetCoordinateSystem().GetDataAsMultiplexer(),
newCoords,
newCellset);

@ -85,7 +85,8 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute(
const auto cellset =
vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy, *this);
const auto& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetData();
const auto coords =
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetDataAsMultiplexer();
vtkm::cont::ArrayHandle<vtkm::Vec3f> faceNormals;
vtkm::worklet::FacetedSurfaceNormals faceted;

@ -18,6 +18,25 @@
namespace
{
struct CheckCellMeasuresFunctor
{
template <typename ArrayType>
void operator()(const ArrayType& resultArrayHandle,
const std::vector<vtkm::Float32>& expected) const
{
VTKM_TEST_ASSERT(resultArrayHandle.GetNumberOfValues() ==
static_cast<vtkm::Id>(expected.size()),
"Wrong number of entries in the output dataset");
auto portal = resultArrayHandle.ReadPortal();
for (std::size_t i = 0; i < expected.size(); ++i)
{
VTKM_TEST_ASSERT(test_equal(portal.Get(static_cast<vtkm::Id>(i)), expected[i]),
"Wrong result for CellMeasure filter");
}
}
};
template <typename IntegrationType>
void TestCellMeasuresFilter(vtkm::cont::DataSet& dataset,
const char* msg,
@ -29,28 +48,19 @@ void TestCellMeasuresFilter(vtkm::cont::DataSet& dataset,
vtkm::filter::CellMeasures<IntegrationType> vols;
vtkm::cont::DataSet outputData = vols.Execute(dataset);
VTKM_TEST_ASSERT(vols.GetCellMeasureName().empty(), "Default output field name should be empty.");
VTKM_TEST_ASSERT(vols.GetCellMeasureName() == "measure");
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
"Wrong number of coordinate systems in the output dataset");
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == static_cast<vtkm::Id>(expected.size()),
"Wrong number of cells in the output dataset");
// Check that the empty measure name above produced a field with the expected name.
vols.SetCellMeasureName("measure");
auto temp = outputData.GetField(vols.GetCellMeasureName()).GetData();
VTKM_TEST_ASSERT(temp.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
auto result = outputData.GetField(vols.GetCellMeasureName()).GetData();
VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
"Output field could not be found or was improper.");
vtkm::cont::ArrayHandle<vtkm::FloatDefault> resultArrayHandle;
temp.CopyTo(resultArrayHandle);
VTKM_TEST_ASSERT(resultArrayHandle.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
"Wrong number of entries in the output dataset");
for (unsigned int i = 0; i < static_cast<unsigned int>(expected.size()); ++i)
{
VTKM_TEST_ASSERT(test_equal(resultArrayHandle.ReadPortal().Get(vtkm::Id(i)), expected[i]),
"Wrong result for CellMeasure filter");
}
vtkm::cont::CastAndCall(
result.ResetTypes(vtkm::TypeListFieldScalar{}), CheckCellMeasuresFunctor{}, expected);
}
void TestCellMeasures()

@ -75,7 +75,7 @@ void TestPointMerging()
//Convert the baseData implicit points to explicit points, since the contour
//filter for uniform data always does point merging
vtkm::cont::ArrayHandle<vtkm::Vec3f> newcoords;
vtkm::cont::Algorithm::Copy(baseData.GetCoordinateSystem().GetData(), newcoords);
vtkm::cont::ArrayCopy(baseData.GetCoordinateSystem().GetData(), newcoords);
baseData.GetCoordinateSystem().SetData(newcoords);
vtkm::filter::Contour marchingCubes;

@ -102,8 +102,8 @@ void ValidateCoordTransform(const vtkm::cont::DataSet& ds,
const vtkm::cont::DataSet& dsTrn,
const std::vector<bool>& isAngle)
{
auto points = ds.GetCoordinateSystem().GetData();
auto pointsTrn = dsTrn.GetCoordinateSystem().GetData();
auto points = ds.GetCoordinateSystem().GetDataAsMultiplexer();
auto pointsTrn = dsTrn.GetCoordinateSystem().GetDataAsMultiplexer();
VTKM_TEST_ASSERT(points.GetNumberOfValues() == pointsTrn.GetNumberOfValues(),
"Incorrect number of points in point transform");

@ -172,7 +172,7 @@ static vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, vtkm::Id numJ, vtkm::Id n
vtkm::cont::DataSet dsUniform = MakeUniform(numI, numJ, numK, numLayers);
auto coordData = dsUniform.GetCoordinateSystem(0).GetData();
auto coordData = dsUniform.GetCoordinateSystem(0).GetDataAsMultiplexer();
vtkm::Id numPts = coordData.GetNumberOfValues();
vtkm::cont::ArrayHandle<CoordType> explCoords;

@ -122,7 +122,7 @@ bool TestMeshQualityFilter(const vtkm::cont::DataSet& input,
//Test the computed metric values (for all cells) and expected metric
//values for equality.
vtkm::cont::ArrayHandle<vtkm::FloatDefault> values;
vtkm::cont::ArrayHandle<vtkm::Float64> values;
output.GetField(outputname).GetData().CopyTo(values);
auto portal1 = values.ReadPortal();
if (portal1.GetNumberOfValues() != (vtkm::Id)expectedVals.size())

@ -101,7 +101,7 @@ void TestFile(const std::string& fname,
particleAdvection.SetActiveField("vec");
auto output = particleAdvection.Execute(ds);
auto coords = output.GetCoordinateSystem().GetData();
auto coords = output.GetCoordinateSystem().GetDataAsMultiplexer();
vtkm::cont::DynamicCellSet dcells = output.GetCellSet();
VTKM_TEST_ASSERT(dcells.GetNumberOfCells() == numPoints, "Wrong number of cells");
VTKM_TEST_ASSERT(dcells.IsType<vtkm::cont::CellSetSingleType<>>(), "Wrong cell type");

@ -76,12 +76,13 @@ void TestPointElevationNoPolicy()
vtkm::cont::ArrayHandle<vtkm::Float64> resultArrayHandle;
result.GetPointField("height").GetData().CopyTo(resultArrayHandle);
auto coordinates = inputData.GetCoordinateSystem().GetData();
auto coordinates = inputData.GetCoordinateSystem().GetDataAsMultiplexer();
auto coordsPortal = coordinates.ReadPortal();
auto resultPortal = resultArrayHandle.ReadPortal();
for (vtkm::Id i = 0; i < resultArrayHandle.GetNumberOfValues(); ++i)
{
VTKM_TEST_ASSERT(
test_equal(coordinates.ReadPortal().Get(i)[1] * 2.0, resultArrayHandle.ReadPortal().Get(i)),
"Wrong result for PointElevation worklet");
VTKM_TEST_ASSERT(test_equal(coordsPortal.Get(i)[1] * 2.0, resultPortal.Get(i)),
"Wrong result for PointElevation worklet");
}
}
@ -106,12 +107,13 @@ void TestPointElevationWithPolicy()
vtkm::cont::ArrayHandle<vtkm::Float64> resultArrayHandle;
result.GetPointField("elevation").GetData().CopyTo(resultArrayHandle);
auto coordinates = inputData.GetCoordinateSystem().GetData();
auto coordinates = inputData.GetCoordinateSystem().GetDataAsMultiplexer();
auto coordsPortal = coordinates.ReadPortal();
auto resultPortal = resultArrayHandle.ReadPortal();
for (vtkm::Id i = 0; i < resultArrayHandle.GetNumberOfValues(); ++i)
{
VTKM_TEST_ASSERT(
test_equal(coordinates.ReadPortal().Get(i)[1] * 2.0, resultArrayHandle.ReadPortal().Get(i)),
"Wrong result for PointElevation worklet");
VTKM_TEST_ASSERT(test_equal(coordsPortal.Get(i)[1] * 2.0, resultPortal.Get(i)),
"Wrong result for PointElevation worklet");
}
}

@ -74,10 +74,9 @@ void ValidatePointTransform(const vtkm::cont::CoordinateSystem& coords,
.GetData()
.CopyTo(resultArrayHandle);
vtkm::cont::ArrayHandleVirtualCoordinates outPointsArrayHandle =
result.GetCoordinateSystem().GetData();
auto outPointsArrayHandle = result.GetCoordinateSystem().GetDataAsMultiplexer();
auto points = coords.GetData();
auto points = coords.GetDataAsMultiplexer();
VTKM_TEST_ASSERT(points.GetNumberOfValues() == resultArrayHandle.GetNumberOfValues(),
"Incorrect number of points in point transform");

@ -132,7 +132,7 @@ void TestSplitSharpEdgesFilterSplitEveryEdge(vtkm::cont::DataSet& simpleCubeWith
splitSharpEdgesFilter.SetActiveField("Normals", vtkm::cont::Field::Association::CELL_SET);
vtkm::cont::DataSet result = splitSharpEdgesFilter.Execute(simpleCubeWithSN);
auto newCoords = result.GetCoordinateSystem().GetData();
auto newCoords = result.GetCoordinateSystem().GetDataAsMultiplexer();
auto newCoordsP = newCoords.ReadPortal();
vtkm::cont::ArrayHandle<vtkm::FloatDefault> newPointvarField;
result.GetField("pointvar").GetData().CopyTo(newPointvarField);
@ -165,7 +165,7 @@ void TestSplitSharpEdgesFilterNoSplit(vtkm::cont::DataSet& simpleCubeWithSN,
splitSharpEdgesFilter.SetActiveField("Normals", vtkm::cont::Field::Association::CELL_SET);
vtkm::cont::DataSet result = splitSharpEdgesFilter.Execute(simpleCubeWithSN);
auto newCoords = result.GetCoordinateSystem().GetData();
auto newCoords = result.GetCoordinateSystem().GetDataAsMultiplexer();
vtkm::cont::CellSetExplicit<>& newCellset =
result.GetCellSet().Cast<vtkm::cont::CellSetExplicit<>>();
auto newCoordsP = newCoords.ReadPortal();

@ -139,7 +139,7 @@ void TestStreamlineFile(const std::string& fname,
streamline.SetActiveField("vec");
auto output = streamline.Execute(ds);
auto coords = output.GetCoordinateSystem().GetData();
auto coords = output.GetCoordinateSystem().GetDataAsMultiplexer();
vtkm::cont::DynamicCellSet dcells = output.GetCellSet();
VTKM_TEST_ASSERT(dcells.GetNumberOfCells() == numPoints, "Wrong number of cells");
VTKM_TEST_ASSERT(dcells.IsType<vtkm::cont::CellSetExplicit<>>(), "Wrong cell type");

@ -60,7 +60,7 @@ void TestVertexClustering()
}
{
auto pointArray = output.GetCoordinateSystem(0).GetData();
auto pointArray = output.GetCoordinateSystem(0).GetDataAsMultiplexer();
std::cerr << "output_points = " << pointArray.GetNumberOfValues() << "\n";
std::cerr << "output_point[] = ";
vtkm::cont::printSummary_ArrayHandle(pointArray, std::cerr, true);
@ -70,7 +70,7 @@ void TestVertexClustering()
vtkm::cont::printSummary_ArrayHandle(cellvar, std::cerr, true);
using PointType = vtkm::Vec3f_64;
auto pointArray = output.GetCoordinateSystem(0).GetData();
auto pointArray = output.GetCoordinateSystem(0).GetDataAsMultiplexer();
VTKM_TEST_ASSERT(pointArray.GetNumberOfValues() == output_points,
"Number of output points mismatch");
auto pointArrayPortal = pointArray.ReadPortal();

@ -10,6 +10,7 @@
#ifndef vtk_m_internal_FunctionInterface_h
#define vtk_m_internal_FunctionInterface_h
#include <vtkm/Deprecated.h>
#include <vtkm/Types.h>
#include <vtkm/internal/FunctionInterfaceDetailPre.h>
@ -237,8 +238,19 @@ VTKM_EXEC_CONT auto ParameterGet(const FunctionInterface<FunctionSignature>& fIn
template <typename R, typename... Args>
FunctionInterface<R(Args...)> make_FunctionInterface(const Args&... args)
{
// MSVC will issue deprecation warnings if this templated method is instantiated with
// a deprecated class here even if the method is called from a section of code where
// deprecation warnings are suppressed. This is annoying behavior since this templated
// method has no control over what class it is used from. To get around it, we have to
// suppress all deprecation warnings here.
#ifdef VTKM_MSVC
VTKM_DEPRECATED_SUPPRESS_BEGIN
#endif
detail::ParameterContainer<R(Args...)> container = { args... };
return FunctionInterface<R(Args...)>{ container };
#ifdef VTKM_MSVC
VTKM_DEPRECATED_SUPPRESS_END
#endif
}
}
} // namespace vtkm::internal

@ -159,11 +159,13 @@ void WritePoints(std::ostream& out, const vtkm::cont::DataSet& dataSet)
int cindex = 0;
auto cdata = dataSet.GetCoordinateSystem(cindex).GetData();
vtkm::Id npoints = cdata.GetNumberOfValues();
out << "POINTS " << npoints << " " << vtkm::io::internal::DataTypeName<vtkm::FloatDefault>::Name()
<< " " << '\n';
std::string typeName;
vtkm::cont::CastAndCall(cdata, GetDataTypeName(typeName));
OutputPointsFunctor{ out }(cdata);
vtkm::Id npoints = cdata.GetNumberOfValues();
out << "POINTS " << npoints << " " << typeName << " " << '\n';
cdata.CastAndCall(OutputPointsFunctor{ out });
}
template <class CellSetType>
@ -381,7 +383,7 @@ void WriteDataSetAsStructured(std::ostream& out,
///\todo: support rectilinear
// Type of structured grid (uniform, rectilinear, curvilinear) is determined by coordinate system
vtkm::cont::ArrayHandleVirtualCoordinates coordSystem = dataSet.GetCoordinateSystem().GetData();
auto coordSystem = dataSet.GetCoordinateSystem().GetData();
if (coordSystem.IsType<vtkm::cont::ArrayHandleUniformPointCoordinates>())
{
// uniform is written as "structured points"

@ -44,6 +44,13 @@ struct CheckSameCoordinateSystem
CheckSameField{}(originalArray, fileCoords);
}
template <typename T>
void operator()(const vtkm::cont::ArrayHandleVirtual<T>& originalArray,
const vtkm::cont::CoordinateSystem& fileCoords) const
{
CheckSameField{}(originalArray, fileCoords);
}
void operator()(const vtkm::cont::ArrayHandleUniformPointCoordinates& originalArray,
const vtkm::cont::CoordinateSystem& fileCoords) const
{
@ -57,16 +64,19 @@ struct CheckSameCoordinateSystem
VTKM_TEST_ASSERT(test_equal(originalPortal.GetRange3(), filePortal.GetRange3()));
}
using ArrayHandleRectilinearCoords =
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>;
void operator()(const ArrayHandleRectilinearCoords& originalArray,
template <typename T>
using ArrayHandleRectilinearCoords = vtkm::cont::ArrayHandle<
T,
typename vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandle<T>>::StorageTag>;
template <typename T>
void operator()(const ArrayHandleRectilinearCoords<T>& originalArray,
const vtkm::cont::CoordinateSystem& fileCoords) const
{
VTKM_TEST_ASSERT(fileCoords.GetData().IsType<ArrayHandleRectilinearCoords>());
ArrayHandleRectilinearCoords fileArray =
fileCoords.GetData().Cast<ArrayHandleRectilinearCoords>();
VTKM_TEST_ASSERT(fileCoords.GetData().IsType<ArrayHandleRectilinearCoords<T>>());
ArrayHandleRectilinearCoords<T> fileArray =
fileCoords.GetData().Cast<ArrayHandleRectilinearCoords<T>>();
auto originalPortal = originalArray.ReadPortal();
auto filePortal = fileArray.ReadPortal();
VTKM_TEST_ASSERT(
@ -76,23 +86,6 @@ struct CheckSameCoordinateSystem
VTKM_TEST_ASSERT(
test_equal_portals(originalPortal.GetThirdPortal(), filePortal.GetThirdPortal()));
}
void operator()(const vtkm::cont::ArrayHandleVirtualCoordinates& originalArray,
const vtkm::cont::CoordinateSystem& fileCoords) const
{
if (originalArray.IsType<vtkm::cont::ArrayHandleUniformPointCoordinates>())
{
(*this)(originalArray.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>(), fileCoords);
}
else if (originalArray.IsType<ArrayHandleRectilinearCoords>())
{
(*this)(originalArray.Cast<ArrayHandleRectilinearCoords>(), fileCoords);
}
else
{
CheckSameField{}(originalArray, fileCoords);
}
}
};
void CheckWrittenReadData(const vtkm::cont::DataSet& originalData,
@ -111,8 +104,9 @@ void CheckWrittenReadData(const vtkm::cont::DataSet& originalData,
}
VTKM_TEST_ASSERT(fileData.GetNumberOfCoordinateSystems() > 0);
CheckSameCoordinateSystem{}(originalData.GetCoordinateSystem().GetData(),
fileData.GetCoordinateSystem());
vtkm::cont::CastAndCall(originalData.GetCoordinateSystem().GetData(),
CheckSameCoordinateSystem{},
fileData.GetCoordinateSystem());
}
void TestVTKWriteTestData(const std::string& methodName, const vtkm::cont::DataSet& data)

@ -509,12 +509,13 @@ public:
template <typename CellSetType,
typename ShapeHandleType,
typename ConnHandleType,
typename OffsetsHandleType>
typename OffsetsHandleType,
typename CoordsType>
VTKM_CONT void GenerateFaceConnnectivity(const CellSetType cellSet,
const ShapeHandleType shapes,
const ConnHandleType conn,
const OffsetsHandleType shapeOffsets,
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
const CoordsType& coords,
vtkm::cont::ArrayHandle<vtkm::Id>& faceConnectivity,
vtkm::cont::ArrayHandle<vtkm::Id3>& cellFaceId,
vtkm::Float32 BoundingBox[6],
@ -662,7 +663,7 @@ MeshConnectivityBuilder::~MeshConnectivityBuilder()
VTKM_CONT
void MeshConnectivityBuilder::BuildConnectivity(
vtkm::cont::CellSetSingleType<>& cellSetUnstructured,
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
vtkm::Bounds coordsBounds)
{
Logger* logger = Logger::GetInstance();
@ -725,7 +726,7 @@ void MeshConnectivityBuilder::BuildConnectivity(
VTKM_CONT
void MeshConnectivityBuilder::BuildConnectivity(
vtkm::cont::CellSetExplicit<>& cellSetUnstructured,
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
vtkm::Bounds coordsBounds)
{
Logger* logger = Logger::GetInstance();
@ -902,14 +903,14 @@ MeshConnContainer* MeshConnectivityBuilder::BuildConnectivity(
if (type == Unstructured)
{
vtkm::cont::CellSetExplicit<> cells = cellset.Cast<vtkm::cont::CellSetExplicit<>>();
this->BuildConnectivity(cells, coordinates.GetData(), coordBounds);
this->BuildConnectivity(cells, coordinates.GetDataAsMultiplexer(), coordBounds);
meshConn =
new UnstructuredContainer(cells, coordinates, FaceConnectivity, FaceOffsets, Triangles);
}
else if (type == UnstructuredSingle)
{
vtkm::cont::CellSetSingleType<> cells = cellset.Cast<vtkm::cont::CellSetSingleType<>>();
this->BuildConnectivity(cells, coordinates.GetData(), coordBounds);
this->BuildConnectivity(cells, coordinates.GetDataAsMultiplexer(), coordBounds);
meshConn = new UnstructuredSingleContainer(cells, coordinates, FaceConnectivity, Triangles);
}
else if (type == Structured)

@ -43,12 +43,12 @@ public:
protected:
VTKM_CONT
void BuildConnectivity(vtkm::cont::CellSetSingleType<>& cellSetUnstructured,
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
vtkm::Bounds coordsBounds);
VTKM_CONT
void BuildConnectivity(vtkm::cont::CellSetExplicit<>& cellSetUnstructured,
const vtkm::cont::ArrayHandleVirtualCoordinates& coordinates,
const vtkm::cont::CoordinateSystem::MultiplexerArrayType& coordinates,
vtkm::Bounds coordsBounds);
vtkm::cont::ArrayHandle<vtkm::Id> FaceConnectivity;

@ -737,7 +737,7 @@ void VolumeRendererStructured::SetData(const vtkm::cont::CoordinateSystem& coord
IsUniformDataSet = !coords.GetData().IsType<CartesianArrayHandle>();
IsSceneDirty = true;
SpatialExtent = coords.GetBounds();
Coordinates = coords.GetData();
Coordinates = coords;
ScalarField = &scalarField;
Cellset = cellset;
ScalarRange = scalarRange;
@ -829,7 +829,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
{
vtkm::cont::Token token;
vtkm::cont::ArrayHandleUniformPointCoordinates vertices;
vertices = Coordinates.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
vertices = Coordinates.GetData().Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
UniformLocator<Device> locator(vertices, Cellset, token);
if (isAssocPoints)
@ -872,7 +872,7 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
{
vtkm::cont::Token token;
CartesianArrayHandle vertices;
vertices = Coordinates.Cast<CartesianArrayHandle>();
vertices = Coordinates.GetData().Cast<CartesianArrayHandle>();
RectilinearLocator<Device> locator(vertices, Cellset, token);
if (isAssocPoints)
{

@ -66,7 +66,7 @@ protected:
bool IsSceneDirty;
bool IsUniformDataSet;
vtkm::Bounds SpatialExtent;
vtkm::cont::ArrayHandleVirtualCoordinates Coordinates;
vtkm::cont::CoordinateSystem Coordinates;
vtkm::cont::CellSetStructured<3> Cellset;
const vtkm::cont::Field* ScalarField;
vtkm::cont::ArrayHandle<vtkm::Vec4f_32> ColorMap;

@ -65,10 +65,10 @@ struct AverageByKey
/// This method uses an existing \c Keys object to collected values by those keys and find
/// the average of those groups.
///
template <typename ValueType, typename InValuesStorage, typename OutAveragesStorage>
template <typename InArrayType, typename OutArrayType>
VTKM_CONT static void Run(const vtkm::worklet::internal::KeysBase& keys,
const vtkm::cont::ArrayHandle<ValueType, InValuesStorage>& inValues,
vtkm::cont::ArrayHandle<ValueType, OutAveragesStorage>& outAverages)
const InArrayType& inValues,
OutArrayType& outAverages)
{
vtkm::worklet::DispatcherReduceByKey<AverageWorklet> dispatcher;

@ -41,10 +41,11 @@ struct DeduceCoordType
}
template <typename... Args>
void operator()(const vtkm::cont::ArrayHandleUniformPointCoordinates& coords,
const vtkm::cont::CellSetStructured<3>& cells,
vtkm::cont::CellSetSingleType<>& result,
Args&&... args) const
void operator()(
const vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>& coords,
const vtkm::cont::CellSetStructured<3>& cells,
vtkm::cont::CellSetSingleType<>& result,
Args&&... args) const
{
result = flying_edges::execute(cells, coords, std::forward<Args>(args)...);
}

@ -424,8 +424,7 @@ private:
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>::Superclass;
vtkm::cont::ArrayHandleVirtualCoordinates MapCoordinatesUniform(
const UniformCoordinatesArrayHandle& coords)
UniformCoordinatesArrayHandle MapCoordinatesUniform(const UniformCoordinatesArrayHandle& coords)
{
using CoordsArray = vtkm::cont::ArrayHandleUniformPointCoordinates;
using CoordType = CoordsArray::ValueType;
@ -441,11 +440,10 @@ private:
inOrigin[2] + static_cast<ValueType>(this->VOI.Z.Min) * inSpacing[2]);
CoordType outSpacing = inSpacing * static_cast<CoordType>(this->SampleRate);
auto out = CoordsArray(this->OutputDimensions, outOrigin, outSpacing);
return vtkm::cont::ArrayHandleVirtualCoordinates(out);
return CoordsArray(this->OutputDimensions, outOrigin, outSpacing);
}
vtkm::cont::ArrayHandleVirtualCoordinates MapCoordinatesRectilinear(
RectilinearCoordinatesArrayHandle MapCoordinatesRectilinear(
const RectilinearCoordinatesArrayHandle& coords)
{
// For structured datasets, the cellsets are of different types based on
@ -478,28 +476,43 @@ private:
}
VTKM_ASSERT(dim == this->InputDimensionality);
auto out = vtkm::cont::make_ArrayHandleCartesianProduct(xyzs[0], xyzs[1], xyzs[2]);
return vtkm::cont::ArrayHandleVirtualCoordinates(out);
return vtkm::cont::make_ArrayHandleCartesianProduct(xyzs[0], xyzs[1], xyzs[2]);
}
struct MapCoordinatesFunctor
{
template <typename T, typename S>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, S>& coords,
ExtractStructured& self,
vtkm::cont::VariantArrayHandleCommon& output) const
{
output = self.ProcessPointField(coords);
}
VTKM_CONT void operator()(const UniformCoordinatesArrayHandle& coords,
ExtractStructured& self,
vtkm::cont::VariantArrayHandleCommon& output) const
{
output = self.MapCoordinatesUniform(coords);
}
VTKM_CONT void operator()(const RectilinearCoordinatesArrayHandle& coords,
ExtractStructured& self,
vtkm::cont::VariantArrayHandleCommon& output) const
{
output = self.MapCoordinatesRectilinear(coords);
}
};
friend MapCoordinatesFunctor;
public:
vtkm::cont::ArrayHandleVirtualCoordinates MapCoordinates(
vtkm::cont::VariantArrayHandleCommon MapCoordinates(
const vtkm::cont::CoordinateSystem& coordinates)
{
auto coArray = coordinates.GetData();
if (coArray.IsType<UniformCoordinatesArrayHandle>())
{
return this->MapCoordinatesUniform(coArray.Cast<UniformCoordinatesArrayHandle>());
}
else if (coArray.IsType<RectilinearCoordinatesArrayHandle>())
{
return this->MapCoordinatesRectilinear(coArray.Cast<RectilinearCoordinatesArrayHandle>());
}
else
{
auto out = this->ProcessPointField(coArray);
return vtkm::cont::ArrayHandleVirtualCoordinates(out);
}
vtkm::cont::VariantArrayHandleCommon output;
vtkm::cont::CastAndCall(coordinates, MapCoordinatesFunctor{}, *this, output);
return output;
}
public:

@ -25,6 +25,7 @@
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/ExecutionAndControlObjectBase.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/cont/VariantArrayHandle.h>
#include <vtkm/Bounds.h>
#include <vtkm/Hash.h>
@ -419,17 +420,18 @@ public:
points = uniquePointCoordinates;
}
template <typename TL>
VTKM_CONT void Run(
vtkm::Float64 delta, // Distance to consider two points coincident
bool fastCheck, // If true, approximate distances are used
const vtkm::Bounds& bounds, // Bounds of points
vtkm::cont::ArrayHandleVirtualCoordinates& points) // coordinates, modified to merge close
vtkm::Float64 delta, // Distance to consider two points coincident
bool fastCheck, // If true, approximate distances are used
const vtkm::Bounds& bounds, // Bounds of points
vtkm::cont::VariantArrayHandleBase<TL>& points) // coordinates, modified to merge close
{
// Get a cast to a concrete set of point coordiantes so that it can be modified in place
vtkm::cont::ArrayHandle<vtkm::Vec3f> concretePoints;
if (points.IsType<decltype(concretePoints)>())
if (points.template IsType<decltype(concretePoints)>())
{
concretePoints = points.Cast<decltype(concretePoints)>();
concretePoints = points.template Cast<decltype(concretePoints)>();
}
else
{
@ -439,7 +441,7 @@ public:
Run(delta, fastCheck, bounds, concretePoints);
// Make sure that the modified points are reflected back in the virtual array.
points = vtkm::cont::ArrayHandleVirtualCoordinates(concretePoints);
points = concretePoints;
}
template <typename ShapeStorage, typename ConnectivityStorage, typename OffsetsStorage>
@ -452,27 +454,46 @@ public:
inCellSet, this->PointInputToOutputMap, this->MergeKeys.GetInputRange());
}
private:
struct MapPointFieldFunctor
{
template <typename T, typename S>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, S>& inArray,
vtkm::cont::VariantArrayHandleCommon& outHolder,
const PointMerge& self) const
{
vtkm::cont::ArrayHandle<T> outArray;
self.MapPointField(inArray, outArray);
outHolder = vtkm::cont::VariantArrayHandleCommon(outArray);
}
};
public:
template <typename InArrayHandle, typename OutArrayHandle>
VTKM_CONT void MapPointField(const InArrayHandle& inArray, OutArrayHandle& outArray) const
{
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
VTKM_IS_ARRAY_HANDLE(OutArrayHandle);
vtkm::worklet::AverageByKey::Run(this->MergeKeys, inArray, outArray);
}
template <typename InArrayHandle>
VTKM_CONT vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> MapPointField(
const InArrayHandle& inArray) const
template <typename T, typename S>
VTKM_CONT vtkm::cont::ArrayHandle<T> MapPointField(
const vtkm::cont::ArrayHandle<T, S>& inArray) const
{
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> outArray;
vtkm::cont::ArrayHandle<T> outArray;
this->MapPointField(inArray, outArray);
return outArray;
}
template <typename InTypes>
VTKM_CONT vtkm::cont::VariantArrayHandleBase<InTypes> MapPointField(
const vtkm::cont::VariantArrayHandleBase<InTypes>& inArray) const
{
vtkm::cont::VariantArrayHandleBase<InTypes> outArray;
vtkm::cont::CastAndCall(inArray, MapPointFieldFunctor{}, outArray, *this);
return outArray;
}
vtkm::worklet::Keys<vtkm::Id> GetMergeKeys() const { return this->MergeKeys; }
private:

@ -194,12 +194,37 @@ public:
VTKM_CONT vtkm::cont::ArrayHandlePermutation<vtkm::cont::ArrayHandle<vtkm::Id>, InArrayHandle>
MapPointFieldShallow(const InArrayHandle& inArray) const
{
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
VTKM_ASSERT(this->PointScatter);
return vtkm::cont::make_ArrayHandlePermutation(this->PointScatter->GetOutputToInputMap(),
inArray);
}
private:
struct MapPointFieldDeepFunctor
{
template <typename InT, typename InS, typename OutT, typename OutS>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<InT, InS>& inArray,
vtkm::cont::ArrayHandle<OutT, OutS>& outArray,
const RemoveUnusedPoints& self) const
{
self.MapPointFieldDeep(inArray, outArray);
}
template <typename InT, typename InS>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<InT, InS>& inArray,
vtkm::cont::VariantArrayHandleCommon& outHolder,
const RemoveUnusedPoints& self) const
{
vtkm::cont::ArrayHandle<InT> outArray;
(*this)(inArray, outArray, self);
outHolder = vtkm::cont::VariantArrayHandleCommon{ outArray };
}
};
public:
///@{
/// \brief Maps a point field from the original points to the new reduced points
///
/// Given an array handle that holds the values for a point field of the
@ -209,36 +234,41 @@ public:
/// This version of point mapping performs a deep copy into the destination
/// array provided.
///
template <typename InArrayHandle, typename OutArrayHandle>
VTKM_CONT void MapPointFieldDeep(const InArrayHandle& inArray, OutArrayHandle& outArray) const
template <typename InT, typename InS, typename OutT, typename OutS>
VTKM_CONT void MapPointFieldDeep(const vtkm::cont::ArrayHandle<InT, InS>& inArray,
vtkm::cont::ArrayHandle<OutT, OutS>& outArray) const
{
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
VTKM_IS_ARRAY_HANDLE(OutArrayHandle);
vtkm::cont::ArrayCopy(this->MapPointFieldShallow(inArray), outArray);
}
/// \brief Maps a point field from the original points to the new reduced points
///
/// Given an array handle that holds the values for a point field of the
/// original data set, returns a new array handle containing field values
/// rearranged to the new indices of the reduced point set.
///
/// This version of point mapping performs a deep copy into an array that is
/// returned.
///
template <typename InArrayHandle>
vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> MapPointFieldDeep(
const InArrayHandle& inArray) const
template <typename T, typename S>
VTKM_CONT vtkm::cont::ArrayHandle<T> MapPointFieldDeep(
const vtkm::cont::ArrayHandle<T, S>& inArray) const
{
VTKM_IS_ARRAY_HANDLE(InArrayHandle);
vtkm::cont::ArrayHandle<typename InArrayHandle::ValueType> outArray;
vtkm::cont::ArrayHandle<T> outArray;
this->MapPointFieldDeep(inArray, outArray);
return outArray;
}
template <typename InArrayTypes, typename OutArrayHandle>
VTKM_CONT void MapPointFieldDeep(const vtkm::cont::VariantArrayHandleBase<InArrayTypes>& inArray,
OutArrayHandle& outArray) const
{
vtkm::cont::CastAndCall(inArray, MapPointFieldDeepFunctor{}, outArray, *this);
}
template <typename InTypes>
VTKM_CONT vtkm::cont::VariantArrayHandleBase<InTypes> MapPointFieldDeep(
const vtkm::cont::VariantArrayHandleBase<InTypes>& inArray) const
{
vtkm::cont::VariantArrayHandleBase<InTypes> outArray;
vtkm::cont::CastAndCall(inArray, MapPointFieldDeepFunctor{}, outArray, *this);
return outArray;
}
///@}
const vtkm::worklet::ScatterCounting& GetPointScatter() const
{
return *this->PointScatter.get();

@ -131,9 +131,9 @@ public:
}
}
template <typename CellSetType, typename NormalCompType>
template <typename CellSetType, typename PointsType, typename NormalCompType>
void Run(const CellSetType& cellset,
const vtkm::cont::VariantArrayHandleBase<vtkm::TypeListFieldVec3>& points,
const PointsType& points,
vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>>& normals)
{
if (this->Normalize)

@ -164,17 +164,11 @@ public:
vtkm::cont::DynamicCellSet Result;
// Generic handler:
template <typename CellSetType,
typename PointComponentType,
typename PointStorageType,
typename CellNormalComponentType,
typename CellNormalStorageType>
VTKM_CONT void operator()(
const CellSetType& cellSet,
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
cellNormals,
...)
template <typename CellSetType, typename CoordsType, typename CellNormalsType>
VTKM_CONT void operator()(const CellSetType& cellSet,
const CoordsType& coords,
const CellNormalsType& cellNormals,
...)
{
const auto numCells = cellSet.GetNumberOfCells();
if (numCells == 0)
@ -257,19 +251,11 @@ public:
}
// Specialization for CellSetExplicit
template <typename S,
typename C,
typename O,
typename PointComponentType,
typename PointStorageType,
typename CellNormalComponentType,
typename CellNormalStorageType>
VTKM_CONT void operator()(
const vtkm::cont::CellSetExplicit<S, C, O>& cellSet,
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
cellNormals,
int)
template <typename S, typename C, typename O, typename CoordsType, typename CellNormalsType>
VTKM_CONT void operator()(const vtkm::cont::CellSetExplicit<S, C, O>& cellSet,
const CoordsType& coords,
const CellNormalsType& cellNormals,
int)
{
using WindToCellNormals = vtkm::worklet::DispatcherMapField<WorkletWindToCellNormals>;
@ -303,17 +289,11 @@ public:
}
// Specialization for CellSetSingleType
template <typename C,
typename PointComponentType,
typename PointStorageType,
typename CellNormalComponentType,
typename CellNormalStorageType>
VTKM_CONT void operator()(
const vtkm::cont::CellSetSingleType<C>& cellSet,
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
cellNormals,
int)
template <typename C, typename CoordsType, typename CellNormalsType>
VTKM_CONT void operator()(const vtkm::cont::CellSetSingleType<C>& cellSet,
const CoordsType& coords,
const CellNormalsType& cellNormals,
int)
{
using WindToCellNormals = vtkm::worklet::DispatcherMapField<WorkletWindToCellNormals>;
@ -348,16 +328,10 @@ public:
}
};
template <typename CellSetType,
typename PointComponentType,
typename PointStorageType,
typename CellNormalComponentType,
typename CellNormalStorageType>
VTKM_CONT static vtkm::cont::DynamicCellSet Run(
const CellSetType& cellSet,
const vtkm::cont::ArrayHandle<vtkm::Vec<PointComponentType, 3>, PointStorageType>& coords,
const vtkm::cont::ArrayHandle<vtkm::Vec<CellNormalComponentType, 3>, CellNormalStorageType>&
cellNormals)
template <typename CellSetType, typename CoordsType, typename CellNormalsType>
VTKM_CONT static vtkm::cont::DynamicCellSet Run(const CellSetType& cellSet,
const CoordsType& coords,
const CellNormalsType& cellNormals)
{
Launcher launcher;
// The last arg is just to help with overload resolution on the templated

@ -65,7 +65,7 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponen
using Timer = vtkm::cont::Timer;
vtkm::cont::DynamicCellSet cellSet = dataSet.GetCellSet();
vtkm::cont::ArrayHandleVirtualCoordinates vertices = dataSet.GetCoordinateSystem().GetData();
auto vertices = dataSet.GetCoordinateSystem().GetDataAsMultiplexer();
std::cout << "Using numPlanes: " << numPlanes << "\n";
std::cout << "Building Bounding Interval Hierarchy Tree" << std::endl;

@ -27,7 +27,8 @@ void TestCellMeasureUniform3D()
vtkm::cont::ArrayHandle<vtkm::FloatDefault> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<vtkm::Volume>> dispatcher;
dispatcher.Invoke(dataSet.GetCellSet(), dataSet.GetCoordinateSystem(), result);
dispatcher.Invoke(
dataSet.GetCellSet(), dataSet.GetCoordinateSystem().GetDataAsMultiplexer(), result);
vtkm::Float32 expected[4] = { 1.f, 1.f, 1.f, 1.f };
for (int i = 0; i < 4; ++i)
@ -48,7 +49,8 @@ void TestCellMeasureWorklet(vtkm::cont::DataSet& dataset,
vtkm::cont::ArrayHandle<vtkm::FloatDefault> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<IntegrationType>> dispatcher;
dispatcher.Invoke(dataset.GetCellSet(), dataset.GetCoordinateSystem(), result);
dispatcher.Invoke(
dataset.GetCellSet(), dataset.GetCoordinateSystem().GetDataAsMultiplexer(), result);
VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
"Wrong number of values in the output array");

@ -120,7 +120,7 @@ void TestClippingExplicit()
clipValue,
invertClip);
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
@ -176,7 +176,7 @@ void TestClippingStructured()
clipValue,
invertClip);
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
CoordsOutType coords = clip.ProcessPointField(coordsIn);
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
@ -238,7 +238,7 @@ void TestClippingWithImplicitFunction()
ds.GetCoordinateSystem("coords"),
invertClip);
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;
@ -297,7 +297,7 @@ void TestClippingWithImplicitFunctionInverted()
ds.GetCoordinateSystem("coords"),
invertClip);
auto coordsIn = ds.GetCoordinateSystem("coords").GetData();
auto coordsIn = ds.GetCoordinateSystem("coords").GetDataAsMultiplexer();
vtkm::cont::ArrayHandle<Coord3D> coords = clip.ProcessPointField(coordsIn);
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsIn;

@ -107,7 +107,7 @@ void ValidateCoordTransform(const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::ArrayHandle<vtkm::Vec3f>& doubleTransform,
const std::vector<bool>& isAngle)
{
auto points = coords.GetData();
auto points = coords.GetDataAsMultiplexer();
VTKM_TEST_ASSERT(points.GetNumberOfValues() == transform.GetNumberOfValues() &&
points.GetNumberOfValues() == doubleTransform.GetNumberOfValues(),
"Incorrect number of points in point transform");

@ -85,7 +85,7 @@ struct ValidateNormals
using NormalType = vtkm::Vec<vtkm::FloatDefault, 3>;
using NormalsArrayType = vtkm::cont::ArrayHandleVirtual<NormalType>;
using NormalsPortalType = decltype(std::declval<NormalsArrayType>().ReadPortal());
using PointsType = decltype(std::declval<vtkm::cont::CoordinateSystem>().GetData().ReadPortal());
using PointsType = decltype(std::declval<vtkm::cont::CoordinateSystem>().GetDataAsMultiplexer());
vtkm::cont::CoordinateSystem Coords;
CellSetType Cells;
@ -139,7 +139,7 @@ struct ValidateNormals
const vtkm::cont::Field& cellNormalsField)
: Coords{ dataset.GetCoordinateSystem() }
, Cells{ dataset.GetCellSet().Cast<CellSetType>() }
, Points{ this->Coords.GetData().ReadPortal() }
, Points{ this->Coords.GetDataAsMultiplexer() }
, CheckPoints(checkPoints)
, CheckCells(checkCells)
{
@ -170,7 +170,8 @@ struct ValidateNormals
// Locate a point with the minimum x coordinate:
const vtkm::Id startPoint = [&]() -> vtkm::Id {
const vtkm::Float64 xMin = this->Coords.GetBounds().X.Min;
const auto points = this->Coords.GetData().ReadPortal();
const auto pointArray = this->Coords.GetDataAsMultiplexer();
const auto points = pointArray.ReadPortal();
const vtkm::Id numPoints = points.GetNumberOfValues();
vtkm::Id resultIdx = -1;
for (vtkm::Id pointIdx = 0; pointIdx < numPoints; ++pointIdx)
@ -240,6 +241,7 @@ private:
vtkm::TopologyElementTagCell{},
token);
auto points = this->Points.ReadPortal();
while (!queue.empty())
{
const vtkm::Id curPtIdx = queue.back().first;
@ -251,7 +253,7 @@ private:
const NormalType curNormal = this->PointNormals.Get(curPtIdx);
if (!this->SameHemisphere(curNormal, refNormal))
{
const auto coord = this->Points.Get(curPtIdx);
const auto coord = points.Get(curPtIdx);
std::cerr << "BadPointNormal PtId: " << curPtIdx << "\n\t"
<< "- Normal: {" << curNormal[0] << ", " << curNormal[1] << ", " << curNormal[2]
<< "}\n\t"
@ -343,7 +345,7 @@ void TestOrientNormals(bool testPoints, bool testCells)
}
// modify normals in place
const auto coords = dataset.GetCoordinateSystem().GetData();
const auto coords = dataset.GetCoordinateSystem().GetDataAsMultiplexer();
const auto cells = dataset.GetCellSet();
if (testPoints && testCells)
{

@ -78,12 +78,13 @@ void TestPointElevation()
pointElevationWorklet);
dispatcher.Invoke(dataSet.GetCoordinateSystem(), result);
auto coordinates = dataSet.GetCoordinateSystem().GetData();
auto coordinates = dataSet.GetCoordinateSystem().GetDataAsMultiplexer();
auto coordinatesPortal = coordinates.ReadPortal();
auto resultPortal = result.ReadPortal();
for (vtkm::Id i = 0; i < result.GetNumberOfValues(); ++i)
{
VTKM_TEST_ASSERT(
test_equal(coordinates.ReadPortal().Get(i)[1] * 2.0, result.ReadPortal().Get(i)),
"Wrong result for PointElevation worklet");
VTKM_TEST_ASSERT(test_equal(coordinatesPortal.Get(i)[1] * 2.0, resultPortal.Get(i)),
"Wrong result for PointElevation worklet");
}
}

@ -66,7 +66,7 @@ void ValidatePointTransform(const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::ArrayHandle<vtkm::Vec3f>& result,
const vtkm::Matrix<vtkm::FloatDefault, 4, 4>& matrix)
{
auto points = coords.GetData();
auto points = coords.GetDataAsMultiplexer();
VTKM_TEST_ASSERT(points.GetNumberOfValues() == result.GetNumberOfValues(),
"Incorrect number of points in point transform");

@ -121,7 +121,7 @@ void TestSplitSharpEdgesSplitEveryEdge(vtkm::cont::DataSet& simpleCube,
splitSharpEdges.Run(simpleCube.GetCellSet(),
featureAngle,
faceNormals,
simpleCube.GetCoordinateSystem().GetData(),
simpleCube.GetCoordinateSystem().GetDataAsMultiplexer(),
newCoords,
newCellset);
@ -166,7 +166,7 @@ void TestSplitSharpEdgesNoSplit(vtkm::cont::DataSet& simpleCube,
splitSharpEdges.Run(simpleCube.GetCellSet(),
featureAngle,
faceNormals,
simpleCube.GetCoordinateSystem().GetData(),
simpleCube.GetCoordinateSystem().GetDataAsMultiplexer(),
newCoords,
newCellset);
@ -213,7 +213,8 @@ void TestSplitSharpEdges()
vtkm::cont::DataSet simpleCube = Make3DExplicitSimpleCube();
NormalsArrayHandle faceNormals;
vtkm::worklet::FacetedSurfaceNormals faceted;
faceted.Run(simpleCube.GetCellSet(), simpleCube.GetCoordinateSystem().GetData(), faceNormals);
faceted.Run(
simpleCube.GetCellSet(), simpleCube.GetCoordinateSystem().GetDataAsMultiplexer(), faceNormals);
vtkm::worklet::SplitSharpEdges splitSharpEdges;

@ -53,7 +53,7 @@ vtkm::cont::DataSet GenerateDataSet()
void Validate(vtkm::cont::DataSet dataSet)
{
const auto cellSet = dataSet.GetCellSet().Cast<vtkm::cont::CellSetExplicit<>>();
const auto coordsArray = dataSet.GetCoordinateSystem().GetData();
const auto coordsArray = dataSet.GetCoordinateSystem().GetDataAsMultiplexer();
const auto conn =
cellSet.GetConnectivityArray(vtkm::TopologyElementTagCell{}, vtkm::TopologyElementTagPoint{});
const auto offsets =

@ -69,7 +69,7 @@ void TestVertexClustering()
auto pointArray = outDataSet.GetCoordinateSystem(0).GetData();
std::cerr << "output_points = " << pointArray.GetNumberOfValues() << "\n";
std::cerr << "output_point[] = ";
vtkm::cont::printSummary_ArrayHandle(pointArray, std::cerr, true);
pointArray.PrintSummary(std::cerr);
}
vtkm::cont::printSummary_ArrayHandle(pointvar, std::cerr, true);
@ -78,7 +78,7 @@ void TestVertexClustering()
VTKM_TEST_ASSERT(outDataSet.GetNumberOfCoordinateSystems() == 1,
"Number of output coordinate systems mismatch");
using PointType = vtkm::Vec3f_64;
auto pointArray = outDataSet.GetCoordinateSystem(0).GetData();
auto pointArray = outDataSet.GetCoordinateSystem(0).GetDataAsMultiplexer();
VTKM_TEST_ASSERT(pointArray.GetNumberOfValues() == output_points,
"Number of output points mismatch");
for (vtkm::Id i = 0; i < pointArray.GetNumberOfValues(); ++i)

@ -60,7 +60,7 @@ void TestWarpScalar()
vecType normal = vtkm::make_Vec<vtkm::FloatDefault>(static_cast<vtkm::FloatDefault>(0.0),
static_cast<vtkm::FloatDefault>(0.0),
static_cast<vtkm::FloatDefault>(1.0));
auto coordinate = ds.GetCoordinateSystem().GetData();
auto coordinate = ds.GetCoordinateSystem().GetDataAsMultiplexer();
vtkm::Id nov = coordinate.GetNumberOfValues();
vtkm::cont::ArrayHandleConstant<vecType> normalAH =
vtkm::cont::make_ArrayHandleConstant(normal, nov);
@ -70,7 +70,8 @@ void TestWarpScalar()
scaleFactor.CopyTo(scaleFactorArray);
vtkm::worklet::WarpScalar warpWorklet;
warpWorklet.Run(ds.GetCoordinateSystem(), normalAH, scaleFactor, scaleAmount, result);
warpWorklet.Run(
ds.GetCoordinateSystem().GetDataAsMultiplexer(), normalAH, scaleFactor, scaleAmount, result);
auto sFAPortal = scaleFactorArray.ReadPortal();
auto resultPortal = result.ReadPortal();

@ -73,7 +73,7 @@ void TestWarpVector()
vecType vector = vtkm::make_Vec<vtkm::FloatDefault>(static_cast<vtkm::FloatDefault>(0.0),
static_cast<vtkm::FloatDefault>(0.0),
static_cast<vtkm::FloatDefault>(2.0));
auto coordinate = ds.GetCoordinateSystem().GetData();
auto coordinate = ds.GetCoordinateSystem().GetDataAsMultiplexer();
vtkm::Id nov = coordinate.GetNumberOfValues();
vtkm::cont::ArrayHandleConstant<vecType> vectorAH =
vtkm::cont::make_ArrayHandleConstant(vector, nov);