Slicer constantly closing after distanceFilter.Update()

Hello.

I’m trying to calculate the distance between two meshes using vtkDistancePolyDataFilter() in my extension. Below is a snippet of my code:

distanceFilter = vtk.vtkDistancePolyDataFilter()
distanceFilter.SetInputData(0, mesh_1)
distanceFilter.SetInputData(1, mesh_2)
distanceFilter.SetSignedDistance(True)
distanceFilter.Update()

But my slicer keeps closing after running the code. I suppose that “distanceFilter.Update()” might be responsible for that because it stops closing when I remove the update.

Is this a problem from my end or slicer bug, please?

Note: I’m using 3D slicer 5.4.0

The most likely reason is that there is something wrong with the inputs.

Nevertheless, VTK library should display a meaningful error message explaining what is wrong with the inputs in instead of just crashing. Try with the latest Slicer Preview Release and if ytou can make that crash, too, then describe the exact steps you do to get to this error and we’ll report it to VTK developers.

Thank you so much for your response.

Yes, you are right. One of my inputs was the reason for the crash.

I don’t know why though.

The defective input is a tube created with a vtkTubeFilter through a vtkLineSource.

I used node = getNode(“myTube”) to get the node of the tube, and node_p = node.GetPolyData() to get the polydata of the node which I then gave as input to distanceFilter.SetInputData(0, node_p).

So I’m not sure where the problem is.

Maybe you need to triangulate the input, maybe even compute normals. Tube filter output is often self-intersecting, which may be a problem, too.

Thank you for your help.

I will definitely try your recommendations