# UnstructuredGrid::GetCellLinks() get null value after I upgrade from 8.2 to 9.4

**URL:** <https://discourse.vtk.org/t/unstructuredgrid-getcelllinks-get-null-value-after-i-upgrade-from-8-2-to-9-4/14947>\
**Category:** Development\
**Created:** [December 3, 2024, 6:40am UTC](https://discourse.vtk.org/t/unstructuredgrid-getcelllinks-get-null-value-after-i-upgrade-from-8-2-to-9-4/14947 "2024-12-03T06:40:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmodel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/7ab992/32.png) [@cmodel](https://discourse.vtk.org/u/cmodel)\
**Post date:** [December 3, 2024, 6:40am UTC](https://discourse.vtk.org/t/unstructuredgrid-getcelllinks-get-null-value-after-i-upgrade-from-8-2-to-9-4/14947/1 "2024-12-03T06:40:42Z")

</div>

As described in the title, I am upgrading from 8.2 to 9.4, all works fine in the codebase of 8.2, which I have the following:

mesh is type of vtkPointSet \*, which is argument in the method.

```auto
vtkUnstructuredGrid * grid = vtkUnstructuredGrid::SafeDownCast(mesh);
vtkCellLinks * links = nullptr;
if (grid != nullptr)
{
    links = vtkCellLinks::SafeDownCast(grid->GetCellLinks());
}

```

in 8.2, links get the real contents.  
but in 9.4, links get null.

I have read the document that GetCellLinks() is deprecated. So I changed to GetLinks() directly.

```auto
vtkAbstractCellLinks *links = grid->GetLinks();

```

This has the real address value. But when I downcast to vtkCellLinks, it still returns null value.

What is possible cause of this issue? Thanks.

---

<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:** [December 3, 2024, 7:08pm UTC](https://discourse.vtk.org/t/unstructuredgrid-getcelllinks-get-null-value-after-i-upgrade-from-8-2-to-9-4/14947/2 "2024-12-03T19:08:57Z")

</div>

Hello,

From what I understand from the docs, in VTK 9.4 you, first, use `GetLinks()`‘s returned `vtkAbstractCellLinks`’ (do not downcast) `GetType()` method to query its concrete data type (the six constants below are defined in `vtkAbstractCellLinks::CellLinksTypes` enum [VTK: vtkAbstractCellLinks Class Reference](https://vtk.org/doc/nightly/html/classvtkAbstractCellLinks.html#a4c80002ab331684c03f132be37dbef77)):

- `LINKS_NOT_DEFINED` (0): is a `nullptr`;
- `CELL_LINKS ` (1): is a [`vtkCellLinks`](https://vtk.org/doc/nightly/html/classvtkCellLinks.html);
- `STATIC_CELL_LINKS_USHORT` (2): is a `vtkStaticCellLinksTemplate<VTK_UNSIGNED_SHORT>`;
- `STATIC_CELL_LINKS_UINT` (3): is a `vtkStaticCellLinksTemplate<VTK_UNSIGNED_INT>`;
- `STATIC_CELL_LINKS_IDTYPE` (4): is a `vtkStaticCellLinksTemplate<VTK_ID_TYPE>`;
- `STATIC_CELL_LINKS_SPECIALIZED` (5): dunno what this is (docs are unclear, likely to be a `vtkStaticCellLinks`);

Reference: [VTK: vtkUnstructuredGrid Class Reference](https://vtk.org/doc/nightly/html/classvtkUnstructuredGrid.html#af65d7bf13393fec159fb9a0f08c9d357)

Then you can use, for instance, a `switch(){}` structure to use the appropriate downcast.

best,

PC

---

<div class="post-metadata">

**Author:** ![cmodel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/7ab992/32.png) [@cmodel](https://discourse.vtk.org/u/cmodel)\
**Post date:** [December 4, 2024, 3:07am UTC](https://discourse.vtk.org/t/unstructuredgrid-getcelllinks-get-null-value-after-i-upgrade-from-8-2-to-9-4/14947/3 "2024-12-04T03:07:31Z")

</div>

Thanks Paulo.

That’s right. Previously in 8.2, I can directly use GetCellLinks() and get the Link internal type inside it, then query the cell size and the cell list.

Now after the upgrade, I need check which type of the link it is. And now I have used the type condition check to get the correct value.

I just wonder why in previous 8.2, I get the links data with the type of CellLinks, while on the contrary the links changed to be the type of Static Cell Links in 9.4 version. I have not delved into the code changes in 9.4. The value of Links type is changed, is that caused by the design change of data storage? Maybe I need to debug into the implementation of new vtk codes.

---

<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:** [December 4, 2024, 3:23pm UTC](https://discourse.vtk.org/t/unstructuredgrid-getcelllinks-get-null-value-after-i-upgrade-from-8-2-to-9-4/14947/4 "2024-12-04T15:23:48Z")

</div>

> [@cmodel](#):
>
> I just wonder why in previous 8.2, I get the links data with the type of CellLinks, while on the contrary the links changed to be the type of Static Cell Links in 9.4 version.

You still have the original `vtkCellLinks` as one of the available options. The reason for the new design is in the docs ([VTK: vtkStaticCellLinksTemplate\< TIds \> Class Template Reference](https://vtk.org/doc/nightly/html/classvtkStaticCellLinksTemplate.html#details)):

> This class is a faster implementation of [vtkCellLinks](https://vtk.org/doc/nightly/html/classvtkCellLinks.html). However, it cannot be incrementally constructed; it is meant to be constructed once (statically) and must be rebuilt if the cells change.
> 
> This is a templated implementation for [vtkStaticCellLinks](https://vtk.org/doc/nightly/html/classvtkStaticCellLinks.html). The reason for the templating is to gain performance and reduce memory by using smaller integral types to represent ids. For example, if the maximum id can be represented by an int (as compared to a vtkIdType), it is possible to reduce memory requirements by half and increase performance. This templated class can be used directly; alternatively the non-templated class [vtkStaticCellLinks](https://vtk.org/doc/nightly/html/classvtkStaticCellLinks.html) can be used for convenience; although it uses vtkIdType and so will lose some speed and memory advantages.

best,

PC

---

<div class="post-metadata">

**Author:** ![cmodel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/7ab992/32.png) [@cmodel](https://discourse.vtk.org/u/cmodel)\
**Post date:** [December 5, 2024, 7:10am UTC](https://discourse.vtk.org/t/unstructuredgrid-getcelllinks-get-null-value-after-i-upgrade-from-8-2-to-9-4/14947/5 "2024-12-05T07:10:55Z")

</div>

Yes. got it.

Thanks.
