[vtkusers] Re: Duplicating a vtkActor

Mike Jackson imikejackson at gmail.com
Wed Feb 22 09:12:03 EST 2006


On Feb 21, 2006, at 10:32 PM, mike jackson wrote:

> I am using a bunch of vtkActors to render my 3D scene. Each actor is
> created from a vtkPolyData object with the intermediate
> vtkPolyDataMapper object. This works just fine (although I do not know
> how it will scale..) and I can remove actors from the scene and put
> them back in (filtering) and everything runs just fine. By run I mean
> I can get about 60 frames per second when interacting with the scene.
>   Now I would like to let the user "duplicate" one of the actors so
> that they can move the copy somewhere else in the scene (Think
> periodic boundary conditions). I added the code that I thought was
> necessary and while the program "works", I can only achieve about 1
> frame per second. I tried about 8 different models (all STL files) and
> all exhibit this behavior. I can reproduce it every time. I can load
> the model, interact with it at full speed, "copy" an actor and then my
> speed drops to about 1 FPS.
>
> Here is the code that I am using:
> //actors is a vtkActorCollection
> //_numRegions is the number of actors in the scene. Each actor has its
> //   own PolyData it renders.. is this a good idea?
> // _colorTable is a vtkColorTable that I generated earlier. It will be
> one short as it
> //    only has _numRegions of entries BEFORE I increment _numRegions
> //
>
> vtkActor *actor = vtkActor::SafeDownCast( actors->GetItemAsObject 
> (rowIndex) );
> vtkPolyData *copy = vtkPolyData::New();
> copy->DeepCopy(actor->GetMapper()->GetInput());
> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
> _numRegions++;
> mapper->SetInput(copy);
> 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(actor->GetPosition() );
> actors->AddItem(dataActor);
>
> [vtkView renderer]->AddActor(dataActor);
> dataActor->Delete();
> mapper->Delete();
> copy->Delete();
>
> I was hoping there was something like an actor->DeepCopy(); method
> that I could call but
> I did not find anything in the docs.
>
> Is there something glaring that I am missing?
>
> Thanks for any help.
> --
> Mike Jackson
> imikejackson _at_ gee-mail dot com

After using some utilities I think that the problem is with OpenGL  
Display Lists. When the "copy" of a PolyData is visible Display Lists  
are NOT used. When I toggle the actor invisible then Display lists  
are used.
    Would adding an actor to a scene trigger immediate mode rendering  
ON?

Thanks


--------
Mike Jackson
imikejackson <at> gmail <dot> com






More information about the vtkusers mailing list