[vtkusers] Problems with the lookup table.

Анна Найман annainnet at mail.ru
Thu Apr 24 00:32:11 EDT 2003


Hello, can anybody help me? 
I need to work with colors in vtk. 
I have a polydata file, and I want to set colors to te poligons in this file. I tryed to execute following simple example, and this example worked perfecly differently, then I expected. In file I have a cube, different scalars correspond to different faces of this cube, and different colors correspond to different scalars. But while executing, I see in my screen the cube, one face of which is red and all another are blue. Setting different colors to the faces of cube, I made sure that actualy mean only first and last colors in the lookup table. What is incorrect in my example?  

Anna Naiman (Russia)

This is my polydata file:

# vtk DataFile Version 2.0
Cube example
ASCII
DATASET POLYDATA
POINTS 8 float
0.0 0.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 1.0
0.0 1.0 1.0
POLYGONS 6 30
4 0 1 2 3
4 4 5 6 7
4 0 1 5 4
4 2 3 7 6
4 0 4 7 3
4 1 2 6 5

CELL_DATA 6
SCALARS cell_scalars int 1
LOOKUP_TABLE lt
0
1
2
3
4
5

LOOKUP_TABLE lt 6
1.0 0.0 0.0 1.0
0.0 1.0 0.0 1.0
1.0 1.0 0.0 1.0
0.0 1.0 1.0 1.0
1.0 0.0 1.0 1.0
0.0 0.0 1.0 1.0



This is the code, processing polydata file:

import vtk.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Math;
import sun.awt.*;
import java.beans.*;

public class cubic
{

  static { 
    System.loadLibrary("vtkCommonJava"); 
    System.loadLibrary("vtkFilteringJava"); 
    System.loadLibrary("vtkIOJava"); 
    System.loadLibrary("vtkImagingJava"); 
    System.loadLibrary("vtkGraphicsJava"); 
    System.loadLibrary("vtkRenderingJava"); 
  }

public static void main(String args[])

{
vtkPolyDataReader reader=new vtkPolyDataReader();
reader.SetFileName("cub.vtk");
vtkPolyDataMapper lineMapper=new vtkPolyDataMapper();
    lineMapper.SetInput (reader.GetOutput());
vtkActor lineActor=new vtkActor();
    lineActor.SetMapper(lineMapper);
    
    vtkRenderer ren1 = new vtkRenderer();
    ren1.AddActor( lineActor );
    ren1.SetBackground( 0.1, 0.2, 0.4 );

    vtkRenderWindow renWin = new vtkRenderWindow();
    renWin.AddRenderer( ren1 );
    renWin.SetSize( 300, 300 );

    int i;
    for (i = 0; i < 300; ++i)
      {renWin.Render();
      ren1.GetActiveCamera().Azimuth( 1 );
      }

}




More information about the vtkusers mailing list