X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fstd%2Fsrc%2FbbstdMathOperation.cxx;h=fdedc101c8e7997c6978e0a25f7193d024df4e3a;hb=433d792763e9cebb963243fbd49fff719f69ed4a;hp=68db44335898fdcdad1de2400d74a83f4e7de2cd;hpb=81cf34a7ea4edd0cef61258e6d65df60e80bbb6a;p=bbtk.git diff --git a/packages/std/src/bbstdMathOperation.cxx b/packages/std/src/bbstdMathOperation.cxx index 68db443..fdedc10 100644 --- a/packages/std/src/bbstdMathOperation.cxx +++ b/packages/std/src/bbstdMathOperation.cxx @@ -37,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() ); @@ -63,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() ) ); @@ -78,6 +84,7 @@ void MathOperation::Process() 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)