# when use surfaceFilter to filter the surface, sometime globalIds is nullptr, and sometime globalIds is not nullptr

**URL:** https://discourse.vtk.org/t/when-use-surfacefilter-to-filter-the-surface-sometime-globalids-is-nullptr-and-sometime-globalids-is-not-nullptr/12731
**Category:** Support
**Tags:** jobs, code
**Created:** [November 16, 2023, 12:15pm UTC](https://discourse.vtk.org/t/when-use-surfacefilter-to-filter-the-surface-sometime-globalids-is-nullptr-and-sometime-globalids-is-not-nullptr/12731 "2023-11-16T12:15:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![SkyFishers](https://discourse.vtk.org/user_avatar/discourse.vtk.org/skyfishers/32/7347_2.png) [@SkyFishers](https://discourse.vtk.org/u/SkyFishers)
#### Post date: [November 16, 2023, 12:15pm UTC](https://discourse.vtk.org/t/when-use-surfacefilter-to-filter-the-surface-sometime-globalids-is-nullptr-and-sometime-globalids-is-not-nullptr/12731/1 "2023-11-16T12:15:54Z")

</div>

grid is one vtkUnstructuredGrid,when use surfaceFilter to filter the surface,  
after do that,for different grid,some globalIds is nullptr, and sometime globalIds is not nullptr; why?  
(vtk Version is 9.2)

```auto
//grid : vtkUnstructuredGrid
grid->GetCellData()->SetGlobalIds(global_element_id);
grid->GetPointData()->SetGlobalIds(global_element_id); 
auto surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
auto mapper = vtkSmartPointer<vtkDataSetMapper>::New();
surfaceFilter->SetInputData(source);
mapper->SetInputConnection(surfaceFilter->GetOutputPort());
mapper->SetResolveCoincidentTopologyToPolygonOffset();
mapper->Update();

/*
when use surfaceFilter to filter the surface, 
after do that,
sometime globalIds is nullptr, and sometime globalIds is not nullptr
*/
auto globalIds = mapper->GetInput()->GetPointData()->GetGlobalIds();

```

---

<div class="post-metadata">

### Author: ![SkyFishers](https://discourse.vtk.org/user_avatar/discourse.vtk.org/skyfishers/32/7347_2.png) [@SkyFishers](https://discourse.vtk.org/u/SkyFishers)
#### Post date: [November 16, 2023, 1:14pm UTC](https://discourse.vtk.org/t/when-use-surfacefilter-to-filter-the-surface-sometime-globalids-is-nullptr-and-sometime-globalids-is-not-nullptr/12731/2 "2023-11-16T13:14:06Z")

</div>

I try to use these setting ,but still dont work

```auto
//surfaceFilter->SetUseStrips(false);
surfaceFilter->SetPassThroughPointIds(true);
surfaceFilter->SetPassThroughCellIds(true);

```

---

<div class="post-metadata">

### Author: ![greschd](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/a88e4f/32.png) [@greschd](https://discourse.vtk.org/u/greschd)
#### Post date: [November 22, 2023, 10:18am UTC](https://discourse.vtk.org/t/when-use-surfacefilter-to-filter-the-surface-sometime-globalids-is-nullptr-and-sometime-globalids-is-not-nullptr/12731/3 "2023-11-22T10:18:08Z")

</div>

I have just stumbled upon this behavior as well.

For me, the `globalIds` are set if the grid contains only linear elements, and unset if it contains quadratic elements (even when `SetNonlinearSubdivisionLevel (0)` is used).

Looking into the code a bit, it appears a `vtkUnstructuredGridGeometryFilter` is added in this case, [here](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Geometry/vtkDataSetSurfaceFilter.cxx?ref_type=v9.3.0#L1401).

To test this, I have added

```auto
  outputPD->SetCopyGlobalIds(true);
  outputCD->SetCopyGlobalIds(true);

```

in the `vtkUnstructuredGridGeometryFilter` code after [this line](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Geometry/vtkUnstructuredGridGeometryFilter.cxx?ref_type=v9.3.0#L880), and the global IDs are then set.

However, I’m not sure if copying the global IDs in this way actually makes sense in the context of the `vtkUnstructuredGridGeometryFilter`. Maybe someone with a better understanding of the ID handling can comment on this.  
I also noticed that without changes, we can still get the `vtkOriginalCellIds` and `vtkOriginalPointIds` [1]. Are these the same as the global IDs? If not, how are they different?

[1] These are controlled by the `SetPassThrough<..>Ids` calls I believe

---

<div class="post-metadata">

### Author: ![greschd](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/a88e4f/32.png) [@greschd](https://discourse.vtk.org/u/greschd)
#### Post date: [November 22, 2023, 1:53pm UTC](https://discourse.vtk.org/t/when-use-surfacefilter-to-filter-the-surface-sometime-globalids-is-nullptr-and-sometime-globalids-is-not-nullptr/12731/4 "2023-11-22T13:53:10Z")

</div>

Adding to this, in our case the behavior changed when upgrading from an older VTK version (7.1.1). I believe the change is due to commit `320464e6a249b598f5d98f7839cfcb2d477d4ba9`:

In [https://gitlab.kitware.com/vtk/vtk/-/commit/320464e6a249b598f5d98f7839cfcb2d477d4ba9?page=2#6ba64f37e49ed3a9d62d009d4efd872e27e46ea3\_1477\_1495](https://gitlab.kitware.com/vtk/vtk/-/commit/320464e6a249b598f5d98f7839cfcb2d477d4ba9?page=2#6ba64f37e49ed3a9d62d009d4efd872e27e46ea3_1477_1495), the `handleSubdivision` flag can now become `true` even when `NonlinearSubdivisionLevel` is zero.
