How to wrap a `std::vector<ImagePointer>` in swig with ITKWrap

I have a couple of helper functions here and here, which deal with std::vector<itk::Image<X,Dim>::Pointer>, as input argument in the first case, and as an output for the later.

I have an usable python module (pip install itk-isotropicwavelets), but is not fully wrapping the external module. When using those classes I get a few issues involving this unwrapped vector:

  1. swig/python detected a memory leak of type 'std::vector< itkImageCF2_Pointer,std::allocator< itkImageCF2_Pointer > > *', no destructor found. when using the first case with waveletForward.GetOutputs()

  2. The swig objects are non-mutable from python.

  3. I cannot generate a new swig-object from python to use it as input for waveletInverse.GetInputs(a_vector_of_image_pointers)

I have no much knowledge about swig, but I have seen there are different types in itk.vector, such as itk.vector.itkStatisticalLabelObjectUL2, and they seem generated in Wrapping/WrapITKTypes.

Is it possible to modify or append types from an external module? Is there an existing wrapped type for std::vector of ImagePointers?


Hi @phcerdan,

One option to address this issue is to use itk::VectorContainer, which is wrapped and has a ModifiedTime so it can be used in ITK pipelines.

1 Like