replace CallWorklet with lambda
This commit is contained in:
parent
c222a99537
commit
ca463a8a6f
@ -133,22 +133,11 @@ struct RemoveDegenerateCells
|
||||
return output;
|
||||
}
|
||||
|
||||
struct CallWorklet
|
||||
{
|
||||
template <typename CellSetType>
|
||||
void operator()(const CellSetType& cellSet,
|
||||
RemoveDegenerateCells& self,
|
||||
vtkm::cont::CellSetExplicit<>& output) const
|
||||
{
|
||||
output = self.Run(cellSet);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CellSetList>
|
||||
vtkm::cont::CellSetExplicit<> Run(const vtkm::cont::UncertainCellSet<CellSetList>& cellSet)
|
||||
{
|
||||
vtkm::cont::CellSetExplicit<> output;
|
||||
cellSet.CastAndCall(CallWorklet(), *this, output);
|
||||
cellSet.CastAndCall([&](const auto& concrete) { output = this->Run(concrete); });
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -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 <typename CellSetType>
|
||||
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<VTKM_DEFAULT_CELL_SET_LIST>(worker);
|
||||
|
||||
cells.CastAndCallForTypes<VTKM_DEFAULT_CELL_SET_LIST>([&](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); };
|
||||
|
@ -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 <typename CellSetType>
|
||||
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<VTKM_DEFAULT_CELL_SET_LIST>(workletCaller);
|
||||
cells.CastAndCallForTypes<VTKM_DEFAULT_CELL_SET_LIST>(
|
||||
[&](const auto& concrete) { cellOut = worklet.Run(concrete, this->Stride); });
|
||||
|
||||
// create the output dataset
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||
|
Loading…
Reference in New Issue
Block a user