mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Deprecate Execute with policy
The version of `Filter::Execute` that takes a policy as an argument is now deprecated. Filters are now able to specify their own fields and types, which is often why you want to customize the policy for an execution. The other reason is that you are compiling VTK-m into some other source that uses a particular types of storage. However, there is now a mechanism in the CMake configuration to allow you to provide a header that customizes the "default" types used in filters. This is a much more convenient way to compile filters for specific types. One thing that filters were not able to do was to customize what cell sets they allowed using. This allows filters to self-select what types of cell sets they support (beyond simply just structured or unstructured). To support this, the lists `SupportedCellSets`, `SupportedStructuredCellSets`, and `SupportedUnstructuredCellSets` have been added to `Filter`. When you apply a policy to a cell set, you now have to also provide the filter.
This commit is contained in:
parent
963c871b76
commit
72cd0107ee
17
docs/changelog/deprecate-execute-with-policy.md
Normal file
17
docs/changelog/deprecate-execute-with-policy.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Deprecate Execute with policy
|
||||||
|
|
||||||
|
The version of `Filter::Execute` that takes a policy as an argument is now
|
||||||
|
deprecated. Filters are now able to specify their own fields and types,
|
||||||
|
which is often why you want to customize the policy for an execution. The
|
||||||
|
other reason is that you are compiling VTK-m into some other source that
|
||||||
|
uses a particular types of storage. However, there is now a mechanism in
|
||||||
|
the CMake configuration to allow you to provide a header that customizes
|
||||||
|
the "default" types used in filters. This is a much more convenient way to
|
||||||
|
compile filters for specific types.
|
||||||
|
|
||||||
|
One thing that filters were not able to do was to customize what cell sets
|
||||||
|
they allowed using. This allows filters to self-select what types of cell
|
||||||
|
sets they support (beyond simply just structured or unstructured). To
|
||||||
|
support this, the lists `SupportedCellSets`, `SupportedStructuredCellSets`,
|
||||||
|
and `SupportedUnstructuredCellSets` have been added to `Filter`. When you
|
||||||
|
apply a policy to a cell set, you now have to also provide the filter.
|
@ -219,7 +219,9 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet MultiDeviceGradient::PrepareForE
|
|||||||
[=]() {
|
[=]() {
|
||||||
vtkm::filter::Gradient perThreadGrad = gradient;
|
vtkm::filter::Gradient perThreadGrad = gradient;
|
||||||
|
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||||
vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy);
|
vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy);
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_END
|
||||||
outPtr->ReplacePartition(0, result);
|
outPtr->ReplacePartition(0, result);
|
||||||
});
|
});
|
||||||
this->Queue.waitForAllTasksToComplete();
|
this->Queue.waitForAllTasksToComplete();
|
||||||
@ -238,7 +240,9 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet MultiDeviceGradient::PrepareForE
|
|||||||
[=]() {
|
[=]() {
|
||||||
vtkm::filter::Gradient perThreadGrad = gradient;
|
vtkm::filter::Gradient perThreadGrad = gradient;
|
||||||
|
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||||
vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy);
|
vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy);
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_END
|
||||||
outPtr->ReplacePartition(index, result);
|
outPtr->ReplacePartition(index, result);
|
||||||
});
|
});
|
||||||
index++;
|
index++;
|
||||||
|
@ -38,11 +38,12 @@ static vtkmdiy::ContinuousBounds convert(const vtkm::Bounds& bds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy, typename FilterType>
|
||||||
class Redistributor
|
class Redistributor
|
||||||
{
|
{
|
||||||
const vtkmdiy::RegularDecomposer<vtkmdiy::ContinuousBounds>& Decomposer;
|
const vtkmdiy::RegularDecomposer<vtkmdiy::ContinuousBounds>& Decomposer;
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& Policy;
|
const vtkm::filter::PolicyBase<DerivedPolicy>& Policy;
|
||||||
|
const FilterType& Filter;
|
||||||
|
|
||||||
vtkm::cont::DataSet Extract(const vtkm::cont::DataSet& input,
|
vtkm::cont::DataSet Extract(const vtkm::cont::DataSet& input,
|
||||||
const vtkmdiy::ContinuousBounds& bds) const
|
const vtkmdiy::ContinuousBounds& bds) const
|
||||||
@ -53,7 +54,9 @@ class Redistributor
|
|||||||
vtkm::filter::ExtractPoints extractor;
|
vtkm::filter::ExtractPoints extractor;
|
||||||
extractor.SetCompactPoints(true);
|
extractor.SetCompactPoints(true);
|
||||||
extractor.SetImplicitFunction(vtkm::cont::make_ImplicitFunctionHandle(box));
|
extractor.SetImplicitFunction(vtkm::cont::make_ImplicitFunctionHandle(box));
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||||
return extractor.Execute(input, this->Policy);
|
return extractor.Execute(input, this->Policy);
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_END
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConcatenateFields
|
class ConcatenateFields
|
||||||
@ -120,9 +123,11 @@ class Redistributor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Redistributor(const vtkmdiy::RegularDecomposer<vtkmdiy::ContinuousBounds>& decomposer,
|
Redistributor(const vtkmdiy::RegularDecomposer<vtkmdiy::ContinuousBounds>& decomposer,
|
||||||
const vtkm::filter::PolicyBase<DerivedPolicy>& policy)
|
const vtkm::filter::PolicyBase<DerivedPolicy>& policy,
|
||||||
|
const FilterType& filter)
|
||||||
: Decomposer(decomposer)
|
: Decomposer(decomposer)
|
||||||
, Policy(policy)
|
, Policy(policy)
|
||||||
|
, Filter(filter)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +145,9 @@ public:
|
|||||||
this->Decomposer.fill_bounds(bds, target.gid);
|
this->Decomposer.fill_bounds(bds, target.gid);
|
||||||
|
|
||||||
auto extractedDS = this->Extract(*block, bds);
|
auto extractedDS = this->Extract(*block, bds);
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||||
rp.enqueue(target, vtkm::filter::MakeSerializableDataSet(extractedDS, DerivedPolicy{}));
|
rp.enqueue(target, vtkm::filter::MakeSerializableDataSet(extractedDS, DerivedPolicy{}));
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_END
|
||||||
}
|
}
|
||||||
// clear our dataset.
|
// clear our dataset.
|
||||||
*block = vtkm::cont::DataSet();
|
*block = vtkm::cont::DataSet();
|
||||||
@ -155,7 +162,7 @@ public:
|
|||||||
auto target = rp.in_link().target(cc);
|
auto target = rp.in_link().target(cc);
|
||||||
if (rp.incoming(target.gid).size() > 0)
|
if (rp.incoming(target.gid).size() > 0)
|
||||||
{
|
{
|
||||||
auto sds = vtkm::filter::MakeSerializableDataSet(DerivedPolicy{});
|
auto sds = vtkm::filter::MakeSerializableDataSet(DerivedPolicy{}, this->Filter);
|
||||||
rp.dequeue(target.gid, sds);
|
rp.dequeue(target.gid, sds);
|
||||||
receives.push_back(sds.DataSet);
|
receives.push_back(sds.DataSet);
|
||||||
numValues += receives.back().GetCoordinateSystem(0).GetNumberOfPoints();
|
numValues += receives.back().GetCoordinateSystem(0).GetNumberOfPoints();
|
||||||
@ -237,7 +244,8 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet RedistributePoints::PrepareForEx
|
|||||||
*ds = input.GetPartition(lid);
|
*ds = input.GetPartition(lid);
|
||||||
});
|
});
|
||||||
|
|
||||||
internal::Redistributor<DerivedPolicy> redistributor(decomposer, policy);
|
internal::Redistributor<DerivedPolicy, RedistributePoints> redistributor(
|
||||||
|
decomposer, policy, *this);
|
||||||
vtkmdiy::all_to_all(master, assigner, redistributor, /*k=*/2);
|
vtkmdiy::all_to_all(master, assigner, redistributor, /*k=*/2);
|
||||||
|
|
||||||
vtkm::cont::PartitionedDataSet result;
|
vtkm::cont::PartitionedDataSet result;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include <vtkm/filter/PointAverage.h>
|
#include <vtkm/filter/PointAverage.h>
|
||||||
#include <vtkm/filter/PointAverage.hxx>
|
#include <vtkm/filter/PointAverage.hxx>
|
||||||
#include <vtkm/filter/PolicyExtrude.h>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -144,7 +143,7 @@ int TestCellSetExtrude()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
avg.SetActiveField("cfield");
|
avg.SetActiveField("cfield");
|
||||||
auto result = avg.Execute(dataset, vtkm::filter::PolicyExtrude{});
|
auto result = avg.Execute(dataset);
|
||||||
VTKM_TEST_ASSERT(result.HasPointField("cfield"), "filter resulting dataset should be valid");
|
VTKM_TEST_ASSERT(result.HasPointField("cfield"), "filter resulting dataset should be valid");
|
||||||
}
|
}
|
||||||
catch (const vtkm::cont::Error& err)
|
catch (const vtkm::cont::Error& err)
|
||||||
|
@ -37,7 +37,8 @@ inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
|
|||||||
//If the input is implicit, we should know what to fall back to
|
//If the input is implicit, we should know what to fall back to
|
||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
|
|
||||||
this->Invoke(this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy), inField, outArray);
|
this->Invoke(
|
||||||
|
this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy, *this), inField, outArray);
|
||||||
|
|
||||||
std::string outputName = this->GetOutputFieldName();
|
std::string outputName = this->GetOutputFieldName();
|
||||||
if (outputName.empty())
|
if (outputName.empty())
|
||||||
|
@ -45,7 +45,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
|
|||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
|
|
||||||
this->Invoke(vtkm::worklet::CellMeasure<IntegrationType>{},
|
this->Invoke(vtkm::worklet::CellMeasure<IntegrationType>{},
|
||||||
vtkm::filter::ApplyPolicyCellSet(cellset, policy),
|
vtkm::filter::ApplyPolicyCellSet(cellset, policy, *this),
|
||||||
points,
|
points,
|
||||||
outArray);
|
outArray);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellSetConnectivity::DoExecute(
|
|||||||
vtkm::cont::ArrayHandle<vtkm::Id> component;
|
vtkm::cont::ArrayHandle<vtkm::Id> component;
|
||||||
|
|
||||||
vtkm::worklet::connectivity::CellSetConnectivity().Run(
|
vtkm::worklet::connectivity::CellSetConnectivity().Run(
|
||||||
vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy), component);
|
vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), component);
|
||||||
|
|
||||||
return CreateResultFieldCell(input, component, this->GetOutputFieldName());
|
return CreateResultFieldCell(input, component, this->GetOutputFieldName());
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::Data
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Clean the grid
|
{ // Clean the grid
|
||||||
auto deducedCellSet = vtkm::filter::ApplyPolicyCellSet(inCellSet, policy);
|
auto deducedCellSet = vtkm::filter::ApplyPolicyCellSet(inCellSet, policy, *this);
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> numIndices;
|
||||||
|
|
||||||
this->Invoke(worklet::CellDeepCopy::CountCellPoints{}, deducedCellSet, numIndices);
|
this->Invoke(worklet::CellDeepCopy::CountCellPoints{}, deducedCellSet, numIndices);
|
||||||
|
@ -41,7 +41,7 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute(
|
|||||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy), field, this->ClipValue, this->Invert);
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, this->ClipValue, this->Invert);
|
||||||
|
|
||||||
//create the output data
|
//create the output data
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
|
@ -31,8 +31,11 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute(
|
|||||||
const vtkm::cont::CoordinateSystem& inputCoords =
|
const vtkm::cont::CoordinateSystem& inputCoords =
|
||||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex());
|
||||||
|
|
||||||
vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run(
|
vtkm::cont::CellSetExplicit<> outputCellSet =
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy), this->Function, inputCoords, this->Invert);
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
|
this->Function,
|
||||||
|
inputCoords,
|
||||||
|
this->Invert);
|
||||||
|
|
||||||
// compute output coordinates
|
// compute output coordinates
|
||||||
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData());
|
||||||
|
@ -98,7 +98,7 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
|
|||||||
if (this->GenerateNormals && generateHighQualityNormals)
|
if (this->GenerateNormals && generateHighQualityNormals)
|
||||||
{
|
{
|
||||||
outputCells = this->Worklet.Run(ivalues,
|
outputCells = this->Worklet.Run(ivalues,
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
coords.GetData(),
|
coords.GetData(),
|
||||||
field,
|
field,
|
||||||
vertices,
|
vertices,
|
||||||
@ -106,8 +106,11 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outputCells = this->Worklet.Run(
|
outputCells = this->Worklet.Run(ivalues,
|
||||||
ivalues, vtkm::filter::ApplyPolicyCellSet(cells, policy), coords.GetData(), field, vertices);
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
|
coords.GetData(),
|
||||||
|
field,
|
||||||
|
vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->GenerateNormals)
|
if (this->GenerateNormals)
|
||||||
|
@ -624,7 +624,7 @@ vtkm::cont::DataSet ContourTreeAugmented::DoExecute(
|
|||||||
vtkm::Id nCols;
|
vtkm::Id nCols;
|
||||||
vtkm::Id nSlices = 1;
|
vtkm::Id nSlices = 1;
|
||||||
const auto& cells = input.GetCellSet();
|
const auto& cells = input.GetCellSet();
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy)
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this)
|
||||||
.CastAndCall(GetRowsColsSlices(), nRows, nCols, nSlices);
|
.CastAndCall(GetRowsColsSlices(), nRows, nCols, nSlices);
|
||||||
// TODO blockIndex needs to change if we have multiple blocks per MPI rank and DoExecute is called for multiple blocks
|
// TODO blockIndex needs to change if we have multiple blocks per MPI rank and DoExecute is called for multiple blocks
|
||||||
std::size_t blockIndex = 0;
|
std::size_t blockIndex = 0;
|
||||||
|
@ -56,7 +56,7 @@ vtkm::cont::DataSet ExternalFaces::GenerateOutput(const vtkm::cont::DataSet& inp
|
|||||||
{
|
{
|
||||||
this->Compactor.SetCompactPointFields(true);
|
this->Compactor.SetCompactPointFields(true);
|
||||||
this->Compactor.SetMergePoints(false);
|
this->Compactor.SetMergePoints(false);
|
||||||
return this->Compactor.Execute(output, PolicyDefault{});
|
return this->Compactor.Execute(output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,8 @@ inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(cells, policy), outCellSet);
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(cells, policy, *this),
|
||||||
|
outCellSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->GenerateOutput(input, outCellSet);
|
return this->GenerateOutput(input, outCellSet);
|
||||||
|
@ -93,7 +93,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractGeometry::DoExecute(
|
|||||||
this->ExtractInside,
|
this->ExtractInside,
|
||||||
this->ExtractBoundaryCells,
|
this->ExtractBoundaryCells,
|
||||||
this->ExtractOnlyBoundaryCells);
|
this->ExtractOnlyBoundaryCells);
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy).CastAndCall(worker);
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this).CastAndCall(worker);
|
||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
|
@ -41,7 +41,7 @@ inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& i
|
|||||||
vtkm::cont::CellSetSingleType<> outCellSet;
|
vtkm::cont::CellSetSingleType<> outCellSet;
|
||||||
vtkm::worklet::ExtractPoints worklet;
|
vtkm::worklet::ExtractPoints worklet;
|
||||||
|
|
||||||
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
coords.GetData(),
|
coords.GetData(),
|
||||||
this->Function,
|
this->Function,
|
||||||
this->ExtractInside);
|
this->ExtractInside);
|
||||||
@ -56,7 +56,7 @@ inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& i
|
|||||||
{
|
{
|
||||||
this->Compactor.SetCompactPointFields(true);
|
this->Compactor.SetCompactPointFields(true);
|
||||||
this->Compactor.SetMergePoints(false);
|
this->Compactor.SetMergePoints(false);
|
||||||
return this->Compactor.Execute(output, PolicyDefault{});
|
return this->Compactor.Execute(output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractStructured::DoExecute(
|
|||||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||||
const vtkm::cont::CoordinateSystem& coordinates = input.GetCoordinateSystem();
|
const vtkm::cont::CoordinateSystem& coordinates = input.GetCoordinateSystem();
|
||||||
|
|
||||||
auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetStructured(cells, policy),
|
auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetStructured(cells, policy, *this),
|
||||||
this->VOI,
|
this->VOI,
|
||||||
this->SampleRate,
|
this->SampleRate,
|
||||||
this->IncludeBoundary,
|
this->IncludeBoundary,
|
||||||
|
@ -181,21 +181,39 @@ public:
|
|||||||
|
|
||||||
/// \brief Specify which subset of types a filter supports.
|
/// \brief Specify which subset of types a filter supports.
|
||||||
///
|
///
|
||||||
/// A filter is able to state what subset of types it supports
|
/// A filter is able to state what subset of types it supports.
|
||||||
/// by default. By default we use ListUniversal to represent that the
|
|
||||||
/// filter accepts all types specified by the users provided policy
|
|
||||||
using SupportedTypes = VTKM_DEFAULT_TYPE_LIST;
|
using SupportedTypes = VTKM_DEFAULT_TYPE_LIST;
|
||||||
|
|
||||||
/// \brief Specify which additional field storage to support.
|
/// \brief Specify which additional field storage to support.
|
||||||
///
|
///
|
||||||
/// When a filter gets a field value from a DataSet, it has to determine what type
|
/// 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
|
/// of storage the array has. Typically this is taken from the default storage
|
||||||
/// the filter's execute. In some cases it is useful to support additional types.
|
/// types defined in DefaultTypes.h. In some cases it is useful to support additional
|
||||||
/// For example, the filter might make sense to support ArrayHandleIndex or
|
/// types. For example, the filter might make sense to support ArrayHandleIndex or
|
||||||
/// ArrayHandleConstant. If so, the storage of those additional types should be
|
/// ArrayHandleConstant. If so, the storage of those additional types should be
|
||||||
/// listed here.
|
/// listed here.
|
||||||
using AdditionalFieldStorage = vtkm::ListEmpty;
|
using AdditionalFieldStorage = vtkm::ListEmpty;
|
||||||
|
|
||||||
|
/// \brief Specify which structured cell sets to support.
|
||||||
|
///
|
||||||
|
/// When a filter gets a cell set from a DataSet, it has to determine what type
|
||||||
|
/// of concrete cell set it is. This provides a list of supported structured
|
||||||
|
/// cell sets.
|
||||||
|
using SupportedStructuredCellSets = VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED;
|
||||||
|
|
||||||
|
/// \brief Specify which unstructured cell sets to support.
|
||||||
|
///
|
||||||
|
/// When a filter gets a cell set from a DataSet, it has to determine what type
|
||||||
|
/// of concrete cell set it is. This provides a list of supported unstructured
|
||||||
|
/// cell sets.
|
||||||
|
using SupportedUnstructuredCellSets = VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED;
|
||||||
|
|
||||||
|
/// \brief Specify which unstructured cell sets to support.
|
||||||
|
///
|
||||||
|
/// When a filter gets a cell set from a DataSet, it has to determine what type
|
||||||
|
/// of concrete cell set it is. This provides a list of supported cell sets.
|
||||||
|
using SupportedCellSets = VTKM_DEFAULT_CELL_SET_LIST;
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// \brief Specify which fields get passed from input to output.
|
/// \brief Specify which fields get passed from input to output.
|
||||||
///
|
///
|
||||||
@ -242,8 +260,11 @@ public:
|
|||||||
VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input);
|
VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input);
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input,
|
VTKM_DEPRECATED(1.6,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
"Filter::Execute no longer guarantees policy modifications. "
|
||||||
|
"Specify default types in CMake configuration instead.")
|
||||||
|
VTKM_CONT vtkm::cont::DataSet
|
||||||
|
Execute(const vtkm::cont::DataSet& input, vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
@ -253,6 +274,9 @@ public:
|
|||||||
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input);
|
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input);
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
|
VTKM_DEPRECATED(1.6,
|
||||||
|
"Filter::Execute no longer guarantees policy modifications. "
|
||||||
|
"Specify default types in CMake configuration instead.")
|
||||||
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input,
|
VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
//@}
|
//@}
|
||||||
|
@ -249,7 +249,16 @@ inline VTKM_CONT Filter<Derived>::~Filter()
|
|||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(const vtkm::cont::DataSet& input)
|
inline VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(const vtkm::cont::DataSet& input)
|
||||||
{
|
{
|
||||||
return this->Execute(input, vtkm::filter::PolicyDefault());
|
VTKM_LOG_SCOPE(
|
||||||
|
vtkm::cont::LogLevel::Perf, "Filter: '%s'", vtkm::cont::TypeToString<Derived>().c_str());
|
||||||
|
|
||||||
|
Derived* self = static_cast<Derived*>(this);
|
||||||
|
vtkm::cont::PartitionedDataSet output = self->Execute(vtkm::cont::PartitionedDataSet(input));
|
||||||
|
if (output.GetNumberOfPartitions() > 1)
|
||||||
|
{
|
||||||
|
throw vtkm::cont::ErrorFilterExecution("Expecting at most 1 block.");
|
||||||
|
}
|
||||||
|
return output.GetNumberOfPartitions() == 1 ? output.GetPartition(0) : vtkm::cont::DataSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -257,7 +266,23 @@ template <typename Derived>
|
|||||||
inline VTKM_CONT vtkm::cont::PartitionedDataSet Filter<Derived>::Execute(
|
inline VTKM_CONT vtkm::cont::PartitionedDataSet Filter<Derived>::Execute(
|
||||||
const vtkm::cont::PartitionedDataSet& input)
|
const vtkm::cont::PartitionedDataSet& input)
|
||||||
{
|
{
|
||||||
return this->Execute(input, vtkm::filter::PolicyDefault());
|
VTKM_LOG_SCOPE(vtkm::cont::LogLevel::Perf,
|
||||||
|
"Filter (PartitionedDataSet): '%s'",
|
||||||
|
vtkm::cont::TypeToString<Derived>().c_str());
|
||||||
|
|
||||||
|
Derived* self = static_cast<Derived*>(this);
|
||||||
|
|
||||||
|
vtkm::filter::PolicyDefault policy;
|
||||||
|
|
||||||
|
// Call `void Derived::PreExecute<DerivedPolicy>(input, policy)`, if defined.
|
||||||
|
internal::CallPreExecute(self, input, policy);
|
||||||
|
|
||||||
|
// Call `PrepareForExecution` (which should probably be renamed at some point)
|
||||||
|
vtkm::cont::PartitionedDataSet output = internal::CallPrepareForExecution(self, input, policy);
|
||||||
|
|
||||||
|
// Call `Derived::PostExecute<DerivedPolicy>(input, output, policy)` if defined.
|
||||||
|
internal::CallPostExecute(self, input, output, policy);
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,8 +297,10 @@ VTKM_CONT vtkm::cont::DataSet Filter<Derived>::Execute(
|
|||||||
vtkm::cont::LogLevel::Perf, "Filter: '%s'", vtkm::cont::TypeToString<Derived>().c_str());
|
vtkm::cont::LogLevel::Perf, "Filter: '%s'", vtkm::cont::TypeToString<Derived>().c_str());
|
||||||
|
|
||||||
Derived* self = static_cast<Derived*>(this);
|
Derived* self = static_cast<Derived*>(this);
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||||
vtkm::cont::PartitionedDataSet output =
|
vtkm::cont::PartitionedDataSet output =
|
||||||
self->Execute(vtkm::cont::PartitionedDataSet(input), policy);
|
self->Execute(vtkm::cont::PartitionedDataSet(input), policy);
|
||||||
|
VTKM_DEPRECATED_SUPPRESS_END
|
||||||
if (output.GetNumberOfPartitions() > 1)
|
if (output.GetNumberOfPartitions() > 1)
|
||||||
{
|
{
|
||||||
throw vtkm::cont::ErrorFilterExecution("Expecting at most 1 block.");
|
throw vtkm::cont::ErrorFilterExecution("Expecting at most 1 block.");
|
||||||
|
@ -17,7 +17,9 @@ namespace vtkm
|
|||||||
namespace filter
|
namespace filter
|
||||||
{
|
{
|
||||||
|
|
||||||
struct GhostCellClassifyPolicy : vtkm::filter::PolicyBase<GhostCellClassifyPolicy>
|
struct VTKM_DEPRECATED(1.6,
|
||||||
|
"GhostCellClassifyPolicy no longer has an effect.") GhostCellClassifyPolicy
|
||||||
|
: vtkm::filter::PolicyBase<GhostCellClassifyPolicy>
|
||||||
{
|
{
|
||||||
using FieldTypeList = vtkm::List<vtkm::UInt8>;
|
using FieldTypeList = vtkm::List<vtkm::UInt8>;
|
||||||
};
|
};
|
||||||
|
@ -335,14 +335,14 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
|
|||||||
|
|
||||||
if (this->GetRemoveAllGhost())
|
if (this->GetRemoveAllGhost())
|
||||||
{
|
{
|
||||||
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
field,
|
field,
|
||||||
fieldMeta.GetAssociation(),
|
fieldMeta.GetAssociation(),
|
||||||
RemoveAllGhosts());
|
RemoveAllGhosts());
|
||||||
}
|
}
|
||||||
else if (this->GetRemoveByType())
|
else if (this->GetRemoveByType())
|
||||||
{
|
{
|
||||||
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
field,
|
field,
|
||||||
fieldMeta.GetAssociation(),
|
fieldMeta.GetAssociation(),
|
||||||
RemoveGhostByType(this->GetRemoveType()));
|
RemoveGhostByType(this->GetRemoveType()));
|
||||||
|
@ -86,13 +86,13 @@ inline vtkm::cont::DataSet Gradient::DoExecute(
|
|||||||
{
|
{
|
||||||
vtkm::worklet::PointGradient gradient;
|
vtkm::worklet::PointGradient gradient;
|
||||||
outArray = gradient.Run(
|
outArray = gradient.Run(
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy), coords, inField, gradientfields);
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), coords, inField, gradientfields);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkm::worklet::CellGradient gradient;
|
vtkm::worklet::CellGradient gradient;
|
||||||
outArray = gradient.Run(
|
outArray = gradient.Run(
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy), coords, inField, gradientfields);
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), coords, inField, gradientfields);
|
||||||
}
|
}
|
||||||
if (!this->RowOrdering)
|
if (!this->RowOrdering)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ inline VTKM_CONT vtkm::cont::DataSet ImageConnectivity::DoExecute(
|
|||||||
vtkm::cont::ArrayHandle<vtkm::Id> component;
|
vtkm::cont::ArrayHandle<vtkm::Id> component;
|
||||||
|
|
||||||
vtkm::worklet::connectivity::ImageConnectivity().Run(
|
vtkm::worklet::connectivity::ImageConnectivity().Run(
|
||||||
vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy), field, component);
|
vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), field, component);
|
||||||
|
|
||||||
auto result = CreateResult(input, component, this->GetOutputFieldName(), fieldMetadata);
|
auto result = CreateResult(input, component, this->GetOutputFieldName(), fieldMetadata);
|
||||||
return result;
|
return result;
|
||||||
|
@ -108,7 +108,7 @@ inline VTKM_CONT vtkm::cont::DataSet ImageMedian::DoExecute(
|
|||||||
if (this->Neighborhood == 1 || this->Neighborhood == 2)
|
if (this->Neighborhood == 1 || this->Neighborhood == 2)
|
||||||
{
|
{
|
||||||
this->Invoke(worklet::ImageMedian{ this->Neighborhood },
|
this->Invoke(worklet::ImageMedian{ this->Neighborhood },
|
||||||
vtkm::filter::ApplyPolicyCellSetStructured(cells, policy),
|
vtkm::filter::ApplyPolicyCellSetStructured(cells, policy, *this),
|
||||||
field,
|
field,
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ inline VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet&
|
|||||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||||
vtkm::cont::DynamicCellSet cellOut;
|
vtkm::cont::DynamicCellSet cellOut;
|
||||||
CallWorklet workletCaller(this->Stride, cellOut, this->Worklet);
|
CallWorklet workletCaller(this->Stride, cellOut, this->Worklet);
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy).CastAndCall(workletCaller);
|
vtkm::filter::ApplyPolicyCellSet(cells, policy, *this).CastAndCall(workletCaller);
|
||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
|
@ -37,7 +37,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(
|
|||||||
vtkm::cont::CellSetSingleType<> outCellSet;
|
vtkm::cont::CellSetSingleType<> outCellSet;
|
||||||
vtkm::worklet::MaskPoints worklet;
|
vtkm::worklet::MaskPoints worklet;
|
||||||
|
|
||||||
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), this->Stride);
|
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), this->Stride);
|
||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
@ -49,7 +49,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(
|
|||||||
{
|
{
|
||||||
this->Compactor.SetCompactPointFields(true);
|
this->Compactor.SetCompactPointFields(true);
|
||||||
this->Compactor.SetMergePoints(false);
|
this->Compactor.SetMergePoints(false);
|
||||||
return this->Compactor.Execute(output, PolicyDefault{});
|
return this->Compactor.Execute(output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -69,13 +69,15 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(
|
|||||||
vtkm::worklet::MeshQuality<CellMetric> subWorklet;
|
vtkm::worklet::MeshQuality<CellMetric> subWorklet;
|
||||||
vtkm::cont::ArrayHandle<T> array;
|
vtkm::cont::ArrayHandle<T> array;
|
||||||
subWorklet.SetMetric(vtkm::filter::CellMetric::AREA);
|
subWorklet.SetMetric(vtkm::filter::CellMetric::AREA);
|
||||||
this->Invoke(subWorklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy), points, array);
|
this->Invoke(
|
||||||
|
subWorklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy, *this), points, array);
|
||||||
T zero = 0.0;
|
T zero = 0.0;
|
||||||
vtkm::FloatDefault totalArea = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, zero);
|
vtkm::FloatDefault totalArea = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, zero);
|
||||||
|
|
||||||
vtkm::FloatDefault averageVolume = 1.;
|
vtkm::FloatDefault averageVolume = 1.;
|
||||||
subWorklet.SetMetric(vtkm::filter::CellMetric::VOLUME);
|
subWorklet.SetMetric(vtkm::filter::CellMetric::VOLUME);
|
||||||
this->Invoke(subWorklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy), points, array);
|
this->Invoke(
|
||||||
|
subWorklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy, *this), points, array);
|
||||||
vtkm::FloatDefault totalVolume = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, zero);
|
vtkm::FloatDefault totalVolume = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, zero);
|
||||||
|
|
||||||
vtkm::Id numVals = array.GetNumberOfValues();
|
vtkm::Id numVals = array.GetNumberOfValues();
|
||||||
@ -91,7 +93,8 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(
|
|||||||
//Invoke the MeshQuality worklet
|
//Invoke the MeshQuality worklet
|
||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
qualityWorklet.SetMetric(this->MyMetric);
|
qualityWorklet.SetMetric(this->MyMetric);
|
||||||
this->Invoke(qualityWorklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy), points, outArray);
|
this->Invoke(
|
||||||
|
qualityWorklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy, *this), points, outArray);
|
||||||
|
|
||||||
vtkm::cont::DataSet result;
|
vtkm::cont::DataSet result;
|
||||||
result.CopyStructure(input); //clone of the input dataset
|
result.CopyStructure(input); //clone of the input dataset
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <vtkm/filter/vtkm_filter_export.h>
|
#include <vtkm/filter/vtkm_filter_export.h>
|
||||||
|
|
||||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||||
|
#include <vtkm/cont/CellSetExtrude.h>
|
||||||
#include <vtkm/filter/FilterCell.h>
|
#include <vtkm/filter/FilterCell.h>
|
||||||
#include <vtkm/worklet/PointAverage.h>
|
#include <vtkm/worklet/PointAverage.h>
|
||||||
|
|
||||||
@ -36,6 +37,11 @@ public:
|
|||||||
const vtkm::filter::FieldMetadata& fieldMeta,
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
vtkm::filter::PolicyBase<DerivedPolicy> policy);
|
||||||
|
|
||||||
|
// PointAverage is a simple filter that is used to test custom filter types.
|
||||||
|
using AdditionalFieldStorage = vtkm::List<vtkm::cont::internal::StorageTagExtrude>;
|
||||||
|
using SupportedCellSets =
|
||||||
|
vtkm::ListAppend<vtkm::List<vtkm::cont::CellSetExtrude>, VTKM_DEFAULT_CELL_SET_LIST>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::worklet::PointAverage Worklet;
|
vtkm::worklet::PointAverage Worklet;
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,8 @@ inline VTKM_CONT vtkm::cont::DataSet PointAverage::DoExecute(
|
|||||||
//todo: we need to ask the policy what storage type we should be using
|
//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
|
//If the input is implicit, we should know what to fall back to
|
||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
this->Invoke(this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy), inField, outArray);
|
this->Invoke(
|
||||||
|
this->Worklet, vtkm::filter::ApplyPolicyCellSet(cellSet, policy, *this), inField, outArray);
|
||||||
|
|
||||||
std::string outputName = this->GetOutputFieldName();
|
std::string outputName = this->GetOutputFieldName();
|
||||||
if (outputName.empty())
|
if (outputName.empty())
|
||||||
|
@ -277,7 +277,20 @@ ApplyPolicyFieldActive(const vtkm::cont::Field& field,
|
|||||||
///
|
///
|
||||||
/// Adjusts the types of `CellSet`s to support those types specified in a policy.
|
/// Adjusts the types of `CellSet`s to support those types specified in a policy.
|
||||||
///
|
///
|
||||||
|
template <typename DerivedPolicy, typename DerivedFilter>
|
||||||
|
VTKM_CONT vtkm::cont::DynamicCellSetBase<vtkm::ListAppend<typename DerivedFilter::SupportedCellSets,
|
||||||
|
typename DerivedPolicy::AllCellSetList>>
|
||||||
|
ApplyPolicyCellSet(const vtkm::cont::DynamicCellSet& cellset,
|
||||||
|
vtkm::filter::PolicyBase<DerivedPolicy>,
|
||||||
|
const vtkm::filter::Filter<DerivedFilter>&)
|
||||||
|
{
|
||||||
|
using CellSetList = vtkm::ListAppend<typename DerivedFilter::SupportedCellSets,
|
||||||
|
typename DerivedPolicy::AllCellSetList>;
|
||||||
|
return cellset.ResetCellSetList(CellSetList());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
|
VTKM_DEPRECATED(1.6, "ApplyPolicyCellSet now takes the filter as an argument.")
|
||||||
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::AllCellSetList> ApplyPolicyCellSet(
|
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::AllCellSetList> ApplyPolicyCellSet(
|
||||||
const vtkm::cont::DynamicCellSet& cellset,
|
const vtkm::cont::DynamicCellSet& cellset,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
@ -292,10 +305,25 @@ VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::AllCellSetList>
|
|||||||
/// Adjusts the types of `CellSet`s to support those structured cell set types
|
/// Adjusts the types of `CellSet`s to support those structured cell set types
|
||||||
/// specified in a policy.
|
/// specified in a policy.
|
||||||
///
|
///
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy, typename DerivedFilter>
|
||||||
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::StructuredCellSetList>
|
VTKM_CONT vtkm::cont::DynamicCellSetBase<
|
||||||
|
vtkm::ListAppend<typename DerivedFilter::SupportedStructuredCellSets,
|
||||||
|
typename DerivedPolicy::StructuredCellSetList>>
|
||||||
ApplyPolicyCellSetStructured(const vtkm::cont::DynamicCellSet& cellset,
|
ApplyPolicyCellSetStructured(const vtkm::cont::DynamicCellSet& cellset,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
vtkm::filter::PolicyBase<DerivedPolicy>,
|
||||||
|
const vtkm::filter::Filter<DerivedFilter>&)
|
||||||
|
{
|
||||||
|
using CellSetList = vtkm::ListAppend<typename DerivedFilter::SupportedStructuredCellSets,
|
||||||
|
typename DerivedPolicy::StructuredCellSetList>;
|
||||||
|
return cellset.ResetCellSetList(CellSetList());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DerivedPolicy>
|
||||||
|
VTKM_DEPRECATED(1.6, "ApplyPolicyCellSetStructured now takes the filter as an argument.")
|
||||||
|
VTKM_CONT vtkm::cont::
|
||||||
|
DynamicCellSetBase<typename DerivedPolicy::StructuredCellSetList> ApplyPolicyCellSetStructured(
|
||||||
|
const vtkm::cont::DynamicCellSet& cellset,
|
||||||
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
{
|
{
|
||||||
using CellSetList = typename DerivedPolicy::StructuredCellSetList;
|
using CellSetList = typename DerivedPolicy::StructuredCellSetList;
|
||||||
return cellset.ResetCellSetList(CellSetList());
|
return cellset.ResetCellSetList(CellSetList());
|
||||||
@ -307,10 +335,26 @@ ApplyPolicyCellSetStructured(const vtkm::cont::DynamicCellSet& cellset,
|
|||||||
/// Adjusts the types of `CellSet`s to support those unstructured cell set types
|
/// Adjusts the types of `CellSet`s to support those unstructured cell set types
|
||||||
/// specified in a policy.
|
/// specified in a policy.
|
||||||
///
|
///
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy, typename DerivedFilter>
|
||||||
VTKM_CONT vtkm::cont::DynamicCellSetBase<typename DerivedPolicy::UnstructuredCellSetList>
|
VTKM_CONT vtkm::cont::DynamicCellSetBase<
|
||||||
|
vtkm::ListAppend<typename DerivedFilter::SupportedUnstructuredCellSets,
|
||||||
|
typename DerivedPolicy::UnstructuredCellSetList>>
|
||||||
ApplyPolicyCellSetUnstructured(const vtkm::cont::DynamicCellSet& cellset,
|
ApplyPolicyCellSetUnstructured(const vtkm::cont::DynamicCellSet& cellset,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy>)
|
vtkm::filter::PolicyBase<DerivedPolicy>,
|
||||||
|
const vtkm::filter::Filter<DerivedFilter>&)
|
||||||
|
{
|
||||||
|
using CellSetList = vtkm::ListAppend<typename DerivedFilter::SupportedUnstructuredCellSets,
|
||||||
|
typename DerivedPolicy::UnstructuredCellSetList>;
|
||||||
|
return cellset.ResetCellSetList(CellSetList());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DerivedPolicy>
|
||||||
|
VTKM_DEPRECATED(1.6, "ApplyPolicyCellSetUnstructured now takes the filter as an argument.")
|
||||||
|
VTKM_CONT vtkm::cont::DynamicCellSetBase<
|
||||||
|
typename DerivedPolicy::
|
||||||
|
UnstructuredCellSetList> ApplyPolicyCellSetUnstructured(const vtkm::cont::DynamicCellSet&
|
||||||
|
cellset,
|
||||||
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
||||||
{
|
{
|
||||||
using CellSetList = typename DerivedPolicy::UnstructuredCellSetList;
|
using CellSetList = typename DerivedPolicy::UnstructuredCellSetList;
|
||||||
return cellset.ResetCellSetList(CellSetList());
|
return cellset.ResetCellSetList(CellSetList());
|
||||||
@ -332,21 +376,54 @@ MakeSerializableField(const vtkm::cont::Field& field, vtkm::filter::PolicyBase<D
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
|
VTKM_DEPRECATED(1.6, "MakeSerializableDataSet now takes the filter as an argument.")
|
||||||
typename DerivedPolicy::AllCellSetList>
|
VTKM_CONT vtkm::cont::SerializableDataSet<
|
||||||
MakeSerializableDataSet(vtkm::filter::PolicyBase<DerivedPolicy>)
|
typename DerivedPolicy::FieldTypeList,
|
||||||
|
typename DerivedPolicy::AllCellSetList> MakeSerializableDataSet(vtkm::filter::
|
||||||
|
PolicyBase<DerivedPolicy>)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename DerivedPolicy, typename DerivedFilter>
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
|
||||||
|
vtkm::ListAppend<typename DerivedFilter::SupportedCellSets,
|
||||||
|
typename DerivedPolicy::AllCellSetList>>
|
||||||
|
MakeSerializableDataSet(vtkm::filter::PolicyBase<DerivedPolicy>,
|
||||||
|
const vtkm::filter::Filter<DerivedFilter>&)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DerivedPolicy>
|
template <typename DerivedPolicy>
|
||||||
VTKM_CONT vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
|
VTKM_DEPRECATED(1.6, "MakeSerializableDataSet now takes the filter as an argument.")
|
||||||
typename DerivedPolicy::AllCellSetList>
|
VTKM_CONT vtkm::cont::SerializableDataSet<
|
||||||
MakeSerializableDataSet(const vtkm::cont::DataSet& dataset, vtkm::filter::PolicyBase<DerivedPolicy>)
|
typename DerivedPolicy::FieldTypeList,
|
||||||
|
typename DerivedPolicy::AllCellSetList> MakeSerializableDataSet(const vtkm::cont::DataSet&
|
||||||
|
dataset,
|
||||||
|
vtkm::filter::PolicyBase<
|
||||||
|
DerivedPolicy>)
|
||||||
{
|
{
|
||||||
return vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
|
return vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
|
||||||
typename DerivedPolicy::AllCellSetList>{ dataset };
|
typename DerivedPolicy::AllCellSetList>{ dataset };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename DerivedPolicy, typename DerivedFilter>
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
|
||||||
|
vtkm::ListAppend<typename DerivedFilter::SupportedCellSets,
|
||||||
|
typename DerivedPolicy::AllCellSetList>>
|
||||||
|
MakeSerializableDataSet(const vtkm::cont::DataSet& dataset,
|
||||||
|
vtkm::filter::PolicyBase<DerivedPolicy>,
|
||||||
|
const vtkm::filter::Filter<DerivedFilter>&)
|
||||||
|
{
|
||||||
|
return vtkm::cont::SerializableDataSet<typename DerivedPolicy::FieldTypeList,
|
||||||
|
vtkm::ListAppend<typename DerivedFilter::SupportedCellSets,
|
||||||
|
typename DerivedPolicy::AllCellSetList>>{
|
||||||
|
dataset
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // vtkm::filter
|
} // vtkm::filter
|
||||||
|
|
||||||
|
@ -28,14 +28,14 @@ VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute(
|
|||||||
const vtkm::cont::DataSet& input,
|
const vtkm::cont::DataSet& input,
|
||||||
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
||||||
{
|
{
|
||||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy),
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this),
|
||||||
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()),
|
||||||
this->Geometry.GetCoordinateSystem().GetData());
|
this->Geometry.GetCoordinateSystem().GetData());
|
||||||
|
|
||||||
auto output = this->Geometry;
|
auto output = this->Geometry;
|
||||||
auto hpf = this->Worklet.GetHiddenPointsField();
|
auto hpf = this->Worklet.GetHiddenPointsField();
|
||||||
auto hcf = this->Worklet.GetHiddenCellsField(
|
auto hcf = this->Worklet.GetHiddenCellsField(
|
||||||
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy));
|
vtkm::filter::ApplyPolicyCellSet(output.GetCellSet(), policy, *this));
|
||||||
|
|
||||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
|
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", hpf));
|
||||||
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
|
output.AddField(vtkm::cont::make_FieldCell("HIDDEN", hcf));
|
||||||
|
@ -41,7 +41,7 @@ inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute(
|
|||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> newCoords;
|
vtkm::cont::ArrayHandle<vtkm::Vec3f> newCoords;
|
||||||
vtkm::cont::CellSetExplicit<> newCellset;
|
vtkm::cont::CellSetExplicit<> newCellset;
|
||||||
|
|
||||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
this->FeatureAngle,
|
this->FeatureAngle,
|
||||||
field,
|
field,
|
||||||
input.GetCoordinateSystem().GetData(),
|
input.GetCoordinateSystem().GetData(),
|
||||||
|
@ -83,7 +83,8 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute(
|
|||||||
throw vtkm::cont::ErrorFilterExecution("No normals selected.");
|
throw vtkm::cont::ErrorFilterExecution("No normals selected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto cellset = vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy);
|
const auto cellset =
|
||||||
|
vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy, *this);
|
||||||
const auto& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetData();
|
const auto& coords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()).GetData();
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> faceNormals;
|
vtkm::cont::ArrayHandle<vtkm::Vec3f> faceNormals;
|
||||||
|
@ -46,8 +46,10 @@ inline VTKM_CONT vtkm::cont::DataSet Tetrahedralize::DoExecute(
|
|||||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||||
|
|
||||||
vtkm::cont::CellSetSingleType<> outCellSet;
|
vtkm::cont::CellSetSingleType<> outCellSet;
|
||||||
vtkm::cont::CastAndCall(
|
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy), DeduceCellSet{}, this->Worklet, outCellSet);
|
DeduceCellSet{},
|
||||||
|
this->Worklet,
|
||||||
|
outCellSet);
|
||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
|
@ -68,8 +68,11 @@ inline VTKM_CONT vtkm::cont::DataSet Threshold::DoExecute(
|
|||||||
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
||||||
|
|
||||||
ThresholdRange predicate(this->GetLowerThreshold(), this->GetUpperThreshold());
|
ThresholdRange predicate(this->GetLowerThreshold(), this->GetUpperThreshold());
|
||||||
vtkm::cont::DynamicCellSet cellOut = this->Worklet.Run(
|
vtkm::cont::DynamicCellSet cellOut =
|
||||||
vtkm::filter::ApplyPolicyCellSet(cells, policy), field, fieldMeta.GetAssociation(), predicate);
|
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
|
field,
|
||||||
|
fieldMeta.GetAssociation(),
|
||||||
|
predicate);
|
||||||
|
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
output.SetCellSet(cellOut);
|
output.SetCellSet(cellOut);
|
||||||
|
@ -146,14 +146,14 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(
|
|||||||
{
|
{
|
||||||
case THRESHOLD_BELOW:
|
case THRESHOLD_BELOW:
|
||||||
{
|
{
|
||||||
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
field,
|
field,
|
||||||
ValuesBelow(this->GetLowerThreshold()));
|
ValuesBelow(this->GetLowerThreshold()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case THRESHOLD_ABOVE:
|
case THRESHOLD_ABOVE:
|
||||||
{
|
{
|
||||||
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
field,
|
field,
|
||||||
ValuesAbove(this->GetUpperThreshold()));
|
ValuesAbove(this->GetUpperThreshold()));
|
||||||
break;
|
break;
|
||||||
@ -161,7 +161,7 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(
|
|||||||
case THRESHOLD_BETWEEN:
|
case THRESHOLD_BETWEEN:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy),
|
outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
||||||
field,
|
field,
|
||||||
ValuesBetween(this->GetLowerThreshold(), this->GetUpperThreshold()));
|
ValuesBetween(this->GetLowerThreshold(), this->GetUpperThreshold()));
|
||||||
break;
|
break;
|
||||||
@ -178,7 +178,7 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(
|
|||||||
{
|
{
|
||||||
this->Compactor.SetCompactPointFields(true);
|
this->Compactor.SetCompactPointFields(true);
|
||||||
this->Compactor.SetMergePoints(true);
|
this->Compactor.SetMergePoints(true);
|
||||||
return this->Compactor.Execute(output, PolicyDefault{});
|
return this->Compactor.Execute(output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ inline VTKM_CONT vtkm::cont::DataSet Triangulate::DoExecute(
|
|||||||
vtkm::cont::CellSetSingleType<> outCellSet;
|
vtkm::cont::CellSetSingleType<> outCellSet;
|
||||||
DeduceCellSet triangulate(this->Worklet, outCellSet);
|
DeduceCellSet triangulate(this->Worklet, outCellSet);
|
||||||
|
|
||||||
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyCellSet(cells, policy), triangulate);
|
vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), triangulate);
|
||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
|
@ -33,11 +33,11 @@ inline VTKM_CONT vtkm::cont::DataSet VertexClustering::DoExecute(
|
|||||||
//need to compute bounds first
|
//need to compute bounds first
|
||||||
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();
|
vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds();
|
||||||
|
|
||||||
vtkm::cont::DataSet outDataSet =
|
vtkm::cont::DataSet outDataSet = this->Worklet.Run(
|
||||||
this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy),
|
vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy, *this),
|
||||||
input.GetCoordinateSystem(),
|
input.GetCoordinateSystem(),
|
||||||
bounds,
|
bounds,
|
||||||
this->GetNumberOfDivisions());
|
this->GetNumberOfDivisions());
|
||||||
|
|
||||||
return outDataSet;
|
return outDataSet;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ set(unit_tests
|
|||||||
UnitTestClipWithFieldFilter.cxx
|
UnitTestClipWithFieldFilter.cxx
|
||||||
UnitTestClipWithImplicitFunctionFilter.cxx
|
UnitTestClipWithImplicitFunctionFilter.cxx
|
||||||
UnitTestContourFilter.cxx
|
UnitTestContourFilter.cxx
|
||||||
UnitTestContourFilterCustomPolicy.cxx
|
|
||||||
UnitTestContourFilterNormals.cxx
|
UnitTestContourFilterNormals.cxx
|
||||||
UnitTestContourTreeUniformFilter.cxx
|
UnitTestContourTreeUniformFilter.cxx
|
||||||
UnitTestContourTreeUniformAugmentedFilter.cxx
|
UnitTestContourTreeUniformAugmentedFilter.cxx
|
||||||
|
@ -1,218 +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.
|
|
||||||
//============================================================================
|
|
||||||
|
|
||||||
#include <vtkm/Math.h>
|
|
||||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
|
||||||
#include <vtkm/cont/CellSetSingleType.h>
|
|
||||||
#include <vtkm/cont/DataSet.h>
|
|
||||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
|
||||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
|
||||||
#include <vtkm/cont/testing/Testing.h>
|
|
||||||
|
|
||||||
#include <vtkm/filter/Contour.h>
|
|
||||||
#include <vtkm/filter/Contour.hxx>
|
|
||||||
|
|
||||||
namespace vtkm_ut_mc_policy
|
|
||||||
{
|
|
||||||
class EuclideanNorm
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VTKM_EXEC_CONT
|
|
||||||
EuclideanNorm()
|
|
||||||
: Reference(0., 0., 0.)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
VTKM_EXEC_CONT
|
|
||||||
EuclideanNorm(vtkm::Vec3f_32 reference)
|
|
||||||
: Reference(reference)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_EXEC_CONT
|
|
||||||
vtkm::Float32 operator()(vtkm::Vec3f_32 v) const
|
|
||||||
{
|
|
||||||
vtkm::Vec3f_32 d(
|
|
||||||
v[0] - this->Reference[0], v[1] - this->Reference[1], v[2] - this->Reference[2]);
|
|
||||||
return vtkm::Magnitude(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
vtkm::Vec3f_32 Reference;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CubeGridConnectivity
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VTKM_EXEC_CONT
|
|
||||||
CubeGridConnectivity()
|
|
||||||
: Dimension(1)
|
|
||||||
, DimSquared(1)
|
|
||||||
, DimPlus1Squared(4)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
VTKM_EXEC_CONT
|
|
||||||
CubeGridConnectivity(vtkm::Id dim)
|
|
||||||
: Dimension(dim)
|
|
||||||
, DimSquared(dim * dim)
|
|
||||||
, DimPlus1Squared((dim + 1) * (dim + 1))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
VTKM_EXEC_CONT
|
|
||||||
vtkm::Id operator()(vtkm::Id vertex) const
|
|
||||||
{
|
|
||||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
|
||||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
|
||||||
|
|
||||||
vtkm::Id cellId = vertex / HexTraits::NUM_POINTS;
|
|
||||||
vtkm::Id localId = vertex % HexTraits::NUM_POINTS;
|
|
||||||
vtkm::Id globalId =
|
|
||||||
(cellId + cellId / this->Dimension + (this->Dimension + 1) * (cellId / (this->DimSquared)));
|
|
||||||
|
|
||||||
switch (localId)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
globalId += 1;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
globalId += this->Dimension + 2;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
globalId += this->Dimension + 1;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
globalId += this->DimPlus1Squared;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
globalId += this->DimPlus1Squared + 1;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
globalId += this->Dimension + this->DimPlus1Squared + 2;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
globalId += this->Dimension + this->DimPlus1Squared + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return globalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
vtkm::Id Dimension;
|
|
||||||
vtkm::Id DimSquared;
|
|
||||||
vtkm::Id DimPlus1Squared;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MakeRadiantDataSet
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using CoordinateArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
|
||||||
using DataArrayHandle =
|
|
||||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleUniformPointCoordinates, EuclideanNorm>;
|
|
||||||
using ConnectivityArrayHandle =
|
|
||||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
|
||||||
CubeGridConnectivity>;
|
|
||||||
|
|
||||||
using CellSet = vtkm::cont::CellSetSingleType<
|
|
||||||
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<vtkm::Id>,
|
|
||||||
CubeGridConnectivity>::StorageTag>;
|
|
||||||
|
|
||||||
vtkm::cont::DataSet Make3DRadiantDataSet(vtkm::IdComponent dim = 5);
|
|
||||||
};
|
|
||||||
|
|
||||||
class PolicyRadiantDataSet : public vtkm::filter::PolicyBase<PolicyRadiantDataSet>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using TypeListRadiantCellSetTypes = vtkm::List<MakeRadiantDataSet::CellSet>;
|
|
||||||
|
|
||||||
using AllCellSetList = TypeListRadiantCellSetTypes;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComponent dim)
|
|
||||||
{
|
|
||||||
// create a cube from -.5 to .5 in x,y,z, consisting of <dim> cells on each
|
|
||||||
// axis, with point values equal to the Euclidean distance from the origin.
|
|
||||||
|
|
||||||
vtkm::cont::DataSet dataSet;
|
|
||||||
|
|
||||||
using HexTag = vtkm::CellShapeTagHexahedron;
|
|
||||||
using HexTraits = vtkm::CellTraits<HexTag>;
|
|
||||||
|
|
||||||
using CoordType = vtkm::Vec3f_32;
|
|
||||||
|
|
||||||
const vtkm::IdComponent nCells = dim * dim * dim;
|
|
||||||
|
|
||||||
vtkm::Float32 spacing = vtkm::Float32(1. / dim);
|
|
||||||
CoordinateArrayHandle coordinates(vtkm::Id3(dim + 1, dim + 1, dim + 1),
|
|
||||||
CoordType(-.5, -.5, -.5),
|
|
||||||
CoordType(spacing, spacing, spacing));
|
|
||||||
|
|
||||||
DataArrayHandle distanceToOrigin(coordinates);
|
|
||||||
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
|
|
||||||
|
|
||||||
ConnectivityArrayHandle connectivity(
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
|
|
||||||
CubeGridConnectivity(dim));
|
|
||||||
|
|
||||||
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
|
|
||||||
|
|
||||||
//Set point scalar
|
|
||||||
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;
|
|
||||||
cellSet.Fill(coordinates.GetNumberOfValues(), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
|
|
||||||
|
|
||||||
dataSet.SetCellSet(cellSet);
|
|
||||||
|
|
||||||
return dataSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestContourCustomPolicy()
|
|
||||||
{
|
|
||||||
std::cout << "Testing Contour filter with custom field and cellset" << std::endl;
|
|
||||||
|
|
||||||
using DataSetGenerator = MakeRadiantDataSet;
|
|
||||||
DataSetGenerator dataSetGenerator;
|
|
||||||
|
|
||||||
const vtkm::IdComponent Dimension = 10;
|
|
||||||
vtkm::cont::DataSet dataSet = dataSetGenerator.Make3DRadiantDataSet(Dimension);
|
|
||||||
|
|
||||||
vtkm::filter::Contour mc;
|
|
||||||
|
|
||||||
mc.SetGenerateNormals(false);
|
|
||||||
mc.SetIsoValue(0, 0.45);
|
|
||||||
mc.SetIsoValue(1, 0.45);
|
|
||||||
mc.SetIsoValue(2, 0.45);
|
|
||||||
mc.SetIsoValue(3, 0.45);
|
|
||||||
|
|
||||||
//We specify a custom execution policy here, since the "distanceToOrigin" is a
|
|
||||||
//custom field type
|
|
||||||
mc.SetActiveField("distanceToOrigin");
|
|
||||||
mc.SetFieldsToPass({ "distanceToOrigin", "distanceToOther" });
|
|
||||||
vtkm::cont::DataSet outputData = mc.Execute(dataSet, PolicyRadiantDataSet{});
|
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
|
|
||||||
"Wrong number of fields in the output dataset");
|
|
||||||
|
|
||||||
vtkm::cont::CoordinateSystem coords = outputData.GetCoordinateSystem();
|
|
||||||
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == (414 * 4), "Should have some coordinates");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
int UnitTestContourFilterCustomPolicy(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_policy::TestContourCustomPolicy, argc, argv);
|
|
||||||
}
|
|
@ -103,7 +103,7 @@ void TestStructured()
|
|||||||
|
|
||||||
vtkm::filter::GhostCellClassify addGhost;
|
vtkm::filter::GhostCellClassify addGhost;
|
||||||
|
|
||||||
auto output = addGhost.Execute(ds, vtkm::filter::GhostCellClassifyPolicy());
|
auto output = addGhost.Execute(ds);
|
||||||
|
|
||||||
//Validate the output.
|
//Validate the output.
|
||||||
VTKM_TEST_ASSERT(output.HasCellField("vtkmGhostCells"),
|
VTKM_TEST_ASSERT(output.HasCellField("vtkmGhostCells"),
|
||||||
|
@ -99,8 +99,7 @@ void TestPointElevationWithPolicy()
|
|||||||
filter.SetRange(0.0, 2.0);
|
filter.SetRange(0.0, 2.0);
|
||||||
filter.SetUseCoordinateSystemAsField(true);
|
filter.SetUseCoordinateSystemAsField(true);
|
||||||
|
|
||||||
vtkm::filter::PolicyDefault p;
|
auto result = filter.Execute(inputData);
|
||||||
auto result = filter.Execute(inputData, p);
|
|
||||||
|
|
||||||
//verify the result
|
//verify the result
|
||||||
VTKM_TEST_ASSERT(result.HasPointField("elevation"), "Output field has wrong association");
|
VTKM_TEST_ASSERT(result.HasPointField("elevation"), "Output field has wrong association");
|
||||||
|
@ -219,14 +219,6 @@ void TestWithExplicitData()
|
|||||||
TestSplitSharpEdgesFilterNoSplit(simpleCubeWithSN, splitSharpEdgesFilter);
|
TestSplitSharpEdgesFilterNoSplit(simpleCubeWithSN, splitSharpEdgesFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SplitSharpTestPolicy : public vtkm::filter::PolicyBase<SplitSharpTestPolicy>
|
|
||||||
{
|
|
||||||
using StructuredCellSetList = vtkm::List<vtkm::cont::CellSetStructured<3>>;
|
|
||||||
using UnstructuredCellSetList = vtkm::List<vtkm::cont::CellSetSingleType<>>;
|
|
||||||
using AllCellSetList = vtkm::ListAppend<StructuredCellSetList, UnstructuredCellSetList>;
|
|
||||||
using FieldTypeList = vtkm::List<vtkm::FloatDefault, vtkm::Vec3f>;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void TestWithStructuredData()
|
void TestWithStructuredData()
|
||||||
{
|
{
|
||||||
@ -254,7 +246,7 @@ void TestWithStructuredData()
|
|||||||
std::cout << dataSet.GetNumberOfPoints() << std::endl;
|
std::cout << dataSet.GetNumberOfPoints() << std::endl;
|
||||||
vtkm::filter::SplitSharpEdges split;
|
vtkm::filter::SplitSharpEdges split;
|
||||||
split.SetActiveField("normals", vtkm::cont::Field::Association::CELL_SET);
|
split.SetActiveField("normals", vtkm::cont::Field::Association::CELL_SET);
|
||||||
dataSet = split.Execute(dataSet, SplitSharpTestPolicy{});
|
dataSet = split.Execute(dataSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,15 +51,6 @@ vtkm::cont::DataSet MakeWarpVectorTestDataSet()
|
|||||||
return dataSet;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PolicyWarpVector : public vtkm::filter::PolicyBase<PolicyWarpVector>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using vecType = vtkm::Vec3f;
|
|
||||||
using TypeListWarpVectorTags = vtkm::List<vtkm::cont::ArrayHandleConstant<vecType>::StorageTag,
|
|
||||||
vtkm::cont::ArrayHandle<vecType>::StorageTag>;
|
|
||||||
using FieldStorageList = TypeListWarpVectorTags;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CheckResult(const vtkm::filter::WarpVector& filter, const vtkm::cont::DataSet& result)
|
void CheckResult(const vtkm::filter::WarpVector& filter, const vtkm::cont::DataSet& result)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(result.HasPointField("warpvector"), "Output filed WarpVector is missing");
|
VTKM_TEST_ASSERT(result.HasPointField("warpvector"), "Output filed WarpVector is missing");
|
||||||
@ -100,7 +91,7 @@ void TestWarpVectorFilter()
|
|||||||
vtkm::filter::WarpVector filter(scale);
|
vtkm::filter::WarpVector filter(scale);
|
||||||
filter.SetUseCoordinateSystemAsField(true);
|
filter.SetUseCoordinateSystemAsField(true);
|
||||||
filter.SetVectorField("vec2");
|
filter.SetVectorField("vec2");
|
||||||
vtkm::cont::DataSet result = filter.Execute(ds, PolicyWarpVector());
|
vtkm::cont::DataSet result = filter.Execute(ds);
|
||||||
CheckResult(filter, result);
|
CheckResult(filter, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +100,7 @@ void TestWarpVectorFilter()
|
|||||||
vtkm::filter::WarpVector filter(scale);
|
vtkm::filter::WarpVector filter(scale);
|
||||||
filter.SetActiveField("vec1");
|
filter.SetActiveField("vec1");
|
||||||
filter.SetVectorField("vec2");
|
filter.SetVectorField("vec2");
|
||||||
vtkm::cont::DataSet result = filter.Execute(ds, PolicyWarpVector());
|
vtkm::cont::DataSet result = filter.Execute(ds);
|
||||||
CheckResult(filter, result);
|
CheckResult(filter, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,6 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
struct TestPolicy : public vtkm::filter::PolicyBase<TestPolicy>
|
|
||||||
{
|
|
||||||
using StructuredCellSetList = vtkm::List<vtkm::cont::CellSetStructured<3>>;
|
|
||||||
using UnstructuredCellSetList = vtkm::List<vtkm::cont::CellSetSingleType<>>;
|
|
||||||
using AllCellSetList = vtkm::ListAppend<StructuredCellSetList, UnstructuredCellSetList>;
|
|
||||||
using FieldTypeList = vtkm::List<vtkm::FloatDefault, vtkm::Vec<vtkm::FloatDefault, 3>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
vtkm::cont::DataSet CreateDataSet(bool pointNormals, bool cellNormals)
|
vtkm::cont::DataSet CreateDataSet(bool pointNormals, bool cellNormals)
|
||||||
{
|
{
|
||||||
@ -79,7 +71,7 @@ vtkm::cont::DataSet CreateDataSet(bool pointNormals, bool cellNormals)
|
|||||||
normals.SetPointNormalsName("normals");
|
normals.SetPointNormalsName("normals");
|
||||||
normals.SetCellNormalsName("normals");
|
normals.SetCellNormalsName("normals");
|
||||||
normals.SetAutoOrientNormals(false);
|
normals.SetAutoOrientNormals(false);
|
||||||
dataSet = normals.Execute(dataSet, TestPolicy{});
|
dataSet = normals.Execute(dataSet);
|
||||||
|
|
||||||
return dataSet;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user