Shortcut for generic access to index buffer

Hi Developers

I have made a small raycaster using Embree. For the initial concept, I use

// Access to points. I know this is not a viable solution. In my small test example, my polydata is the output from a vtkSphereSource that is passed throught a vtkTriangleFilter
// For the indices, I iterate over the cells and get the cell points

Ideally, I would like to avoid copying indices (and points) and make things the right way.

My plan is to look into vtkOpenGLIndexBufferObject and use vtkArrayDispatch for copying indices and coordinates into structures supported by Embree. Internally, I will add an observer on the vtkPolyData such that whenever the data are modified, I will update the data used by Embree. Embree uses unsigned int for IBO and positions are float.

Would this be the correct way to proceede?

P.S. I am aware of the progress made on the vtkEmbreePointLocator.

Thanks in advance

Sounds like a good next step plan to me.

Be wary that some amount of data translation is going to be necessary in most cases because VTK’s cells are quite varied.

When you take a close look at vtkOpenGLIndexBufferObject, you will find what it does to prepare them for openGL shaders. When you take a close look at VTK’s RayTracing code you can see a similar thing, except that code is older/simpler because I modelled it after Ken Martin’s vtkGLIBO code as it was a long time ago.

Regardless I like the plan and there are probably good opportunities for zero copy sharing in the newer code base.

1 Like

Perhaps, I should consider start working in branches of the VTK main repository, then it is easier to share ideas. Right now, I have a 150 kLOC repository, where I have used all the CMake macros from VTK and all modules are simply named VTK::vtkSpsName.

I have a working concept accepting vtkDataSet derived from vtkPassInputArrayFilter. The intersections and distances are added to the points and a second output port can output the data as vtkPolyData.

Another perhaps more complete addition is an interpolator that I made to be used with the vtkContourWidget. It uses Dijkstra followed by two consecutive spline filters to produce smooth geodesics when contouring on a surface.

Thanks for pointing my in the direction of how OpenGL buffers are prepared an the variations of VTK’s cells.