From: Eduardo DAVILA Date: Mon, 22 Jul 2019 14:33:34 +0000 (+0200) Subject: #3280 BBTK Feature New Normal - MathOperation X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=fbfcf39b0f5c8b6e34cb251564df64974b656d31;p=bbtk.git #3280 BBTK Feature New Normal - MathOperation --- diff --git a/packages/std/src/bbstdMathOperation.cxx b/packages/std/src/bbstdMathOperation.cxx index fdedc10..ee22c24 100644 --- a/packages/std/src/bbstdMathOperation.cxx +++ b/packages/std/src/bbstdMathOperation.cxx @@ -85,6 +85,8 @@ void MathOperation::Process() 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) diff --git a/packages/std/src/bbstdMathOperation.h b/packages/std/src/bbstdMathOperation.h index 097545e..8d6d8ee 100644 --- a/packages/std/src/bbstdMathOperation.h +++ b/packages/std/src/bbstdMathOperation.h @@ -42,7 +42,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(MathOperation,bbtk::AtomicBlackBox); BBTK_CATEGORY("empty"); BBTK_INPUT(MathOperation,In1,"First input",double,""); BBTK_INPUT(MathOperation,In2,"Second input",double,""); - BBTK_INPUT(MathOperation,Type,"Type (defalult 0): 0 adition (default), 1 sustraction In1-In2, 2 multiplication In1*In2, 3 divisiuon In1/In2, 4 sqrt In1, 5 log In1, 6 exp In1, 7 incremental int [In1..In2], 8 random int [In1..In2], 9 sin In1-rad, 10 cos In1-rad, 11 tan In1-rad, 12 asin In 1, 13 acos In1, 14 atan In1, 15 atan2 In1 In2 , 16 min, 17 max, 18 abs In1, 19 module In1%In2 ",int,""); + BBTK_INPUT(MathOperation,Type,"Type (defalult 0): 0 adition (default), 1 sustraction In1-In2, 2 multiplication In1*In2, 3 divisiuon In1/In2, 4 sqrt In1, 5 log In1, 6 exp In1, 7 incremental int [In1..In2], 8 random int [In1..In2], 9 sin In1-rad, 10 cos In1-rad, 11 tan In1-rad, 12 asin In 1, 13 acos In1, 14 atan In1, 15 atan2 In1 In2 , 16 min, 17 max, 18 abs In1, 19 module In1%In2 , 20 lessThan In1In2",int,""); BBTK_OUTPUT(MathOperation,Out,"Output",double,""); BBTK_END_DESCRIBE_BLACK_BOX(MathOperation); diff --git a/packages/std/src/bbstdMathOperationVector.cxx b/packages/std/src/bbstdMathOperationVector.cxx index 454311f..f6d9309 100644 --- a/packages/std/src/bbstdMathOperationVector.cxx +++ b/packages/std/src/bbstdMathOperationVector.cxx @@ -415,7 +415,35 @@ void MathOperationVector::Process() resultVec.push_back( (int)bbGetInputIn0()[i] % (int)bbGetInputIn1()[i] ); } // for i bbSetOutputOut( resultVec ); - } // Type 18 + } // Type 19 + + if (bbGetInputType()==20) + { + for (i=0;i bbGetInputIn1()[i]) + { + resultVec.push_back( 1 ); + } else { + resultVec.push_back( 0 ); + } + } // for i + bbSetOutputOut( resultVec ); + } // Type 21 } diff --git a/packages/std/src/bbstdMathOperationVector.h b/packages/std/src/bbstdMathOperationVector.h index 7801557..7e8b0fe 100644 --- a/packages/std/src/bbstdMathOperationVector.h +++ b/packages/std/src/bbstdMathOperationVector.h @@ -63,7 +63,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(MathOperationVector,bbtk::AtomicBlackBox); BBTK_INPUT(MathOperationVector,In7,"Input vector 7",std::vector,""); BBTK_INPUT(MathOperationVector,In8,"Input vector 8",std::vector,""); BBTK_INPUT(MathOperationVector,In9,"Input vector 9",std::vector,""); - BBTK_INPUT(MathOperationVector,Type,"Type (defalult 0): 0 adition (default) In0[i]+In1[i]+..+In9[i], -99 adition In0[i] In1[i] ... In[9], 1 sustraction In0[i]-In1[i]-..-In9[i], 2 multiplication In0[i]*In2[i]*...*In9[i], 3 division In0/In1/.../In9, 4 sqrt In1, 5 log10 In1, 6 exp In1, 7 incremental int [In0..In1], 8 random int [In0..In1], 9 (rad) sin In0, 10 (rad) cos In0, 11 tan (rad) In0, 12 asin In0, 13 acos In0, 14 atan In0, 15 atan2 In0 In1 , 16 min (In0[i],In1[i]..In9[i]), -16 min(In0) min(In1) ... min(In9) , 17 max (In0[i],In1[i]..In9[i]), -17 max(In0) max(In1) ... max(In9) , 18 abs In0 , 19 module In0[i]%In1[i] " ,int,""); + BBTK_INPUT(MathOperationVector,Type,"Type (defalult 0): 0 adition (default) In0[i]+In1[i]+..+In9[i], -99 adition In0[i] In1[i] ... In[9], 1 sustraction In0[i]-In1[i]-..-In9[i], 2 multiplication In0[i]*In2[i]*...*In9[i], 3 division In0/In1/.../In9, 4 sqrt In1, 5 log10 In1, 6 exp In1, 7 incremental int [In0..In1], 8 random int [In0..In1], 9 (rad) sin In0, 10 (rad) cos In0, 11 tan (rad) In0, 12 asin In0, 13 acos In0, 14 atan In0, 15 atan2 In0 In1 , 16 min (In0[i],In1[i]..In9[i]), -16 min(In0) min(In1) ... min(In9) , 17 max (In0[i],In1[i]..In9[i]), -17 max(In0) max(In1) ... max(In9) , 18 abs In0 , 19 module In0[i]%In1[i] , 20 lessThan In0[i]In1[i] " ,int,""); BBTK_OUTPUT(MathOperationVector,Out,"Output vector",std::vector,""); diff --git a/packages/std/src/bbstdVectorFilterDouble.cxx b/packages/std/src/bbstdVectorFilterDouble.cxx index 85dee1f..63d2271 100644 --- a/packages/std/src/bbstdVectorFilterDouble.cxx +++ b/packages/std/src/bbstdVectorFilterDouble.cxx @@ -113,7 +113,7 @@ void VectorFilterDouble::Process() int ipLstvec2; double iLine; int sizeLines = (*pLstVec[0]).size(); - double step = (double)sizeLines/(double)bbGetInputk1(); + double step = (double)sizeLines/((double)bbGetInputk1()-1); for (iLine=0 ; iLine