]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdMathOperation.cxx
#3280 BBTK Feature New Normal - MathOperation
[bbtk.git] / packages / std / src / bbstdMathOperation.cxx
index a4b7272d6d25dcee9c5216cf9efa8fe5193b13ae..ee22c24468cf353f5bb8429bf46f8046a796848a 100644 (file)
@@ -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 (acum<bbGetInputIn1()) acum=bbGetInputIn1();
+               bbSetOutputOut( acum );
+               acum++;
+               if (acum>bbGetInputIn2()) acum=bbGetInputIn1();
+               back_acum_In1=bbGetInputIn1();
         }
     if (bbGetInputType()==8 ) bbSetOutputOut( rand() %  (int) (bbGetInputIn2()-bbGetInputIn1()) +  bbGetInputIn1() );
     if (bbGetInputType()==9 ) bbSetOutputOut( sin( bbGetInputIn1() ) );
@@ -74,9 +81,12 @@ 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() );
+    if (bbGetInputType()==20) if (bbGetInputIn1()<(int)bbGetInputIn2()) { bbSetOutputOut(1); } else { bbSetOutputOut(0); } ;
+    if (bbGetInputType()==21) if (bbGetInputIn1()>(int)bbGetInputIn2()) { bbSetOutputOut(1); } else { bbSetOutputOut(0); } ;
 }
 //===== 
 // 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)