vtkContourGrid example

I am looking for a vtkContourGrid example since I couldn’t find one with the online vtkContourGrid class documentation.

I have scalar cell data assigned to my vtkUnstructuredGrid object. Based on the vtkContourFilter examples, I think that output from the vtkUnstructuredGrid object can be read into the vtkContourGrid.

If this works, do I then need to process normals for the contour surface?

vtkContourFilter calls vtkContourGrid internally when unstructured grid are processed, and i am pretty sure there are examples out there for vtkContourFilter .

Maybe I misunderstood, but contouring operations require point data (you refer to cell data).

Yes. I only have cell data available.

you can consider using vtkCellDataToPointData so that you have the array of cell data that you want interpolated as an array of point data and then use it as input for the contour filter.

I thought that there might be a method to convert cell data to point. I know that I wouldn’t have found that routine without asking. I’ll look into it.

To wrap this up, I was able to get this to work. This is all that I needed in this particular case:

            vtkNew<vtkCellDataToPointData> c2p;

            vtkNew<vtkContourFilter> contour;
            contour->SetInputConnection(0, c2p->GetOutputPort(0));

Of course there is other code, but this is the essentials to the question that I asked.

I’ve a follow on to this I’ll put in another post.

Using what I last posted to this topic, I’m not convinced that the cell data is being converted to point data as I thought it would. When I co-plot the cell data with a contour from the converted data, the two don’t align. That is, the contour doesn’t coincide with the cell data.

Is there a way that I can dump some of the data to see what is going on?

The vtkCellDataToPointData is a highly tested filter and it’s doing what it is supposed to do. But you should know that point values are set by averaging the neighboring cells, no weighted averaging the neighboring cells, that’s why you probably don’t get the results you expect.