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

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)

//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();
1 Like

I try to use these setting ,but still dont work

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

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.

To test this, I have added

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

in the vtkUnstructuredGridGeometryFilter code after this line, 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

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, the handleSubdivision flag can now become true even when NonlinearSubdivisionLevel is zero.