# How to get the convexHull of a segment

**URL:** <https://discourse.slicer.org/t/how-to-get-the-convexhull-of-a-segment/31541>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [September 4, 2023, 10:10am UTC](https://discourse.slicer.org/t/how-to-get-the-convexhull-of-a-segment/31541 "2023-09-04T10:10:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matteboo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matteboo/32/66548_2.png) [@Matteboo](https://discourse.slicer.org/u/Matteboo)\
**Post date:** [September 4, 2023, 10:10am UTC](https://discourse.slicer.org/t/how-to-get-the-convexhull-of-a-segment/31541/1 "2023-09-04T10:10:07Z")

</div>

Hello,  
I want to obtain the convex hull of a segment. (I don’t know how to upload an nrrd file but I can give it necessary)  
I saw [this](https://discourse.slicer.org/t/fill-holes-in-3d-model/13508) conversation but I can’t figure out what node I should get.  
I want to use this snippet of code

```auto
modelNode = getNode('mySurface')

convexHull = vtk.vtkDelaunay3D()
convexHull.SetInputData(modelNode.GetPolyData())
outerSurface = vtk.vtkGeometryFilter()
outerSurface.SetInputConnection(convexHull.GetOutputPort())
outerSurface.Update()
modelNode.SetAndObservePolyData(outerSurface.GetOutput())

```

But I don’t know what I should put in ‘mysurface’  
From my understanding I should put the name of an vtkMRMLModelNode so that I can call GetPolyData()

However when I do getNode(‘mysegmentation’) I get a vtkMRMLSegmentationNode

I don’t know how to get the vtkMRMLModelNode could you help me with that ?  
Or if you have another way to get the convec hull that works too

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 4, 2023, 1:49pm UTC](https://discourse.slicer.org/t/how-to-get-the-convexhull-of-a-segment/31541/2 "2023-09-04T13:49:59Z")

</div>

Probably you want one of these methods:

> <https://github.com/Slicer/Slicer/blob/4a668bea6ebd183d9d0b70a510e87ea38164fd33/Modules/Loadable/Segmentations/Logic/vtkSlicerSegmentationsModuleLogic.h#L140-L152>

---

<div class="post-metadata">

**Author:** ![Matteboo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/matteboo/32/66548_2.png) [@Matteboo](https://discourse.slicer.org/u/Matteboo)\
**Post date:** [September 20, 2023, 1:52pm UTC](https://discourse.slicer.org/t/how-to-get-the-convexhull-of-a-segment/31541/3 "2023-09-20T13:52:24Z")

</div>

Thanks you I managed to make it work 🙂
