ITK 5.0 Alpha 1: Modern C++

April 17, 2018

ITK 5.0 Alpha 1 is ready for testing!

ITK 5.0 brings dramatic improvements to ITK’s API and performance. At the same time, there are minimal changes that break backwards compatibility.

This the first in a series of alpha releases to enable the community to test and improve these major changes.

In this first alpha release, we highlight ITK’s adoption of and requirement for the C++11 standard. Prior to this release, a subset of C++11 functionality was utilized, when available, through backports and macros. ITKv5 deprecates or removes these macros (e.g. ITK_NULLPTRITK_DELETED_FUNCTIONITK_NOEXCEPTITK_CONSTEXPR) and directly uses C++11 keywords such as deleteconstexprnullptroverridenoexcept. The keywords auto and using as well as range-based loops are also now used heavily throughout ITK.

ITKv5 includes some API changes. Even though we tried to minimize backward compatibility issues, there will be a few (see below for important changes). These changes were discussed by the community on the ITK Discourse forum [1][2][3][4]. This ITK alpha release is purposefully created with the goal of helping developers to test their current software with this new ITK version, update their code if necessary, and report problems they encountered during this process.

ITK now requires CMake 3.9.5 for configuration and a compiler that supports C++11. This means that Visual Studio 2015 or later is required for Windows development with the Microsoft toolchain.

Important changes in style have also been integrated in ITK to match the C++11 best practices. This includes replacing typedef calls with the using keyword, the usage of the keyword auto when appropriate, and moving the macro ITK_DISALLOW_COPY_AND_ASSIGN from the private class section to the public class section. The ITK Software Guide has been updated to match these changes.

As shown below, toolkit has adopted the application of the using keyword for type aliases, which many developers find easier to read and understand.

  template< typename TInputImage, typename TOutputImage > 
  class ITK_TEMPLATE_EXPORT BoxImageFilter:
    public ImageToImageFilter< TInputImage, TOutputImage >
  { 
  public:
    ITK_DISALLOW_COPY_AND_ASSIGN(BoxImageFilter);
  
    /⋆⋆ Standard class type alias. ⋆/ 
    using Self = BoxImageFilter;
    using Superclass = ImageToImageFilter< TInputImage, TOutputImage >;
  
    [...]
   
  protected:
    BoxImageFilter();
    ~BoxImageFilter() {}
  
    void GenerateInputRequestedRegion() override; 
    void PrintSelf(std::ostream & os, Indent indent) const override;
  
  private: 
    RadiusType m_Radius;
  };
  
  } // end namespace itk

For more information on style changes, see the Coding Style Guide found in the ITK Software Guide.

To test the 5.0 Alpha 1 Python packages, run

python -m pip install --upgrade pip
python -m pip install --upgrade --pre itk

The community has been busy — there have been 319 commits, 97,794 insertions, 152,791 deletions since 4.13.0 was released in December!

Please discuss your experiences on Discourse. The API is expected to change across alpha releases as we improve the library based on our experiences.

Leave a Reply