[vtk-developers] shift error in vtkVolumeTextureMapper2D

David Gobbi dgobbi at imaging.robarts.ca
Thu Jul 18 15:00:49 EDT 2002


Hi Lisa,

The vtkVolumeTextureMapper2D seems to have a half-pixel
offset error in either the generation of the textures or
in the mapping of the textures to display.

I've attached a tcl script that demonstrates the problem.
It volume-renders a sphere along with a wireframe sphere
of the same dimensions.  The ray-cast volume rendering
matches the wireframe surface perfectly, but the
texture-map volume rendering (when you interact with
the window) is definitely off.

 - David

-- 
  David Gobbi, MSc                dgobbi at imaging.robarts.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

=======================================================
package require vtk

vtkImageEllipsoidSource reader
    reader SetOutputScalarTypeToUnsignedChar
    reader SetWholeExtent 0 31 0 31 0 31
    reader SetCenter 15.5 15.5 15.5
    reader SetRadius 14 14 14
    reader SetInValue 200
    reader SetOutValue 0

    reader UpdateWholeExtent
    [reader GetOutput] SetOrigin -15.5 -15.5 -15.5
    [reader GetOutput] SetSpacing 1 1 1

vtkImageGaussianSmooth blur
    blur SetInput [reader GetOutput]
    blur SetStandardDeviation 1.5
    blur SetRadiusFactor 3
    blur UpdateWholeExtent

# Create transfer functions for opacity and color
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint    0   0.0
    opacityTransferFunction AddPoint   95   0.0
    opacityTransferFunction AddPoint  105   1.0
    opacityTransferFunction AddPoint  255   1.0

vtkColorTransferFunction colorTransferFunction
    colorTransferFunction SetColorSpaceToRGB
    colorTransferFunction AddHSVPoint      0.0 0.01 1.0 1.0
    colorTransferFunction AddHSVPoint    127.5 0.50 1.0 1.0
    colorTransferFunction AddHSVPoint    255.0 0.99 1.0 1.0
    colorTransferFunction SetColorSpaceToHSV

# Create properties, mappers, volume actors, and ray cast function
vtkVolumeProperty volumeProperty
    volumeProperty SetColor colorTransferFunction
    volumeProperty SetScalarOpacity opacityTransferFunction
    volumeProperty SetInterpolationTypeToLinear

vtkVolumeRayCastCompositeFunction  compositeFunction

vtkVolumeRayCastMapper volumeMapper
    volumeMapper SetInput [blur GetOutput]
    volumeMapper SetVolumeRayCastFunction compositeFunction

vtkVolumeTextureMapper2D volumeTexMapper
    volumeTexMapper SetInput [blur GetOutput]
    volumeTexMapper SetTargetTextureSize 32 32
    volumeTexMapper SetMaximumNumberOfPlanes 32

vtkLODProp3D volume
    volume AddLOD volumeMapper volumeProperty 0.2
    volume AddLOD volumeTexMapper volumeProperty 0.05

# Create geometric sphere
vtkSphereSource sphereSource
    sphereSource SetCenter  0 0 0
    sphereSource SetRadius  14
    sphereSource SetThetaResolution 15
    sphereSource SetPhiResolution 15

vtkPolyDataMapper sphereMapper
    sphereMapper SetInput [sphereSource GetOutput]

vtkActor sphereActor
    sphereActor SetMapper sphereMapper
    [sphereActor GetProperty] SetRepresentationToWireframe

# Okay now the graphics stuff
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin SetSize 256 256
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

[ren1 GetCullers] InitTraversal
set culler [[ren1 GetCullers] GetNextItem]
$culler SetSortingStyleToBackToFront

ren1 AddProp sphereActor
ren1 AddProp volume
ren1 SetBackground 0.1 0.2 0.4
renWin Render

wm withdraw .

iren Initialize
-------------- next part --------------
A non-text attachment was scrubbed...
Name: voltmp.tcl
Type: application/x-tcl
Size: 2725 bytes
Desc: 
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20020718/ede4f7cc/attachment-0001.tcl>


More information about the vtk-developers mailing list