[Insight-users] how to wrap std::vector?
Gaëtan Lehmann
gaetan.lehmann at jouy.inra.fr
Fri Sep 18 16:59:17 EDT 2009
Le 18 sept. 09 à 11:05, Mario Ceresa a écrit :
> Hello Gaëtan,
> Thanks a lot for your response!
>
> You were right: using double as a PointType works perfectly. How
> silly of me!
>
> BTW should I ever have to extend the swig part of wrap_itk,
What do you mean by "extend the swig part"? WrapITK is mostly based on
swig, so it can mean a lot of things :-)
> is it
> correct to look at Languages/Python/PyBase/wrap_pyBase.i?
That's only a small peace of the code. There are many .i files
generated - look into the Typedefs directory.
All those files are generated by some cmake code.
>
> Cheers,
>
> Mario
>
> 2009/9/17 Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr>:
>>
>> Le 10 sept. 09 à 14:32, Mario Ceresa a écrit :
>>
>>> Hello everybody,
>>
>> Hi Mario,
>>
>>> I stumbled upon a fascinating problem while using wrap_itk and I
>>> thought that maybe someone here could help me :)
>>>
>>> I have a method called GetAlives which returns me a collection of
>>> points as a std::vector<itk::Point>. How can I use it from python?
>>> So
>>> far I only managed to get a SwigPointer to the collection, not the
>>> collection itself:
>>>
>>> (Pdb) print alives
>>> <Swig Object of type 'std::vector< itk::Point< unsigned short,3u
>>>>
>>>> ,std::allocator< itk::Point< unsigned short,3u > > > *' at
>>>> 0x3f18870>
>>>
>>> (Pdb) print dir(alives)
>>> ['__class__', '__cmp__', '__delattr__', '__doc__', '__eq__',
>>> '__ge__',
>>> '__getattribute__', '__gt__', '__hash__', '__hex__', '__init__',
>>> '__int__', '__le__', '__long__', '__lt__', '__ne__', '__new__',
>>> '__oct__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
>>> '__str__', 'acquire', 'append', 'disown', 'next', 'own']
>>>
>>> Is there a way to get access to the collection using wrap_itk?
>>>
>>
>> You can access to the type std::vector< itk::Point< double, 3 > >
>> in the
>> last wrapitk version - http://wrapitk.googlecode.com. Here is an
>> example:
>>
>> In [3]: v = itk.vector.itkPointD3()
>>
>> In [4]: v.size()
>> Out[4]: 0
>>
>> In [5]: v.push_back([1,1,2])
>>
>> In [6]: v.size()
>> Out[6]: 1
>>
>> In [7]: v[0]
>> Out[7]: itkPointD3([1, 1, 2])
>>
>> It's not exactly the type you're looking for though, but there I
>> think you
>> may have made a mistake by using itk::Point< unsigned short, 3 >.
>> Can you
>> explain why you chose this type?
>>
>>> You can see all the details in the attached cmake project.
>>>
>>> Thanks for any help or suggestion you could provide!
>>>
>>
>> Thanks for providing the sources - as always, it helps a lot :-)
>>
>> Gaëtan
>>
>> --
>> Gaëtan Lehmann
>> Biologie du Développement et de la Reproduction
>> INRA de Jouy-en-Josas (France)
>> tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
>> http://voxel.jouy.inra.fr http://www.itk.org
>> http://www.mandriva.org http://www.bepo.fr
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr http://www.itk.org
http://www.mandriva.org http://www.bepo.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090918/f3081f3c/attachment.pgp>
More information about the Insight-users
mailing list