Commit f63be1ab authored by Robert Maynard's avatar Robert Maynard

Update vtkm/filter to work with ArrayHandleVariant

parent eed321aa
......@@ -21,7 +21,6 @@
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
......@@ -31,29 +30,6 @@ namespace vtkm
namespace filter
{
namespace clipwithfield
{
struct PointMapHelper
{
PointMapHelper(const vtkm::worklet::Clip& worklet, vtkm::cont::DynamicArrayHandle& output)
: Worklet(worklet)
, Output(output)
{
}
template <typename ArrayType>
void operator()(const ArrayType& array) const
{
this->Output = this->Worklet.ProcessPointField(array);
}
const vtkm::worklet::Clip& Worklet;
vtkm::cont::DynamicArrayHandle& Output;
};
} // end namespace clipwithfield
//-----------------------------------------------------------------------------
inline VTKM_CONT ClipWithField::ClipWithField()
: vtkm::filter::FilterDataSetWithField<ClipWithField>()
......@@ -71,8 +47,6 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
const vtkm::filter::FieldMetadata& fieldMeta,
vtkm::filter::PolicyBase<DerivedPolicy> policy)
{
using namespace clipwithfield;
if (fieldMeta.IsPointField() == false)
{
throw vtkm::cont::ErrorFilterExecution("Point field expected.");
......
......@@ -28,30 +28,6 @@ namespace vtkm
{
namespace filter
{
namespace clipwithimplicitfunction
{
struct PointMapHelper
{
PointMapHelper(const vtkm::worklet::Clip& worklet, vtkm::cont::DynamicArrayHandle& output)
: Worklet(worklet)
, Output(output)
{
}
template <typename ArrayType>
void operator()(const ArrayType& array) const
{
this->Output = this->Worklet.ProcessPointField(array);
}
const vtkm::worklet::Clip& Worklet;
vtkm::cont::DynamicArrayHandle& Output;
};
} // end namespace clipwithimplicitfunction
//-----------------------------------------------------------------------------
ClipWithImplicitFunction::ClipWithImplicitFunction()
......@@ -64,8 +40,6 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
{
using namespace clipwithimplicitfunction;
//get the cells and coordinates of the dataset
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(this->GetActiveCellSetIndex());
......
......@@ -82,7 +82,7 @@ inline VTKM_CONT vtkm::cont::DataSet CrossProduct::DoExecute(
inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation),
policy,
Traits())
.ResetTypeList(TypeList())
.ResetTypes(TypeList())
.CastAndCall(functor, field);
}
}
......
......@@ -83,7 +83,7 @@ inline VTKM_CONT vtkm::cont::DataSet DotProduct::DoExecute(
inDataSet.GetField(this->SecondaryFieldName, this->SecondaryFieldAssociation),
policy,
Traits())
.ResetTypeList(TypeList())
.ResetTypes(TypeList())
.CastAndCall(functor, field);
}
}
......
......@@ -119,7 +119,7 @@ inline VTKM_CONT bool ExtractGeometry::DoMapField(
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
vtkm::cont::DynamicArrayHandle output;
vtkm::cont::ArrayHandleVariant output;
if (fieldMeta.IsPointField())
{
......
......@@ -74,29 +74,26 @@ public:
template <typename T, typename StorageTag>
VTKM_CONT vtkm::cont::Field AsField(const vtkm::cont::ArrayHandle<T, StorageTag>& handle) const
{
//Field only handles arrayHandles with default storage tag, so use
//dynamic array handles
vtkm::cont::DynamicArrayHandle dhandle(handle);
if (this->IsCellField())
{
return vtkm::cont::Field(this->Name, this->Association, this->CellSetName, dhandle);
return vtkm::cont::Field(this->Name, this->Association, this->CellSetName, handle);
}
else
{
return vtkm::cont::Field(this->Name, this->Association, dhandle);
return vtkm::cont::Field(this->Name, this->Association, handle);
}
}
VTKM_CONT
vtkm::cont::Field AsField(const vtkm::cont::DynamicArrayHandle& dhandle) const
vtkm::cont::Field AsField(const vtkm::cont::ArrayHandleVariant& handle) const
{
if (this->IsCellField())
{
return vtkm::cont::Field(this->Name, this->Association, this->CellSetName, dhandle);
return vtkm::cont::Field(this->Name, this->Association, this->CellSetName, handle);
}
else
{
return vtkm::cont::Field(this->Name, this->Association, dhandle);
return vtkm::cont::Field(this->Name, this->Association, handle);
}
}
......
......@@ -231,18 +231,14 @@ inline VTKM_CONT void Histogram::PreExecute(const vtkm::cont::MultiBlock& input,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
using TypeList = typename DerivedPolicy::FieldTypeList;
using StorageList = typename DerivedPolicy::FieldStorageList;
if (this->Range.IsNonEmpty())
{
this->ComputedRange = this->Range;
}
else
{
auto handle = vtkm::cont::FieldRangeGlobalCompute(input,
this->GetActiveFieldName(),
this->GetActiveFieldAssociation(),
TypeList(),
StorageList());
auto handle = vtkm::cont::FieldRangeGlobalCompute(
input, this->GetActiveFieldName(), this->GetActiveFieldAssociation(), TypeList());
if (handle.GetNumberOfValues() != 1)
{
throw vtkm::cont::ErrorFilterExecution("expecting scalar field.");
......
......@@ -21,7 +21,6 @@
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ErrorFilterExecution.h>
......
......@@ -42,7 +42,6 @@ template <typename Derived>
struct PolicyBase
{
using FieldTypeList = VTKM_DEFAULT_TYPE_LIST_TAG;
using FieldStorageList = VTKM_DEFAULT_STORAGE_LIST_TAG;
using StructuredCellSetList = vtkm::cont::CellSetListTagStructured;
using UnstructuredCellSetList = vtkm::cont::CellSetListTagUnstructured;
......@@ -51,29 +50,25 @@ struct PolicyBase
//-----------------------------------------------------------------------------
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::DynamicArrayHandleBase<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::FieldStorageList>
ApplyPolicy(const vtkm::cont::Field& field, const vtkm::filter::PolicyBase<DerivedPolicy>&)
VTKM_CONT vtkm::cont::ArrayHandleVariantBase<typename DerivedPolicy::FieldTypeList> ApplyPolicy(
const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
using TypeList = typename DerivedPolicy::FieldTypeList;
using StorageList = typename DerivedPolicy::FieldStorageList;
return field.GetData().ResetTypeAndStorageLists(TypeList(), StorageList());
return field.GetData().ResetTypes(TypeList());
}
//-----------------------------------------------------------------------------
template <typename DerivedPolicy, typename FilterType, typename FieldTag>
VTKM_CONT vtkm::cont::DynamicArrayHandleBase<
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, FilterType, FieldTag>::TypeList,
typename DerivedPolicy::FieldStorageList>
VTKM_CONT vtkm::cont::ArrayHandleVariantBase<
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, FilterType, FieldTag>::TypeList>
ApplyPolicy(const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&,
const vtkm::filter::FilterTraits<FilterType, FieldTag>&)
{
using TypeList =
typename vtkm::filter::DeduceFilterFieldTypes<DerivedPolicy, FilterType, FieldTag>::TypeList;
using StorageList = typename DerivedPolicy::FieldStorageList;
return field.GetData().ResetTypeAndStorageLists(TypeList(), StorageList());
return field.GetData().ResetTypes(TypeList());
}
//-----------------------------------------------------------------------------
......@@ -108,26 +103,22 @@ ApplyPolicyUnstructured(const vtkm::cont::DynamicCellSet& cellset,
//-----------------------------------------------------------------------------
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::FieldStorageList>
VTKM_CONT vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList>
MakeSerializableField(const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
return {};
}
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::FieldStorageList>
VTKM_CONT vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList>
MakeSerializableField(const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
return vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::FieldStorageList>{ field };
return vtkm::cont::SerializableField<typename DerivedPolicy::FieldTypeList>{ field };
}
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::FieldStorageList,
typename DerivedPolicy::AllCellSetList>
MakeSerializableDataSet(const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
......@@ -136,13 +127,11 @@ MakeSerializableDataSet(const vtkm::filter::PolicyBase<DerivedPolicy>&)
template <typename DerivedPolicy>
VTKM_CONT vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::FieldStorageList,
typename DerivedPolicy::AllCellSetList>
MakeSerializableDataSet(const vtkm::cont::DataSet& dataset,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
return vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
typename DerivedPolicy::FieldStorageList,
typename DerivedPolicy::AllCellSetList>{ dataset };
}
}
......
......@@ -108,7 +108,7 @@ inline VTKM_CONT vtkm::cont::DataSet CreateResult(
return clone;
}
/// Use this function if you have a DynamicArrayHandle that holds the data
/// Use this function if you have a ArrayHandleVariant that holds the data
/// for the field. You also need to specify a name and an association for the
/// field. If the field is associated with a particular element set (for
/// example, a cell association is associated with a cell set), the name of
......@@ -116,7 +116,7 @@ inline VTKM_CONT vtkm::cont::DataSet CreateResult(
/// for \c Association::WHOLE_MESH and \c Association::POINTS associations.
///
inline VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet,
const vtkm::cont::DynamicArrayHandle& fieldArray,
const vtkm::cont::ArrayHandleVariant& fieldArray,
const std::string& fieldName,
vtkm::cont::Field::Association fieldAssociation,
const std::string& elementSetName = "")
......
......@@ -20,7 +20,6 @@
#include "vtkm/filter/CellMeasures.h"
#include "vtkm/cont/DynamicArrayHandle.h"
#include "vtkm/cont/testing/MakeTestDataSet.h"
#include "vtkm/cont/testing/Testing.h"
......@@ -51,7 +50,7 @@ void TestCellMeasuresFilter(vtkm::cont::DataSet& dataset,
// Check that the empty measure name above produced a field with the expected name.
vols.SetCellMeasureName("measure");
vtkm::cont::DynamicArrayHandle temp = outputData.GetField(vols.GetCellMeasureName()).GetData();
auto temp = outputData.GetField(vols.GetCellMeasureName()).GetData();
VTKM_TEST_ASSERT(temp.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
"Output field could not be found or was improper.");
......
......@@ -20,7 +20,6 @@
#include <vtkm/filter/ClipWithField.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
......@@ -80,7 +79,7 @@ void TestClipExplicit()
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
"Wrong number of fields in the output dataset");
vtkm::cont::DynamicArrayHandle temp = outputData.GetField("scalars").GetData();
auto temp = outputData.GetField("scalars").GetData();
vtkm::cont::ArrayHandle<vtkm::Float32> resultArrayHandle;
temp.CopyTo(resultArrayHandle);
......
......@@ -20,7 +20,6 @@
#include <vtkm/filter/ClipWithImplicitFunction.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
......@@ -76,7 +75,7 @@ void TestClipStructured()
VTKM_TEST_ASSERT(outputData.GetCellSet().GetNumberOfCells() == 8,
"Wrong number of cells in the output dataset");
vtkm::cont::DynamicArrayHandle temp = outputData.GetField("scalars").GetData();
vtkm::cont::ArrayHandleVariant temp = outputData.GetField("scalars").GetData();
vtkm::cont::ArrayHandle<vtkm::Float32> resultArrayHandle;
temp.CopyTo(resultArrayHandle);
......@@ -116,7 +115,7 @@ void TestClipStructuredInverted()
VTKM_TEST_ASSERT(outputData.GetCellSet().GetNumberOfCells() == 4,
"Wrong number of cells in the output dataset");
vtkm::cont::DynamicArrayHandle temp = outputData.GetField("scalars").GetData();
vtkm::cont::ArrayHandleVariant temp = outputData.GetField("scalars").GetData();
vtkm::cont::ArrayHandle<vtkm::Float32> resultArrayHandle;
temp.CopyTo(resultArrayHandle);
......
......@@ -24,7 +24,6 @@
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/CleanGrid.h>
......@@ -229,22 +228,7 @@ public:
class PolicyRadiantDataSet : public vtkm::filter::PolicyBase<PolicyRadiantDataSet>
{
using DataHandleType = MakeRadiantDataSet::DataArrayHandle;
using CountingHandleType = MakeRadiantDataSet::ConnectivityArrayHandle;
using TransformHandleType =
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
CubeGridConnectivity>;
public:
struct TypeListTagRadiantTypes : vtkm::ListTagBase<DataHandleType::StorageTag,
CountingHandleType::StorageTag,
TransformHandleType::StorageTag>
{
};
using FieldStorageList = TypeListTagRadiantTypes;
struct TypeListTagRadiantCellSetTypes : vtkm::ListTagBase<MakeRadiantDataSet::CellSet>
{
};
......@@ -281,12 +265,10 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
//Set point scalar
dataSet.AddField(vtkm::cont::Field("distanceToOrigin",
vtkm::cont::Field::Association::POINTS,
vtkm::cont::DynamicArrayHandle(distanceToOrigin)));
dataSet.AddField(vtkm::cont::Field("distanceToOther",
vtkm::cont::Field::Association::POINTS,
vtkm::cont::DynamicArrayHandle(distanceToOther)));
dataSet.AddField(vtkm::cont::Field(
"distanceToOrigin", vtkm::cont::Field::Association::POINTS, distanceToOrigin));
dataSet.AddField(
vtkm::cont::Field("distanceToOther", vtkm::cont::Field::Association::POINTS, distanceToOther));
CellSet cellSet("cells");
cellSet.Fill(coordinates.GetNumberOfValues(), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
......@@ -384,7 +366,7 @@ void TestMarchingCubesCustomPolicy()
//custom field type
mc.SetActiveField("distanceToOrigin");
mc.SetFieldsToPass({ "distanceToOrigin", "distanceToOther" });
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet());
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet{});
VTKM_TEST_ASSERT(outputData.GetNumberOfCellSets() == 1,
"Wrong number of cellsets in the output dataset");
......
......@@ -24,7 +24,6 @@
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/MultiBlock.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
......
......@@ -64,19 +64,6 @@ vtkm::cont::DataSet MakeWarpScalarTestDataSet()
return dataSet;
}
class PolicyWarpScalar : public vtkm::filter::PolicyBase<PolicyWarpScalar>
{
public:
using vecType = vtkm::Vec<vtkm::FloatDefault, 3>;
struct TypeListTagWarpScalarTags
: vtkm::ListTagBase<vtkm::cont::ArrayHandleConstant<vecType>::StorageTag,
vtkm::cont::ArrayHandle<vecType>::StorageTag,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>::StorageTag>
{
};
using FieldStorageList = TypeListTagWarpScalarTags;
};
void CheckResult(const vtkm::filter::WarpScalar& filter, const vtkm::cont::DataSet& result)
{
VTKM_TEST_ASSERT(result.HasField("warpscalar", vtkm::cont::Field::Association::POINTS),
......@@ -124,7 +111,7 @@ void TestWarpScalarFilter()
filter.SetUseCoordinateSystemAsPrimaryField(true);
filter.SetNormalField("normal");
filter.SetScalarFactorField("scalarfactor");
vtkm::cont::DataSet result = filter.Execute(ds, PolicyWarpScalar());
vtkm::cont::DataSet result = filter.Execute(ds);
CheckResult(filter, result);
}
......@@ -134,7 +121,7 @@ void TestWarpScalarFilter()
filter.SetPrimaryField("vec1");
filter.SetNormalField("normal");
filter.SetScalarFactorField("scalarfactor");
vtkm::cont::DataSet result = filter.Execute(ds, PolicyWarpScalar());
vtkm::cont::DataSet result = filter.Execute(ds);
CheckResult(filter, result);
}
}
......
......@@ -286,7 +286,7 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
void TestMarchingCubesUniformGrid()
{
std::cout << "Testing MarchingCubes filter on a uniform grid" << std::endl;
std::cout << "Testing MarchingCubes worklet on a uniform grid" << std::endl;
vtkm::Id3 dims(4, 4, 4);
vtkm::cont::DataSet dataSet = vtkm_ut_mc_worklet::MakeIsosurfaceTestDataSet(dims);
......@@ -341,7 +341,7 @@ void TestMarchingCubesUniformGrid()
void TestMarchingCubesExplicit()
{
std::cout << "Testing MarchingCubes filter on explicit data" << std::endl;
std::cout << "Testing MarchingCubes worklet on explicit data" << std::endl;
using DataSetGenerator = vtkm_ut_mc_worklet::MakeRadiantDataSet;
using Vec3Handle = vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>>;
......@@ -400,11 +400,11 @@ void TestMarchingCubesExplicit()
VTKM_TEST_ASSERT(result.GetNumberOfCells() == cellFieldArrayOut.GetNumberOfValues(),
"Output cell data invalid");
VTKM_TEST_ASSERT(test_equal(vertices.GetNumberOfValues(), 2472),
"Wrong vertices result for MarchingCubes filter");
"Wrong vertices result for MarchingCubes worklet");
VTKM_TEST_ASSERT(test_equal(normals.GetNumberOfValues(), 2472),
"Wrong normals result for MarchingCubes filter");
"Wrong normals result for MarchingCubes worklet");
VTKM_TEST_ASSERT(test_equal(scalars.GetNumberOfValues(), 2472),
"Wrong scalars result for MarchingCubes filter");
"Wrong scalars result for MarchingCubes worklet");
}
void TestMarchingCubes()
......
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