[Insight-users] passing itk::BSplineDeformableTransform between functions

Ziv Yaniv zivy at isis.imac.georgetown.edu
Tue Aug 1 15:03:21 EDT 2006


Hi all,

I'm using the itk::BSplineDeformableTransform class and I was wondering 
how I pass an object of this
type between functions without causing a memory leak. The problem is 
that the transformation object only holds a
pointer to the parameters array and does not give access to the pointer 
later on so that the user can release the
memory.

This is my scenario in pseudocode:

void f() {

  itk::Transform<>::Pointer transformation = itk::Transform<>;
  FixedImageType::Pointer fixedImage = FixedImageType::New();
  MovingImageType::Pointer movingImage = MovingImageType::New();

  register(fixedImage, movingImage, transformation);

           //At this location I have the transformation and I can 
downcast it to
           //BSplineDeformableTransform, but I can't get the pointer to 
the parameters array to release it
}

void register(FixedImageType::Pointer & fixedImage,
              MovingImageType::Pointer & movingImage,
              itk::Transform<>::Pointer &transformation)
{
    itk::BSplineDeformableTransform<>::Pointer bSplineTransformation = 
itk::BSplineDeformableTransform<>::New();

    transformation = bSplineTransformation; //point to what will be the 
result

               //allocate the parameters array on the heap so that it 
still exists after we exit the method
    itk::BSplineDeformableTransform<>::ParametersType *param = new 
itk::BSplineDeformableTransform<>::ParametersType();

    bSplineTransformation->SetParameters(*param);

}

Perhaps I'm missing something.

                               thanks
                                    Ziv



More information about the Insight-users mailing list