# How can i calculate the surface area of a boundaryEdges?

**URL:** https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915
**Category:** Development
**Created:** [October 11, 2019, 9:23am UTC](https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915 "2019-10-11T09:23:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Matthijs\_Hendriks](https://discourse.vtk.org/user_avatar/discourse.vtk.org/matthijs_hendriks/32/845_2.png) [@Matthijs\_Hendriks](https://discourse.vtk.org/u/Matthijs_Hendriks)
#### Post date: [October 11, 2019, 9:23am UTC](https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915/1 "2019-10-11T09:23:46Z")

</div>

I have the following code. Get a 0 value for the surface area. Is the slice of the boundaryEdges to small? If yess, how do you solve the slice thickness?

```
    boundaryEdges = vtk.vtkFeatureEdges()
    boundaryEdges.SetInputData(polyData)
    boundaryEdges.BoundaryEdgesOn()
    boundaryEdges.FeatureEdgesOff()
    boundaryEdges.NonManifoldEdgesOff()
    boundaryEdges.ManifoldEdgesOff()

    boundaryStrips = vtk.vtkStripper()
    boundaryStrips.SetInputConnection(boundaryEdges.GetOutputPort())
    boundaryStrips.Update()

    boundaryPoly = vtk.vtkPolyData()
    boundaryPoly.SetPoints(boundaryStrips.GetOutput().GetPoints())
    boundaryPoly.SetPolys(boundaryStrips.GetOutput().GetLines())
    
    polygonProperties = vtk.vtkMassProperties()
    polygonProperties.SetInputData(boundaryPoly)
    

    print(polygonProperties.GetSurfaceArea())
    output -> 0 value
```

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [October 11, 2019, 12:49pm UTC](https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915/2 "2019-10-11T12:49:27Z")

</div>

Edges are lines. They have length but do not have any surface area.

---

<div class="post-metadata">

### Author: ![Matthijs\_Hendriks](https://discourse.vtk.org/user_avatar/discourse.vtk.org/matthijs_hendriks/32/845_2.png) [@Matthijs\_Hendriks](https://discourse.vtk.org/u/Matthijs_Hendriks)
#### Post date: [October 11, 2019, 1:52pm UTC](https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915/3 "2019-10-11T13:52:04Z")

</div>

Thanks for your reply.

Maybe, I have to introduce my main problem first 😉

I have a cylindrical polydata and have to know where the polydata is the thickest  
I have a polydata and do multiple ‘plane’ cuts over the x-axis-line of the polydata.  
First, i make a boudaryEdge, i know these are lines, therefore i generate boundarystrips end convert it to a new polydata (see the code) . The surface area will be then calculated with these new polydata…

How can i solve the problem then?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [October 11, 2019, 1:55pm UTC](https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915/4 "2019-10-11T13:55:50Z")

</div>

To measure surface area of a region enclosed by lines then you neeto triangulate it. VTK’s Delaunay triangulation filter should work well for this.

---

<div class="post-metadata">

### Author: ![Matthijs\_Hendriks](https://discourse.vtk.org/user_avatar/discourse.vtk.org/matthijs_hendriks/32/845_2.png) [@Matthijs\_Hendriks](https://discourse.vtk.org/u/Matthijs_Hendriks)
#### Post date: [October 11, 2019, 3:13pm UTC](https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915/5 "2019-10-11T15:13:49Z")

</div>

Thanx! Adding vtkCleanPolyData and vtkDelaunay2D solved the problem!

```
    boundaryEdges = vtk.vtkFeatureEdges()
    boundaryEdges.SetInputData(polyData)
    boundaryEdges.BoundaryEdgesOn()
    boundaryEdges.FeatureEdgesOff()
    boundaryEdges.NonManifoldEdgesOff()
    boundaryEdges.ManifoldEdgesOff()

    boundaryStrips = vtk.vtkStripper()
    boundaryStrips.SetInputConnection(boundaryEdges.GetOutputPort())
    boundaryStrips.Update()

    boundaryPoly = vtk.vtkPolyData()
    boundaryPoly.SetPoints(boundaryStrips.GetOutput().GetPoints())
    boundaryPoly.SetPolys(boundaryStrips.GetOutput().GetLines())
    
    cleanPolyData = vtk.vtkCleanPolyData()
    cleanPolyData.SetInputData(boundaryPoly)
    cleanPolyData.PointMergingOn()
    cleanPolyData.Update()
    
    delaunay = vtk.vtkDelaunay2D()
    delaunay.SetInputData(cleanPolyData.GetOutput())
                     
    polygonProperties = vtk.vtkMassProperties()
    polygonProperties.SetInputConnection(delaunay.GetOutputPort())
    polygonProperties.Update()
    
    print(polygonProperties.GetSurfaceArea())
```

---

<div class="post-metadata">

### Author: ![figueiredo](https://discourse.vtk.org/user_avatar/discourse.vtk.org/figueiredo/32/304_2.png) [@figueiredo](https://discourse.vtk.org/u/figueiredo)
#### Post date: [October 11, 2019, 10:55pm UTC](https://discourse.vtk.org/t/how-can-i-calculate-the-surface-area-of-a-boundaryedges/1915/6 "2019-10-11T22:55:36Z")

</div>

Hi there @Matthijs_Hendriks ,  
I see you already marked as solved, but I’m curious. By reading your problem description:

> [@Matthijs\_Hendriks](#):
>
> I have a cylindrical polydata and have to know where the polydata is the thickest  
> I have a polydata and do multiple ‘plane’ cuts over the x-axis-line of the polydata.

I assume you have a tubular-like object, towards X axis. If that’s the case, wouldn’t be easier to simply get the length of the contours (perimeter), rather than 1. create a strip, 2. clean, 3. triangulate, 4.calculate area?  
And if your object is guaranteed to be along X axis, you could even use the max Y or Z values of the cuts as a metric for the thickest cut. In fact, you could just use `cut->getLength()` -that is the length of the diagonal of the bounding box, of your polydata `cut`.

If I were you I would avoid unnecessarily computations specially inside a iterative algorithm.

Hope it helps!  
Rodrigo F. Figueiredo.
