# vtkIntegrateAttributes (possible error)

**URL:** https://discourse.vtk.org/t/vtkintegrateattributes-possible-error/12390
**Category:** Support
**Created:** [September 29, 2023, 7:35pm UTC](https://discourse.vtk.org/t/vtkintegrateattributes-possible-error/12390 "2023-09-29T19:35:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [September 29, 2023, 7:35pm UTC](https://discourse.vtk.org/t/vtkintegrateattributes-possible-error/12390/1 "2023-09-29T19:35:27Z")

</div>

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

```auto
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

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [September 30, 2023, 1:10pm UTC](https://discourse.vtk.org/t/vtkintegrateattributes-possible-error/12390/2 "2023-09-30T13:10:59Z")

</div>

> [@Jens\_Munk\_Hansen](#):
>
> `intValues.GetValue(0)`

Hello,

My two cents: maybe the normalized varlues are refered by a different array?

regards,

PC

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [September 30, 2023, 5:38pm UTC](https://discourse.vtk.org/t/vtkintegrateattributes-possible-error/12390/3 "2023-09-30T17:38:52Z")

</div>

Also my initial thought. I went through all the output arrays, both `PointData` and `CellData`, no normalized values are present. Will debug the filter and figure out what is going on. Looked into the filter since I needed to compute the variance of integrated attributes.
