[vtkusers] 3D Plane with Color Mapping
Eric Engelhard
eric_cl at pacbell.net
Thu Nov 29 18:47:43 EST 2001
Please forgive my novice question and feel free to (gruffly) point me
towards an example. I have both vtk books and associated CDs. My first
effort is to create a 3D plane from a structured points data file and
map a color at each point. This plane will eventually be transformed
into a surface (holding z to zero just for now).
Questions:
1. Is the data set correctly formatted?
2. Am I misguided in my use of vtkStructuredPointsGeometryFilter below?
3. what is the best color mapping method to use here?
Much appreciated,
Eric Engelhard
My sample.vtk (no color mapping applied):
DATASET STRUCTURED_POINTS
DIMENSIONS 2810,2810,0
ORIGIN 0,0,0
SPACING 1,1,1
(lots of x,y,z data)
SCALARS co_mutation int 1
(scalar associated with each point listed above, range 1 - 125)
My sample.tcl:
catch {load vtktcl}
if { [catch {set VTK_TCL $env(VTK_TCL)}] != 0} { set VTK_TCL
"/usr/lib/vtk/examplesTcl" }
if { [catch {set VTK_DATA $env(VTK_DATA)}] != 0} { set VTK_DATA "~/vtk"
}
# get the interactor ui
source $VTK_TCL/vtkInt.tcl
# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
#read from vtk file
vtkStructuredPointsReader data
data SetFileName $VTK_DATA/structured_points_test.vtk
vtkStructuredPointsGeometryFilter polydata
polydata SetInput [data GetOutput]
polydata SetExtent 0 2810 0 2810 0 0
vtkPolyDataMapper planeMapper
planeMapper SetInput [polydata GetOutput]
vtkActor planeActor
planeActor SetMapper planeMapper
[planeActor GetProperty] SetRepresentationToWireframe
# Add the actors to the renderer, set the background and size
#
ren1 AddActor planeMapper
ren1 SetBackground 0.1 0.2 0.4
renWin SetSize 500 500
# render the image
#
iren SetUserMethod {wm deiconify .vtkInteract}
set cam1 [ren1 GetActiveCamera]
$cam1 Zoom 1.4
iren Initialize
#renWin SetFileName "stl.tcl.ppm"
#renWin SaveImageAsPPM
# test regeneration of the LODMappers
stlActor Modified
# prevent the tk window from showing up then start the event loop
wm withdraw .
My error message:
Error in startup script: vtk bad argument, type conversion failed for
object planeMapper.
Could not type convert planeMapper which is of type
vtkOpenGLPolyDataMapper, to type vtkProp.
Object named: ren1, could not find requested method: AddActor
or the method was called with incorrect arguments.
while executing
"ren1 AddActor planeMapper"
(file "test_plane.tcl" line 30)
More information about the vtkusers
mailing list