[vtkusers] changes from 4.x to 5.x
Dave Reed
davelist at mac.com
Mon Sep 8 18:04:43 EDT 2008
I'm getting back to using VTK after being gone for a while so I'm
trying to adjust to some of the changes between 4.x and 5.x. At the
moment, I have 5.0.3 on my Mac because that was the easiest to get
working via MacPorts.
At the bottom of this message is some old Python code that worked on
4.x and printed the number of polygons that were rendered. I've also
tried updating the code to use the SetInputConnection and
GetOutputPort methods, but that has no effect.
With 5.0.3 on my system, it says GetNumberOfPolys is not a valid
attribute.
The output says it's a vtkPolyData, but the Python dir command doesn't
list many of the vtkPolyData methods. Here is the output:
vtkPolyData
['AddObserver', 'BreakOnError', 'DebugOff', 'DebugOn', 'FastDelete',
'GetAddressAsString', 'GetClassName', 'GetDebug',
'GetGlobalWarningDisplay', 'GetMTime', 'GetReferenceCount',
'GlobalWarningDisplayOff', 'GlobalWarningDisplayOn', 'HasObserver',
'InvokeEvent', 'IsA', 'IsTypeOf', 'Modified', 'NewInstance',
'PrintRevisions', 'Register', 'RemoveObserver', 'RemoveObservers',
'SafeDownCast', 'SetDebug', 'SetGlobalWarningDisplay',
'SetReferenceCount', 'UnRegister']
Shouldn't a vtkPolyData object have a GetNumberOfPolys attribute/
method (and many others that are missing.
Am I doing something wrong, or is something wrong with my installation
or is this a bug in 5.0.3 or is something else wrong?
Thanks,
Dave
# create the renderer and window
ren = vtkRenderer()
ren_win = vtkRenderWindow()
ren_win.AddRenderer(ren)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(ren_win)
# read the volume
reader = vtkImageReader()
reader.SetDataExtent(0, 63, 0, 63, 1, 93)
reader.SetDataByteOrderToLittleEndian()
reader.SetFilePrefix(VTK_DATA + "/headsq/quarter")
reader.SetDataSpacing(3.2, 3.2, 1.5)
reader.SetDataScalarTypeToUnsignedShort()
# extract the skin
skin_extractor = vtkContourFilter()
skin_extractor.SetInput(reader.GetOutput())
skin_extractor.SetValue(0, 500)
skin_mapper = vtkPolyDataMapper()
skin_mapper.SetInput(skin_extractor.GetOutput())
skin_mapper.ScalarVisibilityOff()
skin_actor = vtkActor()
skin_actor.SetMapper(skin_mapper)
# create the outline
outline = vtkOutlineFilter()
outline.SetInput(reader.GetOutput())
outline_mapper = vtkPolyDataMapper()
outline_mapper.SetInput(outline.GetOutput())
outline_actor = vtkActor()
outline_actor.SetMapper(outline_mapper)
outline_actor.GetProperty().SetColor(1,1,1)
# Add the actors to the renderer
ren.AddActor(outline_actor)
ren.AddActor(skin_actor)
ren.ResetCamera()
ren_win.SetSize(300, 300)
ren_win.Render()
print skin_mapper.GetInput().GetClassName()
print dir(skin_mapper.GetInput())
print skin_mapper.GetInput().GetNumberOfPolys()
iren.Start()
More information about the vtkusers
mailing list