[vtkusers] mapper question..

Will Schroeder will.schroeder at kitware.com
Mon Feb 3 11:23:01 EST 2003


The attached script works fine for me.
Will

At 07:39 PM 2/1/2003 -0500, K.R.Subramanian wrote:

>I am trying to display images using
>
>vtkPlaneSource (1x1 size)
>vtkTexture

-------------
# This simple example shows how to do basic texture mapping.
#
# We start off by loading some Tcl modules. One is the basic VTK library;
# the other is a package for rendering.
#
package require vtk
package require vtkinteraction

# Load in the texture map. A texture is any unsigned char image. If it
# is not of this type, you will have to map it through a lookup table
# or by using vtkImageShiftScale.
#
# This creates a black to white lut.
vtkLookupTable lut
     lut SetNumberOfColors 16
     lut SetHueRange 0 0
     lut SetSaturationRange 0 0
     lut SetValueRange 0.5 1.0
     lut Build

vtkStructuredPointsReader reader
   reader SetFileName "krs.vtk"
vtkTexture atext
   atext SetInput [reader GetOutput]
#  atext InterpolateOn
   atext SetLookupTable lut

# Create a plane source and actor. The vtkPlanesSource generates
# texture coordinates.
#
vtkPlaneSource plane
   plane SetXResolution 10
   plane SetYResolution 10
vtkPolyDataMapper  planeMapper
   planeMapper SetInput [plane GetOutput]
   planeMapper ScalarVisibilityOff
vtkActor planeActor
   planeActor SetMapper planeMapper
   planeActor SetTexture atext

# Create the RenderWindow, Renderer and both Actors
vtkRenderer ren1
vtkRenderWindow renWin
     renWin AddRenderer ren1
vtkRenderWindowInteractor iren
     iren SetRenderWindow renWin

# Add the actors to the renderer, set the background and size
ren1 AddActor planeActor
ren1 SetBackground 0.1 0.2 0.4
renWin SetSize 500 500

# render the image
iren AddObserver UserEvent {wm deiconify .vtkInteract}
renWin Render

# prevent the tk window from showing up then start the event loop
wm withdraw .


--------------krs.vtk
# vtk DataFile Version 2.0
Texture map for KRS

ASCII

DATASET STRUCTURED_POINTS
DIMENSIONS 16 8 1
SPACING 1 1 1
ORIGIN 0.0 0.0 0.0

POINT_DATA 128
SCALARS texture float
LOOKUP_TABLE default
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.125
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.25
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.375
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.625
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.75
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875
0.875







More information about the vtkusers mailing list