# Min distance between a curveNode and another node?

**URL:** <https://discourse.slicer.org/t/min-distance-between-a-curvenode-and-another-node/28566>\
**Category:** Development\
**Created:** [March 24, 2023, 8:01pm UTC](https://discourse.slicer.org/t/min-distance-between-a-curvenode-and-another-node/28566 "2023-03-24T20:01:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pixilla/32/52535_2.png) [@pixilla](https://discourse.slicer.org/u/pixilla)\
**Post date:** [March 24, 2023, 8:01pm UTC](https://discourse.slicer.org/t/min-distance-between-a-curvenode-and-another-node/28566/1 "2023-03-24T20:01:16Z")

</div>

Hello,  
I wanted to find the minimum distance between the curve (defined by a list of point in a vtkmrmlCurveNode) and other nodes which are vtkPolyData by using (I think) a vtkPolyDataDistanceFIlter. I started by created this curve node with the method where pointPositions is my list of points:  
curveNode = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLMarkupsCurveNode”)  
slicer.util.updateMarkupsControlPointsFromArray(curveNode, pointPositions)

After that I’ve tried to use the vtkPolyDataDistanceFIlter:

```
    distanceFilter = vtk.vtkDistancePolyDataFilter()
    curveA = curve.GetCurveWorld()
    mapper = vtk.vtkDataSetMapper()
    mapper.SetInputData(curveA)
    distanceFilter.SetInputConnection(0,obst.GetPolyDataConnection())
    distanceFilter.SetInputConnection(1,mapper.GetOutputPort())
    distanceFilter.Update()
    d = distanceFilter.GetOutput().GetPointData().GetScalars().GetRange()[0] 

```

My problem is that there is an error for the SetInputConnection of the curve part If I don’t use a mapper, and with the mapper I get a ‘nontype’ for the last line above. I’ve tried by using curve and it is not working.  
Is there a method to resolve the problem please?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 26, 2023, 4:25am UTC](https://discourse.slicer.org/t/min-distance-between-a-curvenode-and-another-node/28566/2 "2023-03-26T04:25:00Z")

</div>

`curve.GetCurveWorld()` returns a `vtkPolyData` object that you can set as input of a VTK filter using `SetInputData()` method.

Since you don’t need to implement any rendering, you can remove the lines that refer to the mapper.
