[Insight-users] ITK Python Wrapping Examples

Charl P. Botha c . p . botha at ewi . tudelft . nl
Wed, 30 Jul 2003 00:34:22 +0200


Charl P. Botha wrote:
> Hua Qian wrote:
>> Is there anyway to print out the parameters in plain numbers?
>  
> This has to do with the way in which SWIG treats references, and 
> GetElement() is actually returning a C++ reference to the element in 
> question, which is why you see a _p_double.
> 
> For now, you can try something like:
> finalParameters.get(0)
> finalParameters.get(1)
> 
> or more generically for any _p_double:
> DArray_getitem(finalParameters.GetElement(0), 0)
> DArray_getitem(finalParameters.GetElement(1), 0)

At a second glance, if the two GetElement() declarations in itkArray.h 
are simply swapped around, the wrapped GetElement() that is chosen by 
the overloaded method resolver in SWIG should be the const one (because 
its first and there are no other parameter differences to resolve with) 
and its result will be a Python float and not a _double_p.  GetElement() 
in Python will then just return a number.

Are there any opinions with regards to this?  Should these two 
declarations be swapped if this would be the end result?  It looks like 
a win-win to me.

Thanks,
Charl

-- 
charl p. botha http://cpbotha . net/ http://visualisation . tudelft . nl/