# Using vtkm-filters in a Paraview Plugin

**URL:** https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771
**Category:** Development
**Tags:** vtk
**Created:** [August 29, 2023, 5:33pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771 "2023-08-29T17:33:17Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 29, 2023, 5:33pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/1 "2023-08-29T17:33:17Z")

</div>

Hi everyone,  
I created a new Plugin for ParaView that just provides some additional vtk filters. To this end I used the `paraview-src/Examples/Plugins/ElevationFilter` template.

Now comes the tricky part. One filter is supposed to use a vtkm filter under the hood (specifically `<vtkm/rendering/ScalarRenderer.h>`). I build PV with vtkm and I can build my plugin with this header. However, at runtime PV crashes when it wants to lookup the ScalarRenderer symbol (shared lib issues…). Strangely enough, I’m able to use `<vtkm/filter/clean_grid/CleanGrid.h>` within my filter without problems. So I guess something goes wrong with the vtkm::rendering export or I need to link to something in my vtk.module or paraview.plugin files. The source code of my plugin can be found here: [pycinema-paraview-plugin](https://gitlab.kitware.com/jones/pycinema-paraview-plugin).

Can anyone give me some pointers here (especially @Kenneth_Moreland)? I’m out of ideas how to address this.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 29, 2023, 5:40pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/2 "2023-08-29T17:40:37Z")

</div>

I forgot to mention that the vtkm-filters are used in the `pycinema-paraview-plugin/Plugin/pcImaging/pcImaging.cxx` file.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [August 29, 2023, 8:41pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/3 "2023-08-29T20:41:31Z")

</div>

`ScalarRenderer` is not a filter in VTK-m. That is to say that it does not inherit from the filter base classes and operate as such.

It is part of VTK-m’s rendering library. When VTK-m is compiled under VTK, the rendering library is turned off ([https://gitlab.kitware.com/vtk/vtk/-/blob/master/ThirdParty/vtkm/vtkvtkm/CMakeLists.txt?ref\_type=heads#L44](https://gitlab.kitware.com/vtk/vtk/-/blob/master/ThirdParty/vtkm/vtkvtkm/CMakeLists.txt?ref_type=heads#L44)). This is because the rendering features of VTK-m are nowhere near as expansive as VTK’s rendering, and it is unclear (at least to us) why you would need them.

---

<div class="post-metadata">

### Author: ![Jonas.Lukasczyk](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jonas.lukasczyk/32/5839_2.png) [@Jonas.Lukasczyk](https://discourse.paraview.org/u/Jonas.Lukasczyk)
#### Post date: [August 29, 2023, 9:38pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/4 "2023-08-29T21:38:05Z")

</div>

Hi Ken,  
thanks for the quick feedback!

Let me provide some context. In short, TTK follows a different approach to exporting Cinema databases than Paraview. Roughly speaking, in PV the Cinema export is kind of build around the VTK processing pipeline, but it is not part of it. In TTK the Cinema export is done via actual VTK filters. For example, the `ttkImaging` filter consumes a set of camera locations and a `vtkDataSet` that needs to be rendered. The filter than generates for each location a `vtkImageData` object via raycasting (currently done via Embree). Making the Cinema export part of the pipeline has several advantages. For instance, one can write a filter that consumes contours to produce a set of good camera positions; those can then be fed into the `ttkImaging` filter. Another advantage is that this kind of export does not require paraview. I think it is super neat and clean that the rendering and export is part of the processing pipeline.

However, there are some technical issues with `Embree + VTK`. For instace, `Embree` only supports 32-bit connectivity lists, but VTK/ParaView by default uses 64-bits, which means we currently have to do a data copy. Btw., if anyone reads this who did the Ospray integration in ParaView: you must have ran into the same issue, do you also just do a data copy?

So to get around the data copy and the additional dependency, I want to swap out the Embree backend with vtkm. In another project I already exported a Cinema database with the vtkm ScalarRenderer, but that was a standalone project that only imported vtkm. Now I want to make this work with the ParaView Plugin architecture without having to install additional dependencies.

I actually did set the `VTKm_MODULE_ENABLE_vtkm_rendering` variable to `YES` while building PV (before I did that I was not even able to find the ScalarRenderer header). However, the shared libs are still missing.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [August 30, 2023, 11:46am UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/5 "2023-08-30T11:46:08Z")

</div>

> [@Jonas.Lukasczyk](#):
>
> I actually did set the `VTKm_MODULE_ENABLE_vtkm_rendering` variable to `YES` while building PV (before I did that I was not even able to find the ScalarRenderer header). However, the shared libs are still missing.

VTK forces it off in a way that cache variables do not override (by setting it as a local variable).

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [August 30, 2023, 1:57pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/6 "2023-08-30T13:57:36Z")

</div>

This is probably more of a question for @sujin, who has been working on the VTK-m to VTK/ParaView interface. It seems reasonable that you could adjust the CMake to allow a (hidden/advanced) option to turn on VTK-m rendering, which should solve the problem as long as you are compiling your own version of ParaView.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [August 30, 2023, 7:17pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/7 "2023-08-30T19:17:06Z")

</div>

I already have concerns about the number of permutations the VTK build system can output. If there’s some rendering bit that VTK should expose through VTK-m, that might be the better way of doing it. Of course, we could also support using an external VTK-m and then VTK doesn’t need to juggle umpteen VTK-m permutations in its own CMake code (even if “hidden/advanced”; it’s either supported or not) and instead can just say “no, that VTK-m doesn’t support what you’ve requested I build” if something isn’t suitable.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [August 30, 2023, 8:33pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/8 "2023-08-30T20:33:36Z")

</div>

> [@ben.boeckel](#):
>
> we could also support using an external VTK-m

That makes sense to me. The VTK-m API should be stable enough to make pulling in external versions feasible.

Again, I defer to @sujin.

---

<div class="post-metadata">

### Author: ![sujin](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sujin/32/4418_2.png) [@sujin](https://discourse.paraview.org/u/sujin)
#### Post date: [August 30, 2023, 9:03pm UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/9 "2023-08-30T21:03:11Z")

</div>

If we don’t want to support all the VTK-m flags in VTK, then external vtk-m is the way to go. Though, It will take some effort to implement support for external VTK-m.

---

<div class="post-metadata">

### Author: ![Charles\_Gueunet](https://discourse.paraview.org/user_avatar/discourse.paraview.org/charles_gueunet/32/40_2.png) [@Charles\_Gueunet](https://discourse.paraview.org/u/Charles_Gueunet)
#### Post date: [September 5, 2023, 8:40am UTC](https://discourse.paraview.org/t/using-vtkm-filters-in-a-paraview-plugin/12771/10 "2023-09-05T08:40:18Z")

</div>

@Louis_Gombert
