# ITK.js: Mesh to polyData conversion

**URL:** https://discourse.itk.org/t/itk-js-mesh-to-polydata-conversion/3065
**Category:** Uncategorized
**Created:** [May 13, 2020, 1:26pm UTC](https://discourse.itk.org/t/itk-js-mesh-to-polydata-conversion/3065 "2020-05-13T13:26:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![emmanuel\_madarassou](https://discourse.itk.org/user_avatar/discourse.itk.org/emmanuel_madarassou/32/1459_2.png) [@emmanuel\_madarassou](https://discourse.itk.org/u/emmanuel_madarassou)
#### Post date: [May 13, 2020, 1:26pm UTC](https://discourse.itk.org/t/itk-js-mesh-to-polydata-conversion/3065/1 "2020-05-13T13:26:54Z")

</div>

Hi everyone, I’m trying to manipulate itk.js and I’m stuck trying to understand the MeshToPolyData.js file in Pipelines. Does it really allow to do the Mesh/Polydata conversion ? if true, how can I use it ?

Thanks.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 13, 2020, 1:39pm UTC](https://discourse.itk.org/t/itk-js-mesh-to-polydata-conversion/3065/2 "2020-05-13T13:39:06Z")

</div>

It should be similar to any other ITK filter. Here is the basic usage:

> <https://github.com/InsightSoftwareConsortium/ITKMeshToPolyData/blob/3f5bcbf5fb06538521bfdf8cf29f585ae29a4d6e/test/itkMeshToPolyDataFilterTest.cxx#L69-L88>

  
The test is written in C++, but it should be easy to translate to JavaScript.

---

<div class="post-metadata">

### Author: ![emmanuel\_madarassou](https://discourse.itk.org/user_avatar/discourse.itk.org/emmanuel_madarassou/32/1459_2.png) [@emmanuel\_madarassou](https://discourse.itk.org/u/emmanuel_madarassou)
#### Post date: [May 13, 2020, 3:55pm UTC](https://discourse.itk.org/t/itk-js-mesh-to-polydata-conversion/3065/3 "2020-05-13T15:55:17Z")

</div>

Thanks for your answer I’ll try to translate your example to Js.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [May 14, 2020, 2:15am UTC](https://discourse.itk.org/t/itk-js-mesh-to-polydata-conversion/3065/4 "2020-05-14T02:15:40Z")

</div>

This is used to convert an itk.js [itk/Mesh](https://insightsoftwareconsortium.github.io/itk-js/api/Mesh.html) to a vtk.js [vtkPolyData](https://kitware.github.io/vtk-js/docs/structures_PolyData.html) for visualization.

Here is an example usage:

> <https://github.com/Kitware/itk-vtk-viewer/blob/3a56474e4c1bf3140fef5b590a91514a10791de2/src/processFiles.js#L110-L135>

Here is the result:

https://kitware.github.io/itk-vtk-viewer/app/?fileToLoad=https://data.kitware.com/api/v1/file/5c8956608d777f072b959540/download/S02_patella.stl
