# vtkDistancePolyDataFilter not working with contours?

**URL:** https://discourse.vtk.org/t/vtkdistancepolydatafilter-not-working-with-contours/5437
**Category:** Support
**Created:** [March 25, 2021, 10:44am UTC](https://discourse.vtk.org/t/vtkdistancepolydatafilter-not-working-with-contours/5437 "2021-03-25T10:44:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ingmar](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/i/cc9497/32.png) [@Ingmar](https://discourse.vtk.org/u/Ingmar)
#### Post date: [March 25, 2021, 10:44am UTC](https://discourse.vtk.org/t/vtkdistancepolydatafilter-not-working-with-contours/5437/1 "2021-03-25T10:44:31Z")

</div>

Dear VTK experts,

I am trying to use a vtkDistancePolyDataFilter out of python (using vtk==8.1.2 pkg). This seems to work fine for triangle meshes.

```
  reader1 = vtk.vtkPolyDataReader()
  reader1.SetFileName('E:/temp/meshEstimated.vtk')
  reader1.Update()
  meshEstimated = reader1.GetOutput()

  reader2 = vtk.vtkPolyDataReader()
  reader2.SetFileName('E:/temp/meshGT.vtk')
  reader2.Update()
  meshGT = reader2.GetOutput()

  # compute distance between both meshes
  distanceFilter = vtk.vtkDistancePolyDataFilter()
  distanceFilter.SignedDistanceOff()
  distanceFilter.SetInputData(0, meshEstimated)
  distanceFilter.SetInputData(1, meshGT)
  distanceFilter.Update()

```

However the same piece of code fails with contours (i.e. points connected by line segments, not triangles) as the filter complains there are supposedly no points / cells to operate on (see also error msg from [VTK/vtkDistancePolyDataFilter.cxx at master · Kitware/VTK · GitHub](https://github.com/Kitware/VTK/blob/master/Filters/General/vtkDistancePolyDataFilter.cxx#L81)).

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/1d96528933273f4b1bf45c1660bed4f4ecf79f06.png)

I am able to get 100+ number of points and cells and also can render the same object - why does the vtkDistancePolyDataFilter not work in this case? How can I debug / fix / work this around? Swapping the order of which the contours as input to the distance filter or inputting two times the same always gives me the same result …

 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/ab82b9d2c2fd32d2c97408dffa073e2442917615.png)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/d/d72731b528483546d15a6fcb99e4761b8829771f.png)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/d/d26c4a4c6d2a312173ec8614c43aa9978f6d87bf.png)

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [March 25, 2021, 1:40pm UTC](https://discourse.vtk.org/t/vtkdistancepolydatafilter-not-working-with-contours/5437/2 "2021-03-25T13:40:17Z")

</div>

That filter only works with triangles, not line segments. It would be great if someone added support for line segments, but I’m not aware of plans to add that support.
