Get scalar value at selected coordinate from interpolated polydata

Hi,
I used PointInterpolater example ( https://kitware.github.io/vtk-examples/site/Cxx/Meshes/PointInterpolator ) 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?

Update:
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,
Emre

1 Like

Hi,
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;
ProbePointPolyData->SetPoints(ProbePoints);

vtkNew<vtkProbeFilter>;
ProbeFilter->SetSourceData(/* Interpolated PolyData*/ );
ProbeFilter->SetInputData(ProbePointPolyData);
ProbeFilter->Update();

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

Hi
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

image