Factory Registration Managers


(Tim Evain) #1

Hello everyone,

Since I always use CMake to get ITK into my own projects, I get the itk(Transform/Image)IOFactoryRegisterManager.h files that are generated during the process.
I’m now on a project without CMake, and I realize that I don’t really understand what are these files for, and if we need to generate something equivalent if we want to use ITK without CMake’s help.

Can any of you enlighten me about this ?

By the way, as this is my first post of 2018, I wish a happy new year to all of you ! :slight_smile:


(Matt McCormick) #2

Hello Tim!

Happy 2018! :slight_smile:

The best source of documentation is current found in comments of the UseITK.cmake file. :tophat: h/t @jcfr

In summary, these files, when included in an executable or library, will register the available itk::ImageIOBase classes to the object factory, so itk::ImageFileReader and itk::ImageFileWriter can find and use them.

This, of course, depends on the available ImageIO modules that ITK has available (depends on ITK’s build options and any external modules). The infrastructure was improved even further in ITK 4.13.0, which makes the use of CMake even more appealing. :tophat: h/t @fbudin

HTH,
Matt


(Tim Evain) #3

Thanks for the precisions Matt!

So if I’m not mistaken, the consequence of not having it is that we have to explicitely set the desired IOBase in Writers/Readers?
What are the reasons that prevent generating these files beforehand when one build ITK?

Tim


(Matt McCormick) #4

To not be restricted to a given image format, the ImageIO’s have to be registered to the factory manually, by calling

itk::MetaImageIOFactory::RegisterOneFactory();
itk::PNGImageIOFactory::RegisterOneFactory();
[...]

More details and an explanation can be found in the Register IO Factories example.

The image IO’s can be extended after the ITK build, e.g. with the ITKIOOpenSlide module.


(Tim Evain) #5

Thanks for the explanation Matt, it’s clearer for me now :slight_smile:.