[vtkusers] Re: Scalar color / LookupTable / Interpolation problem...

Rainer Sabelka sabelka at iue.tuwien.ac.at
Sun May 2 16:28:30 EDT 2004


Hi Steve,

I had a similar problem some time ago.
To bypass OpenGL's  interpolation of colors I used a texture map instead of a 
lookup table. Therefore, the scalars had to be converted to texture 
coordinates. (For this reason I used the filed data array, but I think with a 
more recent vtk version there must be a simpler solution).

Here is the relevant snippet from my tcl program:

----

vtkUnstructuredGridReader reader

vtkAttributeDataToFieldDataFilter atf
atf SetInput [reader GetOutput]
atf PassAttributeDataOff

vtkFieldDataToAttributeDataFilter fta
fta SetInput [atf GetOutput]
fta DefaultNormalizeOn
fta SetInputFieldToPointDataField
fta SetOutputAttributeDataToPointData
fta SetTCoordComponent 0 "PointScalars" 0
fta SetTCoordComponent 1 "PointScalars" 0

vtkDataSetMapper map
map SetInput [fta GetOutput]

# OpenGL requires ncolors to be a power of two
set ncolors 16
vtkScalars scalars
scalars SetDataTypeToFloat
for {set i 0} {$i < $ncolors} {incr i} {
   for {set j 0} {$j < $ncolors} {incr j} {
      scalars InsertNextScalar [expr 1.0 - 1.0 * $i / ($ncolors - 1.0)]
   }
}

vtkStructuredPoints spoints
  spoints SetDimensions $ncolors $ncolors 1
  [spoints GetPointData] SetScalars scalars

vtkTexture texti
texti SetInput spoints
texti RepeatOff
texti InterpolateOff

vtkLODActor act
act SetMapper map
act SetTexture texti

ren1 AddActor act
----

On Friday 30 April 2004 10:43, Steve Joyce wrote:
> Hi,
>
> We would like a solution for this as well for colouring finite element
> models.
> We briefly looked at using some of the contouring classes, but couldn't
> get them to work the way we wanted. I would be very interested in any
> solutions that are proposed.
> A more controllable legend class would be nice too.
>
> Steve



More information about the vtkusers mailing list