I am trying to use the vtkIntegrateAttributes
. According to the documentation the output should be divided by the area or volume if I use vtkIntegrateAttributes.SetDivideAllCellDataByVolume
but the result is unchanged. I have verified that the barycentric integration is correct, but it would be nice it could be normalized by the volume.
a small example demonstrating the issue
import vtk
rnd = vtk.vtkRandomPool()
vertexValues = vtk.vtkDoubleArray()
vertexValues.SetNumberOfComponents(1)
vertexValues.SetNumberOfTuples(3)
vertexValues.SetName("VertexData")
rnd.PopulateDataArray(vertexValues, 0.0, 1.0)
vertices = vtk.vtkDoubleArray()
vertices.SetNumberOfComponents(3)
vertices.SetNumberOfTuples(3)
rnd.PopulateDataArray(vertices, 0.0, 5.0)
points = vtk.vtkPoints()
points.InsertNextPoint(vertices.GetTuple3(0))
points.InsertNextPoint(vertices.GetTuple3(1))
points.InsertNextPoint(vertices.GetTuple3(2))
triangle = vtk.vtkTriangle()
triangle.GetPointIds().SetId(0, 0)
triangle.GetPointIds().SetId(1, 1)
triangle.GetPointIds().SetId(2, 2)
triangles = vtk.vtkCellArray()
triangles.InsertNextCell(triangle)
triangles = vtk.vtkCellArray()
triangles.InsertNextCell(triangle)
trianglePolyData = vtk.vtkPolyData()
trianglePolyData.SetPoints(points)
trianglePolyData.SetPolys(triangles)
trianglePolyData.GetPointData().AddArray(vertexValues)
integrator = vtk.vtkIntegrateAttributes()
integrator.SetInputData(trianglePolyData)
integrator.SetInputArrayToProcess(0,0,0,0, "VertexData")
integrator.Update()
integral = integrator.GetOutput().GetPointData()
intValues = integral.GetArray("VertexData")
print("integrated VertexData: %f" % (intValues.GetValue(0)))
integrator.SetDivideAllCellDataByVolume(1)
integrator.Update()
integral = integrator.GetOutput().GetPointData()
intValues = integral.GetArray("VertexData")
print("integrated VertexData: %f" % (intValues.GetValue(0)))
I can find the area using GetCellData
, but integrated attribute is divided by the area / volume