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

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Sun May 2 17:33:59 EDT 2004


Hi Rainer,
   very interesting, the class I made does just like your vtk code, there
are 2 classes actually, one to generate a texture from a lookuptable,
another to generate texture coordinates from scalars. I liked the end
result so much I started using it in preference to the standard vtk
scalars->colours approach in my applications.

The question in my mind: Is there is a way to do this neatly in existing
vtk? if so then that is preferrable to new classes. If the classes are
useful I would like to contribute them to vtk.

  Dave P




|---------+---------------------------->
|         |           Rainer Sabelka   |
|         |           <sabelka at iue.tuwi|
|         |           en.ac.at>        |
|         |           Sent by:         |
|         |           vtkusers-admin at vt|
|         |           k.org            |
|         |                            |
|         |                            |
|         |           03/05/2004 08:28 |
|         |                            |
|---------+---------------------------->
  >--------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                |
  |       To:       "Steve Joyce" <Steve.Joyce at sercoassurance.com>                                                                 |
  |       cc:       vtkusers at public.kitware.com                                                                                    |
  |       Subject:  Re: [vtkusers] Re: Scalar color / LookupTable / Interpolation problem...                                       |
  >--------------------------------------------------------------------------------------------------------------------------------|




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
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <
http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

_







More information about the vtkusers mailing list