# Upcoming changes to vtkCellArray

**URL:** https://discourse.vtk.org/t/upcoming-changes-to-vtkcellarray/2066
**Category:** Development
**Created:** [November 7, 2019, 10:08pm UTC](https://discourse.vtk.org/t/upcoming-changes-to-vtkcellarray/2066 "2019-11-07T22:08:28Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![pieper](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pieper/32/17_2.png) [@pieper](https://discourse.vtk.org/u/pieper)
#### Post date: [October 12, 2021, 6:55pm UTC](https://discourse.vtk.org/t/upcoming-changes-to-vtkcellarray/2066/9 "2021-10-12T18:55:26Z")

</div>

Generally these changes to `vtkCellArray` seem very positive, but there was a regression that led to a bug in [SlicerDMRI](https://github.com/SlicerDMRI/SlicerDMRI). In earlier VTK versions, calling this method gave a pointer into the `vtkCellArray`

```auto
vtkIdTypeArray *cellArrayIds = cellArray->GetData();

```

but with the new API it returns a copy of the data using `ExportLegacyFormat` in the implementation.

This meant that our code, which operated no the `cellArrayIds` to add lines to the cell array, had no effect on the `vtkPolyData` and the lines were missing. After some investigation I was able to fix it with the patch linked below.

Realistically the change in `GetData` was an API regression because the behavior of the call changed. I’d argue that `vtkCellArray::GetData()` should have been removed along with `GetPointer` / `WritePointer` and replaced with a stub that generated a compile time error with a comment that described the replacement API and how to use it.

In addition, the current implementation of `GetData()` should have been renamed `GetLegacyDataCopy()`.

It’s probably not good to make such a change to the API now that it’s been released, but I wanted to flag this in case somebody else runs into a similar issue in the future.

Perhaps the best solution would be to mark `vtkCellArray::GetData()` as deprecated.

> <https://github.com/SlicerDMRI/SlicerDMRI/pull/151/files>
>
> The behavior of vtkCellArray::GetData changed with vtk9 such
> that is now return…s a copy of the data rather than the actual
> array, so manipulating it has no effect.
> 
> Instead now we must have the cell array import the legacy format.
> 
> This operation is no doubt slower but is a minimal change to restore
> funcationality. This code should really be threaded and reworked to
> use the new API if performance is critical.

---

_[View the full topic](https://discourse.vtk.org/t/upcoming-changes-to-vtkcellarray/2066)._
