# vtkFSLookupTable::MapValue signature changed

**URL:** <https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640>\
**Category:** Development\
**Created:** [December 11, 2017, 11:09pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640 "2017-12-11T23:09:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [December 11, 2017, 11:09pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/1 "2017-12-11T23:09:46Z")

</div>

I get this compile error with hash xxx:  
`55>c:\dev\slicer\libs\freesurfer\vtkFSLookupTable.h(84): error C2555: 'vtkFSLookupTable::MapValue': overriding virtual function return type differs and is not covariant from 'vtkLookupTable::MapValue' [C:\Dev\S3\Slicer-build\Libs\FreeSurfer\FreeSurfer.vcxproj]`

The reason seems to be change of the MapValue method in VTK to return const char \* (it was previously without `const`).

If we are trying to support two versions of VTK, we might need to wrap this definition in an `#if VTK9` block or something similar. If not, just adding `const` will do.

This was introduced in 47e5662bf321acb87f15e83d7f3415faeb44f72f (ENH: Update VTK)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 12, 2017, 1:06am UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/2 "2017-12-12T01:06:54Z")

</div>

Yes, the best would be to keep compatibility with both VTK versions using #ifdef. Just send a pull request and we’ll review and merge.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [December 12, 2017, 3:26pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/3 "2017-12-12T15:26:53Z")

</div>

Commit [ce5575e36aef609c125b8c3a577a9cccd9cdde30](https://github.com/Slicer/VTK/commit/ce5575e36aef609c125b8c3a577a9cccd9cdde30) by Sean McBride “Made vtkScalarsToColor::MapValue() return const” caused this. I think that change could simply be reverted, as it causes a divergence from mainline VTK. The reason for this change was not given in the commit message.

Edit: this is in Slicer’s fork of VTK.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [December 12, 2017, 3:28pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/4 "2017-12-12T15:28:32Z")

</div>

Or we could simply apply the same change on our fork of VTK7, that way after transitioning to VTK9 … the Slicer code base would work without any change.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [December 12, 2017, 5:04pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/5 "2017-12-12T17:04:40Z")

</div>

If making return value const is the right thing to do, why not make a PR to mainstream VTK too? If it is not, we could apply this patch to VTK7 branch too.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [December 12, 2017, 5:06pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/6 "2017-12-12T17:06:19Z")

</div>

> [@dzenanz](#):
>
> why not make a PR to mainstream VTK too?

As you pointed out, the change is already part of mainstream VTK.

the issue is that currently Slicer can be built with version of VTKs with and without this change.

I propose to update the “older” version of VTK used in Slicer to include the change

---

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [December 12, 2017, 5:08pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/7 "2017-12-12T17:08:29Z")

</div>

This change is **not** part of mainline VTK, that’s why I was suggesting its reversion.

Edit: it is, I was accidentally looking at an older master of VTK.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [December 12, 2017, 5:19pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/8 "2017-12-12T17:19:33Z")

</div>

Looking at the change in the master branch of VTK, it looks like the const correctness change is available. See [https://github.com/Kitware/VTK/blame/master/Common/Core/vtkLookupTable.cxx#L740](https://github.com/Kitware/VTK/blame/master/Common/Core/vtkLookupTable.cxx#L740)

If we backport the commit onto the older fork of VTK based of VTK7. See [https://github.com/Slicer/VTK/tree/slicer-v7.1.0-2016-09-23-3b13ad9](https://github.com/Slicer/VTK/tree/slicer-v7.1.0-2016-09-23-3b13ad9)

We wouldn’t have to make the code in Slicer more complex

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [December 12, 2017, 11:28pm UTC](https://discourse.slicer.org/t/vtkfslookuptable-mapvalue-signature-changed/1640/9 "2017-12-12T23:28:20Z")

</div>

Commit was backported to the Slicer fork of VTK7.1, and Slicer code was updated to word with the const signature.

Additionally, the migration guide was updated. See [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide/VTK7-Qt4-to-VTK9-Qt5#VTK9:\_Signature\_of\_vtkFSLookupTable::MapValue\_updated](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide/VTK7-Qt4-to-VTK9-Qt5#VTK9:_Signature_of_vtkFSLookupTable::MapValue_updated)

Fixed in [r26708](http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=26708)
