[vtkusers] vtkActorColor and Background color Problems

Mike Jackson maillist at bluequartz.net
Tue Dec 6 23:50:56 EST 2005


I am trying to change the color of a vtkActor, but somehow the  
background color of my renderer is changed to the same color.

The basic pipeline is as follows:

I read in an STL file and run it through the vtkPolyDataConnectivity  
filter with colors set to "ON". I then generate a Lookup table for  
the colors:
     colorTable = vtkLookupTable::New();
     colorTable->SetNumberOfColors( numRegions );
     colorTable->SetRange ( connections->GetScalarRange() );
     unsigned int size = numRegions;
     for (unsigned int i = 0; i < size; ++i)
     {
         colorTable->SetTableValue(i, ((1 *  rand()) / (float) 
INT_MAX), ((1 *  rand()) / (float)INT_MAX), ((1 *  rand()) / (float) 
INT_MAX), 1.0);
     }

I then loop over all the regions and create a vtkActor for each region:

for (unsigned int i = 0; i < numRegions; ++i)
     {
         d = regions->GetNextItem();
         vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
         mapper->SetInput( d );
         mapper->ScalarVisibilityOn();
         mapper->SetScalarRange (0, numRegions);
         mapper->SetLookupTable(colorTable);
         vtkActor *dataActor = vtkActor::New();
         dataActor->SetMapper(mapper);
         dataActor->GetProperty()->SetOpacity(1.0f);
         dataActor->GetProperty()->SetInterpolation( VTK_GOURAUD );
         dataActor->GetProperty()->SetRepresentationToSurface();
         dataActor->SetPosition(center);
         dataActor->AddObserver(vtkCommand::PickEvent, pickEvent );
         actors->AddItem(dataActor);
         [vtkView renderer]->AddActor(dataActor);
         dataActor->Delete();
         mapper->Delete();
     }

I have another method that receives events from a Color Chooser and  
this is where I try to set the new color into the proper place in the  
lookup table.

-(IBAction) updateParticleColor:(id)sender
{
    //rowIndex is the index into the color table.
       colorTable->SetTableValue(rowIndex, (double)[color  
redComponent], (double)[color greenComponent],
            (double)[color blueComponent], 1.0  );
     [vtkView getInteractor]->GetInteractorStyle()->GetInteractor()- 
 >Render();
}

When the above method gets called, the actor color is set, but also  
the renderer background color, same as if I had called
_renderer->SetBackground( 0.9568, 1.0, 0.7843);

Is there something I am missing about using the lookup table?

TIA
---
Mike Jackson
mike _at_ bluequartz dot net





More information about the vtkusers mailing list