CellData removed after FlyingEdges3d

I am relatively new user of VTK.

I’m rendering an isosurface with the following procedure:
1 Create vtkUnisgnedCharArray with the scalars on a 3D grid.
2 Create an vtkImageData and set the PointData to the scalars array
3 Create a vtkFlyingEdges3D with the ImageData as input data
4 Create a vtkPolyDataMapper taking the OutputPort of FlyingEdges3D
5 Create vtkActor and do the rendering

This procedure works well and I can view the isosurface. The problem arises when I try to color the PolyData. I assumed that the correct method would be to add the color data to the CellData field of vtkImageData, then use SetScalarModeToUseCellData in the PolyDataMapper. The OutputData of FlyingEdges3D, however, does not contain any Arrays in CellData.

Why does FlyingEdges3D not preserve the CellData from ImageData?
Is there a better method of providing the colors to the PolyDataMapper that I am overlooking?


Why does FlyingEdges3D not preserve the CellData from ImageData?

I’ll give you the long answer :slight_smile:

When I wrote FE, my goal was to create the fastest possible continuous function, single-pass isocontouring algorithm, addressing the most common workflows, and to learn more about designing threaded algorithms.

So one of the design requirements was to avoid adding a lot of bells and whistles, which while nice to have, inexorably slow things down. One of the frustrations many of us developers wrestle with is: if we add lots of features, people complain VTK is too slow, if we build a sports car, then people complain that the seats are too hard (i.e., not enough features).

Adding cell data would not be too hard, and probably not impact performance too much (depending on the amount of cell data), and maybe it’s the right thing to do. I leave it up to the community and fellow developers to tell us what to do. I just don’t want to hear any complaints if such a change were to be made :slight_smile:

Thanks for the reply!

At risk of exposing how new I really am to vtk programming…
As a temporary solution, Im trying to build a new PolyData from the output of FlyingEdges3D so that I can add the colors to CellData myself.

I am struggling to obtain the FlyingEdges polys. Is it possible to obtain them, or is the OutputPort necessarily connected to a PolyDataMapper through some pipline? Is there a Filter I could use to merge the color CellData into the pipe?

If, after setting the input data or input connection you perform:

filter->Update(); vtkPolyData* output = filter->GetOutput();
you’ll have a vtkPolyData instance.

However, to save the hassle, why not just use vtkContourFilter or vtkSynchronizedTempates3D? (I believe internally vtkContourFilter delegates to synchronized templates.) If memory serves me correctly these filters do process the cell data. ST is pretty fast, and unless you are in a tight interactive loop with huge data you will probably be just fine. I’d suggest getting something working from point A → point B, and then figure out what if anything needs to be done to improve your application.

Great, thank you so much.

I was missing the call to Update, and can now display the colors!
Your information clears up the purpose of this Algorithm Update routine for me.

Ill experiment with the filters now.


After spending a bit more time on this…

I believe that, in order to color the figure with any scalar/vector data corresponding to the original data grid, FlyingEdges3D must maintain the CellData.

Otherwise, there is no way of knowing the mapping of vertices in the output PolyData to the input data indices.

Any thoughts?

Using synchronized templates is the way to go in the short term :slight_smile:

If you really want to do this, because FE generates triangles in the voxel cells, a probe filter using the center of each triangle could determine the voxel cell that generated the triangle. Then you could grab the voxel cell data etc. Probing is slow though.

Longer term, we should probably modify FE to process cell data.

Thanks for the excellent info and quick responses.