# Detect closed polydata line

**URL:** <https://discourse.slicer.org/t/detect-closed-polydata-line/41553>\
**Category:** Development\
**Created:** [February 7, 2025, 1:39pm UTC](https://discourse.slicer.org/t/detect-closed-polydata-line/41553 "2025-02-07T13:39:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)\
**Post date:** [February 7, 2025, 1:39pm UTC](https://discourse.slicer.org/t/detect-closed-polydata-line/41553/1 "2025-02-07T13:39:00Z")

</div>

Hello,

I have a model which has a rim which is detectable with vtkFeatureEdges by using SetFeatureEdges(True) and SetFeatureAngle to a value between 35 and 45.

Decreasing the feature angle incrementally and selecting the largest segment with SurfaceToolbox.extractLargestConnectedComponent leads to a more and more complete recognition of the rim, until the rim is visually closed.

surface:

 ![surface](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/0/8016a0c4b8dec6be8c6fcee0ab42157f1058e452.png)

feature angle 48°:

 ![rim-48-deg](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/3/a31131d25b6a07220de6bf611328b72690af5dfa.png)

feature angle 45°:

 ![rim-45-deg](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/1/e1b4b78db1a368af2c2a414044d79e37cd363123.png)

feature angle 39°:

 ![rim-39-deg](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/b/eb425c15c722b0961c495f677e7e52d5dbc2b667.png)

The resulting polydata consists of cells which are all of type vtkLine with two points.

Q1: What is the most straightforward way of identifying, if the line is closed?

Q2: Is there is a better strategy for extracting the rim?

Thank you

Kambiz

---

<div class="post-metadata">

**Author:** ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)\
**Post date:** [February 8, 2025, 2:28pm UTC](https://discourse.slicer.org/t/detect-closed-polydata-line/41553/2 "2025-02-08T14:28:44Z")

</div>

Forgot to mention: my ultimate goal is to cut the mesh in two parts at the position of the rim. So any hints on how to achieve this are also highly appreciated.
