# How to distinguish exterior and interior contour from vtkCutter?

**URL:** <https://discourse.vtk.org/t/how-to-distinguish-exterior-and-interior-contour-from-vtkcutter/8356>\
**Category:** Development\
**Created:** [April 23, 2022, 12:25am UTC](https://discourse.vtk.org/t/how-to-distinguish-exterior-and-interior-contour-from-vtkcutter/8356 "2022-04-23T00:25:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cameron](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cameron/32/4063_2.png) [@Cameron](https://discourse.vtk.org/u/Cameron)\
**Post date:** [April 23, 2022, 12:25am UTC](https://discourse.vtk.org/t/how-to-distinguish-exterior-and-interior-contour-from-vtkcutter/8356/1 "2022-04-23T00:25:54Z")

</div>

Say I have a tube. I can use `vtkCutter` to get the intersection between the tube and a plane as vtkPolyData. This polydata contains two disjoint polygon.  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/e/ed31cdea48b04885ab9a53ed1c32f66bdcda1402.png)

I can use `vtkConnectivityFilter` to distinguish the points/cells from disjoint polygons. But what is a robust way to tell which one represents the exterior/interior contour?

 ![image](https://discourse.vtk.org/uploads/default/original/2X/4/4ed19e5a961bf45b139a0d6fe4d2e18aa9083143.png)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/1734c4fcea1ccf7569642b5aa564330149a48ce8.png)

Thanks,  
Cam

---

<div class="post-metadata">

**Author:** ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)\
**Post date:** [April 23, 2022, 1:59pm UTC](https://discourse.vtk.org/t/how-to-distinguish-exterior-and-interior-contour-from-vtkcutter/8356/2 "2022-04-23T13:59:41Z")

</div>

I would use the cell normals wrt axis to distinguish them, eg.:

```python
from vedo import *
d1 = Disc(r1=0.1, r2=0.2)
d2 = Disc(r1=0.3, r2=0.4)
tube = merge(d1,d2).extrude(1).flat().computeNormals()
centers = tube.cellCenters()[:,(0,1)]
normals = tube.celldata["Normals"][:,(0,1)]
value = np.sum(centers*normals, axis=1)
tube.cmap('jet', value, on='cells').show(axes=1)

```

![Screenshot from 2022-04-23 15-52-04](https://discourse.vtk.org/uploads/default/original/2X/e/eaa4b1a6524b84cbd39fc2e091bb738f3e2654a4.png)

---

<div class="post-metadata">

**Author:** ![Cameron](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cameron/32/4063_2.png) [@Cameron](https://discourse.vtk.org/u/Cameron)\
**Post date:** [April 25, 2022, 8:20pm UTC](https://discourse.vtk.org/t/how-to-distinguish-exterior-and-interior-contour-from-vtkcutter/8356/3 "2022-04-25T20:20:55Z")

</div>

> [@marcomusy](#):
>
> `value = np.sum(centers*normals, axis=1)`

what does this line do? Can you elobrate? Thanks.

---

<div class="post-metadata">

**Author:** ![marcomusy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcomusy/32/95_2.png) [@marcomusy](https://discourse.vtk.org/u/marcomusy)\
**Post date:** [April 26, 2022, 8:26pm UTC](https://discourse.vtk.org/t/how-to-distinguish-exterior-and-interior-contour-from-vtkcutter/8356/4 "2022-04-26T20:26:26Z")

</div>

the scalar product of the vector position to the normal (actually a square is missing but it’s just to give the idea).
