Here is an example using the programmable filter as Cory suggested :
- Create some dummy input with celldata
- Source > Unstructured Cells Types
- Filters > PointToCellData
- Create programmable filter with the following script. We will average the “DistanceToCenter” array
import numpy as np
input0 = inputs[0]
num = input0.GetNumberOfCells()
Array = np.zeros(num, dtype=np.float64)
ptIds = vtk.vtkIdList()
cellIds = vtk.vtkIdList()
otherCells = vtk.vtkIdList()
for i in range(num):
input0.GetCellPoints(i,ptIds)
# Get all cells attached to the first point
input0.GetPointCells(ptIds.GetId(0),cellIds)
# similarly for all other points
for j in range(1,ptIds.GetNumberOfIds()):
input0.GetPointCells(ptIds.GetId(j),otherCells)
# merge results
for k in range(otherCells.GetNumberOfIds()):
cellIds.InsertUniqueId(otherCells.GetId(k))
# remove current cell
cellIds.DeleteId(i)
# average results
for k in range(cellIds.GetNumberOfIds()):
Array[i] += input0.CellData["DistanceToCenter"][cellIds.GetId(k)]
Array[i] /= cellIds.GetNumberOfIds()
output.CellData.append(Array, "A")