Skip to content

Commit

Permalink
ENH: Add NumberOfThreads property to itk::TransformixFilter
Browse files Browse the repository at this point in the history
Addressed issue InsightSoftwareConsortium/ITKElastix#163 "No option to set number of threads for Transformix", submitted by Sebastian van der Voort.
  • Loading branch information
N-Dekker committed Aug 26, 2022
1 parent 6bcce44 commit ffab4b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Core/Main/GTesting/itkTransformixFilterGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ GTEST_TEST(itkTransformixFilter, IsDefaultInitialized)
EXPECT_FALSE(transformixFilter.GetLogToConsole());
EXPECT_FALSE(transformixFilter.GetLogToFile());
EXPECT_EQ(transformixFilter.GetOutputMesh(), nullptr);
EXPECT_EQ(transformixFilter.GetNumberOfThreads(), 0);
}


Expand Down
5 changes: 5 additions & 0 deletions Core/Main/itkTransformixFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ class ITK_TEMPLATE_EXPORT TransformixFilter : public ImageSource<TMovingImage>
m_EnableOutput = false;
}

itkSetMacro(NumberOfThreads, int);
itkGetConstMacro(NumberOfThreads, int);

/** Sets an (optional) input mesh. An Update() will transform its points, and store them in the output mesh. */
void
SetInputMesh(typename MeshType::ConstPointer mesh)
Expand Down Expand Up @@ -264,6 +267,8 @@ class ITK_TEMPLATE_EXPORT TransformixFilter : public ImageSource<TMovingImage>
bool m_LogToConsole{ false };
bool m_LogToFile{ false };

int m_NumberOfThreads{ 0 };

typename MeshType::ConstPointer m_InputMesh{ nullptr };
typename MeshType::Pointer m_OutputMesh{ nullptr };
};
Expand Down
5 changes: 5 additions & 0 deletions Core/Main/itkTransformixFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ TransformixFilter<TMovingImage>::GenerateData()
}
}

if (m_NumberOfThreads > 0)
{
argumentMap.insert(ArgumentMapEntryType("-threads", std::to_string(m_NumberOfThreads)));
}

// Setup xout
const auto manager = m_EnableOutput
? std::make_unique<const elx::xoutManager>(logFileName, m_LogToFile, m_LogToConsole)
Expand Down

0 comments on commit ffab4b9

Please sign in to comment.