# 2D contours from mesh / plane intersection

**URL:** <https://discourse.vtk.org/t/2d-contours-from-mesh-plane-intersection/6742>\
**Category:** Web\
**Created:** [October 1, 2021, 5:31am UTC](https://discourse.vtk.org/t/2d-contours-from-mesh-plane-intersection/6742 "2021-10-01T05:31:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_Rannou](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nicolas_rannou/32/1007_2.png) [@Nicolas\_Rannou](https://discourse.vtk.org/u/Nicolas_Rannou)\
**Post date:** [October 1, 2021, 5:31am UTC](https://discourse.vtk.org/t/2d-contours-from-mesh-plane-intersection/6742/1 "2021-10-01T05:31:41Z")

</div>

Hi,

I’m trying to evaluate if **vtk.js** is right for my next project and a feature that I couldn’t find is the ability to generate 2D contours from a mesh + plane intersection. And the contours shall look nice and the solution should scale to 50+ contours displayed at 60FPS.

Is it supported? I’m not sure I’ve seen that in Slicer3D at all.

I’ve been thinking about many ways this problem could be approached but nothing seems to provide fast, scalable, and beautiful solutions. Any clue on how that could be approach would be greatly appreciated.

Here is a snapshot of what I try to achieve, keeping in mind that the contours are the intersections from meshes + plane as opposed to a label map.

Thanks!  
Nicolas

![Screenshot 2021-09-30 at 15.36.04](https://discourse.vtk.org/uploads/default/original/2X/5/5e35159388bdc52f0de6d2199729e8a5926c6fec.png)

[![](https://discourse.vtk.org/uploads/default/original/2X/1/1bd37c64511b793ff0f8dc9bd0520c55c6e11d7c.jpeg "exocad Video Tutorial: exoplan") ](https://www.youtube.com/watch?v=zjoKUg2yv7Q)

---

<div class="post-metadata">

**Author:** ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)\
**Post date:** [October 1, 2021, 8:14am UTC](https://discourse.vtk.org/t/2d-contours-from-mesh-plane-intersection/6742/2 "2021-10-01T08:14:16Z")

</div>

Looks like what you need is a vtkCutter (see [example](https://kitware.github.io/vtk-js/examples/Cutter.html)).  
It is currently CPU based but it seems to be fast regarding the complexity of your meshes.  
The image reslicing can be done on the GPU (see [example](https://kitware.github.io/vtk-js/examples/InteractorStyleMPRSlice.html))

Hth,  
Julien.

---

<div class="post-metadata">

**Author:** ![Nicolas\_Rannou](https://discourse.vtk.org/user_avatar/discourse.vtk.org/nicolas_rannou/32/1007_2.png) [@Nicolas\_Rannou](https://discourse.vtk.org/u/Nicolas_Rannou)\
**Post date:** [October 1, 2021, 8:15am UTC](https://discourse.vtk.org/t/2d-contours-from-mesh-plane-intersection/6742/3 "2021-10-01T08:15:29Z")

</div>

Thanks I’ll give it a shot and keep you in the loop!

Do you think those will perform well on multiple fairly complex shapes?

---

<div class="post-metadata">

**Author:** ![Ingmar](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/i/cc9497/32.png) [@Ingmar](https://discourse.vtk.org/u/Ingmar)\
**Post date:** [May 13, 2022, 12:40pm UTC](https://discourse.vtk.org/t/2d-contours-from-mesh-plane-intersection/6742/4 "2022-05-13T12:40:16Z")

</div>

@Nicolas_Rannou did you manage to visualize the contour intersection? I tried the same in python, but the intersection seems infinitesimally thin, and I don’t know how to inflate / dilate to make it actually visible along the normal … ☹

> [@how to get a "thick" poly line from vtkPlaneCutter & vtkPolyData?](https://discourse.vtk.org/t/how-to-get-a-thick-poly-line-from-vtkplanecutter-vtkpolydata/8480):
>
> I am trying to cut a mesh with a plane and render the contour on top of an image (resliced along using the same plane), much like the image below: [image] The examples at [https://gitlab.kitware.com/vtk/vtk/-/blob/v9.1.0/Filters/Core/Testing/Python/TestPolyDataPlaneCutter.py](https://gitlab.kitware.com/vtk/vtk/-/blob/v9.1.0/Filters/Core/Testing/Python/TestPolyDataPlaneCutter.py) almost do the slicing part that I need But when viewing the contour from the direction of the normal the contour / polyline is invisible (see screenshot below left side) as opposed to viewing it from the side (right side o…

---

<div class="post-metadata">

**Author:** ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)\
**Post date:** [May 16, 2022, 4:28pm UTC](https://discourse.vtk.org/t/2d-contours-from-mesh-plane-intersection/6742/5 "2022-05-16T16:28:15Z")

</div>

Please do not mix VTK C++/Python and VTK.js

you can inflate using:

- line thickness
- a tube filter

Regarding the “visible along the normal”, it is a matter of lighting/shading you need to play with.
