Hi all,
Im posting because I have an analysis that performed one way (with vtkImageData
) is very fast and another (vtkStructuredGrid
) is insanely slow.
I have a polydata that I project a vector from (using normals at each point) to create a vtkLineSource
. I then probe values along this line using vtkProbeFilter()
. The problem comes if I give vtkStructuredGrid instead of vtkImageData to the vtkProbeFilter
.
E.g.,
line = vtk.vtkLineSource()
line.SetResolution(line_resolution)
probe_filter = vtk.vtkProbeFilter()
probe_filter.SetSourceData(vtk_image) # This originally was vtkImageData - now I am trying vtkStructuredGrid
probe_filter.SetInputConnection(line.GetOutputPort())
points = mesh.GetPoints()
normals = (local function gets this for me)
for idx in range(points.GetNumberOfPoints()):
# Some code gets a normal, a length, and a starting point to yield a line start/end
start_pt = (local code gets this)
end_pt = (local code gets this)
line.SetPoint1(start_pt)
line.SetPoint2(end_pt)
probe_filter.Update()
If probe_filter.SetSourceData(vtkImageData)
then it iterates over and processes 20k points <1second. If I probe_filter.SetSourceData(vtkStructuredGrid)
and print stuff on each loop to check out timing the vtkStructuredGrid results appear to pop out in chunks. E.g., 5-6 points are processed immediately then there is a 2-3 second gap before another 5-6 pop out.
You might be wondering why I am trying to use vtkStructuredGrid. The reason is that I want to rotate the image data using a transformation matrix (vtkTransformFilter()
). Which you cant do for a vtkImageData
… well you can, but it returns a vtkStructuredGrid
. I’ve already tried (and it works) to apply the inverse transform to the polydata and then do the probing. The problem is that I have 2 sets of images and 1 polydata. The images arent aligned with one another. So, if I rotate the polydata to align with one image it isnt aligned with the other. So, I’m hoping to transform the images to match one another (I already have a transformation matrix from ITK).
It might simply be that this operation is slow. Or I could be doing something silly. Curious if anyone has any thoughts/insights that might help.
Thanks!
Anthony