[vtkusers] vtk actor inheritance

Simon DROUIN sdrouin at bic.mni.mcgill.ca
Tue May 4 10:19:39 EDT 2004


Ludovic Godrant wrote:

> Hi vtk user !!!
> I want to inherite from vtkActor a custom class. I tried to do it with 
> the normal way in C++ it didn't work : I have acces to the vtkActor 
> methodes but when i add my actor in a renderer nothing is displayed 
> ... :-(
> I have read an old vtkuser mail which deal with my problem. Somebody 
> answered that it's easier to include an instance of vtkActor in the 
> object, but i would like to inherite !!!!!

Hi Ludovic,

I had the same problem. The major problem is that when you normally 
create an instance of vtkActor, the New() method calls a factory which 
in fact, creates a vtkOpenGLActor or vtkMesaActor depending on the 
rendering system you are using. If you derive a class directly from 
vtkActor, none of the OpenGL or Mesa code ever gets called, which is why 
nothing is displayed.

The easy (but not very elegant) solution is to derive your actor class 
from vtkOpenGLActor or vtkMesaActor, depending on your rendering system.

There is probably a more elegant solution using factories, but I haven't 
tried it.

-simon




More information about the vtkusers mailing list