Enable triangulation on CellSetSingleType

The code path for doing either tetrahedralization or triangulation on a
CellSetSingleType was not actually doing any work. Changed the worklet
implementation so that these work on CellSetExplicit with any template
parameters (which includes CellSetSingleType).
This commit is contained in:
Kenneth Moreland 2021-09-08 09:04:45 -06:00
parent c494963626
commit 1bd70d9c22
2 changed files with 30 additions and 44 deletions

@ -95,15 +95,8 @@ public:
}
};
template <typename CellSetType>
vtkm::cont::CellSetSingleType<> Run(
const CellSetType& vtkmNotUsed(cellSet),
vtkm::cont::ArrayHandle<vtkm::IdComponent>& vtkmNotUsed(outCellsPerCell))
{
return vtkm::cont::CellSetSingleType<>();
}
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetExplicit<>& cellSet,
template <typename SS, typename CS, typename OS>
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetExplicit<SS, CS, OS>& cellSet,
vtkm::cont::ArrayHandle<vtkm::IdComponent>& outCellsPerCell)
{
vtkm::cont::CellSetSingleType<> outCellSet;

@ -97,47 +97,40 @@ public:
connectivityOut[2] = connectivityIn[triIndices[2]];
}
};
template <typename CellSetType>
vtkm::cont::CellSetSingleType<> Run(
const CellSetType& vtkmNotUsed(cellSet),
vtkm::cont::ArrayHandle<vtkm::IdComponent>& vtkmNotUsed(outCellsPerCell))
template <typename SS, typename CS, typename OS>
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetExplicit<SS, CS, OS>& cellSet,
vtkm::cont::ArrayHandle<vtkm::IdComponent>& outCellsPerCell)
{
vtkm::cont::CellSetSingleType<> outCellSet;
// Input topology
auto inShapes =
cellSet.GetShapesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
auto inNumIndices =
cellSet.GetNumIndicesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
// Output topology
vtkm::cont::ArrayHandle<vtkm::Id> outConnectivity;
vtkm::worklet::internal::TriangulateTables tables;
// Determine the number of output cells each input cell will generate
vtkm::worklet::DispatcherMapField<TrianglesPerCell> triPerCellDispatcher;
triPerCellDispatcher.Invoke(inShapes, inNumIndices, tables.PrepareForInput(), outCellsPerCell);
// Build new cells
vtkm::worklet::DispatcherMapTopology<TriangulateCell> triangulateDispatcher(
TriangulateCell::MakeScatter(outCellsPerCell));
triangulateDispatcher.Invoke(
cellSet, tables.PrepareForInput(), vtkm::cont::make_ArrayHandleGroupVec<3>(outConnectivity));
// Add cells to output cellset
outCellSet.Fill(
cellSet.GetNumberOfPoints(), vtkm::CellShapeTagTriangle::Id, 3, outConnectivity);
return outCellSet;
}
};
template <>
vtkm::cont::CellSetSingleType<> TriangulateExplicit::Run(
const vtkm::cont::CellSetExplicit<>& cellSet,
vtkm::cont::ArrayHandle<vtkm::IdComponent>& outCellsPerCell)
{
vtkm::cont::CellSetSingleType<> outCellSet;
// Input topology
auto inShapes =
cellSet.GetShapesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
auto inNumIndices =
cellSet.GetNumIndicesArray(vtkm::TopologyElementTagCell(), vtkm::TopologyElementTagPoint());
// Output topology
vtkm::cont::ArrayHandle<vtkm::Id> outConnectivity;
vtkm::worklet::internal::TriangulateTables tables;
// Determine the number of output cells each input cell will generate
vtkm::worklet::DispatcherMapField<TrianglesPerCell> triPerCellDispatcher;
triPerCellDispatcher.Invoke(inShapes, inNumIndices, tables.PrepareForInput(), outCellsPerCell);
// Build new cells
vtkm::worklet::DispatcherMapTopology<TriangulateCell> triangulateDispatcher(
TriangulateCell::MakeScatter(outCellsPerCell));
triangulateDispatcher.Invoke(
cellSet, tables.PrepareForInput(), vtkm::cont::make_ArrayHandleGroupVec<3>(outConnectivity));
// Add cells to output cellset
outCellSet.Fill(cellSet.GetNumberOfPoints(), vtkm::CellShapeTagTriangle::Id, 3, outConnectivity);
return outCellSet;
}
}
} // namespace vtkm::worklet