[vtkusers] Simple-colored polygons in vtk - directly way to set lut_id as cellvalue

Jochen Giese j.giese at gmx.net
Sat Apr 21 07:10:41 EDT 2007


Hallo, 

first I want thank you Marc for help me last time.

My question is the continuation of my last questions:
http://public.kitware.com/pipermail/vtkusers/2007-April/090494.html

I want make polygons with cells have different colors, the colors are in a
lookuptable, so I just need save in an array for the PolyData-Object the
lookuptable-id. At the moment I save it as a float and set the range of
lookuptable to (0,255).

Know somebody a better way? Can I set directly the id of the lookuptable as
the cellvalue (as a char)? 

Thank you for helping me,
Jochen Giese



For better understanding here is an example code, which represent my current
code:
	
vtkPolyData *polydata = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
vtkCellArray *cellarray = vtkCellArray::New();
vtkFloatArray *floatarray = vtkFloatArray::New();
vtkLookupTable *lut = vtkLookupTable::New();

points->InsertPoint(0,x[0]);
// ...
cellarray->InsertNextCell(4,&pts[0]);
// ...

// the value parameter is always whole-number (0...255)
floatarray->InsertTuple1(0,1); 
floatarray->InsertTuple1(1,3);
floatarray->InsertTuple1(2,1);

polydata->SetPoints(points);
polydata->SetPolys(cellarray);
polydata->GetCellData()->SetScalars(floatarray);
	
lut->Allocate();
lut->SetTableValue( 0, 1.0, 0.5, 0.5, 0.3 );
lut->SetTableValue( 1, 0.0, 1.0, 0.0, 1.0 );
// ...

vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
mapper->SetInput(polydata);
mapper->SetLookupTable(lut);
mapper->SetScalarRange(0,255);




More information about the vtkusers mailing list