[vtkusers] vtkUniformGrid blanking

Alexandre Boucher afboucher at gmail.com
Tue Apr 5 16:24:59 EDT 2011


Hello,

For some reason I am unable to use the blanking capability of the
vtkUniformGrid class.  I am interested in blanking cells (do not work on
point either).  For example the following (pyhton) code does not blank
anything.  What am I doing wrong.

I am now doubting that I properly understand what blanking is supposed to
do:  I would expect to only show the cell that are visible (i.e. not
blanked).

Thanks,
Alex
-------------------------------------------------------------------
import vtk

uGrid = vtk.vtkUniformGrid()

uGrid.SetExtent(0,35, 0,35, 0,35)
uGrid.SetOrigin(0, 0,0)
uGrid.SetSpacing(1,1,1)
uGrid.SetScalarTypeToFloat ()
nCells = uGrid.GetNumberOfCells()

# Set the data vector
data = vtk.vtkFloatArray()
data.SetNumberOfValues(nCells)
data.SetNumberOfComponents(1)


# Set the blanking vector
dataBlank = vtk.vtkUnsignedCharArray()
dataBlank.SetNumberOfValues(nCells)
dataBlank.SetNumberOfComponents(1)

for i in range(nCells):
  data.SetValue(i, float(i)/nCells)
  dataBlank.SetValue(i, i%2)

uGrid.GetCellData().SetScalars(data)
uGrid.SetCellVisibilityArray(dataBlank)

#Test to see of the blanking is (internally) correct
for i in range(nCells):
  if uGrid.IsCellVisible(i) : print i

mapper = vtk.vtkDataSetMapper()
mapper.SetInput(uGrid)
actor = vtk.vtkActor()
actor.SetMapper(mapper)

ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(500, 500)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

ren.AddActor(actor)
iren.Initialize()
renWin.Render()
iren.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110405/ead10b94/attachment.htm>


More information about the vtkusers mailing list