diff --git a/vtkm/filter/NewFilterField.h b/vtkm/filter/NewFilterField.h index 5adeaa714..ac09f6e67 100644 --- a/vtkm/filter/NewFilterField.h +++ b/vtkm/filter/NewFilterField.h @@ -142,6 +142,54 @@ protected: } } + template + VTKM_CONT void CastAndCallScalarField(const vtkm::cont::UnknownArrayHandle& fieldArray, + Functor&& functor, + Args&&... args) const + { + fieldArray + .CastAndCallForTypesWithFloatFallback( + std::forward(functor), std::forward(args)...); + } + + template + VTKM_CONT void CastAndCallScalarField(const vtkm::cont::Field& field, + Functor&& functor, + Args&&... args) const + { + this->CastAndCallScalarField( + field.GetData(), std::forward(functor), std::forward(args)...); + } + +private: + template + struct ScalarToVec + { + template + using type = vtkm::Vec; + }; + +protected: + template + VTKM_CONT void CastAndCallVecField(const vtkm::cont::UnknownArrayHandle& fieldArray, + Functor&& functor, + Args&&... args) const + { + using VecList = + vtkm::ListTransform::template type>; + fieldArray.CastAndCallForTypesWithFloatFallback( + std::forward(functor), std::forward(args)...); + } + + template + VTKM_CONT void CastAndCallVecField(const vtkm::cont::Field& field, + Functor&& functor, + Args&&... args) const + { + this->CastAndCallVecField( + field.GetData(), std::forward(functor), std::forward(args)...); + } + private: void ResizeIfNeeded(size_t index_st); diff --git a/vtkm/filter/entity_extraction/ThresholdPoints.cxx b/vtkm/filter/entity_extraction/ThresholdPoints.cxx index a1c69d239..f04b40f3e 100644 --- a/vtkm/filter/entity_extraction/ThresholdPoints.cxx +++ b/vtkm/filter/entity_extraction/ThresholdPoints.cxx @@ -147,7 +147,7 @@ VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(const vtkm::cont::DataS vtkm::cont::CellSetSingleType<> outCellSet; vtkm::worklet::ThresholdPoints worklet; - auto ResolveType = [&, this](const auto& concrete) { + auto resolveType = [&, this](const auto& concrete) { switch (this->ThresholdType) { case THRESHOLD_BELOW: @@ -170,8 +170,7 @@ VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(const vtkm::cont::DataS } }; - const auto& fieldArray = field.GetData(); - fieldArray.CastAndCallForTypes(ResolveType); + this->CastAndCallScalarField(field, resolveType); // create the output dataset vtkm::cont::DataSet output;