How to use vtk with a scenegraph

Hello!!!

I have a need to integrate vtk with a scenegraph. My application is display of hierarchical (think CAD Assembly/Part) models where I have lots of ‘Parts’ that contain 1D, 2D and 3D meshes that I currently display and operate on using vtkUnstructuredGrid and vtkPolyData.

I want to extend by code to support the ability to show/hide individual Parts/Assemblies in the tree, change render style of individual Parts/Assemblies (shaded, shaded with edges, wireframe, hidden line, transparency etc.). And eventually to transform individual Parts/Assemblies.

A scenegraph seems like a good fit for these requirements but I can’t find any examples and hardly even any discussion about using vtk with a scenegraph. I do see that there is a scenegraph module and a vtkNode object - but absolutely no examples or docs that I can make sense of.

What do vtk users do when they need to integrate with a scenegraph?

I mostly work in Python but I can move to C, C# or C++ if I need to.

Thanks in advance for any help!!!

Doug

I think that the combination of vtkMultiblock data, to hold all of your vtkPolyData and vtkUnstructuredGrid, and vtkCompositePolyDataMapper2 with an attached vtkCompositeDataSetDisplayAttributes will get you pretty close to what you are trying to achieve with a minimum amount of effort.

Barring that I think you have to code up the associations (a map from vtkDataSet to vtkProperty/vtkMapper/vtkActor) yourself.

The purpose of the SceneGraph module in VTK is to add a degree of separation and run time separability between VTK’s rendering state (RenderingCore mostly) and low level rendering API (RenderingOpenGL2 mostly). RenderingSceneGraph is currently only used by the very optional ray tracing backend module (RenderingRayTracing in master). This drives OSPRay and more recently OptiX. For examples on how it works in practice, see the associated regression tests. RSG could potentially be extended to do what you are trying to achieve but I think that either of the two above development paths will have a quicker turn around time for you.

I do not have any experience with interfacing VTK to an external, more fully featured, scene graph libraries. Perhaps someone else on the list does and will chime in.

Dave,

Thanks for the response. I did experiment with vtkMultiblock a couple of years ago but recall the performance was pretty bad compared to a single vtkUnstructuredGrid - however at the time I was much less familiar with vtk than I am now, so I’ll revisit.

I’ve also been reviewing the vtkAssembly and vtkPropAssembly classes and it seems like these too could support the behavior I need. Any thoughts on using these classes v’s vtkMultiblock/vtkCompositePolyDataMapper?

Doug

If you only need a hierarchy for transforming actors in groups (e.g., moving rigid bodies connected to each other using joints) then you don’t need to use a scene graph, you can just define a hierarchy of transforms and apply each transform to the corresponding actor as user transform.

Transform hierarchy can be as complex as you need (with arbitrarily level of concatenation, nesting, and inversion), and works with even non-linear transforms. See vtkGeneralTransform for details.