[vtkusers] Coloring polydata with scalars
Mdl
mdl78 at libero.it
Tue Jan 14 05:18:15 EST 2003
> Try adding a line that reads:
> m->ScalarVisibilityOn();
I want to thank Prabhu for his help, I tried but it didn't work.
It shows me a totally white sphere.
I am really puzzled about it... anyone has a clue?
Here's the code:
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);
m->ScalarVisibilityOn();
m->SetScalarModeToUsePointData();
m->SetColorModeToMapScalars();
vtkActor *a = vtkActor::New();
a->SetMapper (m);
vtkRenderWindow *finestra = vtkRenderWindow::New();
vtkRenderer *ren = vtkRenderer::New();
ren->AddActor(a);
ren->SetRenderWindow(finestra);
finestra->AddRenderer(ren);
vtkRenderWindowInteractor *i = vtkRenderWindowInteractor::New();
i->SetRenderWindow(finestra);
finestra->Render();
i->Start();
Many thanks,
________________________________________
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