[Insight-users] why can not write observation to file?

Yu Qi felix_china at yahoo.com.cn
Sat May 21 13:00:43 EDT 2005


Hi,
I want to write the result of observer to a file called Observer_Result.txt
and my code is as follows, but why there is onthing in the file?
 
 
 void Execute(const itk::Object * object, const itk::EventObject & event)
    {
      OptimizerPointer optimizer = 
        dynamic_cast< OptimizerPointer >( object );
      if( typeid( event ) != typeid( itk::IterationEvent ) )
        {
        return;
        }
      std::cout << optimizer->GetCurrentIteration() << "   ";
      std::cout << optimizer->GetValue() << "   ";
      std::cout << optimizer->GetCurrentPosition() << std::endl;
    /////////////////////////////////write to file
    FILE *stream1;
   char fileName1[]= "Observer_Result.txt";
    if( (stream1 = fopen( fileName1, "a+t" )) != NULL )
    { 
    fprintf( stream1, "%d\t", optimizer->GetCurrentIteration());
    fprintf( stream1, "%e\t",optimizer->GetValue());
    OptimizerType::ParametersType observerParameters = 
                    optimizer->GetCurrentPosition();
    
    fprintf( stream1, "%e\t",  observerParameters[0]);
    fprintf( stream1, "%e\t",  observerParameters[1]);
    fprintf( stream1, "%e\t",  observerParameters[2]);
    fprintf( stream1, "%e\t",  observerParameters[3]);
    fprintf( stream1, "%e\t",  observerParameters[4]);
    fprintf( stream1, "%e\t\n",  observerParameters[5]);
  }
 
    }


Best Regards!
 
Yu Qi
 
 




---------------------------------
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050522/741b25a6/attachment.htm


More information about the Insight-users mailing list