[vtkusers] vtkStructuredPointsReader and color
vtk at le.isac.cnr.it
vtk at le.isac.cnr.it
Wed Jun 5 10:03:57 EDT 2002
Hi..
i have an other problem with vtk 4.0 (tcl/tk on linux).
I have a vtkStructuredPointsReader, and i would like to visualize a 2d images with:
********************************************************
vtkStructuredPointsReader reader
reader SetFileName "heart.vtk"
reader Update
vtkPlane cutPlane
eval cutPlane SetOrigin [[reader GetOutput] GetCenter]
cutPlane SetNormal 1 0 0
vtkCutter planeCut
planeCut SetInput [reader GetOutput]
planeCut SetCutFunction cutPlane
# Isosuperficie 2d
vtkDataSetMapper mapper
mapper SetInput [planeCut GetOutput]
eval mapper SetScalarRange [[[[reader GetOutput] GetPointData] GetScalars] GetRange]
# Linee di livello
vtkContourFilter contours
contours SetInput [planeCut GetOutput]
contours GenerateValues 20 0.0 200
# mapper SetInput [contours GetOutput]
vtkActor cutActor
cutActor SetMapper mapper
****************************************************
then i want to visualize a volume, with this code:
************************************************
# Create transfer mapping scalar value to opacity
vtkPiecewiseFunction opacityTransferFunction
opacityTransferFunction AddPoint 20 0.0
opacityTransferFunction AddPoint 255 0.2
vtkColorTransferFunction colorTransferFunction
colorTransferFunction AddRGBPoint 64 0 1 0
colorTransferFunction AddRGBPoint 128 1 0 0
colorTransferFunction AddRGBPoint 255 0 0 1
# 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
********************************************************
my header file data is:
# vtk DataFile Version 2.0
CT scan data of human heart, courtesy by Henk Mastenbroek RuG
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 32 32 12
ORIGIN 0.000 0.000 0.000
SPACING 1.000 1.000 4.000
POINT_DATA 12288
SCALARS colors unsigned_char
LOOKUP_TABLE default
**************************************************
so I visualize the volume with many different color, and the 2d images in the gray scale color.
If I change SCALARS colors unsigned_char in to SCALAR scalars float, i visualize 2d images in many different color and don't view the volume.
What can i do to visualize all images in many different color???
thanks
More information about the vtkusers
mailing list