In order to create a Python wrapping for ITK, Wrapping/Generators/SwigInterface/igenerator.py generates “itk*.i” files for all wrapped ITK types. For example for itk::Size<unsigned int>
, it generates a file named <Bin>\ITK\Wrapping\Typedefs\itkSize.i
. This file contains class definitions for itkSize2, itkSize3, and itkSize4, for example (simplified):
class itkSize2 {
public:
...
itkSize2();
itkSize2(itkSize2 const & arg0);
itkSize2 & operator=(itkSize2 const & arg0);
~itkSize2();
};
These classes (itkSize2, itkSize3, and itkSize4) are then passed to SWIG, in order to wrap them, if I understand correctly.
Is there a specific reason why we do it like that? Instead of passing those classes to SWIG, would it be an option to directly pass the itk::Size<unsigned int>
template to SWIG? SWIG does support templates, for example:
%template(itkSize2) itk::Size<2>;
%template(itkSize3) itk::Size<3>;
%template(itkSize4) itk::Size<4>;
So why don’t we use the SWIG %template
keyword?
See also the discussion I had with @blowekamp at How to wrap a static constexpr data member (an integer value), for Python? · swig/swig · Discussion #3088 · GitHub