From: eduardo.davila@creatis.insa-lyon.fr Date: Fri, 3 Oct 2025 11:49:30 +0000 (+0200) Subject: Clean code X-Git-Url: http://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a73f406712ce1065b361cc424a3eccd1f313592f;p=bbtk.git Clean code --- diff --git a/packages/std/src/bbstdFindOptimalParam.cxx b/packages/std/src/bbstdFindOptimalParam.cxx index 28bcdeb..dc71da3 100644 --- a/packages/std/src/bbstdFindOptimalParam.cxx +++ b/packages/std/src/bbstdFindOptimalParam.cxx @@ -23,12 +23,18 @@ std::string FindOptimalParam::Replace(std::string strCommand, double value) int FindOptimalParam::Evaluate( double value ) { - int result=-9999; - std::string strCommand = Replace( bbGetInputString(), value ); - strCommand=strCommand+" NameFileTransfer="+bbGetInputTransferFile(); - printf("EED FindOptimalParam::Evaluate command=%s\n", strCommand.c_str()); + int result = -9999; + std::string strCommand = Replace( bbGetInputString(), value ); + strCommand = strCommand+" NameFileTransfer="+bbGetInputTransferFile(); + +#ifdef __APPLE__ + strCommand = "source /Users/davila/.bashrc_CreaTools ;" + strCommand; +#endif + + printf("EED FindOptimalParam::Evaluate command=%s\n", strCommand.c_str()); + printf("EED FindOptimalParam::Evaluate start... \n", strCommand.c_str()); system( strCommand.c_str() ); - FILE *ff = fopen( bbGetInputTransferFile().c_str() , "r"); + FILE *ff = fopen( bbGetInputTransferFile().c_str() , "r"); if (ff!=NULL) { fscanf(ff,"%d",&result); @@ -36,10 +42,10 @@ int FindOptimalParam::Evaluate( double value ) printf("EED Warnning!! FindOptimalParam::Evaluate TransferFile not set.\n"); }// ff fclose(ff); + printf("EED FindOptimalParam::Evaluate ...end \n", strCommand.c_str()); return result; } - //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== @@ -93,46 +99,42 @@ void FindOptimalParam::Process() } while ( bbGetInputMinDifference() < (end-start) ); bbSetOutputResult(start); } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void FindOptimalParam::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputInitStart(0); bbSetInputInitEnd(100); bbSetInputString(""); bbSetInputMinDifference(1); - } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void FindOptimalParam::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// if any } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void FindOptimalParam::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } -} -// EO namespace bbstd + +}// EO namespace bbstd diff --git a/packages/std/src/bbstdFindOptimalParam.h b/packages/std/src/bbstdFindOptimalParam.h index 6add6fd..702c096 100644 --- a/packages/std/src/bbstdFindOptimalParam.h +++ b/packages/std/src/bbstdFindOptimalParam.h @@ -28,9 +28,8 @@ class bbstd_EXPORT FindOptimalParam BBTK_PROCESS(Process); void Process(); - std::string Replace(std::string command, double value); - int Evaluate( double value ); - + std::string Replace(std::string command, double value); + int Evaluate( double value ); //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) @@ -42,22 +41,18 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(FindOptimalParam,bbtk::AtomicBlackBox); BBTK_AUTHOR("InfoDev"); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(FindOptimalParam,InitStart,"Initial Start",double,""); BBTK_INPUT(FindOptimalParam,InitEnd,"(defalut 100) Initial End ",double,""); BBTK_INPUT(FindOptimalParam,MinDifference,"(default 1) Minimum (End-Start) to stop iteration ",double,""); BBTK_INPUT(FindOptimalParam,String,"String script evaluation (use 'XXvalueXX' to be optimice)",std::string,""); BBTK_INPUT(FindOptimalParam,TransferFile,"File to check the difference",std::string,""); - BBTK_OUTPUT(FindOptimalParam,Result,"Find optimal parameter",double,""); - - BBTK_END_DESCRIBE_BLACK_BOX(FindOptimalParam); //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== -} -// EO namespace bbstd + +}// EO namespace bbstd #endif // __bbstdFindOptimalParam_h_INCLUDED__