]> Creatis software - bbtk.git/commitdiff
1500 Feature
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 9 Jul 2012 16:15:06 +0000 (16:15 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 9 Jul 2012 16:15:06 +0000 (16:15 +0000)
  TemporaryPicker box

packages/vtk/src/bbvtkTemporalPicker.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkTemporalPicker.h [new file with mode: 0644]

diff --git a/packages/vtk/src/bbvtkTemporalPicker.cxx b/packages/vtk/src/bbvtkTemporalPicker.cxx
new file mode 100644 (file)
index 0000000..1633304
--- /dev/null
@@ -0,0 +1,126 @@
+//===== 
+// 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 "bbvtkTemporalPicker.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,TemporalPicker)
+BBTK_BLACK_BOX_IMPLEMENTATION(TemporalPicker,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 TemporalPicker::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')
+
+       
+       std::vector<double> result;
+       if (bbGetInputIn()!=NULL)
+       {
+               int ext[6];
+               int sizeX,sizeY,sizeZ;
+               bbGetInputIn()->GetWholeExtent(ext);
+               sizeX=ext[1]-ext[0]+1;
+               sizeY=ext[3]-ext[2]+1;
+               sizeZ=ext[5]-ext[4]+1;
+               
+               if (bbGetInputPoint().size()>=2)
+               {
+                       int px=bbGetInputPoint()[0];
+                       int py=bbGetInputPoint()[1]; 
+                       if ((px>=0) && (px<sizeX)  && (py>=0) && (py<sizeY) )
+                       {
+                               int i,j,k;
+                               int minX,maxX,minY,maxY;
+                               int acum=0,numElem=0;
+                               minX=px-bbGetInputSizeRegion()-1;
+                               maxX=px+bbGetInputSizeRegion()-1;
+                               minY=py-bbGetInputSizeRegion()-1;
+                               maxY=py+bbGetInputSizeRegion()-1;
+                               for (k=0;k<sizeZ;k++)
+                               {
+                                       for(i=minX;i<=maxX;i++)
+                                       { 
+                                               for(j=minY;j<=maxY;j++)
+                                               { 
+                                                       if ((i>=0) && (i<sizeX)  && (j>=0) && (j<sizeY) )
+                                                       { 
+                                                               acum = acum + bbGetInputIn()->GetScalarComponentAsDouble(i, j, k, 0);
+                                                               numElem++;
+                                                       }// i j
+                                               }// for j
+                                       } // for i
+                                       
+                                       if (numElem>0) 
+                                       {
+                                               result.push_back( acum/numElem );
+                                       } else {
+                                               result.push_back( 0 );
+                                       } // numElem
+                                       
+                               } // for k
+                       } // px py
+                       
+               } else {// bbGetInputPoint
+                       printf("ERROR:  Input:Point is not good defined in TemporalPicker Box..\n ");
+               } // bbGetInputPoint
+       } else {// bbGetInputIn
+               printf("ERROR:  Missing Input:In vtkImageData* in TemporalPicker Box..\n ");
+       } // bbGetInputIn
+               
+       bbSetOutputOut(result);
+}
+//===== 
+// 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 TemporalPicker::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+       bbSetInputIn(NULL);
+       bbSetInputSizeRegion(1);
+  
+}
+//===== 
+// 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 TemporalPicker::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 TemporalPicker::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbvtk
+
+
diff --git a/packages/vtk/src/bbvtkTemporalPicker.h b/packages/vtk/src/bbvtkTemporalPicker.h
new file mode 100644 (file)
index 0000000..170336b
--- /dev/null
@@ -0,0 +1,53 @@
+//===== 
+// 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 __bbvtkTemporalPicker_h_INCLUDED__
+#define __bbvtkTemporalPicker_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "vtkImageData.h"
+
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT TemporalPicker
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(TemporalPicker,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(In,vtkImageData*);
+    BBTK_DECLARE_INPUT(SizeRegion,int);
+    BBTK_DECLARE_INPUT(Point,std::vector<int>);
+       BBTK_DECLARE_OUTPUT(Out,std::vector<double>);
+  BBTK_PROCESS(Process);
+  void Process();
+//===== 
+// 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(TemporalPicker,bbtk::AtomicBlackBox);
+       BBTK_NAME("TemporalPicker");
+       BBTK_AUTHOR("Info-Dev");
+       BBTK_DESCRIPTION("Pick vector in Z direction");
+       BBTK_CATEGORY("");
+       BBTK_INPUT(TemporalPicker,In,"Input image",vtkImageData*,"");
+       BBTK_INPUT(TemporalPicker,SizeRegion,"Size region (default 1)",int,"");
+       BBTK_INPUT(TemporalPicker,Point,"Point [x,y]",std::vector<int>,"");
+       BBTK_OUTPUT(TemporalPicker,Out,"Output vector with Z information",std::vector<double>,"");
+BBTK_END_DESCRIBE_BLACK_BOX(TemporalPicker);
+//===== 
+// 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 bbvtk
+
+#endif // __bbvtkTemporalPicker_h_INCLUDED__
+
+