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?