Adding support for customizing ITK namespace

Updates

  • The Slicer pull request #6564 adding support for ITK custom namespace has been integrated into Slicer.

  • Use of functionality relying on either ITK C++ or SimpleITK python package built within Slicer and against the customer ITK are working on macOS/Linux/Windows.

  • Use of filter like discrete_gaussian_image_filter provided by the ITK Python package itk 5.3rc4.post3 installed from PyPI is working on Linux and Windows. An issue has been identified on macOS and is been discussed under a different topic here.

Implementation

Slicer/ITK has been updated in Slicer/ITK@69e52f05c. In a nutshell, the itkNamespace.h header was introduced. It provides the logic for redefining “itk” only if a custom namespace has been provided. This ensures that the default behavior remains unchanged.

To minimize the number of files to update, the itkNamespace.h may be included
through three mechanisms:

(1) Through itkConfigure.h: included either directly or indirectly by most files

(2) Through Export header: support case of header like itkFEMSolution.h only including the export header

(3) Through explicit include: support case of header without any includes (e.g itkMakeFilled.h)

cc: @dzenanz @matt.mccormick

Similarly, Slicer/SimpleITK has also been updated introducing sitkNamespace.h. See Slicer/SimpleITK@c7f151412.

cc: @blowekamp

Next steps

The implementation associated with Slicer/ITK and Slicer/SimpleITK unconditionally define:

Logic should be generalized by introducing the CMake options ITK_NAMESPACE and SITK_ITK_NAMESPACE, if associated value is itk … no re-definition should happen.

Within ITK, mangling logic should be applied to remaining third party (zlib, gdcm, …) (thanks @dzenanz for the suggestion)

3 Likes