[vtkusers] Surface color

Amy Squillacote amy.squillacote at kitware.com
Wed Feb 7 15:16:59 EST 2007


Hi Gheorghe,

Try calling ScalarVisibilityOff on the mapper. What I think is happening 
is that when you're generating the sphere using the contour filter, the 
dataset you're rendering has scalar data in it, and the mapper is using 
this scalar data to determine the color of the dataset. Since the scalar 
value is the same for every point in the contour, the resulting surface 
is a solid color.

- Amy

Gheorghe Postelnicu wrote:
> 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
>
> -----------------------------
>



More information about the vtkusers mailing list