Commit 86a747a1 authored by Kenneth Moreland's avatar Kenneth Moreland

Add ability to customize filter policy to auxiliary input fields

The field infrastructure has a "trait" that specifies the valid types
for the default active scalar field. Most filters have at most one input
field. The majority of the remaining filters use the same types for
inputs. There are some examples, however, where some auxiliary fields
use different types. This change adds a second template parameter to
FieldTraits to customize the valid types of the input scalar field to
different fields.

These changes are in anticipation of the removal of list specifier tags
on worklet ControlSignature arguments.
parent 5ded6352
......@@ -28,7 +28,11 @@ namespace vtkm
namespace filter
{
template <typename Filter>
struct DefaultFieldTag
{
};
template <typename Filter, typename FieldTag = DefaultFieldTag>
class FilterTraits
{
public:
......@@ -38,10 +42,10 @@ public:
using InputFieldTypeList = vtkm::ListTagUniversal;
};
template <typename DerivedPolicy, typename FilterType>
template <typename DerivedPolicy, typename FilterType, typename FieldTag>
struct DeduceFilterFieldTypes
{
using FList = typename vtkm::filter::FilterTraits<FilterType>::InputFieldTypeList;
using FList = typename vtkm::filter::FilterTraits<FilterType, FieldTag>::InputFieldTypeList;
using PList = typename DerivedPolicy::FieldTypeList;
using TypeList = vtkm::ListTagIntersect<FList, PList>;
......
......@@ -61,16 +61,16 @@ ApplyPolicy(const vtkm::cont::Field& field, const vtkm::filter::PolicyBase<Deriv
}
//-----------------------------------------------------------------------------
template <typename DerivedPolicy, typename FilterType>
template <typename DerivedPolicy, typename FilterType, typename FieldTag>
VTKM_CONT vtkm::cont::DynamicArrayHandleBase<
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, FilterType>::TypeList,
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, FilterType, FieldTag>::TypeList,
typename DerivedPolicy::FieldStorageList>
ApplyPolicy(const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const vtkm::filter::FilterTraits<FilterType>&)
const vtkm::filter::FilterTraits<FilterType, FieldTag>&)
{
using TypeList =
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, FilterType>::TypeList;
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, FilterType, FieldTag>::TypeList;
using StorageList = typename DerivedPolicy::FieldStorageList;
return field.GetData().ResetTypeAndStorageLists(TypeList(), StorageList());
......
......@@ -154,6 +154,16 @@ public:
// WarpScalar can only applies to Float and Double Vec3 arrays
using InputFieldTypeList = vtkm::TypeListTagFieldVec3;
};
struct WarpScalarScalarFieldTag
{
};
template <>
struct FilterTraits<WarpScalar, WarpScalarScalarFieldTag>
{
using InputFieldTypeList = vtkm::TypeListTagFieldScalar;
};
}
}
......
......@@ -21,6 +21,8 @@
#include <vtkm/filter/internal/CreateResult.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/filter/WarpScalar.h>
namespace vtkm
{
namespace filter
......@@ -51,11 +53,13 @@ inline VTKM_CONT vtkm::cont::DataSet WarpScalar::DoExecute(
auto normalF = inDataSet.GetField(this->NormalFieldName, this->NormalFieldAssociation);
auto sfF = inDataSet.GetField(this->ScalarFactorFieldName, this->ScalarFactorFieldAssociation);
vtkm::cont::ArrayHandle<vecType> result;
this->Worklet.Run(field,
vtkm::filter::ApplyPolicy(normalF, policy),
vtkm::filter::ApplyPolicy(sfF, policy),
this->ScaleAmount,
result);
this->Worklet.Run(
field,
vtkm::filter::ApplyPolicy(normalF, policy, vtkm::filter::FilterTraits<WarpScalar>()),
vtkm::filter::ApplyPolicy(
sfF, policy, vtkm::filter::FilterTraits<WarpScalar, WarpScalarScalarFieldTag>()),
this->ScaleAmount,
result);
return internal::CreateResult(inDataSet,
result,
......
......@@ -42,7 +42,7 @@ public:
class WarpScalarImp : public vtkm::worklet::WorkletMapField
{
public:
using ControlSignature = void(FieldIn<Vec3>, FieldIn<Vec3>, FieldIn<Scalar>, FieldOut<Vec3>);
using ControlSignature = void(FieldIn<>, FieldIn<>, FieldIn<>, FieldOut<>);
using ExecutionSignature = void(_1, _2, _3, _4);
VTKM_CONT
WarpScalarImp(vtkm::FloatDefault scaleAmount)
......
......@@ -77,8 +77,9 @@ void TestWarpScalar()
vtkm::cont::make_ArrayHandleConstant(normal, nov);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> scaleFactorArray;
auto scaleFactor = ds.GetField("scalefactor");
scaleFactor.GetData().CopyTo(scaleFactorArray);
auto scaleFactor =
ds.GetField("scalefactor").GetData().ResetTypeList(vtkm::TypeListTagFieldScalar());
scaleFactor.CopyTo(scaleFactorArray);
auto sFAPortal = scaleFactorArray.GetPortalControl();
vtkm::worklet::WarpScalar warpWorklet;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment