[vtkusers] vtkTransformFilter, Python

Randy Heiland heiland at ncsa.uiuc.edu
Thu Jul 20 16:06:26 EDT 2000


2nd attempt:  As I return to this problem and go dig through
common/vtkPythonUtil.cxx, thought I'd ask the Python users if they've had any
ideas.

Here's a simpler, self-contained example:


#!/usr/local/bin/python

from libVTKCommonPython import *
from libVTKGraphicsPython import *

#-----------------------
sg = vtkStructuredGrid()
sg.Initialize()
nx=2
ny=2
nz=2
sg.SetDimensions(nx,ny,nz)
print 'nx*ny*nz=',nx*ny*nz

pts = vtkPoints()
# Z=0.0 plane
pts.InsertPoint(0, 0.0,0.0,0.0);
pts.InsertPoint(1, 1.0,0.0,0.0);
pts.InsertPoint(2, 0.0,1.0,0.0);
pts.InsertPoint(3, 1.0,1.0,0.0);
# Z=1.0 plane
pts.InsertPoint(4, 0.0,0.0,1.0);
pts.InsertPoint(5, 1.0,0.0,1.0);
pts.InsertPoint(6, 0.0,1.0,1.0);
pts.InsertPoint(7, 1.0,1.0,1.0);

sg.SetPoints(pts)

#-------------------------------------
# Can I scale the pts in this SG?
tran = vtkTransform()
tran.Scale(2,1,1)

sgXform = vtkTransformFilter()
sgXform.SetInput(sg)
sgXform.SetTransform(tran)
sgXform.Update()

sg2 = sgXform.GetOutput()
isaSG = sg2.IsA('vtkStructuredGrid')
print 'isaSG = ',isaSG
isaRG = sg2.IsA('vtkRectilinearGrid')
print 'isaRG = ',isaRG


#-------------------------------------
# See if a SGWriter likes sg2 as input
sgWriter = vtkStructuredGridWriter()
# -- This works fine
#sgWriter.SetInput(sg)
#
# -- Doing the following results in:
#     sgWriter.SetInput(sg2)
#ValueError: method requires a vtkStructuredGrid object, a vtkStructuredGrid
object was provided.

sgWriter.SetInput(sg2)




More information about the vtkusers mailing list