X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fstd%2Fsrc%2FbbstdMathOperation.cxx;h=fdedc101c8e7997c6978e0a25f7193d024df4e3a;hb=5d332eae2105106da042e76430b810b9efe95c81;hp=a4b7272d6d25dcee9c5216cf9efa8fe5193b13ae;hpb=03cc68dd6b831aa98e1e0fad20a977ffa074be39;p=bbtk.git diff --git a/packages/std/src/bbstdMathOperation.cxx b/packages/std/src/bbstdMathOperation.cxx index a4b7272..fdedc10 100644 --- a/packages/std/src/bbstdMathOperation.cxx +++ b/packages/std/src/bbstdMathOperation.cxx @@ -11,6 +11,7 @@ namespace bbstd { + BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MathOperation) BBTK_BLACK_BOX_IMPLEMENTATION(MathOperation,bbtk::AtomicBlackBox); //===== @@ -36,11 +37,14 @@ void MathOperation::Process() { firsttime=false; /* initialize random seed: */ - srand (time(NULL)); + srand (time(NULL)); if (bbGetInputType()==7) acum=bbGetInputIn1(); } - if (bbGetInputType()==0) bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() ); + if (bbGetInputType()==0) + { + bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() ); + } if (bbGetInputType()==1) bbSetOutputOut( bbGetInputIn1() - bbGetInputIn2() ); if (bbGetInputType()==2) bbSetOutputOut( bbGetInputIn1() * bbGetInputIn2() ); @@ -62,9 +66,12 @@ void MathOperation::Process() if (bbGetInputType()==7) { - bbSetOutputOut( acum ); - acum++; - if (acum>bbGetInputIn2()) acum=bbGetInputIn1(); + if ( back_acum_In1!=bbGetInputIn1() ) acum=bbGetInputIn1(); + if (acumbbGetInputIn2()) acum=bbGetInputIn1(); + back_acum_In1=bbGetInputIn1(); } if (bbGetInputType()==8 ) bbSetOutputOut( rand() % (int) (bbGetInputIn2()-bbGetInputIn1()) + bbGetInputIn1() ); if (bbGetInputType()==9 ) bbSetOutputOut( sin( bbGetInputIn1() ) ); @@ -74,9 +81,10 @@ void MathOperation::Process() if (bbGetInputType()==13) bbSetOutputOut( acos( bbGetInputIn1() ) ); if (bbGetInputType()==14) bbSetOutputOut( atan( bbGetInputIn1() ) ); if (bbGetInputType()==15) bbSetOutputOut( atan2( bbGetInputIn1(),bbGetInputIn2() ) ); - if (bbGetInputType()==16) bbSetOutputOut( fmin( bbGetInputIn1(),bbGetInputIn2() ) ); - if (bbGetInputType()==17) bbSetOutputOut( fmax( bbGetInputIn1(),bbGetInputIn2() ) ); + if (bbGetInputType()==16) bbSetOutputOut( std::min( bbGetInputIn1(),bbGetInputIn2() ) ); + if (bbGetInputType()==17) bbSetOutputOut( std::max( bbGetInputIn1(),bbGetInputIn2() ) ); if (bbGetInputType()==18) bbSetOutputOut( fabs( bbGetInputIn1() ) ); + if (bbGetInputType()==19) bbSetOutputOut( (int)bbGetInputIn1() % (int)bbGetInputIn2() ); } //===== // 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)