[vtkusers] LookupTable with (x,y,z)

João Cunha jdc at lnec.pt
Fri Jul 29 12:13:32 EDT 2005


patgo at sapo.pt wrote:

> I send you the whole code (it's not big), written in C#. The 
> problematic lines are marked with ***. They just don't do anything...
>
> Thank you for your time,
>
> Patrícia Gonçalves
>
> using System;
>
> using System.IO;
>
> using vtkDotNetWrap;
>
> namespace Delaunay2Dgraph
>
> {
>
> /// <summary>
>
> /// Summary description for Class1.
>
> /// </summary>
>
> class Del2D
>
> {
>
> [STAThread]
>
> static void Main()
>
> {
>
> //Ler dados de entrada
>
> LerFx lf = new LerFx();
>
> lf.LerFicheiro();
>
> int numberPlies = 4;
>
> int ply;
>
> vtkRenderWindow renWin = vtkRenderWindow.New();
>
> renWin.SetSize(1200, 800);
>
> vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();
>
> iren.SetRenderWindow(renWin);
>
> for (int a=1; a<=numberPlies; a++)
>
> {
>
> //Criar polydata com os dados de entrada
>
> vtkPoints points = vtkPoints.New();
>
> int i=0;
>
> foreach (Linhas l in lf.ListaValores)
>
> {
>
> ply = (int)(l.Ply);
>
> if (ply == a)
>
> {
>
> points.InsertPoint(i, l.Xx, l.Yy, l.S11/50);
>
> i++;
>
> }
>
> }
>
> //Construir células
>
> vtkCellArray polys = vtkCellArray.New();
>
> for (int j=0; j<i; j++)
>
> {
>
> polys.InsertNextCell(1);
>
> polys.InsertCellPoint(j);
>
> }
>
> //Construir polydata de entrada
>
> vtkPolyData profile = vtkPolyData.New();
>
> profile.SetPoints(points);
>
> profile.SetVerts(polys);
>
> //Triangulação de Delaunay 2D nos pontos de entrada
>
> vtkDelaunay2D del = vtkDelaunay2D.New();
>
> del.SetInput(profile);
>
> del.SetTolerance(0.001);
>
> *** //Criar lookuptable
>
> *** vtkLookupTable LookupTable1 = vtkLookupTable.New();
>
> *** LookupTable1.SetNumberOfColors(8);
>
> *** LookupTable1.SetHueRange(0, 0.667f);
>
> *** LookupTable1.SetSaturationRange(0, 1);
>
> *** LookupTable1.SetValueRange(0, 1);
>
> *** LookupTable1.SetTableRange(-0.44f, 2.5f);
>
> *** LookupTable1.Build();
>
> *** for (int h=0; h<8; h++)
>
> *** {
>
> *** LookupTable1.SetTableValue(h,0.01f*h,0.05f*h,0.1f*h,1);
>
> *** }
>
> //Criação do actor
>
> vtkPolyDataMapper map = vtkPolyDataMapper.New();
>
> map.SetInput(del.GetOutput());
>
> *** map.SetLookupTable(LookupTable1);
>
> map.SetScalarRange(0, 10);
>
> vtkActor triangulation = vtkActor.New();
>
> triangulation.SetMapper(map);
>
> vtkRenderer ren = vtkRenderer.New();
>
> renWin.AddRenderer(ren);
>
> ren.AddActor(triangulation);
>
> ren.SetBackground(1, 1, 1);
>
> if (a==1) ren.SetViewport(0,0.5f,0.5f,1);
>
> if (a==2) ren.SetViewport(0.5f,0.5f,1,1);
>
> if (a==3) ren.SetViewport(0,0,0.5f,0.5f);
>
> if (a==4) ren.SetViewport(0.5f,0,1,0.5f);
>
> }
>
> renWin.Render();
>
> iren.Start();
>
> }
>
> }
>
> }
>
>
>
> Citando João Cunha :
>
> Could you attach the relevant piece of code, the one that does not work ?
> João Cunha
>
>
>
> patgo at sapo.pt wrote:
>
> > Hello,
> >
> > I plotted a set of points (x,y,z) and used the 2D Delaunay
> > triangulation to make a surface graphic. This worked just fine! Now I
> > want the graphic to apear in different colors, acordding to the zz
> > coordinate. I built a LookupTable but it doesn't work. Why?
> >
> > All the vtkLookupTable examples use previously built files with data
> > so they're not helping me...
> >
> > Does anybody know how I can do this?
> >
> > Thanks,
> > Patrícia Gonçalves
>
>
> ___________________________________________________________________
>
> O SAPO já está livre de vírus com a Panda Software, fique você também!
> Clique em: http://antivirus.sapo.pt 
> </services/go.php?url=http%3A%2F%2Fantivirus.sapo.pt>

The Profile object does not contain any scalar (z is just a 3rd 
coordinate whcuh is ignored by the
Delaunay triiangulation). I think that you can easily solve the problem 
using vtkElevationFilter to
generate scalar values from z, before or after the triangulation, but 
before passing information to map.
I can´t test the solution directly in your code since I'm using vtk from 
Tcl/Tk.
Hope this helps.
João Cunha

-- 
João Duarte Cunha
Investigador-Coordenador
Director do Centro da Qualidade na Construção
jdc at lnec.pt




More information about the vtkusers mailing list