# Feature Edges not detecting BoundaryEdges

**URL:** https://discourse.vtk.org/t/feature-edges-not-detecting-boundaryedges/11905
**Category:** Support
**Tags:** python
**Created:** [July 8, 2023, 1:48pm UTC](https://discourse.vtk.org/t/feature-edges-not-detecting-boundaryedges/11905 "2023-07-08T13:48:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![madmoonman](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@madmoonman](https://discourse.vtk.org/u/madmoonman)
#### Post date: [July 8, 2023, 1:48pm UTC](https://discourse.vtk.org/t/feature-edges-not-detecting-boundaryedges/11905/1 "2023-07-08T13:48:38Z")

</div>

Hello, I am having trouble detecting BoundaryEdges of a triangulated surface mesh.  
As I am not yet allowed to upload files, I share here the code and the stl file I am using for this test. The stl is a cube made out of 6\*2 triangles. I deleted one of these triangles to create a hole the algorithm should detect. However, when I run the script, the featureEdges object does not contain any cells, which looks like the hole is not detected properly. Am I doing something wrong?  
I also loaded the file in Paraview and used the FeatureEdges filter there and it detects the hole without any problem.

// the code

```auto
import os
from vtkmodules.vtkCommonColor import vtkNamedColors
from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkPolyDataMapper,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
    vtkRenderer
)
from vtk import vtkSTLReader
from vtkmodules.vtkFiltersCore import vtkFeatureEdges

def main(argv):
    colors = vtkNamedColors()

    stlName = 'box_open.stl'
    workDir = os.getcwd()
    fileName = os.path.join(workDir, stlName)

    # create an instance of vtkSTLReader to process stl file
    reader = vtkSTLReader()
    # pass filename to the reader
    reader.SetFileName(fileName)

    polydata = reader.GetOutput()

    featureEdges = vtkFeatureEdges()
    featureEdges.FeatureEdgesOff()
    featureEdges.BoundaryEdgesOn()
    featureEdges.NonManifoldEdgesOn()
    featureEdges.SetInputData(polydata)
    featureEdges.Update()

    print(featureEdges.GetOutput().GetNumberOfCells())

    mapper = vtkPolyDataMapper()
    mapper.SetInputData(featureEdges.GetOutput())

    actor = vtkActor()
    actor.GetProperty().SetColor(colors.GetColor3d('Black'))
    #actor.GetProperty().SetOpacity(1)
    actor.SetMapper(mapper)

    renderer = vtkRenderer()
    ren_win = vtkRenderWindow()
    ren_win.AddRenderer(renderer)
    iren = vtkRenderWindowInteractor()
    iren.SetRenderWindow(ren_win)

    renderer.AddActor(actor)
    renderer.SetBackground(colors.GetColor3d('white'))

    ren_win.Render()
    iren.Initialize()
    iren.Start()

if __name__ == ' __main__':
    import sys

    main(sys.argv)

```

// the stl, save this box\_open.stl and put it next to the python file.

```auto
solid cube
  facet normal -1.000000 0.000000 0.000000
    outer loop
      vertex 0.000000 0.000000 0.000000
      vertex 0.000000 0.000000 10.000000
      vertex 0.000000 10.000000 10.000000
    endloop
  endfacet
  facet normal 1.000000 0.000000 0.000000
    outer loop
      vertex 10.000000 0.000000 10.000000
      vertex 10.000000 0.000000 0.000000
      vertex 10.000000 10.000000 0.000000
    endloop
  endfacet
  facet normal 1.000000 0.000000 0.000000
    outer loop
      vertex 10.000000 10.000000 10.000000
      vertex 10.000000 0.000000 10.000000
      vertex 10.000000 10.000000 0.000000
    endloop
  endfacet
  facet normal 0.000000 -1.000000 0.000000
    outer loop
      vertex 0.000000 0.000000 0.000000
      vertex 10.000000 0.000000 0.000000
      vertex 10.000000 0.000000 10.000000
    endloop
  endfacet
  facet normal -0.000000 -1.000000 0.000000
    outer loop
      vertex 10.000000 0.000000 10.000000
      vertex 0.000000 0.000000 10.000000
      vertex 0.000000 0.000000 0.000000
    endloop
  endfacet
  facet normal 0.000000 1.000000 0.000000
    outer loop
      vertex 10.000000 10.000000 0.000000
      vertex 0.000000 10.000000 0.000000
      vertex 0.000000 10.000000 10.000000
    endloop
  endfacet
  facet normal 0.000000 1.000000 0.000000
    outer loop
      vertex 10.000000 10.000000 10.000000
      vertex 10.000000 10.000000 0.000000
      vertex 0.000000 10.000000 10.000000
    endloop
  endfacet
  facet normal 0.000000 0.000000 -1.000000
    outer loop
      vertex 0.000000 0.000000 0.000000
      vertex 0.000000 10.000000 0.000000
      vertex 10.000000 10.000000 0.000000
    endloop
  endfacet
  facet normal 0.000000 -0.000000 -1.000000
    outer loop
      vertex 10.000000 10.000000 0.000000
      vertex 10.000000 0.000000 0.000000
      vertex 0.000000 0.000000 0.000000
    endloop
  endfacet
  facet normal 0.000000 0.000000 1.000000
    outer loop
      vertex 0.000000 10.000000 10.000000
      vertex 0.000000 0.000000 10.000000
      vertex 10.000000 0.000000 10.000000
    endloop
  endfacet
  facet normal 0.000000 0.000000 1.000000
    outer loop
      vertex 10.000000 10.000000 10.000000
      vertex 0.000000 10.000000 10.000000
      vertex 10.000000 0.000000 10.000000
    endloop
  endfacet
endsolid

```

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [July 9, 2023, 12:31pm UTC](https://discourse.vtk.org/t/feature-edges-not-detecting-boundaryedges/11905/2 "2023-07-09T12:31:28Z")

</div>

You need to update the reader: reader.Update(). Otherwise polydata = reader.GetOutput() returns an empty output.

Because you are using the pattern filter1.SetInputData(polyData) rather than filter1.SetInputConnection(filter2.GetOutputPort()), you are responsible for making the pipeline updates happen.

---

<div class="post-metadata">

### Author: ![madmoonman](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/ee7513/32.png) [@madmoonman](https://discourse.vtk.org/u/madmoonman)
#### Post date: [July 9, 2023, 1:46pm UTC](https://discourse.vtk.org/t/feature-edges-not-detecting-boundaryedges/11905/3 "2023-07-09T13:46:33Z")

</div>

Thank you, it works.  
This tells me I need to look deeper in the concepts of SetInputData and SetInputConnection. Good pointer!  
Thanks again.
