[vtkusers] volume rendering (HELP)

vtk at le.isac.cnr.it vtk at le.isac.cnr.it
Tue Jun 4 04:56:44 EDT 2002


Hi..
I work with VTK 4 and tcl/tk on workstation Linux.
What can I do to configure this function to visualize many different color in volume rendering??

vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint      0 1 0 0
    colorTransferFunction AddRGBPoint     64 2 0 0
    colorTransferFunction AddRGBPoint    128 3 0 0
    colorTransferFunction AddRGBPoint    255 4 0 0
    colorTransferFunction AddRGBPoint    0 0 0 1
    colorTransferFunction AddRGBPoint   64 0 0 2
    colorTransferFunction AddRGBPoint  128 0 0 3
    colorTransferFunction AddRGBPoint  192 0 0 4
    colorTransferFunction AddRGBPoint  255 0 0 5
    colorTransferFunction AddRGBPoint     0 0 1 0 
    colorTransferFunction AddRGBPoint   128 0 2 0 
    colorTransferFunction AddRGBPoint   192 0 3 0 
    colorTransferFunction AddRGBPoint   255 0 4 0 




                *****************************



The source code is:



package require vtk
package require vtkinteraction


# Create the standard renderer, render window
# and interactor
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin


# Create the reader for the data
vtkStructuredPointsReader reader
    reader SetFileName "binHeart.vtk"


# Create transfer mapping scalar value to opacity
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint  20   0.0
    opacityTransferFunction AddPoint  255  0.2


vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint      0 1 0 0
    colorTransferFunction AddRGBPoint     64 2 0 0
    colorTransferFunction AddRGBPoint    128 3 0 0
    colorTransferFunction AddRGBPoint    255 4 0 0
    colorTransferFunction AddRGBPoint    0 0 0 1
    colorTransferFunction AddRGBPoint   64 0 0 2
    colorTransferFunction AddRGBPoint  128 0 0 3
    colorTransferFunction AddRGBPoint  192 0 0 4
    colorTransferFunction AddRGBPoint  255 0 0 5
    colorTransferFunction AddRGBPoint     0 0 1 0 
    colorTransferFunction AddRGBPoint   128 0 2 0 
    colorTransferFunction AddRGBPoint   192 0 3 0 
    colorTransferFunction AddRGBPoint   255 0 4 0 




# The property describes how the data will look
vtkVolumeProperty volumeProperty
    volumeProperty SetColor colorTransferFunction
    volumeProperty SetScalarOpacity opacityTransferFunction


# The mapper / ray cast function know how to render the data
vtkVolumeRayCastCompositeFunction  compositeFunction


vtkVolumeRayCastMapper volumeMapper
    volumeMapper SetVolumeRayCastFunction compositeFunction
    volumeMapper SetInput [reader GetOutput]


# The volume holds the mapper and the property and
# can be used to position/orient the volume
vtkVolume volume
    volume SetMapper volumeMapper
    volume SetProperty volumeProperty


ren1 SetBackground 0 0 0


ren1 AddVolume volume
renWin Render



wm withdraw .







More information about the vtkusers mailing list