How to get the section area?

I want to get the section area of the Lumbar pedicle. I had got a the point cloud the section from numpy arrays, and then use :point_down: code:

def areaSect(points):
        ""
        verts = vtk.vtkPoints()
        polygon = vtk.vtkPolygon()

        polygon_pid = polygon.GetPointIds()
        for i, p in enumerate(points):
            verts.InsertNextPoint(*tuple(p))
            polygon_pid.InsertNextId(i)

        polygon_cell = vtk.vtkCellArray()
        polygon_cell.InsertNextCell(polygon)

        pd = vtk.vtkPolyData()
        pd.SetPoints(verts)
        pd.SetPolys(polygon_cell)

        model = slicer.mrmlScene.AddNewNodeByClass(
            'vtkMRMLModelNode', 'planeMod')
        model.CreateDefaultDisplayNodes()
        model.SetAndObservePolyData(pd)
        tri_converter = vtk.vtkTriangleFilter()
        tri_converter.SetInputDataObject(model.GetMesh())
        tri_converter.Update()
        Mass = vtk.vtkMassProperties() 
        Mass.SetInputData(tri_converter.GetOutput()) 
        Mass.Update() 
        return Mass.GetSurfaceArea()
[in]: areaSect(cP[1])
[out]: 49.16256299367866

However, :point_up_2:t2:this result(49.16256299367866) is too small for the 19*10 section below :point_down:t2:


psarr.csv (7.0 KB)

What’s wrong?

I think the order of points(np.array) seems an import reason, so reorder the np.array… I got a more smooth polygon and more area…but :expressionless: :expressionless::point_down:t2:

How to patch this last seams👆🏻?

我想…其实这似乎就是根据距离最近对点进行排序的问题,对于这样的在同一平面的环形点云, 如何按照最近距离依次排序呢? 比如:以points[0]为起点按照一定方向找到一个最近点(设为points[1]), 然后再以points[1]为起点按照同一方向查找下一个最近点…依次类推…完成排序

I think… Actually, this seems to be a problem of sorting points by the closest distance. For such a circular point cloud on a plane, how to sort by the closest distance? For example: set points[0] as the starting point to find a closest point in a certain direction (set as points[1]), and then set points[1] as the starting point to find the next closest point in the same direction… and so on… complete sorting.

@lassoan@Juicy@jamesobutler @jcfr @pieper@ jmhuie @manjula @szhang