Skip to content

Instantly share code, notes, and snippets.

@N-Dekker
Created November 22, 2020 21:04
Show Gist options
  • Save N-Dekker/b5b85167efb752af1e0c0198d8d0ee68 to your computer and use it in GitHub Desktop.
Save N-Dekker/b5b85167efb752af1e0c0198d8d0ee68 to your computer and use it in GitHub Desktop.
Print ITK Transform classes and their number of parameters
/*
Related to:
https://github.com/SuperElastix/elastix/pull/358#issuecomment-731736374
Niels Dekker, LKEB, Leiden University Medical Center, 2020
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*/
#include "itkTransformBase.h"
#include "itkTransformFactoryBase.h"
int main()
{
int i{};
std::cout << "n | " << "ITK class | # Parameters | # FixedParameters\n";
for (const auto className : itk::TransformFactoryBase::GetFactory()->GetClassOverrideWithNames())
{
const auto instance = itk::ObjectFactoryBase::CreateInstance(className.c_str());
assert(instance != nullptr);
if (dynamic_cast<const itk::TransformBaseTemplate<float>*>(&*instance) == nullptr)
{
const auto inputTransform = dynamic_cast<const itk::TransformBaseTemplate<double>*>(&*instance);
assert(inputTransform != nullptr);
std::cout << ++i
<< " | " << (typeid(*instance).name() + 11)
<< " | " << inputTransform->GetParameters().size()
<< " | " << inputTransform->GetFixedParameters().size()
<< '\n';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment