Need help with Isosurface creation

Hello everyone
I’m new to VTK and I’m developing an application that use VTK for displaying cross section, isosurface and so on using C#.
I’ve succeeded getting cross section vertex position, index and data value for generting my mesh.
Now what I want to achieve is getting the vertex position, vertex index and data value for isosurface

The VTK file I’m using is a RectilinearGrid. I’ve check on the documentation and I should be able to either vtkMarchingContourFilter or vtkRectilinearSynchronizedTemplates.

I’ve first check using Paraview and was able to display Contour after creating a CellDataToPointData.
Now I’m trying to get the same result using in code but IF I use vtkMarchingContourFilter, I got a “no data to contour” error and if I use vtkRectilinearSynchronizedTemplates I got a “no scalars for contouring” error.
I’ve also try the code example at the following link without success.

below is what I’ve done so far:(the VTK contains 3 data array called “all”, “region” and “material”)

string FilePath = <path to vtk>;
vtkRectilinearGridReader reader = vtkRectilinearGridReader.New();

//convert our CellData to PointData
vtkCellDataToPointData CellDataToPointData = vtkCellDataToPointData.New();

vtkPointData PointData = CellDataToPointData.GetOutput().GetPointData();
vtkDataArray FirstArray = PointData.GetArray(0);
double[] Range = FirstArray.GetRange();
double Average = (Range[0] + Range[1]) / 2;

vtkRectilinearSynchronizedTemplates Contour = vtkRectilinearSynchronizedTemplates.New();
Contour.SetInputConnection(CellDataToPointData.GetOutputPort());//no scalars for contouring error
Contour.SetValue(0, Average);

vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
mapper.SetScalarRange(Range[0], Range[1]);

TargetActor = vtkActor.New();
TargetActor.SetPosition(0, 0, 0);
TargetActor.GetProperty().SetColor(1, 1, 1);


Could you please tell me what I’m doing wrong?

I really thank you in advance for your help.

Have you tried specifying the scalar array via vtkAlgorithm::SetInputArrayToProcess?

Thank you for your reply
You are right SetInputArrayToProcess did the trick.

adding line below fix the issue.
Contour.SetInputArrayToProcess(0, 0, 0,0 , “name of the data array”);