Merge topic 'get-cast-array-from-field'

630768600 Suppress CUDA warnings
5fa02057a Rely less on overload resolution for ApplyPolicy
26d7bfd0d Force ArrayPolicy of a specific type to the right template
6c136b978 Remove vtkm::BaseComponent
07c59fcf7 Update filters with secondary fields to use new policy method
3039a18ba Add ability to get an array from a Field for a particular type
2b6e6da6c Add ability to get VariantArrayHandle as an ArrayHandleMultiplexer
6323d6803 Add recursive component queries to VecTraits

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !1829
This commit is contained in:
Kenneth Moreland 2019-09-10 16:04:59 +00:00 committed by Kitware Robot
commit b95b7d6109
70 changed files with 968 additions and 328 deletions

@ -0,0 +1,47 @@
# Add ability to get an array from a Field for a particular type
Previously, whenever you got an array from a `Field` object from a call to
an `ApplyPolicy`, you would get back a `VariantArrayHandle` that allows you
to cast to multiple types. To use that, you then have to cast it to
multiple different types and multiple different storage.
Often, this is what you want. If you are operating on a field, then you
want to cast to the native type. But there are also cases where you know a
specific type you want. For example, if you are operating on two fields, it
makes sense to find the exact type for the first field and then cast the
second field to that type if necessary rather than pointlessly unroll
templates for the cross of every possible combination. Also, we are not
unrolling for different storage types or attempting to create a virtual
array. Instead, we are using an `ArrayHandleMultiplexer` so that you only
have to compile for this array once.
This is done through a new version of `ApplyPolicy`. This version takes a
type of the array as its first template argument, which must be specified.
This requires having a list of potential storage to try. It will use that
to construct an `ArrayHandleMultiplexer` containing all potential types.
This list of storages comes from the policy. A `StorageList` item was added
to the policy. It is also sometimes necessary for a filter to provide its
own special storage types. Thus, an `AdditionalFieldStorage` type was added
to `Filter` which is set to a `ListTag` of storage types that should be
added to those specified by the policy.
Types are automatically converted. So if you ask for a `vtkm::Float64` and
field contains a `vtkm::Float32`, it will the array wrapped in an
`ArrayHandleCast` to give the expected type.
Here is an example where you are doing an operation on a field and
coordinate system. The superclass finds the correct type of the field. Your
result is just going to follow the type of the field.
``` cpp
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet MyFilter::DoExecute(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMetadata,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
vtkm::cont::CoordinateSystem coords = inDataSet.GetCoordianteSystem();
auto coordsArray = vtkm::filter::ApplyPolicy<T>(coords, policy, *this);
```

@ -0,0 +1,39 @@
# Recursive base component queries to VecTraits
This change adds a recursive `BaseComponentType` to `VecTraits` that
recursively finds the base (non-`Vec`) type of a `Vec`. This is useful when
dealing with potentially nested `Vec`s (e.g. `Vec<Vec<T, M>, N>`) and you
want to know the precision of the math being defined.
``` cpp
using NestedVec = vtkm::Vec<vtkm::Vec<vtkm::Float32, 3>, 8>;
// ComponentType becomes vtkm::Vec<vtkm::Float32, 3>
using ComponentType = typename vtkm::VecTraits<NestedVec>::ComponentType;
// BaseComponentType becomes vtkm::Float32
using BaseComponentType = typename vtkm::VecTraits<NestedVec>::BaseComponentType;
```
Also added the ability to `VecTraits` to change the component type of a
vector. The template `RepalceComponentType` resolves to a `Vec` of the same
type with the component replaced with a new type. The template
`ReplaceBaseComponentType` traverses down a nested type and replaces the
base type.
``` cpp
using NestedVec = vtkm::Vec<vtkm::Vec<vtkm::Float32, 3>, 8>;
// NewVec1 becomes vtkm::Vec<vtkm::Float64, 8>
using NewVec1 =
typename vtkm::VecTraits<NestedVec>::template ReplaceComponentType<vtkm::Float64>;
// NewVec2 becomes vtkm::Vec<vtkm::Vec<vtkm::Float64, 3>, 8>
using NewVec1 =
typename vtkm::VecTraits<NestedVec>::template ReplaceBaseComponentType<vtkm::Float64>;
```
This functionality replaces the functionality in `vtkm::BaseComponent`. Unfortunately,
`vtkm::BaseComponent` did not have the ability to replace the base component and
there was no straightforward way to implement that outside of `VecTraits`.

@ -122,7 +122,7 @@ public:
//Update the game state
this->Invoke(
UpdateLifeState{}, vtkm::filter::ApplyPolicy(cells, policy), prevstate, state, colors);
UpdateLifeState{}, vtkm::filter::ApplyPolicyCellSet(cells, policy), prevstate, state, colors);
//save the results
vtkm::cont::DataSet output;

@ -1,64 +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_BaseComponent_h
#define vtk_m_BaseComponent_h
#include <vtkm/Matrix.h>
#include <vtkm/TypeTraits.h>
#include <vtkm/VecTraits.h>
namespace vtkm
{
namespace detail
{
template <typename VecType, typename DimensionalityTag>
struct BaseComponentImpl;
template <typename VecType>
struct BaseComponentImpl<VecType, vtkm::TypeTraitsVectorTag>
{
private:
using ComponentType = typename vtkm::VecTraits<VecType>::ComponentType;
public:
using Type =
typename BaseComponentImpl<ComponentType,
typename vtkm::TypeTraits<ComponentType>::DimensionalityTag>::Type;
};
template <typename VecType>
struct BaseComponentImpl<VecType, vtkm::TypeTraitsMatrixTag>
: BaseComponentImpl<VecType, vtkm::TypeTraitsVectorTag>
{
};
template <typename ScalarType>
struct BaseComponentImpl<ScalarType, vtkm::TypeTraitsScalarTag>
{
using Type = ScalarType;
};
} // namespace detail
// Finds the base component type of a Vec. If you have a Vec of Vecs, it will
// descend all Vecs until you get to the scalar type.
template <typename VecType>
struct BaseComponent
{
using Type =
typename detail::BaseComponentImpl<VecType,
typename vtkm::TypeTraits<VecType>::DimensionalityTag>::Type;
};
} // namespace vtkm
#endif //vtk_m_BaseComponent_h

@ -18,7 +18,6 @@ vtkm_install_headers(
set(headers
Assert.h
BaseComponent.h
BinaryPredicates.h
BinaryOperators.h
Bitset.h

@ -103,13 +103,10 @@ struct ListTagEmpty : detail::ListRoot
/// A tag that is a construction of two other tags joined together. This struct
/// can be subclassed and still behave like a list tag.
template <typename ListTag1, typename ListTag2>
template <typename... ListTags>
struct ListTagJoin : detail::ListRoot
{
VTKM_IS_LIST_TAG(ListTag1);
VTKM_IS_LIST_TAG(ListTag2);
using list = typename detail::ListJoin<internal::ListTagAsBrigandList<ListTag1>,
internal::ListTagAsBrigandList<ListTag2>>::type;
using list = typename detail::ListJoin<internal::ListTagAsBrigandList<ListTags>...>::type;
};

@ -541,6 +541,7 @@ private:
public:
using ComponentType = T;
using BaseComponentType = typename vtkm::VecTraits<T>::BaseComponentType;
static constexpr vtkm::IdComponent NUM_COMPONENTS = NumRow * NumCol;
using HasMultipleComponents = vtkm::VecTraitsTagMultipleComponents;
using IsSizeStatic = vtkm::VecTraitsTagSizeStatic;
@ -567,6 +568,15 @@ public:
{
GetComponent(matrix, component) = value;
}
template <typename NewComponentType>
using ReplaceComponentType = vtkm::Matrix<NewComponentType, NumRow, NumCol>;
template <typename NewComponentType>
using ReplaceBaseComponentType =
vtkm::Matrix<typename vtkm::VecTraits<T>::template ReplaceBaseComponentType<NewComponentType>,
NumRow,
NumCol>;
};
//---------------------------------------------------------------------------

@ -147,6 +147,7 @@ struct VecTraits<vtkm::VecAxisAlignedPointCoordinates<NumDimensions>>
using VecType = vtkm::VecAxisAlignedPointCoordinates<NumDimensions>;
using ComponentType = vtkm::Vec3f;
using BaseComponentType = vtkm::FloatDefault;
using HasMultipleComponents = vtkm::VecTraitsTagMultipleComponents;
using IsSizeStatic = vtkm::VecTraitsTagSizeStatic;
@ -161,6 +162,13 @@ struct VecTraits<vtkm::VecAxisAlignedPointCoordinates<NumDimensions>>
return vector[componentIndex];
}
// These are a bit of a hack since VecAxisAlignedPointCoordinates only supports one component
// type. Using these might not work as expected.
template <typename NewComponentType>
using ReplaceComponentType = vtkm::Vec<NewComponentType, NUM_COMPONENTS>;
template <typename NewComponentType>
using ReplaceBaseComponenttype = vtkm::Vec<vtkm::Vec<NewComponentType, 3>, NUM_COMPONENTS>;
template <vtkm::IdComponent destSize>
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
{

@ -99,6 +99,7 @@ struct VecTraits<vtkm::VecFromPortal<PortalType>>
using VecType = vtkm::VecFromPortal<PortalType>;
using ComponentType = typename VecType::ComponentType;
using BaseComponentType = typename vtkm::VecTraits<ComponentType>::BaseComponentType;
using HasMultipleComponents = vtkm::VecTraitsTagMultipleComponents;
using IsSizeStatic = vtkm::VecTraitsTagSizeVariable;

@ -136,6 +136,7 @@ struct VecTraits<vtkm::VecFromPortalPermute<IndexVecType, PortalType>>
using VecType = vtkm::VecFromPortalPermute<IndexVecType, PortalType>;
using ComponentType = typename VecType::ComponentType;
using BaseComponentType = typename vtkm::VecTraits<ComponentType>::BaseComponentType;
using HasMultipleComponents = vtkm::VecTraitsTagMultipleComponents;
using IsSizeStatic = vtkm::VecTraitsTagSizeVariable;

@ -66,10 +66,19 @@ template <class VecType>
struct VTKM_NEVER_EXPORT VecTraits
{
#ifdef VTKM_DOXYGEN_ONLY
/// Type of the components in the vector.
/// \brief Type of the components in the vector.
///
/// If the type is really a scalar, then the component type is the same as the scalar type.
///
using ComponentType = typename VecType::ComponentType;
/// \brief Base component type in the vector.
///
/// Similar to ComponentType except that for nested vectors (e.g. Vec<Vec<T, M>, N>), it
/// returns the base scalar type at the end of the composition (T in this example).
///
using BaseComponentType = typename vtkm::VecTraits<ComponentType>::BaseComponentType;
/// \brief Number of components in the vector.
///
/// This is only defined for vectors of a static size.
@ -111,6 +120,27 @@ struct VTKM_NEVER_EXPORT VecTraits
vtkm::IdComponent component,
ComponentType value);
/// \brief Get a vector of the same type but with a different component.
///
/// This type resolves to another vector with a different component type. For example,
/// vtkm::VecTraits<vtkm::Vec<T, N>>::ReplaceComponentType<T2> is vtkm::Vec<T2, N>.
/// This replacement is not recursive. So VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2>
/// is vtkm::Vec<T2, N>.
///
template <typename NewComponentType>
using ReplaceComponentType = VecTemplate<NewComponentType, N>;
/// \brief Get a vector of the same type but with a different base component.
///
/// This type resolves to another vector with a different base component type. The replacement
/// is recursive for nested types. For example,
/// VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2> is Vec<Vec<T2, M>, N>.
///
template <typename NewComponentType>
using ReplaceBaseComponentType = VecTemplate<
typename VecTraits<ComponentType>::template ReplaceBaseComponentType<NewComponentType>,
N>;
/// Copies the components in the given vector into a given Vec object.
///
template <vktm::IdComponent destSize>
@ -158,10 +188,19 @@ struct VTKM_NEVER_EXPORT VecTraits<vtkm::Vec<T, Size>>
{
using VecType = vtkm::Vec<T, Size>;
/// Type of the components in the vector.
/// \brief Type of the components in the vector.
///
/// If the type is really a scalar, then the component type is the same as the scalar type.
///
using ComponentType = typename VecType::ComponentType;
/// \brief Base component type in the vector.
///
/// Similar to ComponentType except that for nested vectors (e.g. Vec<Vec<T, M>, N>), it
/// returns the base scalar type at the end of the composition (T in this example).
///
using BaseComponentType = typename vtkm::VecTraits<ComponentType>::BaseComponentType;
/// Number of components in the vector.
///
static constexpr vtkm::IdComponent NUM_COMPONENTS = VecType::NUM_COMPONENTS;
@ -208,6 +247,27 @@ struct VTKM_NEVER_EXPORT VecTraits<vtkm::Vec<T, Size>>
vector[component] = value;
}
/// \brief Get a vector of the same type but with a different component.
///
/// This type resolves to another vector with a different component type. For example,
/// vtkm::VecTraits<vtkm::Vec<T, N>>::ReplaceComponentType<T2> is vtkm::Vec<T2, N>.
/// This replacement is not recursive. So VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2>
/// is vtkm::Vec<T2, N>.
///
template <typename NewComponentType>
using ReplaceComponentType = vtkm::Vec<NewComponentType, Size>;
/// \brief Get a vector of the same type but with a different base component.
///
/// This type resolves to another vector with a different base component type. The replacement
/// is recursive for nested types. For example,
/// VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2> is Vec<Vec<T2, M>, N>.
///
template <typename NewComponentType>
using ReplaceBaseComponentType = vtkm::Vec<
typename vtkm::VecTraits<ComponentType>::template ReplaceBaseComponentType<NewComponentType>,
Size>;
/// Converts whatever type this vector is into the standard VTKm Tuple.
///
template <vtkm::IdComponent destSize>
@ -222,10 +282,19 @@ struct VTKM_NEVER_EXPORT VecTraits<vtkm::VecC<T>>
{
using VecType = vtkm::VecC<T>;
/// Type of the components in the vector.
/// \brief Type of the components in the vector.
///
/// If the type is really a scalar, then the component type is the same as the scalar type.
///
using ComponentType = typename VecType::ComponentType;
/// \brief Base component type in the vector.
///
/// Similar to ComponentType except that for nested vectors (e.g. Vec<Vec<T, M>, N>), it
/// returns the base scalar type at the end of the composition (T in this example).
///
using BaseComponentType = typename vtkm::VecTraits<ComponentType>::BaseComponentType;
/// Number of components in the given vector.
///
VTKM_EXEC_CONT
@ -273,6 +342,26 @@ struct VTKM_NEVER_EXPORT VecTraits<vtkm::VecC<T>>
vector[component] = value;
}
/// \brief Get a vector of the same type but with a different component.
///
/// This type resolves to another vector with a different component type. For example,
/// vtkm::VecTraits<vtkm::Vec<T, N>>::ReplaceComponentType<T2> is vtkm::Vec<T2, N>.
/// This replacement is not recursive. So VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2>
/// is vtkm::Vec<T2, N>.
///
template <typename NewComponentType>
using ReplaceComponentType = vtkm::VecC<NewComponentType>;
/// \brief Get a vector of the same type but with a different base component.
///
/// This type resolves to another vector with a different base component type. The replacement
/// is recursive for nested types. For example,
/// VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2> is Vec<Vec<T2, M>, N>.
///
template <typename NewComponentType>
using ReplaceBaseComponentType = vtkm::VecC<
typename vtkm::VecTraits<ComponentType>::template ReplaceBaseComponentType<NewComponentType>>;
/// Converts whatever type this vector is into the standard VTKm Tuple.
///
template <vtkm::IdComponent destSize>
@ -287,10 +376,19 @@ struct VTKM_NEVER_EXPORT VecTraits<vtkm::VecCConst<T>>
{
using VecType = vtkm::VecCConst<T>;
/// Type of the components in the vector.
/// \brief Type of the components in the vector.
///
/// If the type is really a scalar, then the component type is the same as the scalar type.
///
using ComponentType = typename VecType::ComponentType;
/// \brief Base component type in the vector.
///
/// Similar to ComponentType except that for nested vectors (e.g. Vec<Vec<T, M>, N>), it
/// returns the base scalar type at the end of the composition (T in this example).
///
using BaseComponentType = typename vtkm::VecTraits<ComponentType>::BaseComponentType;
/// Number of components in the given vector.
///
VTKM_EXEC_CONT
@ -333,6 +431,26 @@ struct VTKM_NEVER_EXPORT VecTraits<vtkm::VecCConst<T>>
vector[component] = value;
}
/// \brief Get a vector of the same type but with a different component.
///
/// This type resolves to another vector with a different component type. For example,
/// vtkm::VecTraits<vtkm::Vec<T, N>>::ReplaceComponentType<T2> is vtkm::Vec<T2, N>.
/// This replacement is not recursive. So VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2>
/// is vtkm::Vec<T2, N>.
///
template <typename NewComponentType>
using ReplaceComponentType = vtkm::VecCConst<NewComponentType>;
/// \brief Get a vector of the same type but with a different base component.
///
/// This type resolves to another vector with a different base component type. The replacement
/// is recursive for nested types. For example,
/// VecTraits<Vec<Vec<T, M>, N>::ReplaceComponentType<T2> is Vec<Vec<T2, M>, N>.
///
template <typename NewComponentType>
using ReplaceBaseComponentType = vtkm::VecCConst<
typename vtkm::VecTraits<ComponentType>::template ReplaceBaseComponentType<NewComponentType>>;
/// Converts whatever type this vector is into the standard VTKm Tuple.
///
template <vtkm::IdComponent destSize>
@ -350,6 +468,7 @@ template <typename ScalarType>
struct VTKM_NEVER_EXPORT VecTraitsBasic
{
using ComponentType = ScalarType;
using BaseComponentType = ScalarType;
static constexpr vtkm::IdComponent NUM_COMPONENTS = 1;
using HasMultipleComponents = vtkm::VecTraitsTagSingleComponent;
using IsSizeStatic = vtkm::VecTraitsTagSizeStatic;
@ -372,6 +491,12 @@ struct VTKM_NEVER_EXPORT VecTraitsBasic
vector = value;
}
template <typename NewComponentType>
using ReplaceComponentType = NewComponentType;
template <typename NewComponentType>
using ReplaceBaseComponentType = NewComponentType;
template <vtkm::IdComponent destSize>
VTKM_EXEC_CONT static void CopyInto(const ScalarType& src, vtkm::Vec<ScalarType, destSize>& dest)
{

@ -103,6 +103,7 @@ struct VecTraits<vtkm::VecVariable<T, MaxSize>>
using VecType = vtkm::VecVariable<T, MaxSize>;
using ComponentType = typename VecType::ComponentType;
using BaseComponentType = typename vtkm::VecTraits<ComponentType>::BaseComponentType;
using HasMultipleComponents = vtkm::VecTraitsTagMultipleComponents;
using IsSizeStatic = vtkm::VecTraitsTagSizeVariable;
@ -131,6 +132,14 @@ struct VecTraits<vtkm::VecVariable<T, MaxSize>>
vector[componentIndex] = value;
}
template <typename NewComponentType>
using ReplaceComponentType = vtkm::VecVariable<NewComponentType, MaxSize>;
template <typename NewComponentType>
using ReplaceBaseComponentType = vtkm::VecVariable<
typename vtkm::VecTraits<ComponentType>::template ReplaceBaseComponentType<NewComponentType>,
MaxSize>;
template <vtkm::IdComponent destSize>
VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
{

@ -14,8 +14,8 @@
#include <vtkm/cont/Logging.h>
#include <vtkm/BaseComponent.h>
#include <vtkm/Range.h>
#include <vtkm/VecTraits.h>
#include <limits>
@ -70,8 +70,8 @@ private:
{
#ifdef VTKM_ENABLE_LOGGING
using DstValueType = T;
using SrcComp = typename vtkm::BaseComponent<SrcValueType>::Type;
using DstComp = typename vtkm::BaseComponent<DstValueType>::Type;
using SrcComp = typename vtkm::VecTraits<SrcValueType>::BaseComponentType;
using DstComp = typename vtkm::VecTraits<DstValueType>::BaseComponentType;
using SrcLimits = std::numeric_limits<SrcComp>;
using DstLimits = std::numeric_limits<DstComp>;

@ -41,6 +41,7 @@ struct ArrayPortalMultiplexerGetNumberOfValuesFunctor
struct ArrayPortalMultiplexerGetFunctor
{
VTKM_SUPPRESS_EXEC_WARNINGS
template <typename PortalType>
VTKM_EXEC_CONT typename PortalType::ValueType operator()(const PortalType& portal,
vtkm::Id index) const noexcept
@ -51,6 +52,7 @@ struct ArrayPortalMultiplexerGetFunctor
struct ArrayPortalMultiplexerSetFunctor
{
VTKM_SUPPRESS_EXEC_WARNINGS
template <typename PortalType>
VTKM_EXEC_CONT void operator()(const PortalType& portal,
vtkm::Id index,
@ -211,6 +213,20 @@ public:
{
}
VTKM_CONT bool IsValid() const { return this->ArrayHandleVariant.IsValid(); }
template <typename S>
VTKM_CONT void SetArray(vtkm::cont::ArrayHandle<ValueType, S>&& rhs)
{
this->ArrayHandleVariant = std::move(rhs);
}
template <typename S>
VTKM_CONT void SetArray(const vtkm::cont::ArrayHandle<ValueType, S>& src)
{
this->ArrayHandleVariant = src;
}
private:
struct GetPortalFunctor
{
@ -243,22 +259,56 @@ public:
VTKM_CONT vtkm::Id GetNumberOfValues() const
{
return this->ArrayHandleVariant.CastAndCall(detail::MultiplexerGetNumberOfValuesFunctor{});
if (this->IsValid())
{
return this->ArrayHandleVariant.CastAndCall(detail::MultiplexerGetNumberOfValuesFunctor{});
}
else
{
return 0;
}
}
VTKM_CONT void Allocate(vtkm::Id numberOfValues)
{
this->ArrayHandleVariant.CastAndCall(detail::MultiplexerAllocateFunctor{}, numberOfValues);
if (this->IsValid())
{
this->ArrayHandleVariant.CastAndCall(detail::MultiplexerAllocateFunctor{}, numberOfValues);
}
else if (numberOfValues > 0)
{
throw vtkm::cont::ErrorBadValue(
"Attempted to allocate an ArrayHandleMultiplexer with no underlying array.");
}
else
{
// Special case, OK to perform "0" allocation on invalid array.
}
}
VTKM_CONT void Shrink(vtkm::Id numberOfValues)
{
this->ArrayHandleVariant.CastAndCall(detail::MultiplexerShrinkFunctor{}, numberOfValues);
if (this->IsValid())
{
this->ArrayHandleVariant.CastAndCall(detail::MultiplexerShrinkFunctor{}, numberOfValues);
}
else if (numberOfValues > 0)
{
throw vtkm::cont::ErrorBadValue(
"Attempted to allocate an ArrayHandleMultiplexer with no underlying array.");
}
else
{
// Special case, OK to perform "0" allocation on invalid array.
}
}
VTKM_CONT void ReleaseResources()
{
this->ArrayHandleVariant.CastAndCall(detail::MultiplexerReleaseResourcesFunctor{});
if (this->IsValid())
{
this->ArrayHandleVariant.CastAndCall(detail::MultiplexerReleaseResourcesFunctor{});
}
}
VTKM_CONT ArrayHandleVariantType& GetArrayHandleVariant() { return this->ArrayHandleVariant; }
@ -462,8 +512,31 @@ public:
: Superclass(StorageType(std::move(rhs)))
{
}
VTKM_CONT bool IsValid() const { return this->GetStorage().IsValid(); }
template <typename S>
VTKM_CONT void SetArray(vtkm::cont::ArrayHandle<ValueType, S>&& rhs)
{
this->GetStorage().SetArray(std::move(rhs));
}
template <typename S>
VTKM_CONT void SetArray(const vtkm::cont::ArrayHandle<ValueType, S>& src)
{
this->GetStorage().SetArray(src);
}
};
/// \brief Converts a \c vtkm::ListTag to an \c ArrayHandleMultiplexer
///
/// The argument of this template must be a vtkm::ListTag and furthermore all the types in
/// the list tag must be some type of \c ArrayHandle. The templated type gets aliased to
/// an \c ArrayHandleMultiplexer that can store any of these ArrayHandle types.
///
template <typename ListTag>
using ArrayHandleMultiplexerFromListTag = vtkm::ListTagApply<ListTag, ArrayHandleMultiplexer>;
} // namespace cont
} // namespace vtkm

@ -12,7 +12,7 @@
#include <vtkm/internal/IndicesExtrude.h>
#include <vtkm/BaseComponent.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/ErrorBadType.h>
@ -371,7 +371,7 @@ struct VTKM_ALWAYS_EXPORT StorageTagExtrude
template <typename T>
class Storage<T, internal::StorageTagExtrude>
{
using BaseT = typename BaseComponent<T>::Type;
using BaseT = typename VecTraits<T>::BaseComponentType;
using HandleType = vtkm::cont::ArrayHandle<BaseT>;
using TPortalType = typename HandleType::PortalConstControl;
@ -461,7 +461,7 @@ private:
template <typename T, typename Device>
class VTKM_ALWAYS_EXPORT ArrayTransfer<T, internal::StorageTagExtrude, Device>
{
using BaseT = typename BaseComponent<T>::Type;
using BaseT = typename VecTraits<T>::BaseComponentType;
using TPortalType = decltype(vtkm::cont::ArrayHandle<BaseT>{}.PrepareForInput(Device{}));
public:

@ -15,8 +15,9 @@
#include <vtkm/TypeListTag.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/ArrayHandleMultiplexer.h>
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/ArrayHandleVirtual.h>
#include <vtkm/cont/CastAndCall.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/Logging.h>
@ -143,6 +144,28 @@ public:
return output;
}
/// Returns this array cast to a \c ArrayHandleMultiplexer of the given type.
/// This will attempt to cast the internal array to each supported type of
/// the multiplexer. If none are supported, an invalid ArrayHandleMultiplexer
/// is returned.
///
/// As a special case, if one of the arrays in the \c ArrayHandleMultiplexer's
/// type list is an \c ArrayHandleCast, then the multiplexer will look for type
/// type of array being cast rather than an actual cast array.
///
///@{
template <typename... T>
VTKM_CONT void AsMultiplexer(vtkm::cont::ArrayHandleMultiplexer<T...>& result) const;
template <typename ArrayHandleMultiplexerType>
VTKM_CONT ArrayHandleMultiplexerType AsMultiplexer() const
{
ArrayHandleMultiplexerType result;
this->AsMultiplexer(result);
return result;
}
///@}
/// Given a references to an ArrayHandle object, casts this array to the
/// ArrayHandle's type and sets the given ArrayHandle to this array. Throws
/// \c ErrorBadType if the cast does not work. Use \c
@ -297,6 +320,9 @@ VTKM_CONT inline ArrayHandleType Cast(const vtkm::cont::VariantArrayHandleBase<T
return variant.template Cast<ArrayHandleType>();
}
//=============================================================================
// Out of class implementations
namespace detail
{
@ -422,6 +448,100 @@ VTKM_CONT void VariantArrayHandleBase<TypeList>::CastAndCallImpl(std::true_type,
}
}
namespace detail
{
struct VariantArrayHandleTryMultiplexer
{
template <typename T, typename Storage, typename... TypeList, typename... ArrayTypes>
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, Storage>&,
const vtkm::cont::VariantArrayHandleBase<TypeList...>& self,
vtkm::cont::ArrayHandleMultiplexer<ArrayTypes...>& result) const
{
vtkm::cont::ArrayHandle<T, Storage> targetArray;
bool foundArray = false;
this->FetchArray(targetArray, self, foundArray, result.IsValid());
if (foundArray)
{
result.SetArray(targetArray);
}
}
private:
template <typename T, typename Storage, typename... TypeList>
VTKM_CONT void FetchArrayExact(vtkm::cont::ArrayHandle<T, Storage>& targetArray,
const vtkm::cont::VariantArrayHandleBase<TypeList...>& self,
bool& foundArray) const
{
using ArrayType = vtkm::cont::ArrayHandle<T, Storage>;
if (self.template IsType<ArrayType>())
{
targetArray = self.template Cast<ArrayType>();
foundArray = true;
}
else
{
foundArray = false;
}
}
template <typename T, typename Storage, typename... TypeList>
VTKM_CONT void FetchArray(vtkm::cont::ArrayHandle<T, Storage>& targetArray,
const vtkm::cont::VariantArrayHandleBase<TypeList...>& self,
bool& foundArray,
bool vtkmNotUsed(foundArrayInPreviousCall)) const
{
this->FetchArrayExact(targetArray, self, foundArray);
}
// Special condition for transformed arrays (including cast arrays). Instead of pulling out the
// transform, pull out the array that is being transformed.
template <typename T,
typename SrcArray,
typename ForwardTransform,
typename ReverseTransform,
typename... TypeList>
VTKM_CONT void FetchArray(
vtkm::cont::ArrayHandle<
T,
vtkm::cont::internal::StorageTagTransform<SrcArray, ForwardTransform, ReverseTransform>>&
targetArray,
const vtkm::cont::VariantArrayHandleBase<TypeList...>& self,
bool& foundArray,
bool foundArrayInPreviousCall) const
{
// Attempt to get the array itself first
this->FetchArrayExact(targetArray, self, foundArray);
// Try to get the array to be transformed first, but only do so if the array was not already
// found in another call to this functor. This is to give precedence to getting the array
// exactly rather than creating our own transform.
if (!foundArray && !foundArrayInPreviousCall)
{
SrcArray srcArray;
this->FetchArray(srcArray, self, foundArray, foundArrayInPreviousCall);
if (foundArray)
{
targetArray =
vtkm::cont::ArrayHandleTransform<SrcArray, ForwardTransform, ReverseTransform>(srcArray);
}
}
}
};
} // namespace detail
template <typename TypeList>
template <typename... T>
inline VTKM_CONT void VariantArrayHandleBase<TypeList>::AsMultiplexer(
vtkm::cont::ArrayHandleMultiplexer<T...>& result) const
{
// Make sure IsValid is clear
result = vtkm::cont::ArrayHandleMultiplexer<T...>{};
vtkm::ListForEach(
detail::VariantArrayHandleTryMultiplexer{}, vtkm::ListTagBase<T...>{}, *this, result);
}
namespace internal
{

@ -51,7 +51,6 @@ set(unit_tests
UnitTestArrayHandleUniformPointCoordinates.cxx
UnitTestArrayHandleConcatenate.cxx
UnitTestArrayHandleVirtual.cxx
UnitTestVariantArrayHandle.cxx
UnitTestArrayPortalToIterators.cxx
UnitTestCellLocatorGeneral.cxx
UnitTestCellSet.cxx
@ -81,6 +80,7 @@ set(unit_tests
UnitTestStorageListTag.cxx
UnitTestTimer.cxx
UnitTestTryExecute.cxx
UnitTestVariantArrayHandle.cxx
)
vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG)

@ -369,6 +369,62 @@ void TryNewInstance(T, ArrayVariantType originalArray)
CheckArrayVariant(newArray, vtkm::VecTraits<T>::NUM_COMPONENTS, true, false);
}
template <typename T, typename ArrayVariantType>
void TryAsMultiplexer(T, ArrayVariantType sourceArray)
{
auto originalArray = sourceArray.template Cast<vtkm::cont::ArrayHandle<T>>();
{
std::cout << "Get multiplex array through direct type." << std::endl;
using MultiplexerType = vtkm::cont::ArrayHandleMultiplexer<vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandleConstant<T>>;
MultiplexerType multiplexArray = sourceArray.template AsMultiplexer<MultiplexerType>();
VTKM_TEST_ASSERT(multiplexArray.IsValid());
VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.GetPortalConstControl(),
originalArray.GetPortalConstControl()));
}
{
std::cout << "Get multiplex array through cast type." << std::endl;
using CastT = typename vtkm::VecTraits<T>::template ReplaceBaseComponentType<vtkm::Float64>;
using MultiplexerType = vtkm::cont::ArrayHandleMultiplexer<
vtkm::cont::ArrayHandle<CastT>,
vtkm::cont::ArrayHandleCast<CastT, vtkm::cont::ArrayHandle<T>>>;
MultiplexerType multiplexArray = sourceArray.template AsMultiplexer<MultiplexerType>();
VTKM_TEST_ASSERT(multiplexArray.IsValid());
VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.GetPortalConstControl(),
originalArray.GetPortalConstControl()));
}
{
std::cout << "Make sure multiplex array prefers direct array (1st arg)" << std::endl;
using MultiplexerType = vtkm::cont::ArrayHandleMultiplexer<
vtkm::cont::ArrayHandle<T>,
vtkm::cont::ArrayHandleCast<T, vtkm::cont::ArrayHandle<T>>>;
MultiplexerType multiplexArray = sourceArray.template AsMultiplexer<MultiplexerType>();
VTKM_TEST_ASSERT(multiplexArray.IsValid());
VTKM_TEST_ASSERT(multiplexArray.GetStorage().GetArrayHandleVariant().GetIndex() == 0);
VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.GetPortalConstControl(),
originalArray.GetPortalConstControl()));
}
{
std::cout << "Make sure multiplex array prefers direct array (2nd arg)" << std::endl;
using MultiplexerType =
vtkm::cont::ArrayHandleMultiplexer<vtkm::cont::ArrayHandleCast<T, vtkm::cont::ArrayHandle<T>>,
vtkm::cont::ArrayHandle<T>>;
MultiplexerType multiplexArray = sourceArray.template AsMultiplexer<MultiplexerType>();
VTKM_TEST_ASSERT(multiplexArray.IsValid());
VTKM_TEST_ASSERT(multiplexArray.GetStorage().GetArrayHandleVariant().GetIndex() == 1);
VTKM_TEST_ASSERT(test_equal_portals(multiplexArray.GetPortalConstControl(),
originalArray.GetPortalConstControl()));
}
}
template <typename T>
void TryDefaultType(T)
{
@ -377,6 +433,8 @@ void TryDefaultType(T)
CheckArrayVariant(array, vtkm::VecTraits<T>::NUM_COMPONENTS, true, false);
TryNewInstance(T(), array);
TryAsMultiplexer(T(), array);
}
struct TryBasicVTKmType

@ -11,11 +11,11 @@
#define vtk_m_exec_Derivative_h
#include <vtkm/Assert.h>
#include <vtkm/BaseComponent.h>
#include <vtkm/CellShape.h>
#include <vtkm/Math.h>
#include <vtkm/Matrix.h>
#include <vtkm/VecAxisAlignedPointCoordinates.h>
#include <vtkm/VecTraits.h>
#include <vtkm/VectorAnalysis.h>
#include <vtkm/exec/CellInterpolate.h>
@ -341,7 +341,7 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivativeFor2D
CellShapeTag)
{
using FieldType = typename FieldVecType::ComponentType;
using BaseFieldType = typename BaseComponent<FieldType>::Type;
using BaseFieldType = typename vtkm::VecTraits<FieldType>::BaseComponentType;
// We have an underdetermined system in 3D, so create a 2D space in the
// plane that the polygon sits.
@ -523,7 +523,7 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
VTKM_ASSERT(wCoords.GetNumberOfComponents() == 2);
using FieldType = typename FieldVecType::ComponentType;
using BaseComponentType = typename BaseComponent<FieldType>::Type;
using BaseComponentType = typename vtkm::VecTraits<FieldType>::BaseComponentType;
FieldType deltaField(field[1] - field[0]);
vtkm::Vec<BaseComponentType, 3> vec(wCoords[1] - wCoords[0]);
@ -571,7 +571,7 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
}
using FieldType = typename FieldVecType::ComponentType;
using BaseComponentType = typename BaseComponent<FieldType>::Type;
using BaseComponentType = typename vtkm::VecTraits<FieldType>::BaseComponentType;
ParametricCoordType dt;
dt = static_cast<ParametricCoordType>(1) / static_cast<ParametricCoordType>(numPoints - 1);
@ -690,7 +690,7 @@ template <typename ValueType, typename WCoordType>
VTKM_EXEC vtkm::Vec<ValueType, 3> TriangleDerivative(const vtkm::Vec<ValueType, 3>& field,
const vtkm::Vec<WCoordType, 3>& wCoords)
{
using BaseComponentType = typename BaseComponent<ValueType>::Type;
using BaseComponentType = typename vtkm::VecTraits<ValueType>::BaseComponentType;
// The scalar values of the three points in a triangle completely specify a
// linear field (with constant gradient) assuming the field is constant in
@ -998,7 +998,7 @@ template <typename ValueType, typename WorldCoordType>
VTKM_EXEC vtkm::Vec<ValueType, 3> TetraDerivative(const vtkm::Vec<ValueType, 4>& field,
const vtkm::Vec<WorldCoordType, 4>& wCoords)
{
using BaseComponentType = typename BaseComponent<ValueType>::Type;
using BaseComponentType = typename vtkm::VecTraits<ValueType>::BaseComponentType;
// The scalar values of the four points in a tetrahedron completely specify a
// linear field (with constant gradient). The field, defined by the 3-vector

@ -42,7 +42,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
//If the input is implicit, we should know what to fall back to
vtkm::cont::ArrayHandle<T> outArray;
this->Invoke(this->Worklet, vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);
this->Invoke(this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy), inField, outArray);
std::string outputName = this->GetOutputFieldName();
if (outputName.empty())

@ -42,7 +42,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
vtkm::cont::ArrayHandle<T> outArray;
this->Invoke(vtkm::worklet::CellMeasure<IntegrationType>{},
vtkm::filter::ApplyPolicy(cellset, policy),
vtkm::filter::ApplyPolicyCellSet(cellset, policy),
points,
outArray);

@ -34,7 +34,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellSetConnectivity::DoExecute(
vtkm::cont::ArrayHandle<vtkm::Id> component;
vtkm::worklet::connectivity::CellSetConnectivity().Run(
vtkm::filter::ApplyPolicy(input.GetCellSet(), policy), component);
vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy), component);
return CreateResult(input, component, this->GetOutputFieldName(), fieldMetadata);
}

@ -49,7 +49,7 @@ inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::Data
}
else
{ // Clean the grid
auto deducedCellSet = vtkm::filter::ApplyPolicy(inCellSet, policy);
auto deducedCellSet = vtkm::filter::ApplyPolicyCellSet(inCellSet, policy);
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
this->Invoke(worklet::CellDeepCopy::CountCellPoints{}, deducedCellSet, numIndices);

@ -48,7 +48,7 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
vtkm::filter::ApplyPolicy(cells, policy), field, this->ClipValue, this->Invert);
vtkm::filter::ApplyPolicyCellSet(cells, policy), field, this->ClipValue, this->Invert);
//create the output data
vtkm::cont::DataSet output;

@ -35,7 +35,7 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
vtkm::filter::ApplyPolicy(cells, policy), this->Function, inputCoords, this->Invert);
vtkm::filter::ApplyPolicyCellSet(cells, policy), this->Function, inputCoords, this->Invert);
// compute output coordinates
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());

@ -150,7 +150,7 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
{
outputCells = this->Worklet.Run(&ivalues[0],
static_cast<vtkm::Id>(ivalues.size()),
vtkm::filter::ApplyPolicy(cells, policy),
vtkm::filter::ApplyPolicyCellSet(cells, policy),
coords.GetData(),
field,
vertices,
@ -160,7 +160,7 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
{
outputCells = this->Worklet.Run(&ivalues[0],
static_cast<vtkm::Id>(ivalues.size()),
vtkm::filter::ApplyPolicy(cells, policy),
vtkm::filter::ApplyPolicyCellSet(cells, policy),
coords.GetData(),
field,
vertices);

@ -116,7 +116,8 @@ vtkm::cont::DataSet ContourTreePPP2::DoExecute(const vtkm::cont::DataSet& input,
vtkm::Id nCols;
vtkm::Id nSlices = 1;
const auto& cells = input.GetCellSet();
vtkm::filter::ApplyPolicy(cells, policy).CastAndCall(GetRowsColsSlices(), nRows, nCols, nSlices);
vtkm::filter::ApplyPolicyCellSet(cells, policy)
.CastAndCall(GetRowsColsSlices(), nRows, nCols, nSlices);
// Run the worklet
worklet.Run(field,

@ -17,31 +17,6 @@ namespace vtkm
namespace filter
{
namespace detail
{
struct CrossProductFunctor
{
vtkm::cont::Invoker& Invoke;
CrossProductFunctor(vtkm::cont::Invoker& invoke)
: Invoke(invoke)
{
}
template <typename SecondaryFieldType, typename StorageType, typename T>
void operator()(const SecondaryFieldType& secondaryField,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& primaryField,
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>>& output) const
{
this->Invoke(vtkm::worklet::CrossProduct{},
primaryField,
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
output);
}
};
} // namespace detail
//-----------------------------------------------------------------------------
inline VTKM_CONT CrossProduct::CrossProduct()
: vtkm::filter::FilterField<CrossProduct>()
@ -57,40 +32,24 @@ inline VTKM_CONT CrossProduct::CrossProduct()
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet CrossProduct::DoExecute(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& primary,
const vtkm::filter::FieldMetadata& fieldMetadata,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
vtkm::cont::Field secondaryField;
if (this->UseCoordinateSystemAsSecondaryField)
{
secondaryField = inDataSet.GetCoordinateSystem(this->GetSecondaryCoordinateSystemIndex());
}
else
{
secondaryField = inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation);
}
auto secondary =
vtkm::filter::ApplyPolicyFieldOfType<vtkm::Vec<T, 3>>(secondaryField, policy, *this);
detail::CrossProductFunctor functor(this->Invoke);
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> output;
try
{
if (this->UseCoordinateSystemAsSecondaryField)
{
vtkm::cont::CastAndCall(
inDataSet.GetCoordinateSystem(this->GetSecondaryCoordinateSystemIndex()),
functor,
field,
output);
}
else
{
using Traits = vtkm::filter::FilterTraits<CrossProduct>;
using TypeList = vtkm::ListTagBase<vtkm::Vec<T, 3>>;
vtkm::filter::ApplyPolicy(
inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation),
policy,
Traits())
.ResetTypes(TypeList())
.CastAndCall(functor, field, output);
}
}
catch (const vtkm::cont::Error&)
{
throw vtkm::cont::ErrorExecution("failed to execute.");
}
this->Invoke(vtkm::worklet::CrossProduct{}, primary, secondary, output);
return CreateResult(inDataSet, output, this->GetOutputFieldName(), fieldMetadata);
}

@ -15,31 +15,6 @@ namespace vtkm
namespace filter
{
namespace detail
{
struct DotProductFunctor
{
vtkm::cont::Invoker& Invoke;
DotProductFunctor(vtkm::cont::Invoker& invoke)
: Invoke(invoke)
{
}
template <typename SecondaryFieldType, typename StorageType, typename T>
void operator()(const SecondaryFieldType& secondaryField,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& primaryField,
vtkm::cont::ArrayHandle<T>& output) const
{
this->Invoke(vtkm::worklet::DotProduct{},
primaryField,
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
output);
}
};
} // namespace detail
//-----------------------------------------------------------------------------
inline VTKM_CONT DotProduct::DotProduct()
: vtkm::filter::FilterField<DotProduct>()
@ -55,38 +30,24 @@ inline VTKM_CONT DotProduct::DotProduct()
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet DotProduct::DoExecute(
const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& field,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& primary,
const vtkm::filter::FieldMetadata& fieldMetadata,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
detail::DotProductFunctor functor(this->Invoke);
vtkm::cont::Field secondaryField;
if (this->UseCoordinateSystemAsSecondaryField)
{
secondaryField = inDataSet.GetCoordinateSystem(this->GetSecondaryCoordinateSystemIndex());
}
else
{
secondaryField = inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation);
}
auto secondary =
vtkm::filter::ApplyPolicyFieldOfType<vtkm::Vec<T, 3>>(secondaryField, policy, *this);
vtkm::cont::ArrayHandle<T> output;
try
{
if (this->UseCoordinateSystemAsSecondaryField)
{
vtkm::cont::CastAndCall(
inDataSet.GetCoordinateSystem(this->GetSecondaryCoordinateSystemIndex()),
functor,
field,
output);
}
else
{
using Traits = vtkm::filter::FilterTraits<DotProduct>;
using TypeList = vtkm::ListTagBase<vtkm::Vec<T, 3>>;
vtkm::filter::ApplyPolicy(
inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation),
policy,
Traits())
.ResetTypes(TypeList())
.CastAndCall(functor, field, output);
}
}
catch (const vtkm::cont::Error&)
{
throw vtkm::cont::ErrorExecution("failed to execute.");
}
this->Invoke(vtkm::worklet::DotProduct{}, primary, secondary, output);
return CreateResult(inDataSet, output, this->GetOutputFieldName(), fieldMetadata);
}

@ -61,7 +61,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
}
else
{
this->Worklet.Run(vtkm::filter::ApplyPolicyUnstructured(cells, policy), outCellSet);
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(cells, policy), outCellSet);
}
//3. Check the fields of the dataset to see what kinds of fields are present so

@ -90,7 +90,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractGeometry::DoExecute(
this->ExtractInside,
this->ExtractBoundaryCells,
this->ExtractOnlyBoundaryCells);
vtkm::filter::ApplyPolicy(cells, policy).CastAndCall(worker);
vtkm::filter::ApplyPolicyCellSet(cells, policy).CastAndCall(worker);
// create the output dataset
vtkm::cont::DataSet output;

@ -56,7 +56,7 @@ inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& i
vtkm::cont::CellSetSingleType<> outCellSet;
vtkm::worklet::ExtractPoints worklet;
outCellSet = worklet.Run(vtkm::filter::ApplyPolicy(cells, policy),
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
coords.GetData(),
this->Function,
this->ExtractInside);

@ -33,7 +33,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
const vtkm::cont::CoordinateSystem& coordinates = input.GetCoordinateSystem();
auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyStructured(cells, policy),
auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetStructured(cells, policy),
this->VOI,
this->SampleRate,
this->IncludeBoundary,

@ -179,7 +179,6 @@ public:
VTKM_CONT
~Filter();
//@{
/// \brief Specify which subset of types a filter supports.
///
/// A filter is able to state what subset of types it supports
@ -187,6 +186,16 @@ public:
/// filter accepts all types specified by the users provided policy
using SupportedTypes = vtkm::ListTagUniversal;
/// \brief Specify which additional field storage to support.
///
/// When a filter gets a field value from a DataSet, it has to determine what type
/// of storage the array has. Typically this is taken from the policy passed to
/// the filter's execute. In some cases it is useful to support additional types.
/// For example, the filter might make sense to support ArrayHandleIndex or
/// ArrayHandleConstant. If so, the storage of those additional types should be
/// listed here.
using AdditionalFieldStorage = vtkm::ListTagEmpty;
//@{
/// \brief Specify which fields get passed from input to output.
///

@ -58,7 +58,7 @@ inline VTKM_CONT bool FilterDataSet<Derived>::MapFieldOntoOutput(
FunctorType functor(static_cast<Derived*>(this), result, metaData, policy, valid);
using Traits = vtkm::filter::FilterTraits<Derived>;
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicy(field, policy, Traits()), functor);
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyFieldActive(field, policy, Traits()), functor);
//the bool valid will be modified by the map algorithm to hold if the
//mapping occurred or not. If the mapping was good a new field has been

@ -76,7 +76,7 @@ inline VTKM_CONT vtkm::cont::DataSet FilterDataSetWithField<Derived>::PrepareFor
vtkm::cont::DataSet result;
vtkm::cont::CastAndCall(
vtkm::filter::ApplyPolicy(field, policy, vtkm::filter::FilterTraits<Derived>()),
vtkm::filter::ApplyPolicyFieldActive(field, policy, vtkm::filter::FilterTraits<Derived>()),
internal::ResolveFieldTypeAndExecute(),
static_cast<Derived*>(this),
input,
@ -130,7 +130,7 @@ inline VTKM_CONT bool FilterDataSetWithField<Derived>::MapFieldOntoOutput(
using FunctorType = internal::ResolveFieldTypeAndMap<Derived, DerivedPolicy>;
FunctorType functor(static_cast<Derived*>(this), result, metaData, policy, valid);
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicy(field, policy), functor);
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyFieldNotActive(field, policy), functor);
//the bool valid will be modified by the map algorithm to hold if the
//mapping occurred or not. If the mapping was good a new field has been

@ -76,7 +76,7 @@ inline VTKM_CONT vtkm::cont::DataSet FilterField<Derived>::PrepareForExecution(
vtkm::cont::DataSet result;
vtkm::cont::CastAndCall(
vtkm::filter::ApplyPolicy(field, policy, vtkm::filter::FilterTraits<Derived>()),
vtkm::filter::ApplyPolicyFieldActive(field, policy, vtkm::filter::FilterTraits<Derived>()),
internal::ResolveFieldTypeAndExecute(),
static_cast<Derived*>(this),
input,

@ -35,6 +35,7 @@ struct FilterTraits
{
using InputFieldTypeList =
decltype(detail::as_list(std::declval<typename Filter::SupportedTypes>()));
using AdditionalFieldStorage = typename Filter::AdditionalFieldStorage;
};
template <typename DerivedPolicy, typename ListOfTypes>

@ -335,14 +335,14 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
if (this->GetRemoveAllGhost())
{
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicy(cells, policy),
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
field,
fieldMeta.GetAssociation(),
RemoveAllGhosts());
}
else if (this->GetRemoveByType())
{
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicy(cells, policy),
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
field,
fieldMeta.GetAssociation(),
RemoveGhostByType(this->GetRemoveType()));

@ -69,14 +69,14 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
if (this->ComputePointGradient)
{
vtkm::worklet::PointGradient gradient;
outArray =
gradient.Run(vtkm::filter::ApplyPolicy(cells, policy), coords, inField, gradientfields);
outArray = gradient.Run(
vtkm::filter::ApplyPolicyCellSet(cells, policy), coords, inField, gradientfields);
}
else
{
vtkm::worklet::CellGradient gradient;
outArray =
gradient.Run(vtkm::filter::ApplyPolicy(cells, policy), coords, inField, gradientfields);
outArray = gradient.Run(
vtkm::filter::ApplyPolicyCellSet(cells, policy), coords, inField, gradientfields);
}
if (!this->RowOrdering)
{

@ -33,7 +33,7 @@ inline VTKM_CONT vtkm::cont::DataSet ImageConnectivity::DoExecute(
vtkm::cont::ArrayHandle<vtkm::Id> component;
vtkm::worklet::connectivity::ImageConnectivity().Run(
vtkm::filter::ApplyPolicy(input.GetCellSet(), policy), field, component);
vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy), field, component);
auto result = CreateResult(input, component, this->GetOutputFieldName(), fieldMetadata);
return result;

@ -54,7 +54,7 @@ inline VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet&
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
vtkm::cont::DynamicCellSet cellOut;
CallWorklet workletCaller(this->Stride, cellOut, this->Worklet);
vtkm::filter::ApplyPolicy(cells, policy).CastAndCall(workletCaller);
vtkm::filter::ApplyPolicyCellSet(cells, policy).CastAndCall(workletCaller);
// create the output dataset
vtkm::cont::DataSet output;

@ -52,7 +52,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(
vtkm::cont::CellSetSingleType<> outCellSet;
vtkm::worklet::MaskPoints worklet;
outCellSet = worklet.Run(vtkm::filter::ApplyPolicy(cells, policy), this->Stride);
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), this->Stride);
// create the output dataset
vtkm::cont::DataSet output;

@ -114,7 +114,7 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(
vtkm::cont::ArrayHandle<T> outArray;
vtkm::cont::ArrayHandle<CellMetric> cellMetrics = vtkm::cont::make_ArrayHandle(CellTypeMetrics);
this->Invoke(QualityWorklet{},
vtkm::filter::ApplyPolicy(cellSet, policy),
vtkm::filter::ApplyPolicyCellSet(cellSet, policy),
cellShapeCounts,
cellMetrics,
points,

@ -48,14 +48,15 @@ inline VTKM_CONT vtkm::cont::DataSet NDHistogram::DoExecute(const vtkm::cont::Da
// Add field one by one
// (By using AddFieldAndBin(), the length of FieldNames and NumOfBins must be the same)
for (size_t i = 0; i < FieldNames.size(); i++)
for (size_t i = 0; i < this->FieldNames.size(); i++)
{
vtkm::Range rangeField;
vtkm::Float64 deltaField;
ndHistogram.AddField(vtkm::filter::ApplyPolicy(inData.GetField(FieldNames[i]), policy),
NumOfBins[i],
rangeField,
deltaField);
ndHistogram.AddField(
vtkm::filter::ApplyPolicyFieldNotActive(inData.GetField(this->FieldNames[i]), policy),
this->NumOfBins[i],
rangeField,
deltaField);
DataRanges.push_back(rangeField);
BinDeltas.push_back(deltaField);
}
@ -67,7 +68,7 @@ inline VTKM_CONT vtkm::cont::DataSet NDHistogram::DoExecute(const vtkm::cont::Da
vtkm::cont::DataSet outputData;
for (size_t i = 0; i < binIds.size(); i++)
{
outputData.AddField(vtkm::cont::make_FieldPoint(FieldNames[i], binIds[i]));
outputData.AddField(vtkm::cont::make_FieldPoint(this->FieldNames[i], binIds[i]));
}
outputData.AddField(vtkm::cont::make_FieldPoint("Frequency", freqs));

@ -41,7 +41,7 @@ inline VTKM_CONT vtkm::cont::DataSet PointAverage::DoExecute(
//todo: we need to ask the policy what storage type we should be using
//If the input is implicit, we should know what to fall back to
vtkm::cont::ArrayHandle<T> outArray;
this->Invoke(this->Worklet, vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);
this->Invoke(this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy), inField, outArray);
std::string outputName = this->GetOutputFieldName();
if (outputName.empty())

@ -32,30 +32,251 @@ template <typename Derived>
struct PolicyBase
{
using FieldTypeList = VTKM_DEFAULT_TYPE_LIST_TAG;
using StorageList = vtkm::ListTagJoin<
VTKM_DEFAULT_STORAGE_LIST_TAG,
vtkm::ListTagBase<
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32>,
vtkm::cont::ArrayHandle<vtkm::Float32>>::StorageTag,
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<vtkm::Float64>,
vtkm::cont::ArrayHandle<vtkm::Float64>,
vtkm::cont::ArrayHandle<vtkm::Float64>>::StorageTag>>;
using StructuredCellSetList = vtkm::cont::CellSetListTagStructured;
using UnstructuredCellSetList = vtkm::cont::CellSetListTagUnstructured;
using AllCellSetList = VTKM_DEFAULT_CELL_SET_LIST_TAG;
};
namespace internal
{
namespace detail
{
// Given a base type, forms a list of all types with the same Vec structure but with the
// base component replaced with each of the basic C types.
template <typename BaseType>
struct AllCastingTypes
{
using VTraits = vtkm::VecTraits<BaseType>;
using type =
vtkm::ListTagBase<typename VTraits::template ReplaceBaseComponentType<vtkm::Int8>,
typename VTraits::template ReplaceBaseComponentType<vtkm::UInt8>,
typename VTraits::template ReplaceBaseComponentType<vtkm::Int16>,
typename VTraits::template ReplaceBaseComponentType<vtkm::UInt8>,
typename VTraits::template ReplaceBaseComponentType<vtkm::Int32>,
typename VTraits::template ReplaceBaseComponentType<vtkm::UInt32>,
typename VTraits::template ReplaceBaseComponentType<vtkm::Int64>,
typename VTraits::template ReplaceBaseComponentType<vtkm::UInt64>,
typename VTraits::template ReplaceBaseComponentType<vtkm::Float32>,
typename VTraits::template ReplaceBaseComponentType<vtkm::Float64>>;
};
template <typename TargetT, typename SourceT, typename Storage, bool Valid>
struct CastArrayIfValid;
template <typename TargetT, typename SourceT, typename Storage>
struct CastArrayIfValid<TargetT, SourceT, Storage, true>
{
using type = vtkm::cont::ArrayHandleCast<TargetT, vtkm::cont::ArrayHandle<SourceT, Storage>>;
};
template <typename TargetT, typename SourceT, typename Storage>
struct CastArrayIfValid<TargetT, SourceT, Storage, false>
{
using type = vtkm::cont::ArrayHandleDiscard<TargetT>;
};
// Provides a transform template that builds a cast from an array of some source type to a
// cast array to a specific target type.
template <typename TargetT, typename Storage>
struct CastArrayTransform
{
template <typename SourceT>
using Transform = typename CastArrayIfValid<
TargetT,
SourceT,
Storage,
vtkm::cont::internal::IsValidArrayHandle<SourceT, Storage>::value>::type;
};
template <typename TargetT, typename Storage, bool Valid>
struct AllCastArraysForStorageImpl;
template <typename TargetT, typename Storage>
struct AllCastArraysForStorageImpl<TargetT, Storage, true>
{
using SourceTypes = typename AllCastingTypes<TargetT>::type;
using type = vtkm::ListTagJoin<
vtkm::ListTagBase<vtkm::cont::ArrayHandle<TargetT, Storage>>,
vtkm::ListTagTransform<SourceTypes, CastArrayTransform<TargetT, Storage>::template Transform>>;
};
template <typename TargetT, typename Storage>
struct AllCastArraysForStorageImpl<TargetT, Storage, false>
{
using SourceTypes = typename AllCastingTypes<TargetT>::type;
using type =
vtkm::ListTagTransform<SourceTypes, CastArrayTransform<TargetT, Storage>::template Transform>;
};
// Special cases for known storage with limited type support.
template <>
struct AllCastArraysForStorageImpl<vtkm::Vec3f,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
true>
{
using type = vtkm::ListTagBase<vtkm::cont::ArrayHandleUniformPointCoordinates>;
};
template <typename T>
struct AllCastArraysForStorageImpl<vtkm::Vec<T, 3>,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
false>
{
using type = vtkm::ListTagBase<vtkm::cont::ArrayHandleCast<
vtkm::Vec<T, 3>,
vtkm::cont::ArrayHandle<vtkm::Vec3f,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag>>>;
};
template <typename TargetT>
struct AllCastArraysForStorageImpl<TargetT,
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
false>
{
using type = vtkm::ListTagEmpty;
};
template <typename T, typename S1, typename S2, typename S3>
struct AllCastArraysForStorageImpl<
vtkm::Vec<T, 3>,
vtkm::cont::internal::StorageTagCartesianProduct<vtkm::cont::ArrayHandle<T, S1>,
vtkm::cont::ArrayHandle<T, S2>,
vtkm::cont::ArrayHandle<T, S3>>,
true>
{
using type =
vtkm::ListTagBase<vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<T, S1>,
vtkm::cont::ArrayHandle<T, S2>,
vtkm::cont::ArrayHandle<T, S3>>>;
};
template <typename TargetT, typename SourceT, typename S1, typename S2, typename S3>
struct AllCastArraysForStorageImpl<
vtkm::Vec<TargetT, 3>,
vtkm::cont::internal::StorageTagCartesianProduct<vtkm::cont::ArrayHandle<SourceT, S1>,
vtkm::cont::ArrayHandle<SourceT, S2>,
vtkm::cont::ArrayHandle<SourceT, S3>>,
false>
{
using type = vtkm::ListTagBase<vtkm::cont::ArrayHandleCast<
vtkm::Vec<TargetT, 3>,
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<SourceT, S1>,
vtkm::cont::ArrayHandle<SourceT, S2>,
vtkm::cont::ArrayHandle<SourceT, S3>>>>;
};
template <typename TargetT, typename SourceT, typename S1, typename S2, typename S3>
struct AllCastArraysForStorageImpl<
TargetT,
vtkm::cont::internal::StorageTagCartesianProduct<vtkm::cont::ArrayHandle<SourceT, S1>,
vtkm::cont::ArrayHandle<SourceT, S2>,
vtkm::cont::ArrayHandle<SourceT, S3>>,
false>
{
using type = vtkm::ListTagEmpty;
};
// Given a target type and storage of an array handle, provides a list this array handle plus all
// array handles that can be cast to the target type wrapped in an ArrayHandleCast that does so.
template <typename TargetT, typename Storage>
struct AllCastArraysForStorage
{
using SourceTypes = typename AllCastingTypes<TargetT>::type;
using type = typename AllCastArraysForStorageImpl<
TargetT,
Storage,
vtkm::cont::internal::IsValidArrayHandle<TargetT, Storage>::value>::type;
};
// Provides a transform template that converts a storage type to a list of all arrays that come
// from that storage type and can be cast to a target type (wrapped in an ArrayHandleCast as
// appropriate).
template <typename TargetT>
struct AllCastArraysTransform
{
template <typename Storage>
using Transform = typename AllCastArraysForStorage<TargetT, Storage>::type;
};
// Given a target type and a list of storage types, provides a joined list of all possible arrays
// of any of these storage cast to the target type.
template <typename TargetT, typename StorageList>
struct AllCastArraysForStorageList
{
VTKM_IS_LIST_TAG(StorageList);
using listOfLists =
vtkm::ListTagTransform<StorageList, AllCastArraysTransform<TargetT>::template Transform>;
using type = vtkm::ListTagApply<listOfLists, vtkm::ListTagJoin>;
};
} // detail
template <typename TargetT, typename StorageList>
using ArrayHandleMultiplexerForStorageList = vtkm::cont::ArrayHandleMultiplexerFromListTag<
typename detail::AllCastArraysForStorageList<TargetT, StorageList>::type>;
} // namespace internal
//-----------------------------------------------------------------------------
/// \brief Get an array from a `Field` that is not the active field.
///
/// Use this form for getting a `Field` when you don't know the type and it is not
/// (necessarily) the "active" field of the filter. It is generally used for arrays
/// passed to the `DoMapField` method of filters.
///
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::VariantArrayHandleBase<typename DerivedPolicy::FieldTypeList> ApplyPolicy(
const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
VTKM_CONT vtkm::cont::VariantArrayHandleBase<typename DerivedPolicy::FieldTypeList>
ApplyPolicyFieldNotActive(const vtkm::cont::Field& field, vtkm::filter::PolicyBase<DerivedPolicy>)
{
using TypeList = typename DerivedPolicy::FieldTypeList;
return field.GetData().ResetTypes(TypeList());
}
//-----------------------------------------------------------------------------
/// \brief Get an `ArrayHandle` of a specific type from a `Field`.
///
/// Use this form of `ApplyPolicy` when you know what the value type of a field is or
/// (more likely) there is a type you are going to cast it to anyway.
///
template <typename T, typename DerivedPolicy, typename FilterType>
VTKM_CONT internal::ArrayHandleMultiplexerForStorageList<
T,
vtkm::ListTagJoin<typename vtkm::filter::FilterTraits<FilterType>::AdditionalFieldStorage,
typename DerivedPolicy::StorageList>>
ApplyPolicyFieldOfType(const vtkm::cont::Field& field,
vtkm::filter::PolicyBase<DerivedPolicy>,
const FilterType&)
{
using ArrayHandleMultiplexerType = internal::ArrayHandleMultiplexerForStorageList<
T,
vtkm::ListTagJoin<typename FilterType::AdditionalFieldStorage,
typename DerivedPolicy::StorageList>>;
return field.GetData().AsMultiplexer<ArrayHandleMultiplexerType>();
}
//-----------------------------------------------------------------------------
/// \brief Get an array from a `Field` that follows the types of an active field.
///
/// Use this form for getting a `Field` to build the types that are appropriate for
/// the active field of this filter.
///
template <typename DerivedPolicy, typename FilterType>
VTKM_CONT vtkm::cont::VariantArrayHandleBase<typename vtkm::filter::DeduceFilterFieldTypes<
DerivedPolicy,
typename vtkm::filter::FilterTraits<FilterType>::InputFieldTypeList>::TypeList>
ApplyPolicy(const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const vtkm::filter::FilterTraits<FilterType>&)
ApplyPolicyFieldActive(const vtkm::cont::Field& field,
vtkm::filter::PolicyBase<DerivedPolicy>,
vtkm::filter::FilterTraits<FilterType>)
{
using FilterTypes = typename vtkm::filter::FilterTraits<FilterType>::InputFieldTypeList;
using TypeList =
@ -63,44 +284,59 @@ ApplyPolicy(const vtkm::cont::Field& field,
return field.GetData().ResetTypes(TypeList());
}
//-----------------------------------------------------------------------------
template <typename DerivedPolicy, typename ListOfTypes>
VTKM_CONT vtkm::cont::VariantArrayHandleBase<
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, ListOfTypes>::TypeList>
ApplyPolicy(const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const ListOfTypes&)
{
using TypeList =
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, ListOfTypes>::TypeList;
return field.GetData().ResetTypes(TypeList());
}
////-----------------------------------------------------------------------------
///// \brief Get an array from a `Field` limited to a given set of types.
/////
//template <typename DerivedPolicy, typename ListOfTypes>
//VTKM_CONT vtkm::cont::VariantArrayHandleBase<
// typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, ListOfTypes>::TypeList>
//ApplyPolicyFieldOfTypes(
// const vtkm::cont::Field& field, vtkm::filter::PolicyBase<DerivedPolicy>, ListOfTypes)
//{
// using TypeList =
// typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, ListOfTypes>::TypeList;
// return field.GetData().ResetTypes(TypeList());
//}
//-----------------------------------------------------------------------------
/// \brief Ge a cell set from a `DynamicCellSet` object.
///
/// Adjusts the types of `CellSet`s to support those types specified in a policy.
///
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::AllCellSetList> ApplyPolicy(
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::AllCellSetList> ApplyPolicyCellSet(
const vtkm::cont::DynamicCellSet& cellset,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
vtkm::filter::PolicyBase<DerivedPolicy>)
{
using CellSetList = typename DerivedPolicy::AllCellSetList;
return cellset.ResetCellSetList(CellSetList());
}
//-----------------------------------------------------------------------------
/// \brief Get a structured cell set from a `DynamicCellSet` object.
///
/// Adjusts the types of `CellSet`s to support those structured cell set types
/// specified in a policy.
///
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::StructuredCellSetList>
ApplyPolicyStructured(const vtkm::cont::DynamicCellSet& cellset,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
ApplyPolicyCellSetStructured(const vtkm::cont::DynamicCellSet& cellset,
vtkm::filter::PolicyBase<DerivedPolicy>)
{
using CellSetList = typename DerivedPolicy::StructuredCellSetList;
return cellset.ResetCellSetList(CellSetList());
}
//-----------------------------------------------------------------------------
/// \brief Get an unstructured cell set from a `DynamicCellSet` object.
///
/// Adjusts the types of `CellSet`s to support those unstructured cell set types
/// specified in a policy.
///
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::UnstructuredCellSetList>
ApplyPolicyUnstructured(const vtkm::cont::DynamicCellSet& cellset,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
ApplyPolicyCellSetUnstructured(const vtkm::cont::DynamicCellSet& cellset,
vtkm::filter::PolicyBase<DerivedPolicy>)
{
using CellSetList = typename DerivedPolicy::UnstructuredCellSetList;
return cellset.ResetCellSetList(CellSetList());
@ -109,15 +345,14 @@ ApplyPolicyUnstructured(const vtkm::cont::DynamicCellSet& cellset,
//-----------------------------------------------------------------------------
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList>
MakeSerializableField(const vtkm::filter::PolicyBase<DerivedPolicy>&)
MakeSerializableField(vtkm::filter::PolicyBase<DerivedPolicy>)
{
return {};
}
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList>
MakeSerializableField(const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
MakeSerializableField(const vtkm::cont::Field& field, vtkm::filter::PolicyBase<DerivedPolicy>)
{
return vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList>{ field };
}
@ -125,7 +360,7 @@ MakeSerializableField(const vtkm::cont::Field& field,
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::AllCellSetList>
MakeSerializableDataSet(const vtkm::filter::PolicyBase<DerivedPolicy>&)
MakeSerializableDataSet(vtkm::filter::PolicyBase<DerivedPolicy>)
{
return {};
}
@ -133,8 +368,7 @@ MakeSerializableDataSet(const vtkm::filter::PolicyBase<DerivedPolicy>&)
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::AllCellSetList>
MakeSerializableDataSet(const vtkm::cont::DataSet& dataset,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
MakeSerializableDataSet(const vtkm::cont::DataSet& dataset, vtkm::filter::PolicyBase<DerivedPolicy>)
{
return vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::AllCellSetList>{ dataset };

@ -26,14 +26,14 @@ VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
this->Worklet.Run(vtkm::filter::ApplyPolicy(input.GetCellSet(), policy),
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy),
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
this->Geometry.GetCoordinateSystem().GetData());
auto output = this->Geometry;
auto hpf = this->Worklet.GetHiddenPointsField();
auto hcf =
this->Worklet.GetHiddenCellsField(vtkm::filter::ApplyPolicy(output.GetCellSet(), policy));
auto hcf = this->Worklet.GetHiddenCellsField(
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy));
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));

@ -38,7 +38,7 @@ inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute(
vtkm::cont::ArrayHandle<vtkm::Vec3f> newCoords;
vtkm::cont::CellSetExplicit<> newCellset;
this->Worklet.Run(vtkm::filter::ApplyPolicy(cells, policy),
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
this->FeatureAngle,
field,
input.GetCoordinateSystem().GetData(),

@ -83,7 +83,7 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute(
throw vtkm::cont::ErrorFilterExecution("No normals selected.");
}
const auto cellset = vtkm::filter::ApplyPolicyUnstructured(input.GetCellSet(), policy);
const auto cellset = vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy);
const auto& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetData();
vtkm::cont::ArrayHandle<vtkm::Vec3f> faceNormals;

@ -44,7 +44,7 @@ inline VTKM_CONT vtkm::cont::DataSet Tetrahedralize::DoExecute(
vtkm::cont::CellSetSingleType<> outCellSet;
vtkm::cont::CastAndCall(
vtkm::filter::ApplyPolicy(cells, policy), DeduceCellSet{}, this->Worklet, outCellSet);
vtkm::filter::ApplyPolicyCellSet(cells, policy), DeduceCellSet{}, this->Worklet, outCellSet);
// create the output dataset
vtkm::cont::DataSet output;

@ -65,7 +65,7 @@ inline VTKM_CONT vtkm::cont::DataSet Threshold::DoExecute(
ThresholdRange predicate(this->GetLowerThreshold(), this->GetUpperThreshold());
vtkm::cont::DynamicCellSet cellOut = this->Worklet.Run(
vtkm::filter::ApplyPolicy(cells, policy), field, fieldMeta.GetAssociation(), predicate);
vtkm::filter::ApplyPolicyCellSet(cells, policy), field, fieldMeta.GetAssociation(), predicate);
vtkm::cont::DataSet output;
output.SetCellSet(cellOut);

@ -159,20 +159,22 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(
{
case THRESHOLD_BELOW:
{
outCellSet = worklet.Run(
vtkm::filter::ApplyPolicy(cells, policy), field, ValuesBelow(this->GetLowerThreshold()));
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
field,
ValuesBelow(this->GetLowerThreshold()));
break;
}
case THRESHOLD_ABOVE:
{
outCellSet = worklet.Run(
vtkm::filter::ApplyPolicy(cells, policy), field, ValuesAbove(this->GetUpperThreshold()));
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
field,
ValuesAbove(this->GetUpperThreshold()));
break;
}
case THRESHOLD_BETWEEN:
default:
{
outCellSet = worklet.Run(vtkm::filter::ApplyPolicy(cells, policy),
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
field,
ValuesBetween(this->GetLowerThreshold(), this->GetUpperThreshold()));
break;

@ -70,7 +70,7 @@ inline VTKM_CONT vtkm::cont::DataSet Triangulate::DoExecute(
vtkm::cont::CellSetSingleType<> outCellSet;
DeduceCellSet triangulate(this->Worklet, outCellSet);
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicy(cells, policy), triangulate);
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyCellSet(cells, policy), triangulate);
// create the output dataset
vtkm::cont::DataSet output;

@ -12,6 +12,8 @@
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/filter/PolicyBase.h>
namespace vtkm
{
namespace filter
@ -27,18 +29,17 @@ inline VTKM_CONT Tube::Tube()
//-----------------------------------------------------------------------------
template <typename Policy>
inline VTKM_CONT vtkm::cont::DataSet Tube::DoExecute(const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<Policy>)
vtkm::filter::PolicyBase<Policy> policy)
{
this->Worklet.SetCapping(this->Capping);
this->Worklet.SetNumberOfSides(this->NumberOfSides);
this->Worklet.SetRadius(this->Radius);
auto originalPoints = vtkm::filter::ApplyPolicyFieldOfType<vtkm::Vec3f>(
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()), policy, *this);
vtkm::cont::ArrayHandle<vtkm::Vec3f> newPoints;
vtkm::cont::CellSetSingleType<> newCells;
this->Worklet.Run(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
input.GetCellSet(),
newPoints,
newCells);
this->Worklet.Run(originalPoints, input.GetCellSet(), newPoints, newCells);
vtkm::cont::DataSet outData;
vtkm::cont::CoordinateSystem outCoords("coordinates", newPoints);

@ -32,7 +32,7 @@ inline VTKM_CONT vtkm::cont::DataSet VertexClustering::DoExecute(
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();
vtkm::cont::DataSet outDataSet =
this->Worklet.Run(vtkm::filter::ApplyPolicyUnstructured(input.GetCellSet(), policy),
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy),
input.GetCoordinateSystem(),
bounds,
this->GetNumberOfDivisions());

@ -32,6 +32,11 @@ public:
// WarpScalar can only applies to Float and Double Vec3 arrays
using SupportedTypes = vtkm::TypeListTagFieldVec3;
// WarpScalar often operates on a constant normal value
using AdditionalFieldStorage =
vtkm::ListTagBase<vtkm::cont::ArrayHandleConstant<vtkm::Vec3f_32>::StorageTag,
vtkm::cont::ArrayHandleConstant<vtkm::Vec3f_64>::StorageTag>;
VTKM_CONT
WarpScalar(vtkm::FloatDefault scaleAmount);

@ -35,15 +35,16 @@ inline VTKM_CONT vtkm::cont::DataSet WarpScalar::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
using vecType = vtkm::Vec<T, 3>;
auto normalF = inDataSet.GetField(this->NormalFieldName, this->NormalFieldAssociation);
auto sfF = inDataSet.GetField(this->ScalarFactorFieldName, this->ScalarFactorFieldAssociation);
vtkm::cont::Field normalF =
inDataSet.GetField(this->NormalFieldName, this->NormalFieldAssociation);
vtkm::cont::Field sfF =
inDataSet.GetField(this->ScalarFactorFieldName, this->ScalarFactorFieldAssociation);
vtkm::cont::ArrayHandle<vecType> result;
this->Worklet.Run(
field,
vtkm::filter::ApplyPolicy(normalF, policy, vtkm::filter::FilterTraits<WarpScalar>()),
vtkm::filter::ApplyPolicy(sfF, policy, vtkm::TypeListTagFieldScalar{}),
this->ScaleAmount,
result);
this->Worklet.Run(field,
vtkm::filter::ApplyPolicyFieldOfType<vecType>(normalF, policy, *this),
vtkm::filter::ApplyPolicyFieldOfType<T>(sfF, policy, *this),
this->ScaleAmount,
result);
return CreateResult(inDataSet, result, this->GetOutputFieldName(), fieldMetadata);
}

@ -30,6 +30,9 @@ class WarpVector : public vtkm::filter::FilterField<WarpVector>
{
public:
using SupportedTypes = vtkm::TypeListTagFieldVec3;
using AdditionalFieldStorage =
vtkm::ListTagBase<vtkm::cont::ArrayHandleConstant<vtkm::Vec3f_32>::StorageTag,
vtkm::cont::ArrayHandleConstant<vtkm::Vec3f_64>::StorageTag>;
VTKM_CONT
WarpVector(vtkm::FloatDefault scale);

@ -33,13 +33,13 @@ inline VTKM_CONT vtkm::cont::DataSet WarpVector::DoExecute(
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
using vecType = vtkm::Vec<T, 3>;
auto vectorF = inDataSet.GetField(this->VectorFieldName, this->VectorFieldAssociation);
vtkm::cont::Field vectorF =
inDataSet.GetField(this->VectorFieldName, this->VectorFieldAssociation);
vtkm::cont::ArrayHandle<vecType> result;
this->Worklet.Run(
field,
vtkm::filter::ApplyPolicy(vectorF, policy, vtkm::filter::FilterTraits<WarpVector>()),
this->Scale,
result);
this->Worklet.Run(field,
vtkm::filter::ApplyPolicyFieldOfType<vecType>(vectorF, policy, *this),
this->Scale,
result);
return CreateResult(inDataSet, result, this->GetOutputFieldName(), fieldMetadata);
}

@ -44,10 +44,10 @@ struct UniversalTag
};
//-----------------------------------------------------------------------------
template <typename ListTag1, typename ListTag2>
template <typename... ListTags>
struct ListJoin
{
using type = brigand::append<ListTag1, ListTag2>;
using type = brigand::append<ListTags...>;
};
template <typename ListTag>

@ -25,6 +25,7 @@
#include <vtkm/VecTraits.h>
#include <vtkm/StaticAssert.h>
#include <vtkm/TypeTraits.h>
#include <vtkm/testing/Testing.h>
@ -154,6 +155,40 @@ static void TestVecTypeImpl(const typename std::remove_const<T>::type& inVector,
TestVecTypeWritableImpl<NUM_COMPONENTS, NonConstT>(
inVector, vectorCopy, outVector, typename VecIsWritable<NonConstT>::type());
// Compiler checks for base component types
using BaseComponentType = typename vtkm::VecTraits<T>::BaseComponentType;
VTKM_STATIC_ASSERT((std::is_same<typename vtkm::TypeTraits<BaseComponentType>::DimensionalityTag,
vtkm::TypeTraitsScalarTag>::value));
VTKM_STATIC_ASSERT((std::is_same<typename vtkm::VecTraits<ComponentType>::BaseComponentType,
BaseComponentType>::value));
// Compiler checks for replacing component types
using ReplaceWithVecComponent =
typename vtkm::VecTraits<T>::template ReplaceComponentType<vtkm::Vec<char, 2>>;
VTKM_STATIC_ASSERT(
(std::is_same<typename vtkm::TypeTraits<T>::DimensionalityTag,
vtkm::TypeTraitsVectorTag>::value &&
std::is_same<typename vtkm::VecTraits<ReplaceWithVecComponent>::ComponentType,
vtkm::Vec<char, 2>>::value) ||
(std::is_same<typename vtkm::TypeTraits<T>::DimensionalityTag,
vtkm::TypeTraitsScalarTag>::value &&
std::is_same<typename vtkm::VecTraits<ReplaceWithVecComponent>::ComponentType, char>::value));
VTKM_STATIC_ASSERT(
(std::is_same<typename vtkm::VecTraits<ReplaceWithVecComponent>::BaseComponentType,
char>::value));
using ReplaceBaseComponent =
typename vtkm::VecTraits<ReplaceWithVecComponent>::template ReplaceBaseComponentType<short>;
VTKM_STATIC_ASSERT(
(std::is_same<typename vtkm::TypeTraits<T>::DimensionalityTag,
vtkm::TypeTraitsVectorTag>::value &&
std::is_same<typename vtkm::VecTraits<ReplaceBaseComponent>::ComponentType,
vtkm::Vec<short, 2>>::value) ||
(std::is_same<typename vtkm::TypeTraits<T>::DimensionalityTag,
vtkm::TypeTraitsScalarTag>::value &&
std::is_same<typename vtkm::VecTraits<ReplaceBaseComponent>::ComponentType, short>::value));
VTKM_STATIC_ASSERT((
std::is_same<typename vtkm::VecTraits<ReplaceBaseComponent>::BaseComponentType, short>::value));
}
inline void CheckVecComponentsTag(vtkm::VecTraitsTagMultipleComponents)

@ -114,7 +114,7 @@ struct GradientOutputFields : public vtkm::cont::ExecutionObjectBase
{
using ValueType = T;
using BaseTType = typename vtkm::BaseComponent<T>::Type;
using BaseTType = typename vtkm::VecTraits<T>::BaseComponentType;
template <typename DeviceAdapter>
struct ExecutionTypes

@ -10,7 +10,7 @@
#include <vtkm/worklet/ScalarsToColors.h>
#include <vtkm/BaseComponent.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/ArrayHandleExtractComponent.h>
#include <vtkm/cont/ArrayHandleTransform.h>
@ -54,7 +54,7 @@ void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
{
using namespace vtkm::worklet::colorconversion;
//If our shift is 0 and our scale == 1 no need to apply them
using BaseT = typename vtkm::BaseComponent<T>::Type;
using BaseT = typename vtkm::VecTraits<T>::BaseComponentType;
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{
@ -76,7 +76,7 @@ void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8>& rgbOut) const
{
using namespace vtkm::worklet::colorconversion;
using BaseT = typename vtkm::BaseComponent<T>::Type;
using BaseT = typename vtkm::VecTraits<T>::BaseComponentType;
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{
@ -101,7 +101,7 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
//
using namespace vtkm::worklet::colorconversion;
//If our shift is 0 and our scale == 1 no need to apply them
using BaseT = typename vtkm::BaseComponent<T>::Type;
using BaseT = typename vtkm::VecTraits<T>::BaseComponentType;
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{
@ -126,7 +126,7 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
{
using namespace vtkm::worklet::colorconversion;
using BaseT = typename vtkm::BaseComponent<T>::Type;
using BaseT = typename vtkm::VecTraits<T>::BaseComponentType;
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{

@ -536,18 +536,16 @@ public:
VTKM_CONT
void SetRadius(vtkm::FloatDefault r) { this->Radius = r; }
VTKM_CONT
void Run(const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::DynamicCellSet& cellset,
vtkm::cont::ArrayHandle<vtkm::Vec3f>& newPoints,
vtkm::cont::CellSetSingleType<>& newCells)
template <typename Storage>
VTKM_CONT void Run(const vtkm::cont::ArrayHandle<vtkm::Vec3f, Storage>& coords,
const vtkm::cont::DynamicCellSet& cellset,
vtkm::cont::ArrayHandle<vtkm::Vec3f>& newPoints,
vtkm::cont::CellSetSingleType<>& newCells)
{
using ExplCoordsType = vtkm::cont::ArrayHandle<vtkm::Vec3f>;
using NormalsType = vtkm::cont::ArrayHandle<vtkm::Vec3f>;
if (!(coords.GetData().IsType<ExplCoordsType>() &&
(cellset.IsSameType(vtkm::cont::CellSetExplicit<>()) ||
cellset.IsSameType(vtkm::cont::CellSetSingleType<>()))))
if (!cellset.IsSameType(vtkm::cont::CellSetExplicit<>()) &&
!cellset.IsSameType(vtkm::cont::CellSetSingleType<>()))
{
throw vtkm::cont::ErrorBadValue("Tube filter only supported for polyline data.");
}
@ -574,11 +572,10 @@ public:
vtkm::cont::Algorithm::ScanExclusive(segPerPolyline, segOffset);
//Generate normals at each point on all polylines
ExplCoordsType inCoords = coords.GetData().Cast<ExplCoordsType>();
NormalsType normals;
normals.Allocate(totalPolylinePts);
vtkm::worklet::DispatcherMapTopology<GenerateNormals> genNormalsDisp;
genNormalsDisp.Invoke(cellset, inCoords, polylinePtOffset, normals);
genNormalsDisp.Invoke(cellset, coords, polylinePtOffset, normals);
//Generate the tube points
newPoints.Allocate(totalTubePts);
@ -586,7 +583,7 @@ public:
GeneratePoints genPts(this->Capping, this->NumSides, this->Radius);
vtkm::worklet::DispatcherMapTopology<GeneratePoints> genPtsDisp(genPts);
genPtsDisp.Invoke(cellset,
inCoords,
coords,
normals,
tubePointOffsets,
polylinePtOffset,

@ -11,7 +11,7 @@
#ifndef vtk_m_worklet_gradient_GradientOutput_h
#define vtk_m_worklet_gradient_GradientOutput_h
#include <vtkm/BaseComponent.h>
#include <vtkm/VecTraits.h>
#include <vtkm/cont/arg/TransportTagArrayOut.h>
#include <vtkm/cont/arg/TransportTagExecObject.h>
@ -31,7 +31,7 @@ template <typename T, typename DeviceAdapter>
struct GradientScalarOutputExecutionObject
{
using ValueType = vtkm::Vec<T, 3>;
using BaseTType = typename vtkm::BaseComponent<T>::Type;
using BaseTType = typename vtkm::VecTraits<T>::BaseComponentType;
struct PortalTypes
{
@ -61,7 +61,7 @@ template <typename T>
struct GradientScalarOutput : public vtkm::cont::ExecutionObjectBase
{
using ValueType = vtkm::Vec<T, 3>;
using BaseTType = typename vtkm::BaseComponent<T>::Type;
using BaseTType = typename vtkm::VecTraits<T>::BaseComponentType;
template <typename Device>
VTKM_CONT vtkm::exec::GradientScalarOutputExecutionObject<T, Device> PrepareForExecution(
@ -93,7 +93,7 @@ template <typename T, typename DeviceAdapter>
struct GradientVecOutputExecutionObject
{
using ValueType = vtkm::Vec<T, 3>;
using BaseTType = typename vtkm::BaseComponent<T>::Type;
using BaseTType = typename vtkm::VecTraits<T>::BaseComponentType;
template <typename FieldType>
struct PortalTypes
@ -185,7 +185,7 @@ template <typename T>
struct GradientVecOutput : public vtkm::cont::ExecutionObjectBase
{
using ValueType = vtkm::Vec<T, 3>;
using BaseTType = typename vtkm::BaseComponent<T>::Type;
using BaseTType = typename vtkm::VecTraits<T>::BaseComponentType;
template <typename Device>
VTKM_CONT vtkm::exec::GradientVecOutputExecutionObject<T, Device> PrepareForExecution(

@ -78,7 +78,7 @@ struct PointGradient : public vtkm::worklet::WorkletVisitPointsWithCells
if (numCells != 0)
{
using BaseGradientType = typename vtkm::BaseComponent<ValueType>::Type;
using BaseGradientType = typename vtkm::VecTraits<ValueType>::BaseComponentType;
const BaseGradientType invNumCells =
static_cast<BaseGradientType>(1.) / static_cast<BaseGradientType>(numCells);

@ -47,7 +47,7 @@ struct StructuredPointGradient : public vtkm::worklet::WorkletPointNeighborhood
GradientOutType& outputGradient) const
{
using CoordType = typename PointsIn::ValueType;
using CT = typename vtkm::BaseComponent<CoordType>::Type;
using CT = typename vtkm::VecTraits<CoordType>::BaseComponentType;
using OT = typename GradientOutType::ComponentType;
vtkm::Vec<CT, 3> xi, eta, zeta;

@ -80,7 +80,7 @@ vtkm::Vec4ui_8 as_color<vtkm::Vec4ui_8>(vtkm::Float32 v, vtkm::Float32 alpha)
template <typename T>
vtkm::cont::ArrayHandle<T> make_data(const vtkm::Range& r)
{
using BaseT = typename vtkm::BaseComponent<T>::Type;
using BaseT = typename vtkm::VecTraits<T>::BaseComponentType;
vtkm::Float32 shift, scale;
vtkm::worklet::colorconversion::ComputeShiftScale(r, shift, scale);
const bool shiftscale = vtkm::worklet::colorconversion::needShiftScale(BaseT{}, shift, scale);

@ -120,7 +120,10 @@ void TestTube(bool capEnds, vtkm::FloatDefault radius, vtkm::Id numSides, vtkm::
vtkm::worklet::Tube tubeWorklet(capEnds, numSides, radius);
vtkm::cont::ArrayHandle<vtkm::Vec3f> newPoints;
vtkm::cont::CellSetSingleType<> newCells;
tubeWorklet.Run(ds.GetCoordinateSystem(0), ds.GetCellSet(), newPoints, newCells);
tubeWorklet.Run(ds.GetCoordinateSystem(0).GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Vec3f>>(),
ds.GetCellSet(),
newPoints,
newCells);
VTKM_TEST_ASSERT(newPoints.GetNumberOfValues() == reqNumPts,
"Wrong number of points in Tube worklet");
@ -175,7 +178,11 @@ void TestLinearPolylines()
vtkm::worklet::Tube tubeWorklet(capEnds, numSides, radius);
vtkm::cont::ArrayHandle<vtkm::Vec3f> newPoints;
vtkm::cont::CellSetSingleType<> newCells;
tubeWorklet.Run(ds.GetCoordinateSystem(0), ds.GetCellSet(), newPoints, newCells);
tubeWorklet.Run(
ds.GetCoordinateSystem(0).GetData().Cast<vtkm::cont::ArrayHandle<vtkm::Vec3f>>(),
ds.GetCellSet(),
newPoints,
newCells);
VTKM_TEST_ASSERT(newPoints.GetNumberOfValues() == reqNumPts,
"Wrong number of points in Tube worklet");