[vtkusers] Surface color
Gheorghe Postelnicu
gheorghe.postelnicu at gmail.com
Wed Feb 7 14:24:56 EST 2007
Hi,
I am using the implicit modelling tools provided by VTK and I ran
across the following issue: consider the following toy example code
which builds a sphere using either the SphereSource method or an
implicit pipeline.
The problem is that whenever I display an implicit sphere, its color
is red and I can't seem to figure out how to make it become gray, just
like the original surface.
Any suggestions would be greatly appreciated.
-------------------
package require vtk
package require vtkinteraction
package require vtktesting
vtkPolyDataMapper mapper
vtkActor actor
actor SetMapper mapper
eval [actor GetProperty] SetColor .5 .5 .5
vtkRenderer ren1
ren1 AddActor actor
vtkRenderWindow renWin
renWin AddRenderer ren1
proc Show_smooth {} {
vtkSphereSource vtks
vtks Update
mapper SetInput [vtks GetOutput]
vtks Delete
}
proc Show_bumpy {} {
vtkSphere vtks
vtkPerlinNoise pin
vtkImplicitSum sum
sum SetNormalizeByWeight 1
sum AddFunction vtks
sum AddFunction pin .2
vtkSampleFunction sample
sample SetImplicitFunction sum
sample SetSampleDimensions 20 20 20
sample SetModelBounds -2. 2. -2. 2. -2. 2.
sample ComputeNormalsOn
vtkContourFilter surface
surface SetInputConnection [sample GetOutputPort]
surface SetValue 0 0
mapper SetInput [surface GetOutput]
eval [actor GetProperty] SetColor .5 .5 .5
renWin Render
surface Delete
sample Delete
sum Delete
pin Delete
vtks Delete
}
Show_smooth
set vtkw [vtkTkRenderWidget .ren \
-width 600 \
-height 600 \
-rw renWin ]
::vtk::bind_tk_render_widget $vtkw
frame .btns
renWin Render
set radioType "smooth"
foreach type {smooth bumpy} {
set gui_${type} [ radiobutton .btns.${type} \
-command "Show_${type}" \
-variable radioType \
-value "$type" \
-text "$type" ]
}
pack $gui_smooth $gui_bumpy \
-side left -fill both -ipady 5 -expand 1
pack .btns $vtkw -side left -fill both -expand yes
wm protocol . WM_DELETE_WINDOW ::vtk::cb_exit
tkwait window .
update
-----------------------------
--
Gheorghe Postelnicu, PhD
MGH, Harvard Medical School
More information about the vtkusers
mailing list