[Insight-users] how to cast itkAffineTransform to itkScalableAffineTransform?

Darren Weber darren.weber.lists at gmail.com
Wed Oct 28 19:25:47 EDT 2009


itkAffineTransform objects have been calculated and saved to ascii files.

The following code is supposed to read the file and convert the object to a
ScalableAffineTransform (assume there is an object called transforms that
holds the return transform list from a transform reader, as in transforms =
transformReader->GetTransformList() ):

    ScalableAffineTransformType::Pointer xfm, xfmRead;
    ScalableAffineTransformType::InputVectorType scale;
    for( unsigned short i = 0; i < imgDimension; i++ )
        scale[i] = 1.0;
    // Use an STL iterator on the list of transforms and apply
    // the proper casting of the resulting transform.
    itk::TransformFileReader::TransformListType::const_iterator transformIt;
    transformIt = --(transforms->end()); // get last transform in list
    if( ! strcmp( (*transformIt)->GetNameOfClass(),"AffineTransform"))
        {
        xfmRead = static_cast<ScalableAffineTransformType*>(
(*transformIt).GetPointer() );
        xfm = dynamic_cast<ScalableAffineTransformType*>(
xfmRead.GetPointer() );
        // remove the scale component of the transform
        //const double scale[] = {1.0, 1.0};
        //xfm->SetScale( scale );
        }

This code appears to work fine, but once the xfm-SetScale() method is
called, there are seg faults or bus errors.

Anyone had experience with this?

Thanks in advance,
Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091028/54b67603/attachment.htm>


More information about the Insight-users mailing list