To add insult to injury - the “demo code” I wrote works … I guess that means that there is something wrong with reading the data in from the volume?
EDIT: If I changed volume to be closer to what I’m working with.
#!/usr/bin/env python3
import numpy as np
from vtk.util.numpy_support import vtk_to_numpy, numpy_to_vtk
from vtkmodules.vtkCommonCore import vtkPoints
from vtkmodules.vtkCommonDataModel import vtkStructuredGrid
from vtkmodules.vtkFiltersCore import vtkProbeFilter
from vtkmodules.vtkFiltersSources import vtkLineSource
X, Y, Z = np.meshgrid(
np.linspace( 0.120, 0.225, 51),
np.linspace(-0.006, 0.027, 21),
np.linspace(-0.012, 0.036, 21))
R = np.hypot(X, np.hypot(Y, Z))
W = np.sin(R) / R
W = numpy_to_vtk(W.ravel())
W.SetName("W")
pts = vtkPoints()
for x, y, z in zip(X.ravel(), Y.ravel(), Z.ravel()):
pts.InsertNextPoint(x, y, z)
sg = vtkStructuredGrid()
sg.SetPoints(pts)
sg.SetDimensions(51, 21, 21)
sg.GetPointData().AddArray(W)
sampler = vtkLineSource()
sampler.SetResolution(5)
sampler.SetPoint1(0.120, -0.006, -0.012)
sampler.SetPoint2(0.225, 0.027, 0.036)
probe = vtkProbeFilter()
probe.SetInputConnection(sampler.GetOutputPort())
probe.SetSourceData(sg)
probe.Update()
print(f"valid points: {vtk_to_numpy(probe.GetValidPoints())}")
print(f"probed values: {vtk_to_numpy(probe.GetOutput().GetPointData().GetArray('W'))}")