Orfeo Toolbox  3.16
otbWrapperCommandLineLauncher.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17  =========================================================================*/
19 
20 // Single value parameter
35 #include "otbWrapperRAMParameter.h"
37 
38 // List value parameter
43 
44 #include "otbImageFileWriter.h"
45 
46 
48 #include "otbWrapperApplication.h"
49 #include "otbWrapperTypes.h"
50 #include <itksys/RegularExpression.hxx>
51 #include <string>
52 #include <iostream>
53 
54 namespace otb
55 {
56 namespace Wrapper
57 {
58 
60  m_Expression(""), m_WatcherList(), m_ReportProgress(true), m_MaxKeySize(0)
61 {
65  m_LogOutput->SetStream(std::cout);
66 
67  // Add the callback to be added when a AddProcessToWatch event is invoked
69  m_AddProcessCommand->SetCallbackFunction(this, &CommandLineLauncher::LinkWatchers);
70 }
71 
73  m_Expression(exp)
74 {
77 }
78 
80 {
81  this->DeleteWatcherList();
82 }
83 
85 {
86  for (unsigned int i = 0; i < m_WatcherList.size(); i++)
87  {
88  delete m_WatcherList[i];
89  m_WatcherList[i] = NULL;
90  }
91  m_WatcherList.clear();
92 }
93 
94 bool CommandLineLauncher::Load(const std::string & exp)
95 {
96  std::cout<<exp<<std::endl;
97  m_Expression = exp;
98 
99  return this->Load();
100 }
101 
103 {
104  // Add a space to clarify output logs
105  std::cerr << std::endl;
106  if (m_Expression == "")
107  {
108  itkExceptionMacro("No expression specified...");
109  }
110 
111  if (this->CheckParametersPrefix() == false)
112  {
113  std::cerr << "ERROR: Parameter keys have to set using \"-\", not \"--\"" << std::endl;
114  return false;
115  }
116 
117  if (this->CheckUnicity() == false)
118  {
119  std::cerr << "ERROR: At least one key is not unique in the expression..." << std::endl;
120  return false;
121  }
122 
123  if (this->LoadPath() == false)
124  {
125  if (m_Parser->GetPathsAsString(m_Expression).size() != 0)
126  {
127  std::cerr << "ERROR: At least one specified path within \"" << m_Parser->GetPathsAsString(m_Expression)
128  << "\" is invalid or doesn't exist..." << std::endl;
129  return false;
130  }
131  }
132 
133  this->LoadApplication();
134 
135  return true;
136 }
137 
139 {
140  if (this->BeforeExecute() == false)
141  {
142  return false;
143  }
144 
145  if( m_Application->Execute() == 0 )
146  {
147  this->DisplayOutputParameters();
148  return true;
149  }
150  else
151  return false;
152 }
153 
155 {
156  try
157  {
158  if (this->BeforeExecute() == false)
159  {
160  return false;
161  }
162 
163  if( m_Application->ExecuteAndWriteOutput() == 0 )
164  {
165  this->DisplayOutputParameters();
166  }
167  else
168  return false;
169  }
170  catch(std::exception& err)
171  {
172  std::ostringstream message;
173  message << "The following error occurred during application execution : " << err.what() << std::endl;
174  m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, message.str() );
175  return false;
176  }
177  catch(...)
178  {
179  m_Application->GetLogger()->Write( itk::LoggerBase::FATAL, "An unknown exception has been raised during application execution" );
180  return false;
181  }
182 
183  return true;
184 }
185 
187 {
188  if (m_Application.IsNull())
189  {
190  std::cerr << "ERROR: No loaded application..." << std::endl;
191  return false;
192  }
193 
194  // Check if there's keys in the expression if the application takes
195  // at least 1 mandatory parameter
196  const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
197  std::vector<std::string> keyList = m_Parser->GetKeyList( m_Expression );
198 
199  if( appKeyList.size()!=0 && keyList.size()==0 )
200  {
201  std::cerr << "ERROR: Waiting for at least one parameter..." << std::endl;
202  this->DisplayHelp();
203  return false;
204  }
205 
206  // if help is asked...
207  if (m_Parser->IsAttributExists("-help", m_Expression) == true)
208  {
209  this->DisplayHelp();
210  return false;
211  }
212 
213  // if we want to load test environnement
214  if (m_Parser->IsAttributExists("-testenv", m_Expression) == true)
215  {
216  this->LoadTestEnv();
217  }
218 
219  // Check the key validity (ie. exist in the application parameters)
220  std::string unknownKey;
221  if (this->CheckKeyValidity(unknownKey) == false)
222  {
223  std::cerr << "ERROR: option -"<<unknownKey<<" does not exist in the application." << std::endl;
224  this->DisplayHelp();
225  return false;
226  }
227  try
228  {
229  if (this->LoadParameters() != OKPARAM)
230  {
231  std::cerr << "ERROR: Troubles loading parameter, please check your line argument..." << std::endl;
232  // Force to reload the application, the LoadParameters can change wrong values
233  this->LoadApplication();
234  m_Application->Init();
235  this->DisplayHelp();
236 
237  return false;
238  }
239  }
240  catch (itk::ExceptionObject& err)
241  {
242  std::cerr << "ERROR: Troubles in parameter setting, please check your line argument..." << std::endl;
243  std::cerr << err.GetDescription() << std::endl;
244  // Force to reload the application, the LoadParameters can change wrong values
245  this->LoadApplication();
246  m_Application->Init();
247  this->DisplayHelp();
248 
249  return false;
250  }
251 
252  // Check for the progress report
253  if (m_Parser->IsAttributExists("-progress", m_Expression) == true)
254  {
255  std::vector<std::string> val;
256  val = m_Parser->GetAttribut("-progress", m_Expression);
257  if (val.size() != 1)
258  {
259  std::cerr << "ERROR: Invalid progress argument, must be unique value..." << std::endl;
260  return false;
261  }
262  if (val[0] == "1" || val[0] == "true")
263  {
264  m_ReportProgress = true;
265  }
266  else
267  if (val[0] == "0" || val[0] == "false")
268  {
269  m_ReportProgress = false;
270  }
271  else
272  {
273  std::cerr << "ERROR: Invalid progress argument, must be 0, 1, false or true..." << std::endl;
274  // Force to reload the application, the LoadParameters can change wrong values
275  this->LoadApplication();
276  this->DisplayHelp();
277 
278  return false;
279  }
280  }
281 
282  return true;
283 }
284 
286 {
287  std::vector<std::string> pathList;
288  // If users has set path...
289  if (m_Parser->GetPaths(pathList, m_Expression) == CommandLineParser::OK)
290  {
291  for (unsigned i = 0; i < pathList.size(); i++)
292  {
294  }
295  }
296  else
297  {
298  return false;
299  }
300 
301  return true;
302 }
303 
305 {
306  // Look for the module name
307  std::string moduleName;
308  if (m_Parser->GetModuleName(moduleName, m_Expression) != CommandLineParser::OK)
309  {
310  std::cerr << "ERROR: LoadApplication, no module found..." << std::endl;
311  return;
312  }
313 
314  // Instantiate the application using the factory
316 
317  if (m_Application.IsNull())
318  {
319  std::cerr << "ERROR: Could not find application \"" << moduleName << "\"" << std::endl;
320 
321  const char * ITK_AUTOLOAD_PATH = itksys::SystemTools::GetEnv("ITK_AUTOLOAD_PATH");
322  std::cerr << "ERROR: Module search path: " << (ITK_AUTOLOAD_PATH ? ITK_AUTOLOAD_PATH : "none (check ITK_AUTOLOAD_PATH)") << std::endl;
323 
324  std::vector<std::string> list = ApplicationRegistry::GetAvailableApplications();
325  if (list.size() == 0)
326  {
327  std::cerr << "ERROR: Available modules : none." << std::endl;
328  }
329  else
330  {
331  std::cerr << "ERROR: Available modules :" << std::endl;
332  for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
333  {
334  std::cerr << "\t" << *it << std::endl;
335  }
336  }
337  }
338  else
339  {
340  // Attach log output to the Application logger
341  m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
342  m_Application->GetLogger()->AddLogOutput(m_LogOutput);
343 
344  // Add an observer to the AddedProcess event
346 
347  }
348 }
349 
351 {
352  if (m_Application.IsNull())
353  {
354  itkExceptionMacro("No application loaded");
355  }
356 
357  const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
358  // Loop over each parameter key declared in the application
359  for (unsigned int i = 0; i < appKeyList.size(); i++)
360  {
361  const std::string paramKey(appKeyList[i]);
362  std::vector<std::string> values;
363  Parameter::Pointer param = m_Application->GetParameterByKey(paramKey);
364  ParameterType type = m_Application->GetParameterType(paramKey);
365 
366  const bool paramExists(m_Parser->IsAttributExists(std::string("-").append(paramKey), m_Expression));
367 
368  // if param is a Group, dont do anything, ParamGroup dont have values
369  if (type != ParameterType_Group)
370  {
371  // Get the attribute relative to this key as vector
372  values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_Expression);
373 
374  // If the param does not exists in the cli, dont try to set a
375  // value on it, an exception will be thrown later in this function
376  if (paramExists)
377  {
378  // Check if there is a value associated to the attribute
379  if ( values.empty() )
380  {
381  std::cerr << "ERROR: No value associated to the parameter : \"" << paramKey << "\", invalid number of values " << values.size() << std::endl;
382  return INVALIDNUMBEROFVALUE;
383  }
384 
385  // Ensure that the parameter is enabled
386  m_Application->EnableParameter(paramKey);
387 
389  {
390  dynamic_cast<InputVectorDataListParameter *> (param.GetPointer())->SetListFromFileName(values);
391  }
392  else
393  if (type == ParameterType_InputImageList)
394  {
395  dynamic_cast<InputImageListParameter *> (param.GetPointer())->SetListFromFileName(values);
396  }
397  else
399  {
400  dynamic_cast<InputFilenameListParameter *> (param.GetPointer())->SetListFromFileName(values);
401  }
402  else
403  if (type == ParameterType_StringList)
404  {
405  dynamic_cast<StringListParameter *> (param.GetPointer())->SetValue(values);
406  }
407  else
408  if (type == ParameterType_String)
409  {
410  dynamic_cast<StringParameter *> (param.GetPointer())->SetValue( m_Parser->GetAttributAsString(std::string("-").append(paramKey), m_Expression) );
411  }
412  else
413  if (type == ParameterType_OutputImage)
414  {
415  m_Application->SetParameterString(paramKey, values[0]);
416  // Check if pixel type is given
417  if (values.size() == 2)
418  {
420  if (values[1] == "uint8")
421  outPixType = ImagePixelType_uint8;
422  else if (values[1] == "int16")
423  outPixType = ImagePixelType_int16;
424  else if (values[1] == "uint16")
425  outPixType = ImagePixelType_uint16;
426  else if (values[1] == "int32")
427  outPixType = ImagePixelType_int32;
428  else if (values[1] == "uint32")
429  outPixType = ImagePixelType_uint32;
430  else if (values[1] == "float")
431  outPixType = ImagePixelType_float;
432  else if (values[1] == "double")
433  outPixType = ImagePixelType_double;
434  else
435  {
436  return WRONGPARAMETERVALUE;
437  }
438  dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType);
439  }
440  else
441  if (values.size() != 1 && values.size() != 2)
442  {
443  std::cerr << "ERROR: Invalid number of value for: \"" << paramKey << "\", invalid number of values " << values.size() << std::endl;
444  return INVALIDNUMBEROFVALUE;
445  }
446  }
447  else
448  if (type == ParameterType_ListView)
449  {
450  dynamic_cast<ListViewParameter *> (param.GetPointer())->SetSelectedNames(values);
451  }
452  else
453  if(values.size() != 1)
454  {
455  // Handle space in filename. Only for input
456  // files or directories
459  {
460  for(unsigned int i=1; i<values.size(); i++)
461  {
462  values[0].append(" ");
463  values[0].append(values[i]);
464  }
465  }
466  else if (!param->GetAutomaticValue())
467  {
468  std::cerr << "ERROR: Invalid number of value for: \"" << paramKey << "\", must have 1 value, not "
469  << values.size() << std::endl;
470  return INVALIDNUMBEROFVALUE;
471  }
472  }
473 
474  // Single value parameter
475  if (type == ParameterType_Choice || type == ParameterType_Float || type == ParameterType_Int || type
481  {
482  m_Application->SetParameterString(paramKey, values[0]);
483  }
484  else
485  if (type == ParameterType_Empty)
486  {
487  if (values[0] == "1" || values[0] == "true")
488  {
489  dynamic_cast<EmptyParameter *> (param.GetPointer())->SetActive(true);
490  }
491  else
492  if (values[0] == "0" || values[0] == "false")
493  {
494  dynamic_cast<EmptyParameter *> (param.GetPointer())->SetActive(false);
495  }
496  else
497  {
498  std::cerr << "ERROR: Wrong parameter value: " << paramKey << std::endl;
499  return WRONGPARAMETERVALUE;
500  }
501  }
502  // Update the flag UserValue
503  param->SetUserValue(true);
504  // Call the DoUpdateParameter to update dependant params
505  m_Application->UpdateParameters();
506  }
507  }
508 
509  // When a parameter is mandatory :
510  // it must be set if :
511  // - The param is root
512  // - The param is not root and belonging to a Mandatory Group
513  // wich is activated
514  bool mustBeSet = false;
515  const bool hasValue = m_Application->HasValue(paramKey);
516 
517  if( param->GetMandatory() == true && param->GetRole() != Role_Output && type != ParameterType_Group)
518  {
519  // check if the parameter is linked to a root parameter with a chain of active parameters
520  if( param->IsRoot() || param->GetRoot()->IsRoot())
521  {
522  // the parameter is a root or inside a group at root level
523  mustBeSet = true;
524  }
525  else
526  {
527  Parameter* currentParam = param->GetRoot();
528  while (!currentParam->IsRoot())
529  {
530  if (!currentParam->GetActive())
531  {
532  // the missing parameter is not on an active branch : we can ignore it
533  break;
534  }
535  currentParam = currentParam->GetRoot();
536 
537  if (currentParam->IsRoot())
538  {
539  // the missing parameter is on an active branch : we need it
540  mustBeSet = true;
541  }
542  }
543  }
544  }
545 
546  if( mustBeSet )
547  {
548  if (!paramExists)
549  {
550  // If key doesn't exist and parameter hasn't default value set...
551  if (!hasValue)
552  {
553  std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << " " << m_Application->HasValue(paramKey)
554  << std::endl;
556  }
557  }
558  else
559  {
560  values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_Expression);
561  if (values.size() == 0 && !m_Application->HasValue(paramKey))
562  {
563  std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << std::endl;
564  return MISSINGPARAMETERVALUE;
565  }
566  }
567  }
568 
569  // Check if non mandatory parameter have values
570  else
571  {
572  if( paramExists )
573  {
574  values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_Expression);
575  if (values.size() == 0)
576  {
577  std::cerr << "ERROR: Missing mandatory parameter: " << paramKey << std::endl;
578  return MISSINGPARAMETERVALUE;
579  }
580  }
581 
582  }
583  }
584  return OKPARAM;
585 }
586 
588 {
589  // Report the progress only if asked
590  if (m_ReportProgress)
591  {
592 
593  if (typeid(otb::Wrapper::AddProcessToWatchEvent) == typeid( event ))
594  {
595  const AddProcessToWatchEvent* eventToWacth = dynamic_cast<const AddProcessToWatchEvent*> (&event);
596 
598  eventToWacth->GetProcessDescription());
599  m_WatcherList.push_back(watch);
600  }
601  }
602 }
603 
605 {
606  std::cerr << std::endl;
607 
608  std::cerr << "This is the "<<m_Application->GetName() << " application."<<std::endl;
609  std::cerr<<std::endl;
610  std::cerr << m_Application->GetDescription() << std::endl;
611  std::cerr<<std::endl;
612  std::string link = "http://www.orfeo-toolbox.org/Applications/";
613  link.append(m_Application->GetName());
614  link.append(".html");
615 
616  std::cerr << "Complete documentation: " << link << std::endl;
617  std::cerr<<std::endl;
618  std::cerr << "Parameters: " << std::endl;
619 
620  const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
621  const unsigned int nbOfParam = appKeyList.size();
622 
623  m_MaxKeySize = std::string("progress").size();
624  for (unsigned int i = 0; i < nbOfParam; i++)
625  {
626  if (m_Application->GetParameterRole(appKeyList[i]) != Role_Output)
627  {
628  if( m_MaxKeySize < appKeyList[i].size() )
629  m_MaxKeySize = appKeyList[i].size();
630  }
631  }
632 
634  std::string bigKey = "progress";
635  for(unsigned int i=0; i<m_MaxKeySize-std::string("progress").size(); i++)
636  bigKey.append(" ");
637 
638  std::cerr << " -"<<bigKey<<" <boolean> Report progress " << std::endl;
639 
640  for (unsigned int i = 0; i < nbOfParam; i++)
641  {
642  Parameter::Pointer param = m_Application->GetParameterByKey(appKeyList[i]);
643  if (param->GetRole() != Role_Output)
644  {
645  std::cerr << this->DisplayParameterHelp(param, appKeyList[i]);
646  }
647  }
648 
649  std::cerr<<std::endl;
650  std::string cl(m_Application->GetCLExample());
651  std::cerr << m_Application->GetCLExample() << std::endl;
652 
653 }
654 
655 
657 {
658  //Set seed for rand and itk mersenne twister
659  //srand(1);
660  // itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(121212);
661 }
662 
663 
664 std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & param, const std::string paramKey)
665 {
666  // Display the type the type
667  ParameterType type = m_Application->GetParameterType(paramKey);
668 
669  // Discard Group parameters (they don't need a value)
670  if (type == ParameterType_Group)
671  {
672  return "";
673  }
674 
675  std::ostringstream oss;
676 
677  // When a parameter is mandatory :
678  // it must be set if :
679  // - The param is root
680  // - The param is not root and belonging to a Mandatory Group
681  // wich is activated
682  bool isMissing = false;
683  if (!m_Parser->IsAttributExists(std::string("-").append(paramKey), m_Expression))
684  {
685  if (!m_Application->HasValue(paramKey))
686  {
687  if( param->GetMandatory() && param->GetRole() != Role_Output )
688  {
689  if( param->IsRoot() || param->GetRoot()->IsRoot())
690  {
691  // the parameter is a root or inside a group at root level
692  isMissing = true;
693  }
694  else
695  {
696  Parameter* currentParam = param->GetRoot();
697  while (!currentParam->IsRoot())
698  {
699  if (!currentParam->GetActive())
700  {
701  // the missing parameter is not on an active branch : we can ignore it
702  break;
703  }
704  currentParam = currentParam->GetRoot();
705 
706  if (currentParam->IsRoot())
707  {
708  // the missing parameter is on an active branch : we need it
709  isMissing = true;
710  }
711  }
712  }
713  }
714  }
715  }
716 
717  if( isMissing )
718  {
719  oss << "MISSING ";
720  }
721  else
722  {
723  oss << " ";
724  }
725 
726  std::string bigKey = paramKey;
727  for(unsigned int i=0; i<m_MaxKeySize-paramKey.size(); i++)
728  bigKey.append(" ");
729 
730  oss<< "-" << bigKey << " ";
731 
732  // Display the type the parameter
733  if (type == ParameterType_Radius || type == ParameterType_Int || type == ParameterType_RAM)
734  {
735  oss << "<int32> ";
736  }
737  else if (type == ParameterType_Empty )
738  {
739  oss << "<boolean> ";
740  }
741  else if (type == ParameterType_Float)
742  {
743  oss << "<float> ";
744  }
747  type == ParameterType_String || type == ParameterType_Choice )
748  {
749  oss << "<string> ";
750  }
751  else if (type == ParameterType_OutputImage)
752  {
753  oss << "<string> [pixel]";
754  }
757  type == ParameterType_StringList )
758  {
759  oss << "<string list> ";
760  }
761  else
762  itkExceptionMacro("Not handled parameter type.");
763 
764 
765  oss<< " " << param->GetName() << " ";
766 
767  if (type == ParameterType_OutputImage)
768  {
769  oss << " [pixel=uint8/uint16/int16/uint32/int32/float/double]";
770  oss << " (default value is float)";
771  }
772 
773 
774  if (type == ParameterType_Choice)
775  {
776  std::vector<std::string> keys = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceKeys();
777  std::vector<std::string> names = dynamic_cast<ChoiceParameter*>(param.GetPointer())->GetChoiceNames();
778 
779  oss << "[";
780  for(unsigned int i=0; i<keys.size(); i++)
781  {
782  oss<<keys[i];
783  if( i != keys.size()-1 )
784  oss << "/";
785  }
786 
787  oss << "]";
788  }
789 
790  if(m_Application->IsMandatory(paramKey))
791  {
792  oss<<" (mandatory";
793  }
794  else
795  {
796  oss<<" (optional";
797 
798  if(m_Application->IsParameterEnabled(paramKey))
799  {
800  oss<<", on by default";
801  }
802  else
803  {
804  oss<<", off by default";
805  }
806  }
807 
808  if(m_Application->HasValue(paramKey))
809  {
810  oss<<", default value is "<<m_Application->GetParameterAsString(paramKey);
811  }
812  oss<<")";
813 
814  oss << std::endl;
815  return oss.str();
816 }
817 
819 {
820  bool res = true;
821  // Extract expression keys
822  std::vector<std::string> keyList = m_Parser->GetKeyList(m_Expression);
823 
824  // Check Unicity
825  for (unsigned int i = 0; i < keyList.size(); i++)
826  {
827  std::vector<std::string> listTmp = keyList;
828  const std::string keyRef = keyList[i];
829  listTmp.erase(listTmp.begin() + i);
830  for (unsigned int j = 0; j < listTmp.size(); j++)
831  {
832  if (keyRef == listTmp[j])
833  {
834  res = false;
835  break;
836  }
837  }
838  if (!res)
839  break;
840  }
841 
842  return res;
843 }
844 
846 {
847  bool res = true;
848  // Check if the chain " --" appears in the expression, could be a common mistake
849  if (m_Expression.find(" --") != std::string::npos )
850  {
851  res = false;
852  }
853 
854  return res;
855 }
856 
857 bool CommandLineLauncher::CheckKeyValidity(std::string& refKey)
858 {
859  bool res = true;
860  // Extract expression keys
861  std::vector<std::string> expKeyList = m_Parser->GetKeyList(m_Expression);
862 
863  // Extract application keys
864  std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
865  appKeyList.push_back("help");
866  appKeyList.push_back("progress");
867  appKeyList.push_back("testenv");
868 
869  // Check if each key in the expression exists in the application
870  for (unsigned int i = 0; i < expKeyList.size(); i++)
871  {
872  refKey = expKeyList[i];
873  bool keyExist = false;
874  for (unsigned int j = 0; j < appKeyList.size(); j++)
875  {
876  if (refKey == appKeyList[j])
877  {
878  keyExist = true;
879  break;
880  }
881  }
882  if (keyExist == false)
883  {
884  res = false;
885  break;
886  }
887  }
888 
889  return res;
890 }
891 
893 {
894  std::vector< std::pair<std::string, std::string> > paramList;
895  paramList = m_Application->GetOutputParametersSumUp();
896  if( paramList.size() == 0 )
897  return;
898 
899  std::ostringstream oss;
900  for( unsigned int i=0; i<paramList.size(); i++)
901  {
902  oss << paramList[i].first;
903  oss << ": ";
904  oss << paramList[i].second;
905  oss << std::endl;
906  }
907 
908 
909  if ( m_Parser->IsAttributExists("-testenv", m_Expression) )
910  {
911  std::vector<std::string> val = m_Parser->GetAttribut("-testenv", m_Expression);
912  if( val.size() == 1 )
913  {
914  std::ofstream ofs(val[0].c_str());
915  if (!ofs.is_open())
916  {
917  fprintf(stderr, "Error, can't open file");
918  itkExceptionMacro( << "Error, can't open file "<<val[0]<<".");
919  }
920  ofs << oss.str();
921  ofs.close();
922  }
923  }
924 
925  std::cout << "Output parameters value:" << std::endl;
926  std::cout << oss.str() << std::endl;
927 }
928 
929 }
930 }

Generated at Sun May 19 2013 01:01:44 for Orfeo Toolbox with doxygen 1.8.3.1