[vtkusers] Problems with scalar contours
Daniel Rypl
dr at cml.fsv.cvut.cz
Tue Jan 13 10:36:42 EST 2004
Dear Vtk users,
is it correct that when applying color to a vtkActor as
vtkActor meshActor
meshActor SetMapper meshMapper
[meshActor GetProperty] SetColor 1 0 0
then the scalar contours (defined together with an unstructured
grid in vtk DataFile Version 2.0) are made in that color only
(red in this case) ?
The problem is that I do not know in advance that scalar values
are present in the data file and I still want to use the same Tcl script.
When using without color assigment, scalar contours are OK but
if there are no scalars in data file, the drawing is white (of course).
I am using Vtk 4.2 on Linux RedHat 9 with Mesa 4 and Tcl/Tk 8.3.
It was working fine on Vtk 3.1 RedHat 5.2.
Could anyone advise me?
Thanks a lot for any help
Daniel Rypl
PS: Below is the Vtk data file and Tcl script. Should you be so kind
PS: Below is the Vtk data file and Tcl script. Should you be so kind
and try it running using your vtk, please save the Vtk data file
as m.vtk.
=========================================================================
# vtk DataFile Version 2.0
# simple example
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 4 float
1 1 0
2 1 0
1 2 0
2 2 0
CELLS 6 16
1 0
1 1
1 2
1 3
3 0 1 2
3 1 3 2
CELL_TYPES 6
1
1
1
1
5
5
POINT_DATA 4
SCALARS sample_scalars float
LOOKUP_TABLE my_table
0.0
1.0
2.0
3.0
LOOKUP_TABLE my_table 3
1.0 0.0 0.0 1.0
0.0 1.0 0.0 1.0
0.0 0.0 1.0 1.0
==========================================================================
#package require vtk
package require vtkinteraction
# Display unstructured mesh
set inputFileName m.vtk
# Create renderer stuff
#
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# create pipeline
#
vtkUnstructuredGridReader geometryReader;
geometryReader SetFileName $inputFileName
vtkDataSetMapper meshMapper
meshMapper SetInput [geometryReader GetOutput]
meshMapper ScalarVisibilityOn
meshMapper SetScalarRange -0.00001 3.00001
vtkActor meshActor
meshActor SetMapper meshMapper
#
## Comment the following line to see scalar contours
#
[meshActor GetProperty] SetColor 1 0 0
vtkAxes meshAxesSource
meshAxesSource SetScaleFactor 1
meshAxesSource SetOrigin 0 0 0
vtkPolyDataMapper meshAxesMapper
meshAxesMapper SetInput [meshAxesSource GetOutput]
vtkActor meshAxes
meshAxes SetMapper meshAxesMapper
ren1 AddActor meshAxes
meshAxes VisibilityOff
# Add the actors to the renderer, set the background and size
#
ren1 AddActor meshActor
ren1 SetBackground 0.1 0.2 0.4
renWin SetSize 640 480
[ren1 GetActiveCamera] SetPosition 0 0 10
[ren1 GetActiveCamera] Azimuth 0
[ren1 GetActiveCamera] Dolly 1.4
ren1 ResetCameraClippingRange
meshAxes VisibilityOn
renWin Render
iren AddObserver UserEvent {wm deiconify .vtkInteract}
# prevent the tk window from showing up then start the event loop
#
wm withdraw .
More information about the vtkusers
mailing list