[vtkusers] Strucutred Grid and blanking

Lorenzo Bernardi lorenzo.bernardi at lpn.cnrs.fr
Sun Aug 2 17:24:54 EDT 2009


Dear all,

   I'd like to blank sites from a structure grid and use warpscalar. I'm 
using the BlankPoint method of the vtkStructuredGrid class but it 
doesn't work. I'm missing something obvious?

My use of blanking on the structured grid is to represent the data on 
the Cubic centered lattice. Is blanking made for this kind of things?

  Does someone have and example of how to use vtkBlankStructuredGrid 
with a StructuredGrid object?

my code is given below. If I comment the blanking part I have a plane 
otherwise I have nothing

sincerely

L.





#!/usr/bin/python

import vtk
import math


Vpoints=vtk.vtkPoints()
Vdata=vtk.vtkFloatArray()
Vblank=vtk.vtkUnsignedCharArray()


imax=10
jmax=10
kmax=10

Vsg=vtk.vtkStructuredGrid()
Vsg.SetDimensions(imax,jmax,kmax)

l=0
for k in range(kmax):
    for j in range(jmax):
        for i in range(imax):
            if (i+j+k)%2 == 1:
                Vsg.BlankPoint(l)

            Vpoints.InsertPoint(l,i,j,k)
            
Vdata.InsertValue(l,2.+math.cos(i)*math.cos(j)*math.cos(k))           

            l+=1
   

Vsg.SetPoints(Vpoints)
Vsg.GetPointData().SetScalars(Vdata)


plane = vtk.vtkStructuredGridGeometryFilter()
plane.SetInputConnection(Vsg.GetProducerPort())
plane.SetExtent(0, 40, 0, 40, 1, 1)


warp = vtk.vtkWarpScalar()
warp.SetInputConnection(plane.GetOutputPort())
warp.UseNormalOn()
warp.SetNormal(.0, 0.0, 1.0)
warp.SetScaleFactor(2.5)

normals = vtk.vtkPolyDataNormals()
normals.SetInput(warp.GetPolyDataOutput())
normals.SetFeatureAngle(60)

planeMapper = vtk.vtkPolyDataMapper()
planeMapper.SetInputConnection(normals.GetOutputPort())
planeMapper.SetScalarRange(Vsg.GetScalarRange())

planeActor = vtk.vtkActor()
planeActor.SetMapper(planeMapper)

outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputConnection(Vsg.GetProducerPort())
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
outlineActor.GetProperty().SetColor(0, 0, 0)


ren = vtk.vtkRenderer()
ren.AddActor(outlineActor)
ren.AddActor(planeActor)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
ren.SetBackground(1, 1, 1)


iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

iren.Initialize()
renWin.Render()
iren.Start()









More information about the vtkusers mailing list