diff --git a/docs/changelog/deprecate-execute-with-policy.md b/docs/changelog/deprecate-execute-with-policy.md new file mode 100644 index 000000000..1924bb19e --- /dev/null +++ b/docs/changelog/deprecate-execute-with-policy.md @@ -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. diff --git a/examples/multi_backend/MultiDeviceGradient.hxx b/examples/multi_backend/MultiDeviceGradient.hxx index 12d0daecf..b15369fbc 100644 --- a/examples/multi_backend/MultiDeviceGradient.hxx +++ b/examples/multi_backend/MultiDeviceGradient.hxx @@ -219,7 +219,9 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet MultiDeviceGradient::PrepareForE [=]() { vtkm::filter::Gradient perThreadGrad = gradient; + VTKM_DEPRECATED_SUPPRESS_BEGIN vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy); + VTKM_DEPRECATED_SUPPRESS_END outPtr->ReplacePartition(0, result); }); this->Queue.waitForAllTasksToComplete(); @@ -238,7 +240,9 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet MultiDeviceGradient::PrepareForE [=]() { vtkm::filter::Gradient perThreadGrad = gradient; + VTKM_DEPRECATED_SUPPRESS_BEGIN vtkm::cont::DataSet result = perThreadGrad.Execute(input, policy); + VTKM_DEPRECATED_SUPPRESS_END outPtr->ReplacePartition(index, result); }); index++; diff --git a/examples/redistribute_points/RedistributePoints.h b/examples/redistribute_points/RedistributePoints.h index f7f72f2f6..c8175582c 100644 --- a/examples/redistribute_points/RedistributePoints.h +++ b/examples/redistribute_points/RedistributePoints.h @@ -38,11 +38,12 @@ static vtkmdiy::ContinuousBounds convert(const vtkm::Bounds& bds) } -template +template class Redistributor { const vtkmdiy::RegularDecomposer& Decomposer; const vtkm::filter::PolicyBase& Policy; + const FilterType& Filter; vtkm::cont::DataSet Extract(const vtkm::cont::DataSet& input, const vtkmdiy::ContinuousBounds& bds) const @@ -53,7 +54,9 @@ class Redistributor vtkm::filter::ExtractPoints extractor; extractor.SetCompactPoints(true); extractor.SetImplicitFunction(vtkm::cont::make_ImplicitFunctionHandle(box)); + VTKM_DEPRECATED_SUPPRESS_BEGIN return extractor.Execute(input, this->Policy); + VTKM_DEPRECATED_SUPPRESS_END } class ConcatenateFields @@ -120,9 +123,11 @@ class Redistributor public: Redistributor(const vtkmdiy::RegularDecomposer& decomposer, - const vtkm::filter::PolicyBase& policy) + const vtkm::filter::PolicyBase& policy, + const FilterType& filter) : Decomposer(decomposer) , Policy(policy) + , Filter(filter) { } @@ -140,7 +145,9 @@ public: this->Decomposer.fill_bounds(bds, target.gid); auto extractedDS = this->Extract(*block, bds); + VTKM_DEPRECATED_SUPPRESS_BEGIN rp.enqueue(target, vtkm::filter::MakeSerializableDataSet(extractedDS, DerivedPolicy{})); + VTKM_DEPRECATED_SUPPRESS_END } // clear our dataset. *block = vtkm::cont::DataSet(); @@ -155,7 +162,7 @@ public: auto target = rp.in_link().target(cc); 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); receives.push_back(sds.DataSet); numValues += receives.back().GetCoordinateSystem(0).GetNumberOfPoints(); @@ -237,7 +244,8 @@ inline VTKM_CONT vtkm::cont::PartitionedDataSet RedistributePoints::PrepareForEx *ds = input.GetPartition(lid); }); - internal::Redistributor redistributor(decomposer, policy); + internal::Redistributor redistributor( + decomposer, policy, *this); vtkmdiy::all_to_all(master, assigner, redistributor, /*k=*/2); vtkm::cont::PartitionedDataSet result; diff --git a/vtkm/cont/testing/UnitTestCellSetExtrude.cxx b/vtkm/cont/testing/UnitTestCellSetExtrude.cxx index 28b25b8f7..10637b369 100644 --- a/vtkm/cont/testing/UnitTestCellSetExtrude.cxx +++ b/vtkm/cont/testing/UnitTestCellSetExtrude.cxx @@ -16,7 +16,6 @@ #include #include -#include namespace { @@ -144,7 +143,7 @@ int TestCellSetExtrude() try { 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"); } catch (const vtkm::cont::Error& err) diff --git a/vtkm/filter/CellAverage.hxx b/vtkm/filter/CellAverage.hxx index 224250b06..744cc37f7 100644 --- a/vtkm/filter/CellAverage.hxx +++ b/vtkm/filter/CellAverage.hxx @@ -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 vtkm::cont::ArrayHandle 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(); if (outputName.empty()) diff --git a/vtkm/filter/CellMeasures.hxx b/vtkm/filter/CellMeasures.hxx index 28ec8abb5..8812ead91 100644 --- a/vtkm/filter/CellMeasures.hxx +++ b/vtkm/filter/CellMeasures.hxx @@ -45,7 +45,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures::DoExecute( vtkm::cont::ArrayHandle outArray; this->Invoke(vtkm::worklet::CellMeasure{}, - vtkm::filter::ApplyPolicyCellSet(cellset, policy), + vtkm::filter::ApplyPolicyCellSet(cellset, policy, *this), points, outArray); diff --git a/vtkm/filter/CellSetConnectivity.hxx b/vtkm/filter/CellSetConnectivity.hxx index 2333981d0..f5a7c0591 100644 --- a/vtkm/filter/CellSetConnectivity.hxx +++ b/vtkm/filter/CellSetConnectivity.hxx @@ -32,7 +32,7 @@ inline VTKM_CONT vtkm::cont::DataSet CellSetConnectivity::DoExecute( vtkm::cont::ArrayHandle component; 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()); } diff --git a/vtkm/filter/CleanGrid.hxx b/vtkm/filter/CleanGrid.hxx index a2ae6a4fc..f2ec52133 100644 --- a/vtkm/filter/CleanGrid.hxx +++ b/vtkm/filter/CleanGrid.hxx @@ -37,7 +37,7 @@ inline VTKM_CONT vtkm::cont::DataSet CleanGrid::DoExecute(const vtkm::cont::Data } else { // Clean the grid - auto deducedCellSet = vtkm::filter::ApplyPolicyCellSet(inCellSet, policy); + auto deducedCellSet = vtkm::filter::ApplyPolicyCellSet(inCellSet, policy, *this); vtkm::cont::ArrayHandle numIndices; this->Invoke(worklet::CellDeepCopy::CountCellPoints{}, deducedCellSet, numIndices); diff --git a/vtkm/filter/ClipWithField.hxx b/vtkm/filter/ClipWithField.hxx index d76e91346..3a724b9e3 100644 --- a/vtkm/filter/ClipWithField.hxx +++ b/vtkm/filter/ClipWithField.hxx @@ -41,7 +41,7 @@ inline VTKM_CONT vtkm::cont::DataSet ClipWithField::DoExecute( input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()); 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 vtkm::cont::DataSet output; diff --git a/vtkm/filter/ClipWithImplicitFunction.hxx b/vtkm/filter/ClipWithImplicitFunction.hxx index e3a1e7a42..57b32616f 100644 --- a/vtkm/filter/ClipWithImplicitFunction.hxx +++ b/vtkm/filter/ClipWithImplicitFunction.hxx @@ -31,8 +31,11 @@ inline vtkm::cont::DataSet ClipWithImplicitFunction::DoExecute( const vtkm::cont::CoordinateSystem& inputCoords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()); - vtkm::cont::CellSetExplicit<> outputCellSet = this->Worklet.Run( - vtkm::filter::ApplyPolicyCellSet(cells, policy), this->Function, inputCoords, this->Invert); + vtkm::cont::CellSetExplicit<> outputCellSet = + this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), + this->Function, + inputCoords, + this->Invert); // compute output coordinates auto outputCoordsArray = this->Worklet.ProcessPointField(inputCoords.GetData()); diff --git a/vtkm/filter/Contour.hxx b/vtkm/filter/Contour.hxx index 1a3532730..74b1760b1 100644 --- a/vtkm/filter/Contour.hxx +++ b/vtkm/filter/Contour.hxx @@ -98,7 +98,7 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute( if (this->GenerateNormals && generateHighQualityNormals) { outputCells = this->Worklet.Run(ivalues, - vtkm::filter::ApplyPolicyCellSet(cells, policy), + vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), coords.GetData(), field, vertices, @@ -106,8 +106,11 @@ inline VTKM_CONT vtkm::cont::DataSet Contour::DoExecute( } else { - outputCells = this->Worklet.Run( - ivalues, vtkm::filter::ApplyPolicyCellSet(cells, policy), coords.GetData(), field, vertices); + outputCells = this->Worklet.Run(ivalues, + vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), + coords.GetData(), + field, + vertices); } if (this->GenerateNormals) diff --git a/vtkm/filter/ContourTreeUniformAugmented.hxx b/vtkm/filter/ContourTreeUniformAugmented.hxx index 9adbc0ac5..a707d44ae 100644 --- a/vtkm/filter/ContourTreeUniformAugmented.hxx +++ b/vtkm/filter/ContourTreeUniformAugmented.hxx @@ -624,7 +624,7 @@ vtkm::cont::DataSet ContourTreeAugmented::DoExecute( vtkm::Id nCols; vtkm::Id nSlices = 1; const auto& cells = input.GetCellSet(); - vtkm::filter::ApplyPolicyCellSet(cells, policy) + vtkm::filter::ApplyPolicyCellSet(cells, policy, *this) .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 std::size_t blockIndex = 0; diff --git a/vtkm/filter/ExternalFaces.cxx b/vtkm/filter/ExternalFaces.cxx index 0e36dea71..caafe4f06 100644 --- a/vtkm/filter/ExternalFaces.cxx +++ b/vtkm/filter/ExternalFaces.cxx @@ -56,7 +56,7 @@ vtkm::cont::DataSet ExternalFaces::GenerateOutput(const vtkm::cont::DataSet& inp { this->Compactor.SetCompactPointFields(true); this->Compactor.SetMergePoints(false); - return this->Compactor.Execute(output, PolicyDefault{}); + return this->Compactor.Execute(output); } else { diff --git a/vtkm/filter/ExternalFaces.hxx b/vtkm/filter/ExternalFaces.hxx index e41da2fd5..1d31c6f69 100644 --- a/vtkm/filter/ExternalFaces.hxx +++ b/vtkm/filter/ExternalFaces.hxx @@ -37,7 +37,8 @@ inline VTKM_CONT vtkm::cont::DataSet ExternalFaces::DoExecute( } 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); diff --git a/vtkm/filter/ExtractGeometry.hxx b/vtkm/filter/ExtractGeometry.hxx index 7ba67219d..273c43e01 100644 --- a/vtkm/filter/ExtractGeometry.hxx +++ b/vtkm/filter/ExtractGeometry.hxx @@ -93,7 +93,7 @@ inline VTKM_CONT vtkm::cont::DataSet ExtractGeometry::DoExecute( this->ExtractInside, this->ExtractBoundaryCells, this->ExtractOnlyBoundaryCells); - vtkm::filter::ApplyPolicyCellSet(cells, policy).CastAndCall(worker); + vtkm::filter::ApplyPolicyCellSet(cells, policy, *this).CastAndCall(worker); // create the output dataset vtkm::cont::DataSet output; diff --git a/vtkm/filter/ExtractPoints.hxx b/vtkm/filter/ExtractPoints.hxx index c47c27436..b06c49900 100644 --- a/vtkm/filter/ExtractPoints.hxx +++ b/vtkm/filter/ExtractPoints.hxx @@ -41,7 +41,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::ApplyPolicyCellSet(cells, policy), + outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), coords.GetData(), this->Function, this->ExtractInside); @@ -56,7 +56,7 @@ inline vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& i { this->Compactor.SetCompactPointFields(true); this->Compactor.SetMergePoints(false); - return this->Compactor.Execute(output, PolicyDefault{}); + return this->Compactor.Execute(output); } else { diff --git a/vtkm/filter/ExtractStructured.hxx b/vtkm/filter/ExtractStructured.hxx index 112abaccc..4546a09a6 100644 --- a/vtkm/filter/ExtractStructured.hxx +++ b/vtkm/filter/ExtractStructured.hxx @@ -24,7 +24,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::ApplyPolicyCellSetStructured(cells, policy), + auto cellset = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetStructured(cells, policy, *this), this->VOI, this->SampleRate, this->IncludeBoundary, diff --git a/vtkm/filter/Filter.h b/vtkm/filter/Filter.h index dee4e13e4..2ad449eaa 100644 --- a/vtkm/filter/Filter.h +++ b/vtkm/filter/Filter.h @@ -181,21 +181,39 @@ public: /// \brief Specify which subset of types a filter 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 + /// A filter is able to state what subset of types it supports. using SupportedTypes = VTKM_DEFAULT_TYPE_LIST; /// \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 + /// of storage the array has. Typically this is taken from the default storage + /// types defined in DefaultTypes.h. 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::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. /// @@ -242,8 +260,11 @@ public: VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input); template - VTKM_CONT vtkm::cont::DataSet Execute(const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase policy); + VTKM_DEPRECATED(1.6, + "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 policy); //@} //@{ @@ -253,6 +274,9 @@ public: VTKM_CONT vtkm::cont::PartitionedDataSet Execute(const vtkm::cont::PartitionedDataSet& input); template + 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::filter::PolicyBase policy); //@} diff --git a/vtkm/filter/Filter.hxx b/vtkm/filter/Filter.hxx index 49256157e..8cc86b767 100644 --- a/vtkm/filter/Filter.hxx +++ b/vtkm/filter/Filter.hxx @@ -249,7 +249,16 @@ inline VTKM_CONT Filter::~Filter() template inline VTKM_CONT vtkm::cont::DataSet Filter::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().c_str()); + + Derived* self = static_cast(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 inline VTKM_CONT vtkm::cont::PartitionedDataSet Filter::Execute( 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().c_str()); + + Derived* self = static_cast(this); + + vtkm::filter::PolicyDefault policy; + + // Call `void Derived::PreExecute(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(input, output, policy)` if defined. + internal::CallPostExecute(self, input, output, policy); + return output; } @@ -272,8 +297,10 @@ VTKM_CONT vtkm::cont::DataSet Filter::Execute( vtkm::cont::LogLevel::Perf, "Filter: '%s'", vtkm::cont::TypeToString().c_str()); Derived* self = static_cast(this); + VTKM_DEPRECATED_SUPPRESS_BEGIN vtkm::cont::PartitionedDataSet output = self->Execute(vtkm::cont::PartitionedDataSet(input), policy); + VTKM_DEPRECATED_SUPPRESS_END if (output.GetNumberOfPartitions() > 1) { throw vtkm::cont::ErrorFilterExecution("Expecting at most 1 block."); diff --git a/vtkm/filter/GhostCellClassify.h b/vtkm/filter/GhostCellClassify.h index e0f7f545c..875d79405 100644 --- a/vtkm/filter/GhostCellClassify.h +++ b/vtkm/filter/GhostCellClassify.h @@ -17,7 +17,9 @@ namespace vtkm namespace filter { -struct GhostCellClassifyPolicy : vtkm::filter::PolicyBase +struct VTKM_DEPRECATED(1.6, + "GhostCellClassifyPolicy no longer has an effect.") GhostCellClassifyPolicy + : vtkm::filter::PolicyBase { using FieldTypeList = vtkm::List; }; diff --git a/vtkm/filter/GhostCellRemove.hxx b/vtkm/filter/GhostCellRemove.hxx index 43866abe0..044cc1f19 100644 --- a/vtkm/filter/GhostCellRemove.hxx +++ b/vtkm/filter/GhostCellRemove.hxx @@ -335,14 +335,14 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute( if (this->GetRemoveAllGhost()) { - cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), + cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, fieldMeta.GetAssociation(), RemoveAllGhosts()); } else if (this->GetRemoveByType()) { - cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), + cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, fieldMeta.GetAssociation(), RemoveGhostByType(this->GetRemoveType())); diff --git a/vtkm/filter/Gradient.hxx b/vtkm/filter/Gradient.hxx index 313d372db..a14133406 100644 --- a/vtkm/filter/Gradient.hxx +++ b/vtkm/filter/Gradient.hxx @@ -86,13 +86,13 @@ inline vtkm::cont::DataSet Gradient::DoExecute( { vtkm::worklet::PointGradient gradient; outArray = gradient.Run( - vtkm::filter::ApplyPolicyCellSet(cells, policy), coords, inField, gradientfields); + vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), coords, inField, gradientfields); } else { vtkm::worklet::CellGradient gradient; outArray = gradient.Run( - vtkm::filter::ApplyPolicyCellSet(cells, policy), coords, inField, gradientfields); + vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), coords, inField, gradientfields); } if (!this->RowOrdering) { diff --git a/vtkm/filter/ImageConnectivity.hxx b/vtkm/filter/ImageConnectivity.hxx index 144384b94..3bd094b69 100644 --- a/vtkm/filter/ImageConnectivity.hxx +++ b/vtkm/filter/ImageConnectivity.hxx @@ -31,7 +31,7 @@ inline VTKM_CONT vtkm::cont::DataSet ImageConnectivity::DoExecute( vtkm::cont::ArrayHandle component; 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); return result; diff --git a/vtkm/filter/ImageMedian.hxx b/vtkm/filter/ImageMedian.hxx index d6c5290e3..d5fa33144 100644 --- a/vtkm/filter/ImageMedian.hxx +++ b/vtkm/filter/ImageMedian.hxx @@ -108,7 +108,7 @@ inline VTKM_CONT vtkm::cont::DataSet ImageMedian::DoExecute( if (this->Neighborhood == 1 || this->Neighborhood == 2) { this->Invoke(worklet::ImageMedian{ this->Neighborhood }, - vtkm::filter::ApplyPolicyCellSetStructured(cells, policy), + vtkm::filter::ApplyPolicyCellSetStructured(cells, policy, *this), field, result); } diff --git a/vtkm/filter/Mask.hxx b/vtkm/filter/Mask.hxx index a7b568a90..4bb583704 100644 --- a/vtkm/filter/Mask.hxx +++ b/vtkm/filter/Mask.hxx @@ -56,7 +56,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::ApplyPolicyCellSet(cells, policy).CastAndCall(workletCaller); + vtkm::filter::ApplyPolicyCellSet(cells, policy, *this).CastAndCall(workletCaller); // create the output dataset vtkm::cont::DataSet output; diff --git a/vtkm/filter/MaskPoints.hxx b/vtkm/filter/MaskPoints.hxx index f626d2a36..1134aef6f 100644 --- a/vtkm/filter/MaskPoints.hxx +++ b/vtkm/filter/MaskPoints.hxx @@ -37,7 +37,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute( vtkm::cont::CellSetSingleType<> outCellSet; 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 vtkm::cont::DataSet output; @@ -49,7 +49,7 @@ inline VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute( { this->Compactor.SetCompactPointFields(true); this->Compactor.SetMergePoints(false); - return this->Compactor.Execute(output, PolicyDefault{}); + return this->Compactor.Execute(output); } else { diff --git a/vtkm/filter/MeshQuality.hxx b/vtkm/filter/MeshQuality.hxx index fd1566024..01a8df14a 100644 --- a/vtkm/filter/MeshQuality.hxx +++ b/vtkm/filter/MeshQuality.hxx @@ -69,13 +69,15 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute( vtkm::worklet::MeshQuality subWorklet; vtkm::cont::ArrayHandle array; 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; vtkm::FloatDefault totalArea = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, zero); vtkm::FloatDefault averageVolume = 1.; 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::Id numVals = array.GetNumberOfValues(); @@ -91,7 +93,8 @@ inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute( //Invoke the MeshQuality worklet vtkm::cont::ArrayHandle outArray; 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; result.CopyStructure(input); //clone of the input dataset diff --git a/vtkm/filter/PointAverage.h b/vtkm/filter/PointAverage.h index ee2d16e0c..a0b7d302e 100644 --- a/vtkm/filter/PointAverage.h +++ b/vtkm/filter/PointAverage.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -36,6 +37,11 @@ public: const vtkm::filter::FieldMetadata& fieldMeta, vtkm::filter::PolicyBase policy); + // PointAverage is a simple filter that is used to test custom filter types. + using AdditionalFieldStorage = vtkm::List; + using SupportedCellSets = + vtkm::ListAppend, VTKM_DEFAULT_CELL_SET_LIST>; + private: vtkm::worklet::PointAverage Worklet; }; diff --git a/vtkm/filter/PointAverage.hxx b/vtkm/filter/PointAverage.hxx index 0120714a0..b441c8b6e 100644 --- a/vtkm/filter/PointAverage.hxx +++ b/vtkm/filter/PointAverage.hxx @@ -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 //If the input is implicit, we should know what to fall back to vtkm::cont::ArrayHandle 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(); if (outputName.empty()) diff --git a/vtkm/filter/PolicyBase.h b/vtkm/filter/PolicyBase.h index 613771a68..6c703f7e3 100644 --- a/vtkm/filter/PolicyBase.h +++ b/vtkm/filter/PolicyBase.h @@ -277,7 +277,20 @@ ApplyPolicyFieldActive(const vtkm::cont::Field& field, /// /// Adjusts the types of `CellSet`s to support those types specified in a policy. /// +template +VTKM_CONT vtkm::cont::DynamicCellSetBase> +ApplyPolicyCellSet(const vtkm::cont::DynamicCellSet& cellset, + vtkm::filter::PolicyBase, + const vtkm::filter::Filter&) +{ + using CellSetList = vtkm::ListAppend; + return cellset.ResetCellSetList(CellSetList()); +} + template +VTKM_DEPRECATED(1.6, "ApplyPolicyCellSet now takes the filter as an argument.") VTKM_CONT vtkm::cont::DynamicCellSetBase ApplyPolicyCellSet( const vtkm::cont::DynamicCellSet& cellset, vtkm::filter::PolicyBase) @@ -292,10 +305,25 @@ VTKM_CONT vtkm::cont::DynamicCellSetBase /// Adjusts the types of `CellSet`s to support those structured cell set types /// specified in a policy. /// -template -VTKM_CONT vtkm::cont::DynamicCellSetBase +template +VTKM_CONT vtkm::cont::DynamicCellSetBase< + vtkm::ListAppend> ApplyPolicyCellSetStructured(const vtkm::cont::DynamicCellSet& cellset, - vtkm::filter::PolicyBase) + vtkm::filter::PolicyBase, + const vtkm::filter::Filter&) +{ + using CellSetList = vtkm::ListAppend; + return cellset.ResetCellSetList(CellSetList()); +} + +template +VTKM_DEPRECATED(1.6, "ApplyPolicyCellSetStructured now takes the filter as an argument.") +VTKM_CONT vtkm::cont:: + DynamicCellSetBase ApplyPolicyCellSetStructured( + const vtkm::cont::DynamicCellSet& cellset, + vtkm::filter::PolicyBase) { using CellSetList = typename DerivedPolicy::StructuredCellSetList; 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 /// specified in a policy. /// -template -VTKM_CONT vtkm::cont::DynamicCellSetBase +template +VTKM_CONT vtkm::cont::DynamicCellSetBase< + vtkm::ListAppend> ApplyPolicyCellSetUnstructured(const vtkm::cont::DynamicCellSet& cellset, - vtkm::filter::PolicyBase) + vtkm::filter::PolicyBase, + const vtkm::filter::Filter&) +{ + using CellSetList = vtkm::ListAppend; + return cellset.ResetCellSetList(CellSetList()); +} + +template +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) { using CellSetList = typename DerivedPolicy::UnstructuredCellSetList; return cellset.ResetCellSetList(CellSetList()); @@ -332,21 +376,54 @@ MakeSerializableField(const vtkm::cont::Field& field, vtkm::filter::PolicyBase -VTKM_CONT vtkm::cont::SerializableDataSet - MakeSerializableDataSet(vtkm::filter::PolicyBase) +VTKM_DEPRECATED(1.6, "MakeSerializableDataSet now takes the filter as an argument.") +VTKM_CONT vtkm::cont::SerializableDataSet< + typename DerivedPolicy::FieldTypeList, + typename DerivedPolicy::AllCellSetList> MakeSerializableDataSet(vtkm::filter:: + PolicyBase) +{ + return {}; +} + +template +VTKM_CONT + vtkm::cont::SerializableDataSet> + MakeSerializableDataSet(vtkm::filter::PolicyBase, + const vtkm::filter::Filter&) { return {}; } template -VTKM_CONT vtkm::cont::SerializableDataSet -MakeSerializableDataSet(const vtkm::cont::DataSet& dataset, vtkm::filter::PolicyBase) +VTKM_DEPRECATED(1.6, "MakeSerializableDataSet now takes the filter as an argument.") +VTKM_CONT vtkm::cont::SerializableDataSet< + typename DerivedPolicy::FieldTypeList, + typename DerivedPolicy::AllCellSetList> MakeSerializableDataSet(const vtkm::cont::DataSet& + dataset, + vtkm::filter::PolicyBase< + DerivedPolicy>) { return vtkm::cont::SerializableDataSet{ dataset }; } + +template +VTKM_CONT + vtkm::cont::SerializableDataSet> + MakeSerializableDataSet(const vtkm::cont::DataSet& dataset, + vtkm::filter::PolicyBase, + const vtkm::filter::Filter&) +{ + return vtkm::cont::SerializableDataSet>{ + dataset + }; +} } } // vtkm::filter diff --git a/vtkm/filter/Probe.hxx b/vtkm/filter/Probe.hxx index c3c2691fd..dbaa1f14b 100644 --- a/vtkm/filter/Probe.hxx +++ b/vtkm/filter/Probe.hxx @@ -28,14 +28,14 @@ VTKM_CONT inline vtkm::cont::DataSet Probe::DoExecute( const vtkm::cont::DataSet& input, vtkm::filter::PolicyBase policy) { - this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy), + this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()), this->Geometry.GetCoordinateSystem().GetData()); auto output = this->Geometry; auto hpf = this->Worklet.GetHiddenPointsField(); 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_FieldCell("HIDDEN", hcf)); diff --git a/vtkm/filter/SplitSharpEdges.hxx b/vtkm/filter/SplitSharpEdges.hxx index e2566e870..6b2015848 100644 --- a/vtkm/filter/SplitSharpEdges.hxx +++ b/vtkm/filter/SplitSharpEdges.hxx @@ -41,7 +41,7 @@ inline VTKM_CONT vtkm::cont::DataSet SplitSharpEdges::DoExecute( vtkm::cont::ArrayHandle newCoords; vtkm::cont::CellSetExplicit<> newCellset; - this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), + this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), this->FeatureAngle, field, input.GetCoordinateSystem().GetData(), diff --git a/vtkm/filter/SurfaceNormals.hxx b/vtkm/filter/SurfaceNormals.hxx index a81fdb00a..ddd29f91c 100644 --- a/vtkm/filter/SurfaceNormals.hxx +++ b/vtkm/filter/SurfaceNormals.hxx @@ -83,7 +83,8 @@ inline vtkm::cont::DataSet SurfaceNormals::DoExecute( 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(); vtkm::cont::ArrayHandle faceNormals; diff --git a/vtkm/filter/Tetrahedralize.hxx b/vtkm/filter/Tetrahedralize.hxx index 882e0b406..2508adc8b 100644 --- a/vtkm/filter/Tetrahedralize.hxx +++ b/vtkm/filter/Tetrahedralize.hxx @@ -46,8 +46,10 @@ inline VTKM_CONT vtkm::cont::DataSet Tetrahedralize::DoExecute( const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(); vtkm::cont::CellSetSingleType<> outCellSet; - vtkm::cont::CastAndCall( - vtkm::filter::ApplyPolicyCellSet(cells, policy), DeduceCellSet{}, this->Worklet, outCellSet); + vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), + DeduceCellSet{}, + this->Worklet, + outCellSet); // create the output dataset vtkm::cont::DataSet output; diff --git a/vtkm/filter/Threshold.hxx b/vtkm/filter/Threshold.hxx index 39f1962f4..8f26cbfc8 100644 --- a/vtkm/filter/Threshold.hxx +++ b/vtkm/filter/Threshold.hxx @@ -68,8 +68,11 @@ inline VTKM_CONT vtkm::cont::DataSet Threshold::DoExecute( const vtkm::cont::DynamicCellSet& cells = input.GetCellSet(); ThresholdRange predicate(this->GetLowerThreshold(), this->GetUpperThreshold()); - vtkm::cont::DynamicCellSet cellOut = this->Worklet.Run( - vtkm::filter::ApplyPolicyCellSet(cells, policy), field, fieldMeta.GetAssociation(), predicate); + vtkm::cont::DynamicCellSet cellOut = + this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), + field, + fieldMeta.GetAssociation(), + predicate); vtkm::cont::DataSet output; output.SetCellSet(cellOut); diff --git a/vtkm/filter/ThresholdPoints.hxx b/vtkm/filter/ThresholdPoints.hxx index 2fbbdafa3..ada6c8a5f 100644 --- a/vtkm/filter/ThresholdPoints.hxx +++ b/vtkm/filter/ThresholdPoints.hxx @@ -146,14 +146,14 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute( { case THRESHOLD_BELOW: { - outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), + outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, ValuesBelow(this->GetLowerThreshold())); break; } case THRESHOLD_ABOVE: { - outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), + outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, ValuesAbove(this->GetUpperThreshold())); break; @@ -161,7 +161,7 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute( case THRESHOLD_BETWEEN: default: { - outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy), + outCellSet = worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), field, ValuesBetween(this->GetLowerThreshold(), this->GetUpperThreshold())); break; @@ -178,7 +178,7 @@ inline VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute( { this->Compactor.SetCompactPointFields(true); this->Compactor.SetMergePoints(true); - return this->Compactor.Execute(output, PolicyDefault{}); + return this->Compactor.Execute(output); } else { diff --git a/vtkm/filter/Triangulate.hxx b/vtkm/filter/Triangulate.hxx index ca527d24a..abccdbd93 100644 --- a/vtkm/filter/Triangulate.hxx +++ b/vtkm/filter/Triangulate.hxx @@ -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::ApplyPolicyCellSet(cells, policy), triangulate); + vtkm::cont::CastAndCall(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this), triangulate); // create the output dataset vtkm::cont::DataSet output; diff --git a/vtkm/filter/VertexClustering.hxx b/vtkm/filter/VertexClustering.hxx index a722c36e7..20d9592da 100644 --- a/vtkm/filter/VertexClustering.hxx +++ b/vtkm/filter/VertexClustering.hxx @@ -33,11 +33,11 @@ inline VTKM_CONT vtkm::cont::DataSet VertexClustering::DoExecute( //need to compute bounds first vtkm::Bounds bounds = input.GetCoordinateSystem().GetBounds(); - vtkm::cont::DataSet outDataSet = - this->Worklet.Run(vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy), - input.GetCoordinateSystem(), - bounds, - this->GetNumberOfDivisions()); + vtkm::cont::DataSet outDataSet = this->Worklet.Run( + vtkm::filter::ApplyPolicyCellSetUnstructured(input.GetCellSet(), policy, *this), + input.GetCoordinateSystem(), + bounds, + this->GetNumberOfDivisions()); return outDataSet; } diff --git a/vtkm/filter/testing/CMakeLists.txt b/vtkm/filter/testing/CMakeLists.txt index 72a572eeb..b9116930f 100644 --- a/vtkm/filter/testing/CMakeLists.txt +++ b/vtkm/filter/testing/CMakeLists.txt @@ -16,7 +16,6 @@ set(unit_tests UnitTestClipWithFieldFilter.cxx UnitTestClipWithImplicitFunctionFilter.cxx UnitTestContourFilter.cxx - UnitTestContourFilterCustomPolicy.cxx UnitTestContourFilterNormals.cxx UnitTestContourTreeUniformFilter.cxx UnitTestContourTreeUniformAugmentedFilter.cxx diff --git a/vtkm/filter/testing/UnitTestContourFilterCustomPolicy.cxx b/vtkm/filter/testing/UnitTestContourFilterCustomPolicy.cxx deleted file mode 100644 index 002c5adea..000000000 --- a/vtkm/filter/testing/UnitTestContourFilterCustomPolicy.cxx +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include - -#include -#include - -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; - - 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; - using ConnectivityArrayHandle = - vtkm::cont::ArrayHandleTransform, - CubeGridConnectivity>; - - using CellSet = vtkm::cont::CellSetSingleType< - vtkm::cont::ArrayHandleTransform, - CubeGridConnectivity>::StorageTag>; - - vtkm::cont::DataSet Make3DRadiantDataSet(vtkm::IdComponent dim = 5); -}; - -class PolicyRadiantDataSet : public vtkm::filter::PolicyBase -{ -public: - using TypeListRadiantCellSetTypes = vtkm::List; - - 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 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; - - 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(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); -} diff --git a/vtkm/filter/testing/UnitTestGhostCellClassify.cxx b/vtkm/filter/testing/UnitTestGhostCellClassify.cxx index fa87a94c6..ccaefd5da 100644 --- a/vtkm/filter/testing/UnitTestGhostCellClassify.cxx +++ b/vtkm/filter/testing/UnitTestGhostCellClassify.cxx @@ -103,7 +103,7 @@ void TestStructured() vtkm::filter::GhostCellClassify addGhost; - auto output = addGhost.Execute(ds, vtkm::filter::GhostCellClassifyPolicy()); + auto output = addGhost.Execute(ds); //Validate the output. VTKM_TEST_ASSERT(output.HasCellField("vtkmGhostCells"), diff --git a/vtkm/filter/testing/UnitTestPointElevationFilter.cxx b/vtkm/filter/testing/UnitTestPointElevationFilter.cxx index cf598256e..25e516a16 100644 --- a/vtkm/filter/testing/UnitTestPointElevationFilter.cxx +++ b/vtkm/filter/testing/UnitTestPointElevationFilter.cxx @@ -99,8 +99,7 @@ void TestPointElevationWithPolicy() filter.SetRange(0.0, 2.0); filter.SetUseCoordinateSystemAsField(true); - vtkm::filter::PolicyDefault p; - auto result = filter.Execute(inputData, p); + auto result = filter.Execute(inputData); //verify the result VTKM_TEST_ASSERT(result.HasPointField("elevation"), "Output field has wrong association"); diff --git a/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx b/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx index 70a5dd79d..12749fddf 100644 --- a/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx +++ b/vtkm/filter/testing/UnitTestSplitSharpEdgesFilter.cxx @@ -219,14 +219,6 @@ void TestWithExplicitData() TestSplitSharpEdgesFilterNoSplit(simpleCubeWithSN, splitSharpEdgesFilter); } -struct SplitSharpTestPolicy : public vtkm::filter::PolicyBase -{ - using StructuredCellSetList = vtkm::List>; - using UnstructuredCellSetList = vtkm::List>; - using AllCellSetList = vtkm::ListAppend; - using FieldTypeList = vtkm::List; -}; - void TestWithStructuredData() { @@ -254,7 +246,7 @@ void TestWithStructuredData() std::cout << dataSet.GetNumberOfPoints() << std::endl; vtkm::filter::SplitSharpEdges split; split.SetActiveField("normals", vtkm::cont::Field::Association::CELL_SET); - dataSet = split.Execute(dataSet, SplitSharpTestPolicy{}); + dataSet = split.Execute(dataSet); } diff --git a/vtkm/filter/testing/UnitTestWarpVectorFilter.cxx b/vtkm/filter/testing/UnitTestWarpVectorFilter.cxx index fc49f2f0f..a7017bff8 100644 --- a/vtkm/filter/testing/UnitTestWarpVectorFilter.cxx +++ b/vtkm/filter/testing/UnitTestWarpVectorFilter.cxx @@ -51,15 +51,6 @@ vtkm::cont::DataSet MakeWarpVectorTestDataSet() return dataSet; } -class PolicyWarpVector : public vtkm::filter::PolicyBase -{ -public: - using vecType = vtkm::Vec3f; - using TypeListWarpVectorTags = vtkm::List::StorageTag, - vtkm::cont::ArrayHandle::StorageTag>; - using FieldStorageList = TypeListWarpVectorTags; -}; - void CheckResult(const vtkm::filter::WarpVector& filter, const vtkm::cont::DataSet& result) { VTKM_TEST_ASSERT(result.HasPointField("warpvector"), "Output filed WarpVector is missing"); @@ -100,7 +91,7 @@ void TestWarpVectorFilter() vtkm::filter::WarpVector filter(scale); filter.SetUseCoordinateSystemAsField(true); filter.SetVectorField("vec2"); - vtkm::cont::DataSet result = filter.Execute(ds, PolicyWarpVector()); + vtkm::cont::DataSet result = filter.Execute(ds); CheckResult(filter, result); } @@ -109,7 +100,7 @@ void TestWarpVectorFilter() vtkm::filter::WarpVector filter(scale); filter.SetActiveField("vec1"); filter.SetVectorField("vec2"); - vtkm::cont::DataSet result = filter.Execute(ds, PolicyWarpVector()); + vtkm::cont::DataSet result = filter.Execute(ds); CheckResult(filter, result); } } diff --git a/vtkm/worklet/testing/UnitTestOrientNormals.cxx b/vtkm/worklet/testing/UnitTestOrientNormals.cxx index f31256af1..a7490c010 100644 --- a/vtkm/worklet/testing/UnitTestOrientNormals.cxx +++ b/vtkm/worklet/testing/UnitTestOrientNormals.cxx @@ -48,14 +48,6 @@ namespace { -struct TestPolicy : public vtkm::filter::PolicyBase -{ - using StructuredCellSetList = vtkm::List>; - using UnstructuredCellSetList = vtkm::List>; - using AllCellSetList = vtkm::ListAppend; - using FieldTypeList = vtkm::List>; -}; - VTKM_CONT vtkm::cont::DataSet CreateDataSet(bool pointNormals, bool cellNormals) { @@ -79,7 +71,7 @@ vtkm::cont::DataSet CreateDataSet(bool pointNormals, bool cellNormals) normals.SetPointNormalsName("normals"); normals.SetCellNormalsName("normals"); normals.SetAutoOrientNormals(false); - dataSet = normals.Execute(dataSet, TestPolicy{}); + dataSet = normals.Execute(dataSet); return dataSet; }