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

Thanks for your reply.

Maybe, I have to introduce my main problem first :wink:

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 ,
I see you already marked as solved, but I’m curious. By reading your problem description:

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.