]> Creatis software - bbtk.git/commitdiff
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/bbtk
authorespinosa <Monica.Espinosa@creatis.insa-lyon.fr>
Wed, 25 Mar 2015 13:48:12 +0000 (14:48 +0100)
committerespinosa <Monica.Espinosa@creatis.insa-lyon.fr>
Wed, 25 Mar 2015 13:48:12 +0000 (14:48 +0100)
packages/std/src/bbstdMathOperation.cxx [new file with mode: 0644]
packages/std/src/bbstdMathOperation.h [new file with mode: 0644]
packages/std/src/bbstdReadColumnsString.cxx
packages/std/src/bbstdReadColumnsString.h
packages/vtk/src/bbvtkSurfaceTexture.cxx

diff --git a/packages/std/src/bbstdMathOperation.cxx b/packages/std/src/bbstdMathOperation.cxx
new file mode 100644 (file)
index 0000000..be243d7
--- /dev/null
@@ -0,0 +1,121 @@
+//===== 
+// 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)
+//===== 
+#include "bbstdMathOperation.h"
+#include "bbstdPackage.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <time.h>
+
+namespace bbstd
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MathOperation)
+BBTK_BLACK_BOX_IMPLEMENTATION(MathOperation,bbtk::AtomicBlackBox);
+//===== 
+// 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 MathOperation::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+
+        if (firsttime==true)
+        {
+               firsttime=false;
+      /* initialize random seed: */ 
+      srand (time(NULL));
+               if (bbGetInputType()==7) acum=bbGetInputIn1();
+        }
+
+    if (bbGetInputType()==0) bbSetOutputOut( bbGetInputIn1() +  bbGetInputIn2() );
+    if (bbGetInputType()==1) bbSetOutputOut( bbGetInputIn1() -  bbGetInputIn2() );
+    if (bbGetInputType()==2) bbSetOutputOut( bbGetInputIn1() *  bbGetInputIn2() );
+
+    if (bbGetInputType()==3)
+    {
+                        if (bbGetInputIn2()!=0)  bbSetOutputOut( bbGetInputIn1() /  bbGetInputIn2() );
+              else  bbSetOutputOut( 99999999 );
+    }
+
+    if (bbGetInputType()==4) bbSetOutputOut( sqrt( bbGetInputIn1() ) );
+
+    if (bbGetInputType()==5)
+        {
+                                if (bbGetInputIn2()>0)  bbSetOutputOut( log( bbGetInputIn1() ) );
+              else  bbSetOutputOut( -99999999 );
+        }
+
+    if (bbGetInputType()==6) bbSetOutputOut( exp( bbGetInputIn1() ) );
+    if (bbGetInputType()==7)
+        {
+                bbSetOutputOut( acum );
+                acum++;
+       if (acum>bbGetInputIn2()) acum=bbGetInputIn1();
+        }
+    if (bbGetInputType()==8) bbSetOutputOut( rand() %  (int) (bbGetInputIn2()-bbGetInputIn1()) +  bbGetInputIn1() );
+    if (bbGetInputType()==9) bbSetOutputOut( sin( bbGetInputIn1() ) );
+    if (bbGetInputType()==10) bbSetOutputOut( cos( bbGetInputIn1() ) );
+    if (bbGetInputType()==11) bbSetOutputOut( tan( bbGetInputIn1() ) );
+    if (bbGetInputType()==12) bbSetOutputOut( asin( bbGetInputIn1() ) );
+    if (bbGetInputType()==13) bbSetOutputOut( acos( bbGetInputIn1() ) );
+    if (bbGetInputType()==14) bbSetOutputOut( atan( bbGetInputIn1() ) );
+    if (bbGetInputType()==15) bbSetOutputOut( atan2( bbGetInputIn1(),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)
+//===== 
+void MathOperation::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+   bbSetInputIn1(0);
+   bbSetInputIn2(0);
+   bbSetInputType(0);
+
+   firsttime=true;
+   acum=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)
+//===== 
+void MathOperation::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    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 MathOperation::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbstd
+
+
diff --git a/packages/std/src/bbstdMathOperation.h b/packages/std/src/bbstdMathOperation.h
new file mode 100644 (file)
index 0000000..7ab7eb0
--- /dev/null
@@ -0,0 +1,54 @@
+//===== 
+// 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)
+//===== 
+#ifndef __bbstdMathOperation_h_INCLUDED__
+#define __bbstdMathOperation_h_INCLUDED__
+#include "bbstd_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbstd
+{
+
+class bbstd_EXPORT MathOperation
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(MathOperation,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+  BBTK_DECLARE_INPUT(In1,double);
+  BBTK_DECLARE_INPUT(In2,double);
+  BBTK_DECLARE_INPUT(Type,int);
+  BBTK_DECLARE_OUTPUT(Out,double);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  bool firsttime;
+  double acum;
+
+//===== 
+// 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)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(MathOperation,bbtk::AtomicBlackBox);
+  BBTK_NAME("MathOperation");
+  BBTK_AUTHOR("InfoDev");
+  BBTK_DESCRIPTION("No Description.");
+  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, 10 cos In1, 11 tan In1, 12 asin In 1, 13 acos In1, 14 atan In1, 15 atan2 In1,In2 ",int,"");
+
+  BBTK_OUTPUT(MathOperation,Out,"Output",double,"");
+BBTK_END_DESCRIBE_BLACK_BOX(MathOperation);
+//===== 
+// 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
+
+#endif // __bbstdMathOperation_h_INCLUDED__
+
index 6d9cfe5f3c37b055e60f7449ff3b18648660deb7..afcd636ac19ec6afaa37115cfe629624771fbd22 100644 (file)
@@ -55,12 +55,18 @@ void ReadColumnsString::Process()
                tlst.push_back( new std::vector<std::string> );
        }       
        
+       int iSkipLines;
        int numberOfLines = 0;
-       char tmpValue[50];
+       char tmpValue[500];
        std::vector<std::string> *vecData;
        FILE *ff1 = fopen( bbGetInputFileName().c_str() , "r+" );
        if (ff1!=NULL)
        {
+               for (iSkipLines=0;iSkipLines<bbGetInputSkipLines(); iSkipLines++ )
+      {
+         fgets( tmpValue , 500, ff1 ); 
+      }
+
                while (!feof(ff1))
                {
                        for( i=0 ;  i<bbGetInputDimension() ; i++)
@@ -99,6 +105,7 @@ void ReadColumnsString::bbUserSetDefaultValues()
 
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
+       bbSetInputSkipLines(0); 
        bbSetInputDimension(1); 
        bbSetInputFileName(""); 
   
index 09197bc3dd011e47c8811b882ce390d3e71a06ea..47f18e97d3594519ec4c12d65bc525766a0515fa 100644 (file)
@@ -46,6 +46,7 @@ class bbstd_EXPORT ReadColumnsString
 // 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)
 //===== 
        BBTK_DECLARE_INPUT(FileName,std::string);
+       BBTK_DECLARE_INPUT(SkipLines,int);      
        BBTK_DECLARE_INPUT(Dimension,int);      
        
        BBTK_DECLARE_OUTPUT(lstData1,std::vector<std::string> );
@@ -72,6 +73,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReadColumnsString,bbtk::AtomicBlackBox);
        BBTK_DESCRIPTION("Read Columns from a text file");
        BBTK_CATEGORY("read/write");
        BBTK_INPUT(ReadColumnsString,FileName,"File name of Points",std::string,"");
+       BBTK_INPUT(ReadColumnsString,SkipLines,"(default 0) - Number of lines to be skipe before read data",int,"");
        BBTK_INPUT(ReadColumnsString,Dimension,"(default 1) - The number of columns of the file",int,"");
        
        BBTK_OUTPUT(ReadColumnsString,lstData1,"vector of data",std::vector<std::string>,"");
index 12d32b03aeed898588478a3b1bc4693d72755962..f9f0139004ab1225690dc7d02e298cf080b962a6 100644 (file)
@@ -77,11 +77,6 @@ printf("EED SurfaceTexture::Process Start\n");
 
        }
 
-
-
-       
-
-
        bbGetInputMesh()->GetPointData()->SetScalars(colors);
 
        if (bbGetInputColorType()==1)
@@ -101,7 +96,7 @@ printf("EED SurfaceTexture::Process Start\n");
                bbGetInputTransform()->Update();
        }
        
-       unsigned short gl; 
+       double gl; 
        double p1[3];
        double p2[3];
        double dcolor[3];
@@ -145,9 +140,9 @@ void SurfaceTexture::bbUserSetDefaultValues()
        bbSetInputColorWindow(500);
        bbSetInputTransform(NULL);
   
-       firsttime               = true;
-       colors                  = NULL;
-       colorLookupTable        = NULL;
+       firsttime                               = true;
+       colors                                  = NULL;
+       colorLookupTable                = NULL;
        colorLookupTableWL      = NULL;
 }
 //=====