[vtkusers] Re: problems using LOD on texture volume rendering

jose manjon jmanjon at fis.upv.es
Tue Jul 24 07:30:56 EDT 2001


Hi all,

I have modified the sample for texture 2D volume rendering but it doesn´t works
can anyone tell me what I am doing wrong??

thanks

jose

The code is:


catch {load vtktcl}
# get the interactor ui
source vtkInt.tcl

# Simple volume rendering example.

# read the volume

vtkVolume16Reader reader
  reader SetDataDimensions 256 256
  reader SetFilePrefix "./modelo3/cab"
  reader SetImageRange 0 197
  reader SetDataSpacing 1.0 1.0 1.0

# Create transfer functions for opacity and color
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint  20   0.0
    opacityTransferFunction AddPoint  255  1.0

vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint      0.0 0.0 0.0 0.0
    colorTransferFunction AddRGBPoint    255.0 1.0 1.0 1.0

# Create property, mapper, volume
vtkVolumeProperty volumeProperty
    volumeProperty SetColor colorTransferFunction
    volumeProperty SetScalarOpacity opacityTransferFunction

vtkVolumeTextureMapper2D volumeMapper
    volumeMapper SetInput [reader GetOutput]

vtkVolume volume
    volume SetMapper volumeMapper
    volume SetProperty volumeProperty

# LOD Level Of Detail

vtkImageResample resampler
  resampler SetAxisMagnificationFactor 0 0.5
  resampler SetAxisMagnificationFactor 1 0.5
  resampler SetAxisMagnificationFactor 2 0.5

vtkVolumeTextureMapper2D lowresMapper
  lowresMapper SetInput [resampler GetOutput]

vtkVolumeTextureMapper2D medresMapper
  medresMapper SetInput [reader GetOutput]

vtkVolumeRayCastMapper hiresMapper
  hiresMapper SetInput [reader GetOutput]

vtkLODProp3D volumeLOD
  volumeLOD AddLOD lowresMapper volumeProperty 0.0
  volumeLOD AddLOD medresMapper volumeProperty 0.0
  volumeLOD AddLOD hiresMapper volumeProperty 0.0

# Okay now the graphics stuff
vtkRenderer ren1

vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin SetSize 768 512

vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

ren1 AddVolume volume

ren1 AddProp volumeLOD
ren1 SetBackground 0.0 0.0 0.0

[ren1 GetActiveCamera] SetPosition 0 1 0
[ren1 GetActiveCamera] SetFocalPoint 0 0 0
[ren1 GetActiveCamera] SetViewUp 0 1 0
ren1 ResetCamera

# Render

renWin Render

proc TkCheckAbort {} {
  set foo [renWin GetEventPending]
  if {$foo != 0} {renWin SetAbortRender 1}
}
renWin SetAbortCheckMethod {TkCheckAbort}

iren SetUserMethod {wm deiconify .vtkInteract}

#renWin SetFileName "volTexSimple.tcl.ppm"
#renWin SaveImageAsPPM

wm withdraw .



--
----------------------------------------------------------
Jose Vicente Manjón Herrera
GIM (Group of Medical Informatics)
Applied Physics Department
Technical University of Valencia
46022 Valencia (SPAIN)
----------------------------------------------------------






More information about the vtkusers mailing list