[vtkusers] Change color space without vtkColorTransferFunction()

Amy Squillacote ahs at cfdrc.com
Mon Feb 2 11:06:45 EST 2009


You don't set the vtkColorTransferFunction on a vtkProperty; you set it 
on a vtkMapper (or vtkPolyDataMapper, in your case). vtkActor's 
SetProperty method takes a vtkProperty, so that isn't the problem.

- Amy

Hom Nath Gharti wrote:
> Thanks for the suggestion. I have the python code like this:
>
> import vtk
>
> # Create rendering window and renderer
> ren = vtk.vtkRenderer()
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren)
> renWin.SetSize(600, 600)
>
> # Interacting window
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> # Read VTK image data
> reader = vtk.vtkXMLImageDataReader()
> reader.SetFileName("py_3d_strike0_stack_XY.vti")
>
> plane=vtk.vtkImageDataGeometryFilter()
> plane.SetInputConnection(reader.GetOutputPort())
> plane.SetExtent(0, 60, 0, 60, 0, 0)
> #srange = plane.GetOutput().GetPointData().GetScalars().GetRange()
>
> warp = vtk.vtkWarpScalar()
> warp.SetInputConnection(plane.GetOutputPort())
> warp.UseNormalOn
> warp.SetNormal(0.0,0.0,1.0)
> warp.SetScaleFactor(2.0)
>
> # Color map
> color=vtk.vtkColorTransferFunction()
> color.SetColorSpaceToDiverging()
>
> vprop=vtk.vtkProperty()
> vprop.SetColor(color)
>
> mapper = vtk.vtkPolyDataMapper()
> mapper.SetInputConnection(warp.GetOutputPort())
>
> actor = vtk.vtkActor()
> actor.SetMapper(mapper)
> actor.SetProperty(vprop)
> actor.GetProperty().SetRepresentationToWireframe()
> actor.SetPosition(0.0,0.0,200.0) #Translate
>
> # Add the actors to the renderer, set the background
> ren.AddActor(actor)
>
> ren.ResetCamera()
> ren.GetActiveCamera().Azimuth(0)
> ren.GetActiveCamera().Elevation(-70)
> ren.SetBackground(1.0, 1.0, 1.0)
> ren.ResetCameraClippingRange()
>
> #iren.Initialize()
> renWin.Render()
> iren.Start()
>
>
> Obviously I get the error in in ' actor.SetProperty(vprop) ' and I 
> cannot implement vtkVolumeProperty() here. Am I missing something?
>
> Any help/suggestions will greatly be appreciated.
>
> Thanks,
> Hom Nath
>

-- 
Amy Squillacote                    Phone: (256) 726-4839
Sr. Computer Scientist             Fax: (256) 726-4806
CFD Research Corporation           Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL  35805





More information about the vtkusers mailing list