int
main(int argc, char * argv[])
{
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " transformFile" << std::endl;
return EXIT_FAILURE;
}
const char * transformFileName = argv[1];
using ScalarType = double;
using CompositeTransformType =
AffineTransformType::InputPointType cor;
cor.Fill(12);
affine->SetCenter(cor);
composite->AddTransform(affine);
constexpr unsigned int SplineOrder = 5;
using BSplineTransformType =
using BSplineTransformFType =
BSplineTransformType::OriginType origin;
origin.Fill(100);
BSplineTransformType::PhysicalDimensionsType dimensions;
dimensions.Fill(1.5 * 9.0);
bspline->SetTransformDomainOrigin(origin);
bspline->SetTransformDomainPhysicalDimensions(dimensions);
BSplineTransformType::ParametersType parameters(
bspline->GetNumberOfParameters());
bspline->SetParameters(parameters);
bspline->SetIdentity();
composite->AddTransform(bspline);
writer->SetInput(composite);
writer->SetFileName(transformFileName);
try
{
writer->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << "Error while saving the transforms" << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
using ReadScalarType = float;
using TransformReaderType =
reader->SetFileName(transformFileName);
try
{
reader->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << "Error while reading the transform file" << std::endl;
std::cerr << excp << std::endl;
std::cerr << "[FAILED]" << std::endl;
return EXIT_FAILURE;
}
const TransformReaderType::TransformListType * transforms =
reader->GetTransformList();
std::cout << "Number of transforms = " << transforms->size() << std::endl;
using ReadCompositeTransformType =
auto it = transforms->begin();
if (!strcmp((*it)->GetNameOfClass(), "CompositeTransform"))
{
static_cast<ReadCompositeTransformType *>((*it).GetPointer());
compositeRead->
Print(std::cout);
}
return EXIT_SUCCESS;
}