[vtkusers] problem with isosurface and colors
Julia Faurie
julia at lrde.epita.fr
Tue Jul 23 05:32:20 EDT 2002
thanks for your answer stefano but it changes nothing on the colors...
I really don't see what's wrong.
> I admit I didn't check your code, but ... might this be due to interpolation of pixel colors
> between the vertex points of the isosurface polydata?
> Try with:
> "
> myActor->GetProperty()->SetInterpolationToFlat();
> "
> I hope this can help.
> Bye.
>
> Stefano Mininel
>
> Julia Faurie wrote:
>
> > hi!
> > i have an isosurface and i want to assign a color to each point of the
> > isosurface according to his coordinates (the three coordinates are the
> > red green blue components)
> > So i used a look up table (in my vtk file i associated scalars value to
> > each point, and the data is an colors histogram so every point has a
> > different scalar value)
> > I get an isosurface with rights colors but there are some blobs on the
> > surface which have wrong colors and i can't find why...
> > So if anyone knows what i'm doing wrong or if anyone knows a easier way
> > to do that...
> > thanks
>
my code:
//reader for the isosurface
vtkStructuredPointsReader *reader =
vtkStructuredPointsReader::New();
reader->SetFileName(nomfichier);
reader->SetScalarsName("scalars");
reader->Update();
//Reader fot the colors (scalars values)
vtkStructuredPointsReader *coul =
vtkStructuredPointsReader::New();
coul->SetFileName(nomfichier);
coul->SetScalarsName("scaltab");
coul->Update();
//creation of the look up table
vtkLookupTable *clut=vtkLookupTable::New();
clut->SetNumberOfColors(hsize*hsize*hsize);
clut->Build();
int numerop=0;
for (int r = 0; r < hsize; ++r)
for (int g = 0; g < hsize; ++g)
{
for (int b = 0; b < hsize; ++b)
{
//division to have datas between 0 and 1
float re=((float)r)/248;
float gr=((float)g)/248;
float bl=((float)b)/248;
clut->SetTableValue(numerop,re,gr,bl,1.0);
numerop++;
}
}
...
and later:
//colors+ datas
vtkProbeFilter *probe2=vtkProbeFilter::New();
probe2->SetInput (iso->GetOutput());
probe2->SetSource (coul->GetOutput());
vtkCastToConcrete *cast2=vtkCastToConcrete::New();
cast2->SetInput(probe2->GetOutput());
//normals
vtkPolyDataNormals *normals=vtkPolyDataNormals::New();
normals->SetInput(cast2->GetPolyDataOutput());
normals->SetFeatureAngle(45);
//mapper
isoMap->SetInput(normals->GetOutput());
isoMap->ScalarVisibilityOn();
isoMap->SetScalarRange (scalrang[0],scalrang[1]);
isoMap->SetColorModeToMapScalars();
isoMap->SetLookupTable(lut);
More information about the vtkusers
mailing list