Hidden structured data (shown anyway, bug?)

Hi guys

I am having some trouble hiding cells or points. It seems like no matter what I do, the points as well as the cell remain visible.

from vtkmodules.util.numpy_support import vtk_to_numpy
import numpy as np

nxy = 10
dxy = 0.1

rg = vtkRectilinearGrid()
rg.SetExtent(0, nxy - 1, 0, nxy - 1, 0, 0)
rg.GetXCoordinates().SetNumberOfValues(nxy)
rg.GetYCoordinates().SetNumberOfValues(nxy)
xs = vtk_to_numpy(rg.GetXCoordinates())
ys = vtk_to_numpy(rg.GetYCoordinates())
zs = vtk_to_numpy(rg.GetZCoordinates())
xs[:] = dxy * (np.r_[0:nxy] - 0.5 * (nxy-1))
ys[:] = dxy * (np.r_[0:nxy] - 0.5 * (nxy-1))
zs[0] = 0.0

vColors = vtkUnsignedCharArray()
vColors.SetNumberOfComponents(3)
vColors.SetNumberOfTuples(rg.GetNumberOfPoints())
vColors.SetName("Colors")

rnd = vtkRandomPool()
rnd.PopulateDataArray(vColors, 0, 255)

rg.GetPointData().SetScalars(vColors)

ghosts = rg.AllocatePointGhostArray()
npGhosts = vtk_to_numpy(ghosts)
npGhosts[:] = npGhosts[:] | vtkDataSetAttributes.HIDDENPOINT

ghostCells = rg.AllocateCellGhostArray()
npGhostCells = vtk_to_numpy(ghostCells)
npGhostCells[:] = npGhostCells[:] | vtkDataSetAttributes.HIDDENCELL

renderer = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(renderer)

for i in range((nxy-1)**2):
  oldValue = rg.GetCellData().GetArray(0).GetValue(i)
  rg.GetCellData().GetArray(0).SetValue(i, oldValue | vtkDataSetAttributes.HIDDENCELL)

for i in range(nxy**2):
  oldValue = rg.GetPointData().GetArray(1).GetValue(i)
  rg.GetPointData().GetArray(1).SetValue(i, oldValue | vtkDataSetAttributes.HIDDENPOINT)

mapper = vtkDataSetMapper()
mapper.SetInputData(rg)

actor = vtkActor()
actor.SetMapper(mapper)

renderer.AddActor(actor)

renWinInteractor = vtkRenderWindowInteractor()
renWinInteractor.SetRenderWindow(renWin)

renWin.Render()
renWinInteractor.Start()

It feels like no matter what I do, all structured and unstructured grids ignore any cells or points flagged as hidden. Could this be a bug?

@Yohann_Bearzi

I can see that pyvista uses the same approach for hiding structural VTK data, but also here HIDDENPOINT and HIDDENCELL are completely ignored. If I don’t resolve this issue, I may reintroduce the old way of handing ghost levels… I will try installing an old version of VTK, e.g. 8.2 and see if ghosts also were ignored here for structured data.

I figured out it is a bug in 9.2.6. The example

https://examples.vtk.org/site/Cxx/StructuredGrid/BlankPoint/

is broken.

I will checkout master and see if it is still an issue and report and perhaps fix it. @Yohann_Bearzi