[Insight-users] problem with TransformFileReader

Luis Ibanez luis.ibanez at kitware.com
Tue Jan 2 08:58:40 EST 2007


Hi Xabier,

You probably should check whether the iterator returned by
the "begin()" method is valid or not, before attempting to
use it.


You could use code that looks something like:


TransformListType::const_iterator tit = transforms->begin();
if( tit != transforms->end() )
   {
   const TransformType * readTransform = *tit;
   if( readTransform )
     {
     transform->SetParameters( readTransform->GetParameters() );
     }
   else
     {
     std::cerr << "Invalid Transform pointer" << std::endl;
     }
   }
else
   {
   std::cerr << "Invalid Iterator" << std::endl;
   }


Please give it a try to the code above and let us know
where exactly the run-time error is happening.


   Thanks,


       Luis



=======================================
Xabier Artaechevarria Artieda wrote:
> Hello,
> I am trying to read a Transform File containing the parameters of a 3D  
> affine transformation. I get a segmentation fault when trying to read  
> the parameters contained in the file, at this point of the code:
> 
> TransformListType transforms = transformReader->GetTransformList();
> transform->SetParameters((*transforms->begin())->GetParameters());
> 
> The transform file looks like this:
> 
> #Insight Transform File V1.0
> # Transform 0
> Transform: AffineTransform_double_3_3
> Parameters: 1.00407 0.00202538 -0.000346736 0.00274766 1.00089  
> 0.00463338 -0.00186666 -0.00160371 0.997568 22.8463 16.5753 -19.3539
> FixedParameters: 0 0 0
> 
> I have noticed that the segmentation fault occurs when  
> "GetParameters()" is executed, but I do not why. Any suggestion that  
> may help in finding the problem will be very welcome. Thanks a lot and  
> happy new year to everybody.
> 


More information about the Insight-users mailing list