[vtkusers] Subclassing vtkActor broken?

stoptv stoptv at gmail.com
Tue Apr 18 10:57:18 EDT 2006


I would like to subclass vtkActor, but then the actor becomes invisible..
Curiously enough, interactor seems to be aware of the actor,
but the builtin picker sees nothing there, and neither do I :-)

Can anybody tell me what am I doing wrong?

I've isolated some code..

// test.cpp

#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"

// my vtkActor subclass - as simple as can be

class MyActor : public vtkActor
{
public:
   static MyActor* New() { return new MyActor; }
};

// problems start here

int main()
{
  vtkActor* originalActor = vtkActor::New();

/* -------------------------------------
 * change one for the other and
 * the actor becomes (in)visible ??
 * -----------------------------------*/

//  vtkActor* myActor = vtkActor::New();
  MyActor* myActor = MyActor::New();

//--------------------------------------

  vtkSphereSource *sphere = vtkSphereSource::New();
  vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
  sphereMapper->SetInputConnection(sphere->GetOutputPort());

  myActor->SetMapper(sphereMapper);
  originalActor->SetMapper(sphereMapper);
  originalActor->AddPosition(1,0,0);

  vtkRenderer* renderer = vtkRenderer::New();
  vtkRenderWindow* renderWindow = vtkRenderWindow::New();
  vtkRenderWindowInteractor* interactor = vtkRenderWindowInteractor::New();

  renderWindow->AddRenderer( renderer );
  interactor->SetRenderWindow( renderWindow );

  renderer->AddActor(originalActor);
  renderer->AddActor(myActor);

  renderer->ResetCamera();
  renderWindow->Render();

  interactor->Start();

  return 0;
}

// EOF

Thanks!!
--
stoptv at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060418/b3d66a9d/attachment.htm>


More information about the vtkusers mailing list