Get scalar value at selected coordinate from interpolated polydata

I used PointInterpolater example ( ) code to visualize difference between 3d scanner point cloud data and nominal CAD data.

Is it possible to get scalar value at a picked coordinate on a surface?

Here is a picture of my program. I randomly picked a coordinate(R3). Can I get the scalar value? Should I write my own probe function just like in the vtkPointInterpolator?

Best regards,

1 Like

I did some digging and found a way to get scalar value for .
Here is the code:

vtkNew<vtkPoints> ProbePoints;
ProbePoints->InsertNextPoint(/* Point on Interpolated PolyData */);

vtkNew<vtkPolyData> ProbePointPolyData;

ProbeFilter->SetSourceData(/* Interpolated PolyData*/ );

vtkDataArray* data = ProbeFilter->GetOutput()->GetPointData()->GetScalars();
vtkDoubleArray* doubleData = dynamic_cast<vtkDoubleArray*>(data);

for (int i = 0; i < doubleData->GetNumberOfTuples(); i++)
      double val = doubleData->GetValue(i);

Best regards

I’m new to VTK and I have a similar question to yours,
I have a data array of scalars values (of volume), how to know the corresponding coordinate (x or y or z) of each scalar in my array?
var values = reader.getOutputData().getPointData().getScalars().getData();

Thank you

Hi Lucas

Actually it’s in the getPointData()
Indexes are correspondent.

I just have an array of 11927552 elements, I don’t know how we can differentiate indexes and say that is corresponding to X or Y or Z