[vtkusers] stupid question re: volSimple.py

Maneesh Yadav 97yadavm at utsc.utoronto.ca
Tue Aug 7 15:54:32 EDT 2001


Hi all, I'm having a bit o' trouble visualizing my data...
I stripped the header of the stack as was suggested earlier on the list
and I should be left with the raw data (it's the right size)...
to load the data I do this:

-------------------------------------------------------

from libVTKCommonPython import *
from libVTKGraphicsPython import *


reader=vtkImageReader()
reader.SetFileName("dataset.raw")
reader.SetDataExtent(0,255,0,255,0,249)
reader.SetFileDimensionality(3)
reader.SetHeaderSize(0)
reader.SetDataByteOrderToLittleEndian()
reader.SetDataOrigin(0,0,0)
reader.SetDataScalarTypeToUnsignedChar()
reader.SetDataSpacing(1.0,1.0,1.0)
reader.GetOutput().ReleaseDataFlagOn()

-----------------------------------------------------------

(am I missing anything?)
Things seem to read fine....

I then copy the last part volSimple.py


-----------------------------------------------------------
opacityTransferFunction = vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(20,0.0)
opacityTransferFunction.AddPoint(255,0.2)

colorTransferFunction = vtkColorTransferFunction()
colorTransferFunction.AddRedPoint(0.0,0.0)
colorTransferFunction.AddRedPoint(64.0,1.0)
colorTransferFunction.AddRedPoint(128.0,0.0)
colorTransferFunction.AddRedPoint(255.0,0.0)
colorTransferFunction.AddBluePoint(0.0,0.0)
colorTransferFunction.AddBluePoint(64.0,0.0)
colorTransferFunction.AddBluePoint(128.0,1.0)
colorTransferFunction.AddBluePoint(192.0,0.0)
colorTransferFunction.AddBluePoint(255.0,0.0)
colorTransferFunction.AddGreenPoint(0.0,0.0)
colorTransferFunction.AddGreenPoint(128.0,0.0)
colorTransferFunction.AddGreenPoint(192.0,1.0)
colorTransferFunction.AddGreenPoint(255.0,0.2)

volumeProperty = vtkVolumeProperty()
volumeProperty.SetColor(colorTransferFunction)
volumeProperty.SetScalarOpacity(opacityTransferFunction)

compositeFunction = vtkVolumeRayCastCompositeFunction()

volumeMapper = vtkVolumeRayCastMapper()
volumeMapper.SetInput(reader.GetOutput())
volumeMapper.SetVolumeRayCastFunction(compositeFunction)

volume = vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volumeProperty)


# Okay now the graphics stuff
ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(256,256)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

#ren1 AddActor outlineActor
ren.AddVolume(volume)
ren.SetBackground(0.1,0.2,0.4)
renWin.Render()

def TkCheckAbort():
        foo=renWin.GetEventPending()
        if foo != 0:
                renWin.SetAbortRender(1)

renWin.SetAbortCheckMethod(TkCheckAbort)

iren.Initialize()
-----------------------------------------------------

The program starts a window comes then dissappears (no coredump)...

I just kind of want to 'get started' so I am not particularly concerened
with the coloring right now, but I wouldn't think that would prevent the
program  from running....can anyone help me as to what am I doing wrong?







More information about the vtkusers mailing list