[vtkusers] Why can we still instantiate vtkRenderWindow though it is abstract class?
Jérôme
jerome.velut at gmail.com
Fri Apr 22 04:11:29 EDT 2011
Hi,
This is exactly why you use ::New( ) to instantiate instead of the
usual 'new' operator. VTK implements an object factory that will
choose for you the right concrete class derived from vtkRenderWindow.
See: vtkRenderWindow *vtkRenderWindow::New() in Rendering/vtkRenderWindow.cxx
and: vtkObject* vtkGraphicsFactory::CreateInstance(const char*
vtkclassname ) in Rendering/vtkGraphicsFactory.cxx
VTK's developpers may give some precisions if I missed something!
HTH
Jerome
2011/4/22 wayne5ning <wayne5ning at gmail.com>:
> Usually, we instantiate our window in the following way:
> vtkSmartPointer<vtkRenderWindow> renderWnd = vtkRenderWindow::New();
>
> But when I look into the declaration of vtkRenderWindow, I find that it's an
> abstract class as it has pure abstract member functions like
> virtual void Start() = 0;
>
> So I'm confused because I've learned that abstract classes cannot be
> instantiated, but here the instantiation succeeds.
>
> Then when I examine the class reference of its subclass
> http://www.vtk.org/doc/nightly/html/classvtkOpenGLRenderWindow.html
> vtkOpenGLRenderWindow , I find this:
>
> vtkOpenGLRenderWindow is a concrete implementation of the abstract class
> vtkRenderWindow. vtkOpenGLRenderer interfaces to the OpenGL graphics
> library. Application programmers should normally use vtkRenderWindow instead
> of the OpenGL specific version.
>
> The suggestion "Application programmers should normally use vtkRenderWindow
> instead of the OpenGL specific version." makes me more confused.
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Why-can-we-still-instantiate-vtkRenderWindow-though-it-is-abstract-class-tp4332513p4332513.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list