Commit f231e1f1 authored by Mathieu Westphal's avatar Mathieu Westphal

Fix an error and simplify code

parent 1e80fc00
......@@ -113,9 +113,11 @@ int vtkCellCenters::RequestData(vtkInformation* vtkNotUsed(request),
vtkNew<vtkIdTypeArray> iArray;
iArray->SetNumberOfComponents(1);
iArray->SetNumberOfTuples(numPoints * 2);
vtkIdType n = 0;
std::generate(iArray->GetPointer(0), iArray->GetPointer(numPoints * 2),
[&n]() { return n++ % 2 == 0 ? 1 : n / 2; });
for (vtkIdType i = 0; i < numPoints; i++)
{
iArray->SetValue(2 * i, 1);
iArray->SetValue(2 * i + 1, i);
}
vtkNew<vtkCellArray> verts;
verts->SetCells(numPoints, iArray);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment