[vtk-developers] Factory issue for new VBO and VertexArray painters

Marcus D. Hanwell marcus.hanwell at kitware.com
Tue Mar 18 08:06:08 EDT 2014


Hi,

On Thu, Mar 13, 2014 at 10:31 AM, Xabi Riobe <xabivtk at gmail.com> wrote:
> Hi,
> I have a set of painter classes using VBO (adapted from VTKEdge) and
> VertexArrays that i'm willing to share via gerrit, but there is an issue i
> would like to resolve before, in order to add the test class.
>
> Currently i use them with vtk 5.10.1, and i have a rendering factory to
> instantiate them instead of vtkPolygonsPainter, vtkLinesPainter and
> vtkTStripsPainter.
>
> but with vtk 6.1, the factory mechanism has changed and i can not manage to
> make it work properly. So i first try to localy test my classes with the new
> version by incorporating them directly in vtkRenderingOpenGLObjectFactory,
> adding these lines in Rendering\OpenGL\CMakeLists.txt :
>
> list(APPEND vtk_module_overrides "vtkPolygonsPainter")
> set(vtk_module_vtkPolygonsPainter_override
> "vtkOpenGLVertexArrayPolygonsPainter")
>
> Runing my test in debug, i can see that the class is added in the factory,
> but when the vtkChooserPainter creates the vtkPolygonsPainter, my own class
> is not instantiated, nor it is if i directly call vtkPolygonsPainter::New()
> in the test.
>
> Is there something else i am missing to use my class in a factory with vtk
> 6.1?
>
Part of the VTK 6 changes involved moving from all VTK classes
checking for overrides to only those designed to do so. If you look
the vtkPolygonsPainter uses vtkStandardNewMacro in its implementation,
if you want to override it using the factory mechanism then it should
use vtkObjectFactoryNewMacro which will check the object factory
before falling back to the actual class that was instantiated.

There is also a compile time switch, VTK_ALL_NEW_OBJECT_FACTORY, which
defaults to off and will force all classes to use the object factory
(as was the default before VTK 6.

Hope that makes things clearer.

Marcus



More information about the vtk-developers mailing list