[Insight-users] Using Polymorphism with itk::KernelTransform

Ofri Sadowsky ofri@cs.jhu.edu
Fri, 24 Jan 2003 17:14:21 -0500 (EST)


Hi,

I have finally gone through the build process, and this time it's about
the API.

Is it possible to use the polymorphism of itk::KernelTransform in the
following way:


itk::KernelTransform<MyCoordType, MyDimension> * createTransform(PointSet
sourcePoints, PointSet targetPoints, int transformType)
{
  /* do something like switch over transformType and call the appropriate
   * New() function, then return the new object as a result
   */
}



The problem I see is, that New() returns a ConcreteTransform::Pointer,
which is derived from one or another smart-pointer templated types, and
there will be no parallel derivation of ConcreteTransform::Pointer from
KernelTransform::Pointer .  On the other hand, if I just return a
KernelTransform * , I lose the smart pointer returned from New(), and then
the KernelTransform object is destroyed.

So is there a way to use the KernelTransform abstraction properly?

Thanks,

Ofri.