# Porting C++ app to VTK.js

**URL:** https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303
**Category:** Web
**Created:** [December 17, 2019, 4:40pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303 "2019-12-17T16:40:48Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![LarryMartell59](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@LarryMartell59](https://discourse.vtk.org/u/LarryMartell59)
#### Post date: [December 17, 2019, 4:40pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/1 "2019-12-17T16:40:49Z")

</div>

We have an app written in C++ using Qt. The app used ITK to produce nrrd files and then uses VTK to render dicomm files with the nrrd files on top of them. We want to port this to a web app. Anyone have any experience doing this? Any pointers or references to docs? We want to try and leverage as much of our existing code as possible. Thanks!

---

<div class="post-metadata">

### Author: ![pieper](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pieper/32/17_2.png) [@pieper](https://discourse.vtk.org/u/pieper)
#### Post date: [December 17, 2019, 4:43pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/2 "2019-12-17T16:43:37Z")

</div>

You may want to have a look at these tutorials for inspiration:

> [@New free video tutorials! VTK.js and OHIF web apps](https://discourse.vtk.org/t/new-free-video-tutorials-vtk-js-and-ohif-web-apps/2164):
>
> [image] What: The Open Health Imaging Foundation (OHIF) and Kitware have teamed up to help you create amazing 3D zero-footprint medical imaging web applications using state-of-the-art open- source software. Did we mention it’s totally free and commercially friendly?!? Also, if you ever wanted to try the Visualization Toolkit (VTK) for the web but never knew where to start, now you can watch a few tutorial videos on VTK.js! Learn how to use VTK.js, and harness the power of 3D visualization on th…

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [December 17, 2019, 5:57pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/3 "2019-12-17T17:57:11Z")

</div>

Beware that we don’t have a 1 to 1 capability mapping between VTK/C++ and VTK/js but with the itk.js infrastructure we have some path to convert C++ code to web assembly. (We’ve mostly used it for the readers)

Now that’s said, we have a pretty neat OpenSource application ([ParaView Glance](https://kitware.github.io/paraview-glance/)) leveraging itk.js + vtk.js which provides some good features for medical datasets that is fully client based. This can be a good project for reference.

Also, depending of the amount of data and processing that you want to handle, you might need a server with ITK and/or VTK. And a ParaViewWeb type of infrastructure could be meaningful.

In general, if you need help, [Kitware](https://www.kitware.com/contact-us/) can provide support and/or development. On top of maintaining those OpenSource frameworks, we are helping customers to build or migrate their application using our Web solutions.

---

<div class="post-metadata">

### Author: ![claretb](https://discourse.vtk.org/user_avatar/discourse.vtk.org/claretb/32/1466_2.png) [@claretb](https://discourse.vtk.org/u/claretb)
#### Post date: [February 19, 2020, 3:22pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/4 "2020-02-19T15:22:32Z")

</div>

Are there any new developments in this regard? @Sebastien_Jourdain I didn’t create a new topic to avoid excess.  
Have you tried compiling your project with Emscripten or etc. ? @LarryMartell59

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [February 19, 2020, 3:49pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/5 "2020-02-19T15:49:15Z")

</div>

Actually we are waiting for a contribution from [https://about.dicehub.com/](https://about.dicehub.com/) who managed to get the VTK/C++ rendering working in WebAssembly. They’ve been swamped but we are working together to provide an open-source solution for the community.

---

<div class="post-metadata">

### Author: ![claretb](https://discourse.vtk.org/user_avatar/discourse.vtk.org/claretb/32/1466_2.png) [@claretb](https://discourse.vtk.org/u/claretb)
#### Post date: [February 20, 2020, 7:03am UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/6 "2020-02-20T07:03:13Z")

</div>

Thanks for reply. So how can I compile VTK(without rendering) with Emscripten toolchain? I found some sources. But they are using Docker. I want compile on Windows like compile another library.

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [February 20, 2020, 9:38am UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/7 "2020-02-20T09:38:27Z")

</div>

@thewtex might be able to provide some additional information but I suspect that it won’t be trivial.

---

<div class="post-metadata">

### Author: ![thewtex](https://discourse.vtk.org/user_avatar/discourse.vtk.org/thewtex/32/55_2.png) [@thewtex](https://discourse.vtk.org/u/thewtex)
#### Post date: [February 20, 2020, 7:42pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/8 "2020-02-20T19:42:08Z")

</div>

VTK without rendering can be used with the Emscripten Toolchain by using [itk.js](https://insightsoftwareconsortium.github.io/itk-js/docs/index.html) and the [kitware/itk-js-vtk](https://hub.docker.com/r/kitware/itk-js-vtk) Docker image. This can be used to compile processing pipelines on Windows. itk.js and the Docker image provide:

- The Emscripten toolchain
- CMake configuration
- VTK built with the Emscripten toolchain
- A method to efficiently call the resulting JavaScript and WebAssembly

These are the required components.

---

<div class="post-metadata">

### Author: ![claretb](https://discourse.vtk.org/user_avatar/discourse.vtk.org/claretb/32/1466_2.png) [@claretb](https://discourse.vtk.org/u/claretb)
#### Post date: [February 25, 2020, 7:44am UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/9 "2020-02-25T07:44:44Z")

</div>

Thank you. I succeeded after a little working. But I wonder another thing. Suppose I personalized some part of VTK for myself. Can I create own Docker Image?

---

<div class="post-metadata">

### Author: ![thewtex](https://discourse.vtk.org/user_avatar/discourse.vtk.org/thewtex/32/55_2.png) [@thewtex](https://discourse.vtk.org/u/thewtex)
#### Post date: [February 25, 2020, 8:46pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/10 "2020-02-25T20:46:32Z")

</div>

> [@claretb](#):
>
> Thank you. I succeeded after a little working.

Great!

> [@claretb](#):
>
> Suppose I personalized some part of VTK for myself. Can I create own Docker Image?

Yes. Edit _Dockerfile_ and _build.sh_ [found here](https://github.com/InsightSoftwareConsortium/itk-js/tree/master/src/Docker/itk-js-vtk), then specify the image name with `itk-js build --image <your-image-name> src/path`.

---

<div class="post-metadata">

### Author: ![Donny\_Zimmerman](https://discourse.vtk.org/user_avatar/discourse.vtk.org/donny_zimmerman/32/301_2.png) [@Donny\_Zimmerman](https://discourse.vtk.org/u/Donny_Zimmerman)
#### Post date: [August 21, 2020, 7:12pm UTC](https://discourse.vtk.org/t/porting-c-app-to-vtk-js/2303/11 "2020-08-21T19:12:19Z")

</div>

> [@claretb](#):
>
> Thank you. I succeeded after a little working. But I wonder another thing. Suppose I personalized some part of VTK for myself. Can I create own Docker Image?

I am also trying to compile VTK with Emscripten for Windows. Can you give me some pointers on how you accomplished this?
