diff --git a/Core/Kernel/elxElastixMain.cxx b/Core/Kernel/elxElastixMain.cxx index 27a6d5b6c..8bb057dad 100644 --- a/Core/Kernel/elxElastixMain.cxx +++ b/Core/Kernel/elxElastixMain.cxx @@ -730,6 +730,16 @@ ElastixMain::CreateComponent(const ComponentDescriptionType & name) itkExceptionMacro(<< "The following component could not be created: " << name); } + if (m_NumberOfWorkUnits > 0) + { + const auto processObject = dynamic_cast(component.GetPointer()); + + if (processObject) + { + processObject->SetNumberOfWorkUnits(m_NumberOfWorkUnits); + } + } + return component; } // end CreateComponent() diff --git a/Core/Kernel/elxElastixMain.h b/Core/Kernel/elxElastixMain.h index 0327b95f7..dfbc9d201 100644 --- a/Core/Kernel/elxElastixMain.h +++ b/Core/Kernel/elxElastixMain.h @@ -313,6 +313,13 @@ class ElastixMain : public itk::Object virtual ParameterMapType GetTransformParametersMap() const; + void + SetNumberOfWorkUnits(const itk::ThreadIdType newValue) + { + m_NumberOfWorkUnits = newValue; + } + + protected: ElastixMain(); ~ElastixMain() override; @@ -399,6 +406,8 @@ class ElastixMain : public itk::Object ElastixMain(const Self &) = delete; void operator=(const Self &) = delete; + + itk::ThreadIdType m_NumberOfWorkUnits{ 0 }; }; } // end namespace elastix diff --git a/Core/Main/itkElastixRegistrationMethod.hxx b/Core/Main/itkElastixRegistrationMethod.hxx index 556ff2c5e..b0e002c0e 100644 --- a/Core/Main/itkElastixRegistrationMethod.hxx +++ b/Core/Main/itkElastixRegistrationMethod.hxx @@ -227,6 +227,7 @@ ElastixRegistrationMethod::GenerateData() // Create new instance of ElastixMain elx::DefaultConstruct elastixMain; + elastixMain.SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); // Set elastix levels elastixMain.SetElastixLevel(i); diff --git a/Core/Main/itkTransformixFilter.hxx b/Core/Main/itkTransformixFilter.hxx index 2c9bb4ff4..843429038 100644 --- a/Core/Main/itkTransformixFilter.hxx +++ b/Core/Main/itkTransformixFilter.hxx @@ -154,6 +154,7 @@ TransformixFilter::GenerateData() // Instantiate transformix elx::DefaultConstruct transformixMain; + transformixMain.SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); // Setup transformix for warping input image if given DataObjectContainerPointer inputImageContainer = nullptr;