[vtkusers] Change color space without vtkColorTransferFunction()

Hom Nath Gharti hng.email at gmail.com
Mon Feb 2 10:57:04 EST 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090202/73e0bcef/attachment.htm>


More information about the vtkusers mailing list