Blanked cells do not disappear when creating UniformGrid from python reader plugin


I’m trying to implement a simple python plugin reader that loads a uniform grid with blanked cells.

For testing purpose I’m creating a dummy grid source and blank half the cells with vtkUniformGird.BlankCell() cf. (1.9 KB)

from paraview.util.vtkAlgorithm import *
import vtk

@smproxy.source(name="DummySource", label="Dummy Source with blanked cells")
class DummySource(VTKPythonAlgorithmBase):
   """This is dummy uniform grid source."""

   _default_shape = [10] * 3

   def __init__(self):
           self, nInputPorts=0, nOutputPorts=1, outputType="vtkUniformGrid"
       self._shape = list(DummySource._default_shape)

   @smproperty.intvector(name="VoxelShape", default_values=_default_shape)
   def SetVoxelShape(self, nx, ny, nz):
       self._shape = [n if n > 0 else 1 for n in [nx, ny, nz]]

   def RequestInformation(self, request, inInfoVec, outInfoVec):
       executive = self.GetExecutive()
       outInfo = outInfoVec.GetInformationObject(0)
       nx, ny, nz = self._shape
       outInfo.Set(executive.WHOLE_EXTENT(), 0, nx, 0, ny, 0, nz)
       vtkDO = vtk.vtkDataObject
       outInfo.Set(vtkDO.SPACING(), 1 / nx, 1 / ny, 1 / nz)
       outInfo.Set(vtkDO.ORIGIN(), 0, 0, 0)
       outInfo.Set(vtk.vtkAlgorithm.CAN_PRODUCE_SUB_EXTENT(), 1)
       return 1

   def RequestData(self, request, inInfoVec, outInfoVec):
       output = vtk.vtkUniformGrid.GetData(outInfoVec, 0)
       nx, ny, nz = self._shape
       output.SetExtent(0, nx, 0, ny, 0, nz)
       output.SetDimensions(nx + 1, ny + 1, nz + 1)
       output.SetSpacing(1 / nx, 1 / ny, 1 / nz)
       output.SetOrigin(0.0, 0.0, 0)
       data = output.GetCellData()
       test = vtk.vtkTypeUInt16Array()
       test.Resize(nx * ny * nz)
       test.SetName("k index")
       for k in range(nz):
           for _ in range(nx * ny):
       nb_cells = output.GetNumberOfCells()
       for i in range(nb_cells // 2):
       return 1

Contrary to my expectations the blanked cell do not to show in paraview… whereas the predicate HasAnyBlankedCells retrurns true.

Am I missing something or is this a Paraview bug? (I could not figure this out googling in the paraview issue list).

Kind regards,


1 Like

I see nothing wrong with your code. The cells are indeed blanked. Have you tried to apply a slice through your dataset?

Hint: you can view how cells are marked with a simplePython Calculator and the expression


I think it’s a bug in vtkDataSetSurfaceFilter. When extracting the outer surface, blanking is taken care of for vtkStructuredGrid but not for vtkUniformGrid.