[vtk-developers] Object/Graphics Factories

Sason Ohanian Saki sason at kth.se
Sun May 6 07:47:27 EDT 2012


Hi! 
I have a question about object factories in VTK. I basically want to change what graphics objects are created in vtkGraphicsFactory. From what I can tell, in the createInstance method of GraphicsFactory, the rendering implementations are chosen depending on what macros are defined. An then you simply compare strings and choose an implementation.

Lets say I want to create a new implementation of vtkRenderWindow, vtkGLES2RenderWindow and vtkIOSGLES2RenderWindow that subclass in that order. Do I have to add new macros and create those object in the Graphics Factory, or do I make another GraphicsFactory or something? The question is what is the "preferred" way of doing it? From what I understand so far I would prefer to make a new factory that GraphicsFactory delegates to, given that a macro, say "VTK_USE_GLES2" or "VTK_USE_IOS" is defined.

Also, when it comes to vtkRenderWindow the factory calls vtkXOpenGLRenderWindow::New() where the X i presume stands for the specific platform, e.g. vtkCocaOpenGLRenderWindow. How does this work, how does it go from vtkXOpenGLRenderWindow::New() to vtkCocoaOpenGLRenderWindow::New()?

I come from a java background so I'm used to injecting stuff with component servers, so this seems a bit unflexible and hardcoded to me, but I might be missing something and/or don't have enough c++ skills. Any thoughts?

Thanks!

/Sason


More information about the vtk-developers mailing list