[vtkusers] Coloring an Isosurface

Martin Baumann mailsgetlost at web.de
Sat Aug 5 16:47:10 EDT 2006


Hi,

I have an vtkUnstructuredGrid that contains 4 scalar arrays of point data.
I would like to create an isosorface of one of the 4 scalars and color it with one other scalar array.

My piece of code:

  // read grid from file
  vtkUnstructuredGridReader* reader = vtkUnstructuredGridReader::New();
  reader->SetFileName("myFile.asc");
  reader->ReadAllScalarsOn();
  reader->Update();

  // copy grid
  vtkUnstructuredGrid* grid = vtkUnstructuredGrid::New();
  grid->ShallowCopy(reader->GetOutput());
  grid->Update();

  // make isosurface
  vtkContourFilter* iso = vtkContourFilter::New();
  iso->SetNumberOfContours(1);
  iso->SetValue(0,0.01);
  iso->SetInput(grid);

  // lookuptable
  vtkLookupTable* lut = vtkLookupTable::New();
  lut->SetNumberOfColors(64);
  lut->SetTableRange(grid->GetScalarRange());
  lut->Build();

  // map to graphics library
  vtkPolyDataMapper *map = vtkPolyDataMapper::New();
  map->SetInput(iso->GetOutput());
  map->SelectColorArray(1);   // this doesn't change a thing
  map->SetColorModeToMapScalars();
  map->SetLookupTable(lut);

How can I choose which scalar array should be used to create the contour and which for coloring?

Regards, M.B.

_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000071




More information about the vtkusers mailing list