[vtkusers] inheritance and object factories [SOLUTION]

Charl P. Botha c.p.botha at its.tudelft.nl
Thu Jul 26 07:36:42 EDT 2001


It seems one possible solution is to contain a "real" vtkActor instance
(instantiated with New() in the constructor of the derived class) and use
that to do the actual rendering.  See the "Device" class variable of
vtkFollower.  This obviously does not strictly adhere to the containment
vs inheritance rules usually used in OOP, but it's a small price to pay for
the run-time specialisation.

On Thu, Jul 26, 2001 at 12:19:45PM +0200, Charl P. Botha wrote:
> Hoewever, what should one do if one wants to override one or two methods in
> a vtkActor, but still retain this functionality?  I.e. if I derive a new
> class from vtkActor and instantiate that, the OpenGL modelview
> transformations in vtkOpenGLActor will never be used, as my new child class
> only has access to the methods in vtkActor.  Alternatively, I could derive a
> new subclass of each of the vtkActor specialisations, but that seems awkward.

-- 
charl p. botha      | computer graphics and cad/cam 
http://cpbotha.net/ | http://www.cg.its.tudelft.nl/




More information about the vtkusers mailing list