<br>itkAffineTransform objects have been calculated and saved to ascii files.<br><br>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() ):<br>
<br><span style="font-family: courier new,monospace;"> ScalableAffineTransformType::Pointer xfm, xfmRead;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> ScalableAffineTransformType::InputVectorType scale;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> for( unsigned short i = 0; i < imgDimension; i++ )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> scale[i] = 1.0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> // Use an STL iterator on the list of transforms and apply</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // the proper casting of the resulting transform.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> itk::TransformFileReader::TransformListType::const_iterator transformIt;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> transformIt = --(transforms->end()); // get last transform in list</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if( ! strcmp( (*transformIt)->GetNameOfClass(),"AffineTransform"))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> xfmRead = static_cast<ScalableAffineTransformType*>( (*transformIt).GetPointer() );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> xfm = dynamic_cast<ScalableAffineTransformType*>( xfmRead.GetPointer() );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> // remove the scale component of the transform</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> //const double scale[] = {1.0, 1.0};</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> //xfm->SetScale( scale );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> } </span><br><br>This code appears to work fine, but once the xfm-SetScale() method is called, there are seg faults or bus errors.<br>
<br>Anyone had experience with this?<br><br>Thanks in advance,<br>Darren<br><br>