[vtkusers] what happens to vtkTextActor after adding to vtkRenderer?

Reicht, Ignaz i.reicht at Dkfz-Heidelberg.de
Wed Sep 7 17:35:02 EDT 2011


Dear List,

I am trying to access a vtkTextActor in a vtkRenderer, but the renderer recognizes no actor at all  when calling GetActors(). someone observed same behavior?

thank you!
iggy

here the code
#include "vtkActorCollection.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTextActor.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"


int main(int argc, char* agrv[])
{
// Create a renderer
vtkRenderer* ren = vtkRenderer::New();
ren->SetBackground(0.0,0.0,0.0);


// Create a render window
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->AddRenderer( ren );
renWin->SetSize( 800, 600);



// Create an interactor
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
renWin->SetInteractor( iren );



// Create a TextActor
vtkTextActor* text = vtkTextActor::New();
text->SetInput("Aloha");
text->SetDisplayPosition( 50, 50 );
ren->AddActor2D(text);

  vtkActorCollection* actCollection = ren->GetActors();
  std::cout << actCollection->GetNumberOfItems();

  iren->Initialize();
iren->Start();
}



More information about the vtkusers mailing list