[vtkusers] Coloring polydata with scalars
Mdl
mdl78 at libero.it
Fri Jan 10 19:22:58 EST 2003
Hi everybody,
I'm trying to display a sphere colored according to scalar attributes I
assign to its points; I can't see anything wrong in the code, but it doesn't
work... here it is:
vtkSphereSource *s = vtkSphereSource::New();
s->SetPhiResolution (20);
s->SetThetaResolution (20);
vtkFloatArray *fa = vtkFloatArray::New();
fa->SetNumberOfValues (400);
for (int j=0; j < 400; j++)
fa->SetValue ((vtkIdType) j, values[j]); // values[] is an array
of floats in the range 0..100
s->GetOutput()->GetPointData()->SetScalars(fa);
vtkDataSetMapper *m = vtkDataSetMapper::New();
m->SetInput(s->GetOutput());
m->SetScalarRange (0, 100);
vtkActor *a = vtkActor::New();
a->SetMapper (m);
.....and the usual rendering stuff.
I get a black display... can anyone bring some color in my life? :-)
I also tried to create another vtkPolyData:
vtkPolyData *pd = vtkPolyData::New();
pd->SetSource (s);
pd->GetPointData()->SetScalars(fa);
but no way.
The same if I use GetCellData() instead of GetPointData().
Thanks in advance,
________________________________________
Marco Di Lorenzo
(mdl78 at libero.it)
________________________________________
Tesista presso IAC-CNR di Roma
Istituto per le Applicazioni del Calcolo "M. Picone"
Viale del Policlinico, 137
00161, Roma
________________________________________
More information about the vtkusers
mailing list