[vtkusers] custom colormap
fred
fredantispam at free.fr
Thu Apr 27 11:29:33 EDT 2006
fred a écrit :
> I guess the interesting part tpo create my lut is
>
> ctfun = vtk.vtkColorTransferFunction()
> ctfun.AddRGBPoint(0.0, 0.5, 0.0, 0.0)
> .../...
> ctfun.AddRGBPoint(4095.0, 0.5, 0.5, 0.5)
>
> .../...
>
> volumeProperty.SetColor(ctfun)
Another question : I'm playing with the example from the mayavi UG.
from Numeric import *
# import scipy
# x = (arange(50.0)-25)/2.0
# y = (arange(50.0)-25)/2.0
# r = sqrt(x[:,NewAxis]**2+y**2)
# z = 5.0*scipy.special.j0(r)
# import pyvtk
# z1 = reshape(transpose(z), (-1,))
# point_data = pyvtk.PointData(pyvtk.Scalars(z1))
# grid = pyvtk.StructuredPoints((50,50,1), (-12.5,-12.5,0), (0.5,0.5,1))
# data = pyvtk.VtkData(grid, point_data)
# data.tofile('essai.vtk')
import vtk
ctfun = vtk.vtkColorTransferFunction()
ctfun.AddRGBPoint(-2.0, 0.5, 0.0, 0.0)
ctfun.AddRGBPoint(-1.0, 1.0, 0.5, 0.5)
ctfun.AddRGBPoint(0.0, 0.9, 0.2, 0.3)
ctfun.AddRGBPoint(1.0, 0.81, 0.27, 0.1)
ctfun.AddRGBPoint(2.0, 0.18, 0.72, 0.13)
ctfun.AddRGBPoint(3.0, 0.13, 0.48, 0.72)
ctfun.AddRGBPoint(4.0, 0.25, 0.30, 0.8)
ctfun.AddRGBPoint(5.0, 0.5, 0.5, 0.5)
volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(ctfun)
volumeProperty.SetInterpolationTypeToLinear()
volumeProperty.ShadeOn()
newvol = vtk.vtkVolume()
newvol.SetProperty(volumeProperty)
import mayavi
v = mayavi.mayavi()
d = v.open_vtk('essai.vtk', config=0)
f = v.load_filter('WarpScalar', config=0)
n = v.load_filter('PolyDataNormals', 0)
n.fil.SetFeatureAngle(45)
m = v.load_module('SurfaceMap', 0)
a = v.load_module('Axes', 0)
a.axes.SetCornerOffset(0.0)
o = v.load_module('Outline', 0)
v.Render()
v.master.wait_window()
vtkColorFunctionTransfer does nothing.
What I've missed ?
Cheers,
--
Fred.
More information about the vtkusers
mailing list