[vtkusers] vtkGlyph3D indexing problem !

Sander Verhoeven poepzweer at hotmail.com
Sun Jul 16 09:44:42 EDT 2006


Hello, I'm working on my thesis with the VTK ToolKit and i have some 
problems...

I want to put diffrent actors on some points of a mesh. I use vtkGlyph3D and 
set my sources in and setIndexModeToScalar();
// CODE
  glyph->SetSource(0, spheres->GetOutput());
  glyph->SetSource(1, spheres->GetOutput());
  glyph->SetSource(2, cubes->GetOutput());
  glyph->SetSource(3, spheres->GetOutput());
  glyph->SetSource(4, cubes->GetOutput());
  glyph->SetSource(5, cubes->GetOutput());
  glyph->SetSource(6, cones->GetOutput());
  glyph->SetIndexModeToScalar();
//

==> The problem is that only for the value 0 i see a sphere, the rest of the 
value's are all cones!!!  You can see it at the image : 
http://webs.hogent.be/~023174sv/BC2.jpg

You can see a actor of the lookuptable where you can see that each value has 
a diffrent colour, but alle values 1 --> 6 are CONES , and only number 6 
should be a cone....

Can anyone please help me ?

Also i have a other question, the size of the actors should fit to the mesh, 
that means that when the points are further from eachother the actors should 
be bigger when there are lot's of point laying next to eachother....., is it 
possible in any way to get the maximum distance between points of a 
unstructured grid?? Or any option to solve this problem

// HERE IS PART OF MY CODE:
 vtkConeSource * cones = vtkConeSource::New();
  cones->SetResolution(10);
  cones->SetRadius(radius);
  cones->SetHeight(radius*2);

 vtkSphereSource *spheres = vtkSphereSource::New();
   spheres->SetThetaResolution(10);
   spheres->SetPhiResolution(10);
   spheres->SetRadius(radius);

 vtkCubeSource * cubes = vtkCubeSource::New();
  cubes->SetXLength(radius);
  cubes->SetYLength(radius);
  cubes->SetZLength(radius);

// MOET IN EEN KLASSE KOMEN VIA MAPPER vtkcolor["kleur"] return double*
//
// Setting up a color database: white, red, green, blue, yellow
//                              cyan, magenta, sky blue, black
//
 double** vtkcolors = new double*[9];
 for (int i=0; i<9; i++)
  vtkcolors[i] = new double[4];

 //white
 vtkcolors[0][0]=1;
 vtkcolors[0][1]=1;
 vtkcolors[0][2]=1;
 vtkcolors[0][3]=1;

 //red
 vtkcolors[1][0]=1;
 vtkcolors[1][1]=0;
 vtkcolors[1][2]=0;
 vtkcolors[1][3]=1;

 //green
 vtkcolors[2][0]=0;
 vtkcolors[2][1]=1;
 vtkcolors[2][2]=0;
 vtkcolors[2][3]=1;

 //blue
 vtkcolors[3][0]=0;
 vtkcolors[3][1]=0;
 vtkcolors[3][2]=1;
 vtkcolors[3][3]=1;

 //yellow
 vtkcolors[4][0]=1;
 vtkcolors[4][1]=1;
 vtkcolors[4][2]=0;
 vtkcolors[4][3]=1;

 //cyan
 vtkcolors[5][0]=0;
 vtkcolors[5][1]=1;
 vtkcolors[5][2]=1;
 vtkcolors[5][3]=1;

 //mangenta
 vtkcolors[6][0]=1;
 vtkcolors[6][1]=0;
 vtkcolors[6][2]=1;
 vtkcolors[6][3]=1;

 //sky blue
 vtkcolors[7][0]=0.5;
 vtkcolors[7][1]=0.5;
 vtkcolors[7][2]=1;
 vtkcolors[7][3]=1;

 //black
 vtkcolors[8][0]=0;
 vtkcolors[8][1]=0;
 vtkcolors[8][2]=0;
 vtkcolors[8][3]=1;


 vtkLookupTable *glyphlut = vtkLookupTable::New();
  glyphlut->SetRange(0,6);
  glyphlut->SetNumberOfTableValues(7);
  glyphlut->SetTableValue(0,vtkcolors[1]);
  glyphlut->SetTableValue(1,vtkcolors[2]);
  glyphlut->SetTableValue(2,vtkcolors[3]);
  glyphlut->SetTableValue(3,vtkcolors[4]);
  glyphlut->SetTableValue(4,vtkcolors[5]);
  glyphlut->SetTableValue(5,vtkcolors[6]);
  glyphlut->SetTableValue(6,vtkcolors[7]);
  glyphlut->Build();

 vtkGlyph3D *glyph = vtkGlyph3D::New();
  glyph->SetInput(polydata);
  glyph->ScalingOff();
  glyph->SetNumberOfSources(7);
  glyph->SetSource(0, spheres->GetOutput());
  glyph->SetSource(1, spheres->GetOutput());
  glyph->SetSource(2, cubes->GetOutput());
  glyph->SetSource(3, spheres->GetOutput());
  glyph->SetSource(4, cubes->GetOutput());
  glyph->SetSource(5, cubes->GetOutput());
  glyph->SetSource(6, cones->GetOutput());
  glyph->SetIndexModeToScalar();
  glyph->SetColorModeToColorByScalar();
  glyph->Update();


 //--- MAPPING AND RENDERING ---//
 vtkPolyDataMapper *umap = vtkPolyDataMapper::New();
  umap->SetInput(glyph->GetOutput());
  umap->ScalarVisibilityOn();
  umap->SetLookupTable(glyphlut);
  umap->UseLookupTableScalarRangeOn();
  umap->SetColorModeToMapScalars();

 vtkDataSetMapper *gmap = vtkDataSetMapper::New();
  gmap->SetInput(ugridreader->GetOutput());
  gmap->ScalarVisibilityOff();

//// MOET LEGENDE WORDEN / MAG WEG
  loadBarActor();
  baractor->SetLookupTable(umap->GetLookupTable());
  baractor->SetTitle(toConstChar("Boundairy Conditions"));

 vtkActor *uactor = vtkActor::New();
  uactor->SetMapper(umap);

 vtkActor *gactor = vtkActor::New();
  gactor->SetMapper(gmap);
  gactor->GetProperty()->SetColor(0.5,0.5,0.5);
  gactor->GetProperty()->SetOpacity(0.1);
  gactor->GetProperty()->SetRepresentationToWireframe();

 ren->AddActor(gactor);
 ren->AddActor(uactor);

 //start clock
 Stopwatch test;
 test.start();

 //render
 renWin->Render();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060716/24fba374/attachment.htm>


More information about the vtkusers mailing list