# How to get 2D plane area?

**URL:** https://discourse.vtk.org/t/how-to-get-2d-plane-area/6807
**Category:** Support
**Created:** [October 12, 2021, 10:50am UTC](https://discourse.vtk.org/t/how-to-get-2d-plane-area/6807 "2021-10-12T10:50:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dgg820502](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@Dgg820502](https://discourse.vtk.org/u/Dgg820502)
#### Post date: [October 12, 2021, 10:50am UTC](https://discourse.vtk.org/t/how-to-get-2d-plane-area/6807/1 "2021-10-12T10:50:29Z")

</div>

Dear friends,

The following is my python code for generating the 2D area of a contour by randomly cutting a 3D figure.

I have used vtkCutter and vtkImageReslice functions, but no ideal which function should use to get 2D area of cutting plane contour.

Mass.GetSurfaceArea only gerarate 3D surface area.

Please let me know, many thanks. David.

def my\_call\_back(pWidget,ev):

```
if (pWidget):
    print(pWidget.GetClassName(), "Event Id:", ev)
    planeNew = vtk.vtkPlane()
    pWidget.GetPlane(planeNew)
    cliper.SetClipFunction(planeNew)
    planeNew.GetNormal()
    cliper.Update(); 
   
    clipedData = vtk.vtkPolyData()
    clipedData.DeepCopy(cliper.GetOutput())
    
    ####################################
    cutter = vtk.vtkCutter()
    cutter.SetCutFunction(planeNew)
    cutter.SetInputConnection(cliper.GetOutputPort())
    cutter.Update()
    
    reslice = vtk.vtkImageReslice()
    transform = vtk.vtkTransform()
    #transform.Translate(0,0,0)
    #transform.RotateWXYZ(0, 0, 0，0)
    #reslice.SetResliceTransform(transform)
    reslice.SetInputConnection(cutter.GetOutputPort())
    reslice.SetInterpolationModeToLinear()
    ####################################

    Mass = vtk.vtkMassProperties()
    Mass.SetInputData(cliper.GetOutput())
    #Mass.SetInputData(reslice.GetOutput())
    Mass.Update()
    print("Surface = "+str(Mass.GetSurfaceArea()))
    print("Volume = "+str(Mass.GetVolume()))
    ####################################

    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInputData(clipedData)
    coneMapper.ScalarVisibilityOff()
    coneSkinActor.SetMapper(coneMapper)
    print("Plane Normal = "+str(planeNew.GetNormal()))
    print("Plane Origin = "+str(planeNew.GetOrigin()))

```

show(‘D:/nn/s.mhd’)
