[Insight-developers] Lots of new warnings: Adding an alternative GetInverse() method to the transform hierarchy.

Luis Ibanez luis.ibanez at kitware.com
Sat Jun 28 18:41:12 EDT 2008


Hi Gaetan,

Here is the rationale behind the new signature of the method

                    Transform::GetInverse(()

The requirements of GetInverseI() are:

   1) The inverse may not exist, therefore the method must
      indicate that situation when it arises. (returning a boolean,
      or a null pointer, or throwing an exception,... are some of
      the options).

   2) The type of the inverse doesn't have to be the same
      as the type of the current transform. For example,
      The inverse of a BSplineTransform may be a KernelTransform.

   3) The inverse may in some cases be own by the transform itself,
      while in some cases they may be created on the fly

   4) The method should be Virtual in order to allow for generic
      code that can call computation of transforms without being
      aware of their actual type.


The new signature is an option that satisfy these requirements.
There are probably many other options, any suggestions are welcome.


The reason why a SmartPointer is used here is to address the
case in which a transform may have to be created on the fly.

The alternative signature that you suggest:

      TransformBase::Pointer  GetInverse() const

could also be an option. In this case, the user will have to
test the returned value against NULL in order to check if
the returned transform was valid.


Throwing an exception for the cases when the transform doesn't
exist is an option as well.


The previous GetInverse() method had the following short commings

    a) It was not virtual

    b) It was defined at the level of every individual transform
       by passing  a raw pointer to the Self type of the transform


Giving the limitations of swig, it seems that the signature

       virtual TransformBase::Pointer  GetInverse() const

is a better option to try.


Doug: will this signature work for the coordinates conversions
       that you are looking for ?


   Please let us know, so we can give it a try tomorrow.


      Thanks


        Luis


----------------------
Gaëtan Lehmann wrote:
> 
> Hi Luis,
> 
> I thought that SmartPointers should be used as output of a method only  
> if really needed, and must not be used as input.
> The new method is using it though — I have missed something?
> 
> Is it only to change the method signature? If so, and if the usage of  
> smart pointers can't be avoided, perhaps
> 
>   virtual Pointer GetInverse() const
> 
> would be a better option? A null pointer or an exception can be used  to 
> indicate that no inverse transform can be produced.
> 
> Regards,
> 
> Gaëtan
> 
> 
> PS: a perhaps less important problem for you: swig is currently not  
> able to produce valid code for references to smart pointers. At this  
> time, I think that code would not be usable in python, tcl, etc
> 
> Le 28 juin 08 à 15:54, Luis Ibanez a écrit :
> 
>>
>> Hi Bill,
>>
>> Yeap, the change is now being backed off.
>>
>> The existing GetInverse method use "Self" as argument, therefore
>> every class returns a trasnsform of its own type.
>>
>> The change to virtual was not enough,
>> in practice we need a full new method with a different signature.
>>
>> We are replacing (via backward-compatible deprecation mechanism)
>> the method
>>
>> bool Transform::GetInverse( Self * inverse );
>>
>> with
>>
>> virtual bool
>> TransformBase::GetInverse( TransformBase::Pointer & inverse ) const;
>>
>>
>> The change has been committed now.
>>
>>
>>  Luis
>>
>>
>> ----------------------
>> Bill Lorensen wrote:
>>
>>> Luis,
>>> After your itkTransform.h changes, there are lots of warnings:
>>> http://www.cdash.org/CDash/viewBuildError.php?type=1&buildid=110692
>>> Bill
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
> 
> 


More information about the Insight-developers mailing list