# vtkAffineArray

**URL:** https://discourse.paraview.org/t/vtkaffinearray/14780
**Category:** Development
**Tags:** vtk
**Created:** [June 5, 2024, 4:13pm UTC](https://discourse.paraview.org/t/vtkaffinearray/14780 "2024-06-05T16:13:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [June 5, 2024, 4:13pm UTC](https://discourse.paraview.org/t/vtkaffinearray/14780/1 "2024-06-05T16:13:00Z")

</div>

in a ParaView I/O plugin for particle data, I am attempting to replace this simple piece of code creating the connectivity list for a POLY\_VERTEXCELL (code inspired from vtkConvertToPointCloud)

> ```
> std::vector<vtkIdType> polyVertex(N);
> std::iota(polyVertex.begin(), polyVertex.end(), 0);
> vtkNew<vtkCellArray> verts;
> verts->InsertNextCell(N, polyVertex.data());
> output->SetVerts(verts);
> 
> ```

by a new code using a vtkAffineArray

> ```
> vtkNew<vtkAffineArray<vtkIdType>> polyVertex;
> polyVertex->SetBackend(std::make_shared<vtkAffineImplicitBackend<vtkIdType>>(1, 0));
> polyVertex->SetNumberOfTuples(N);
> vtkNew<vtkCellArray> verts;
> verts->SetData(1, polyVertex);
> output->SetVerts(verts);
> 
> ```

At run-time, I am greeted with this message,  
vtkCellArray.cxx:926 ERR| vtkCellArray (0x60464f495700): Offsets and Connectivity arrays must have the same type.  
So, this is telling me that the automatic offset array creation can’t take my AffineArray as input.  
I’d appreciate a clue on how to fix this. This functionality should eventually end-up in the conduit source for creating implicit pointset connectivity, as suggested to me by a developer.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [June 6, 2024, 8:32am UTC](https://discourse.paraview.org/t/vtkaffinearray/14780/2 "2024-06-06T08:32:40Z")

</div>

Hi @jfavre ,

I fear this is not doable without modification in `vtkCellArray` …  
Maybe the failing check should be changed to be only based on the `vtkAbstractArray::GetDataType` instead of relying on concrete class, but this needs some investigation.

@Charles_Gueunet may have more inputs.

and also maybe @spyridon97 or @Yohann_Bearzi ?

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [June 6, 2024, 12:28pm UTC](https://discourse.paraview.org/t/vtkaffinearray/14780/3 "2024-06-06T12:28:39Z")

</div>

@jaswantp has started this MR, [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/10769](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10769), which is not finished yet, because there are some performance issues to think about and funding of course. This basically allows vtkCellArray to hold any vtkDataArray subclass as offsets or connectivity arrays.

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jaswantp/32/11456_2.png) [@jaswantp](https://discourse.paraview.org/u/jaswantp)
#### Post date: [June 25, 2024, 2:35pm UTC](https://discourse.paraview.org/t/vtkaffinearray/14780/4 "2024-06-25T14:35:48Z")

</div>

> There are some performance issues to think about and funding of course. This basically allows vtkCellArray to hold any vtkDataArray subclass as offsets or connectivity arrays.

Clarifying some points:

1. Only subclasses of the CRTP `vtkGenericDataArray` that have the `ValueType` equivalent to signed integer larger than 2-bytes or any unsigned integer. Floating point is obviously not sensible for connectivity/offsets.
2. The performance issues only occur when the `StorageType` is none of `OptimalInteger32`, `OptimalInteger64` which are the default unless `vtkCellArray::SetData` is called with an unsigned 32/64 bit integer array.
3. @sujin will be working to get the MR in a ready-to-merge state.

I suspect perf loss is due to all that tunelling through `CellStateRoutineInvoker`. I haven’t profiled it. If anyone wants to squeeze more performance out of the `GenericStorage` type, please take a look. I might find time to profile it this week. It’s not a high priority because no existing applications will really see the performance loss.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [October 28, 2025, 10:19am UTC](https://discourse.paraview.org/t/vtkaffinearray/14780/5 "2025-10-28T10:19:22Z")

</div>

Hi @jfavre

I didn’t test if it solves this issue but note that @spyridon97 made some changes in `vtkCellArray` and underlying `vtkDataArray` possible types to be more generic/permissive. See [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/12452](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/12452)

---

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [October 28, 2025, 10:59am UTC](https://discourse.paraview.org/t/vtkaffinearray/14780/6 "2025-10-28T10:59:41Z")

</div>

Hey, this is great progress. I have retested with ParaView master and my plugin now works flawlessly. I use the original code I had posted, using:  
`polyVertex->SetBackend(std::make_shared<vtkAffineImplicitBackend>(1, 0));`

Thank you’all

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [October 28, 2025, 2:11pm UTC](https://discourse.paraview.org/t/vtkaffinearray/14780/7 "2025-10-28T14:11:39Z")

</div>

You are very welcome!
