[Insight-users] Re: itk typemaps again !

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Thu Jul 28 10:23:50 EDT 2005


On Thu, 28 Jul 2005 15:07:35 +0200, Brad King <brad.king at kitware.com>  
wrote:

> 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.
>

cableswig seems to use an old version of swig (1.3.21, 2004-01-10) which  
is not really good with templates.
std::vector can't be used with 2 arguments as you suggest.

this problem was solved in 1.3.24 (see  
http://www.swig.org/Release/CHANGES), and 1.3.25 is out.
Is it possible to update SWIG in CableSwig ?

I have done a diff between SWIG in cableswig and official 1.3.21 release  
and it seems that there is some (lots of?) differences.  Have you got a  
patch to apply to SWIG ?
I thought the policy about SWIG part is to touch nothing. Am I wrong ?

Regards,

Gaetan

-- 
Gaetan Lehmann <gaetan.lehmann at jouy.inra.fr>
Tel: +33 1 34 65 29 66
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
Web: http://voxel.jouy.inra.fr


More information about the Insight-users mailing list