[Insight-users] Re: itk typemaps again !
Brad King
brad.king at kitware.com
Thu Jul 28 09:07:35 EDT 2005
Gaetan Lehmann wrote:
>
> Hi Brad,
>
> I'm again with typemaps in ITK (with a little more experience than last
> time).
> I have wrapped ImageToVTKImageFilter and VTKImageToImageFilter and have
> sucessfully define typemaps for vtkImageExport and vtkImageData
> (http://voxel.jouy.inra.fr/darcs/itkvtk/).
>
> Now I try to do a little more: I want to add typemaps for
> std::vector<...>. It's very simple with swig and works well
> (http://www.swig.org/Doc1.3/Library.html):
>
> %include "std_vector.i"
> %template(DoubleVector) std::vector<double>;
>
> is enough to wrap vector<double>. But I can't make it work with ITK.
> The class DoubleVector is defined, so I can say the %template directive
> does something. However, the type of object returned by an itk method
> is different of type of DoubleVector.
>
> DoubleVector -> _p_std__vectorTdouble_t
> itk method -> _p_std__vectorTdouble_std__allocatorTdouble_t_t
>
> In a pure SWIG program, this is not the case. All are of type
> _p_std__vectorTdouble_std__allocatorTdouble_t_t.
>
> Do you know if that difference of type can explain why typemap don't work ?
> And do you know why we have this difference of type with cableswig and
> not with swig alone ?
CableSwig generates the return type of the method using the results of
GCC-XML, which will give the tempalte instantiation its full name with
all arguments. You are not specifying these arguments to swig, and it
does not know about the default argument of vector. Try specifying the
full name to %template. The following might be the correct syntax:
%template(DoubleVector) std::vector<double, std::allocator<double> >;
but I'm not too familiar with the swig .i syntax.
-Brad
More information about the Insight-users
mailing list