Difference between revisions of "Documentation/Nightly/Developers/Tutorials/MigrationGuide/ITK4-to-ITK5"

From Slicer Wiki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 31: Line 31:
  
 
   itk::MultiThreader::Pointer ProcessingThreader;
 
   itk::MultiThreader::Pointer ProcessingThreader;
 +
 +
  ITK_THREAD_RETURN_TYPE
 +
 +
  ITK_THREAD_RETURN_VALUE
 +
 +
  SetNumberOfThreads()
 
</pre>
 
</pre>
  
Line 38: Line 44:
  
 
   itk::PlatformMultiThreader::Pointer ProcessingThreader;
 
   itk::PlatformMultiThreader::Pointer ProcessingThreader;
 +
 +
  itk::ITK_THREAD_RETURN_TYPE
 +
 +
  itk::ITK_THREAD_RETURN_DEFAULT_VALUE
 +
 +
  SetNumberOfWorkUnits()
 
</pre>
 
</pre>
  
Line 53: Line 65:
 
   FastMutexLock
 
   FastMutexLock
 
   MutexLock
 
   MutexLock
 +
 +
  m_Lock->Lock();
 +
  m_Lock->Unlock();
 
</pre>
 
</pre>
  
Line 60: Line 75:
  
 
   std::mutex
 
   std::mutex
 +
 +
  m_Lock.lock();
 +
  m_Lock.unlock();
 
</pre>
 
</pre>

Latest revision as of 06:30, 1 May 2019

Home < Documentation < Nightly < Developers < Tutorials < MigrationGuide < ITK4-to-ITK5

Transition from ITK4 to ITK5

This section lists categories of code changes necessary to build Slicer with ITK 5. Each category has a short description, an example error message, a suggested upgrade path, and references to relevant commits.

Referencing this list might be helpful if Slicer extensions requiring updates to be compatible with ITK 5.

Make also sure to read through the ITK 5 migration guide.

Utilities/ITKv5Preparation directory contains bash scripts which have been used to update ITK to version 5. These scripts can assist with updating external code bases to ITK 5 content and style.

Upgrading to ITKv5 or keep using ITKv4 GenerateThreadedData

If the ThreadedGenerateData does not use threadId, change the name of the function to DynamicThreadedGenerateData Replace:

  void ThreadedGenerateData( const OutputRegionType& threadRegion, ThreadIdType threadId )

with:

  void DynamicThreadedGenerateData( const OutputRegionType& threadRegion )

If you want to keep using the ITKv4 thread system (with ThreadedGenerateData), add to the constructor of your ITK class:

  this->DynamicMultiThreadingOff();

itkMultiThreader refactor

Replace lines like:

  #include <itkMultiThreader.h>

  itk::MultiThreader::Pointer ProcessingThreader;

  ITK_THREAD_RETURN_TYPE

  ITK_THREAD_RETURN_VALUE

  SetNumberOfThreads()

with:

  #include <itkPlatformMultiThreader.h>

  itk::PlatformMultiThreader::Pointer ProcessingThreader;

  itk::ITK_THREAD_RETURN_TYPE

  itk::ITK_THREAD_RETURN_DEFAULT_VALUE

  SetNumberOfWorkUnits()

SimpleFastMutexLock, FastMutexLock and MutexLock are deprecated

Instead use std::mutex available in C++11

Replace:

  #include "itkSimpleFastMutexLock.h"
  #include "itkFastMutexLock.h"
  #include "itkMutexLock.h"

  SimpleFastMutexLock
  FastMutexLock
  MutexLock

  m_Lock->Lock();
  m_Lock->Unlock();

with:

  #include <mutex>

  std::mutex

  m_Lock.lock();
  m_Lock.unlock();