From ca463a8a6fd8e795321eef1aba384608c5ad5b92 Mon Sep 17 00:00:00 2001 From: Li-Ta Lo Date: Tue, 16 Aug 2022 15:26:02 -0600 Subject: [PATCH] replace CallWorklet with lambda --- .../worklet/RemoveDegenerateCells.h | 13 +---- .../entity_extraction/ExtractGeometry.cxx | 56 +++---------------- vtkm/filter/entity_extraction/Mask.cxx | 24 +------- 3 files changed, 12 insertions(+), 81 deletions(-) diff --git a/vtkm/filter/clean_grid/worklet/RemoveDegenerateCells.h b/vtkm/filter/clean_grid/worklet/RemoveDegenerateCells.h index 74a95ced6..03b5d934e 100644 --- a/vtkm/filter/clean_grid/worklet/RemoveDegenerateCells.h +++ b/vtkm/filter/clean_grid/worklet/RemoveDegenerateCells.h @@ -133,22 +133,11 @@ struct RemoveDegenerateCells return output; } - struct CallWorklet - { - template - void operator()(const CellSetType& cellSet, - RemoveDegenerateCells& self, - vtkm::cont::CellSetExplicit<>& output) const - { - output = self.Run(cellSet); - } - }; - template vtkm::cont::CellSetExplicit<> Run(const vtkm::cont::UncertainCellSet& cellSet) { vtkm::cont::CellSetExplicit<> output; - cellSet.CastAndCall(CallWorklet(), *this, output); + cellSet.CastAndCall([&](const auto& concrete) { output = this->Run(concrete); }); return output; } diff --git a/vtkm/filter/entity_extraction/ExtractGeometry.cxx b/vtkm/filter/entity_extraction/ExtractGeometry.cxx index 9f20297cb..89e000dc7 100644 --- a/vtkm/filter/entity_extraction/ExtractGeometry.cxx +++ b/vtkm/filter/entity_extraction/ExtractGeometry.cxx @@ -16,45 +16,6 @@ namespace { -struct CallWorker -{ - vtkm::cont::UnknownCellSet& Output; - vtkm::worklet::ExtractGeometry& Worklet; - const vtkm::cont::CoordinateSystem& Coords; - const vtkm::ImplicitFunctionGeneral& Function; - bool ExtractInside; - bool ExtractBoundaryCells; - bool ExtractOnlyBoundaryCells; - - CallWorker(vtkm::cont::UnknownCellSet& output, - vtkm::worklet::ExtractGeometry& worklet, - const vtkm::cont::CoordinateSystem& coords, - const vtkm::ImplicitFunctionGeneral& function, - bool extractInside, - bool extractBoundaryCells, - bool extractOnlyBoundaryCells) - : Output(output) - , Worklet(worklet) - , Coords(coords) - , Function(function) - , ExtractInside(extractInside) - , ExtractBoundaryCells(extractBoundaryCells) - , ExtractOnlyBoundaryCells(extractOnlyBoundaryCells) - { - } - - template - void operator()(const CellSetType& cellSet) const - { - this->Output = this->Worklet.Run(cellSet, - this->Coords, - this->Function, - this->ExtractInside, - this->ExtractBoundaryCells, - this->ExtractOnlyBoundaryCells); - } -}; - bool DoMapField(vtkm::cont::DataSet& result, const vtkm::cont::Field& field, const vtkm::worklet::ExtractGeometry& worklet) @@ -97,14 +58,15 @@ vtkm::cont::DataSet ExtractGeometry::DoExecute(const vtkm::cont::DataSet& input) vtkm::worklet::ExtractGeometry worklet; vtkm::cont::UnknownCellSet outCells; - CallWorker worker(outCells, - worklet, - coords, - this->Function, - this->ExtractInside, - this->ExtractBoundaryCells, - this->ExtractOnlyBoundaryCells); - cells.CastAndCallForTypes(worker); + + cells.CastAndCallForTypes([&](const auto& concrete) { + outCells = worklet.Run(concrete, + coords, + this->Function, + this->ExtractInside, + this->ExtractBoundaryCells, + this->ExtractOnlyBoundaryCells); + }); // create the output dataset auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); }; diff --git a/vtkm/filter/entity_extraction/Mask.cxx b/vtkm/filter/entity_extraction/Mask.cxx index cfa9c2b23..f0a7f6c3b 100644 --- a/vtkm/filter/entity_extraction/Mask.cxx +++ b/vtkm/filter/entity_extraction/Mask.cxx @@ -13,26 +13,6 @@ namespace { -struct CallWorklet -{ - vtkm::Id Stride; - vtkm::cont::UnknownCellSet& Output; - vtkm::worklet::Mask& Worklet; - - CallWorklet(vtkm::Id stride, vtkm::cont::UnknownCellSet& output, vtkm::worklet::Mask& worklet) - : Stride(stride) - , Output(output) - , Worklet(worklet) - { - } - - template - void operator()(const CellSetType& cells) const - { - this->Output = this->Worklet.Run(cells, this->Stride); - } -}; - VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result, const vtkm::cont::Field& field, const vtkm::worklet::Mask& worklet) @@ -66,8 +46,8 @@ VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet& input) vtkm::cont::UnknownCellSet cellOut; vtkm::worklet::Mask worklet; - CallWorklet workletCaller(this->Stride, cellOut, worklet); - cells.CastAndCallForTypes(workletCaller); + cells.CastAndCallForTypes( + [&](const auto& concrete) { cellOut = worklet.Run(concrete, this->Stride); }); // create the output dataset auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };