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

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``````

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

1 Like

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?

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.

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())``````
1 Like

Hi there @Matthijs_Hendriks ,
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`.