]> Creatis software - bbtk.git/commitdiff
no message
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 20 Jun 2011 17:35:57 +0000 (17:35 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 20 Jun 2011 17:35:57 +0000 (17:35 +0000)
packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbg [new file with mode: 0644]
packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbs [new file with mode: 0644]
packages/vtk/src/bbvtkExtractVtkImageFilter.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkExtractVtkImageFilter.h [new file with mode: 0644]
packages/vtk/src/bbvtkImageBoundaries.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkImageBoundaries.h [new file with mode: 0644]

diff --git a/packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbg b/packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbg
new file mode 100644 (file)
index 0000000..247081b
--- /dev/null
@@ -0,0 +1,135 @@
+# ----------------------------------
+# - BBTKGEditor v 1.2 BBG BlackBox Diagram file
+# - /Users/davila/Creatis/All3/creatools_source/bbtk/packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+COMPLEXBOX:TRUE
+COMPLEXBOXNAME:SaveMHD_infoCrop-Button
+PACKAGENAME:toolsbbtk
+COMPLEXINPUTS:3
+COMPLEX_PORT
+In
+13.155588:113.505792:900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+Index
+128.720814:110.072097:900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+Size
+171.274484:111.797246:900.000000
+FIN_COMPLEX_PORT
+COMPLEXOUTPUTS:1
+COMPLEX_PORT
+Widget
+55.433007:-170.289369:900.000000
+FIN_COMPLEX_PORT
+BOXES:8
+BOX
+wx:CommandButton:Box00
+ISEXEC:FALSE
+55.532017:70.768091:900.000000
+101.107017:60.768091:900.000000
+PORT
+Label:"Save Image (*.mhd and *.mhd_infoCrop)"
+FIN_BOX
+BOX
+vtk:MetaImageWriter:Box01
+ISEXEC:FALSE
+6.519549:-33.640764:900.000000
+52.094549:-43.640764:900.000000
+FIN_BOX
+BOX
+wx:FileSelector:Box02
+ISEXEC:FALSE
+204.375349:31.917108:900.000000
+249.950349:21.917108:900.000000
+PORT
+OpenSave:Save
+FIN_BOX
+BOX
+std:StringWriter:Box03
+ISEXEC:FALSE
+70.685585:-133.658604:900.000000
+116.260585:-143.658604:900.000000
+FIN_BOX
+BOX
+std:ConcatStrings:Box04
+ISEXEC:FALSE
+122.783824:-49.468839:900.000000
+168.358824:-59.468839:900.000000
+PORT
+In1:"Index "
+FIN_BOX
+BOX
+std:ConcatStrings:Box05
+ISEXEC:FALSE
+84.481569:-33.443405:900.000000
+130.056569:-43.443405:900.000000
+PORT
+In2:"_infoCrop"
+FIN_BOX
+BOX
+std:ConcatStrings:Box06
+ISEXEC:FALSE
+161.925261:-70.680749:900.000000
+207.500261:-80.680749:900.000000
+PORT
+In1:"Size "
+FIN_BOX
+BOX
+std:ConcatStrings:Box07
+ISEXEC:FALSE
+209.351337:-89.276824:900.000000
+254.926337:-99.276824:900.000000
+PORT
+In1:"FileName "
+FIN_BOX
+CONNECTIONS:14
+CONNECTION
+Box00:BoxChange:Box01:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:Box03:In0
+NumberOfControlPoints:0
+CONNECTION
+Box05:Out:Box03:FileName
+NumberOfControlPoints:0
+CONNECTION
+Box00:BoxChange:Box03:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box00:BoxChange:Box02:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box06:Out:Box03:In1
+NumberOfControlPoints:0
+CONNECTION
+Box02:Out:Box05:In1
+NumberOfControlPoints:0
+CONNECTION
+Box07:Out:Box03:In2
+NumberOfControlPoints:0
+CONNECTION
+Box02:Out:Box01:Filename
+NumberOfControlPoints:0
+CONNECTION
+Box02:Out:Box07:In2
+NumberOfControlPoints:0
+CONNECTION
+Box00:Widget:Widget:Widget
+NumberOfControlPoints:0
+CONNECTION
+In:In:Box01:In
+NumberOfControlPoints:0
+CONNECTION
+Size:Size:Box06:In2
+NumberOfControlPoints:0
+CONNECTION
+Index:Index:Box04:In2
+NumberOfControlPoints:0
+APP_END
diff --git a/packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbs b/packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbs
new file mode 100644 (file)
index 0000000..b3fe485
--- /dev/null
@@ -0,0 +1,62 @@
+# ----------------------------------
+# - BBTKGEditor v 1.2 BBS BlackBox Script (Complex Box)
+# - /Users/davila/Creatis/All3/creatools_source/bbtk/packages/toolsbbtk/bbs/boxes/SaveMHD_infoCrop-Button.bbs
+# ----------------------------------
+
+include std
+include itkvtk
+include wx
+include vtk
+include std
+
+define SaveMHD_infoCrop-Button toolsbbtk
+
+author "Author ??"
+description "Description ??"
+
+category "<VOID>"
+
+new CommandButton Box00
+  set Box00.Label "Save Image (*.mhd and *.mhd_infoCrop)"
+
+new MetaImageWriter Box01
+
+new FileSelector Box02
+  set Box02.OpenSave Save
+
+new StringWriter Box03
+
+new ConcatStrings Box04
+  set Box04.In1 "Index "
+
+new ConcatStrings Box05
+  set Box05.In2 "_infoCrop"
+
+new ConcatStrings Box06
+  set Box06.In1 "Size "
+
+new ConcatStrings Box07
+  set Box07.In1 "FileName "
+
+
+connect Box00.BoxChange Box01.BoxExecute
+connect Box04.Out Box03.In0
+connect Box05.Out Box03.FileName
+connect Box00.BoxChange Box03.BoxExecute
+connect Box00.BoxChange Box02.BoxExecute
+connect Box06.Out Box03.In1
+connect Box02.Out Box05.In1
+connect Box07.Out Box03.In2
+connect Box02.Out Box01.Filename
+connect Box02.Out Box07.In2
+
+
+# Complex input ports
+input In Box01.In " "
+input Size Box06.In2 " "
+input Index Box04.In2 " "
+
+# Complex output ports
+output Widget Box00.Widget " "
+
+endefine
diff --git a/packages/vtk/src/bbvtkExtractVtkImageFilter.cxx b/packages/vtk/src/bbvtkExtractVtkImageFilter.cxx
new file mode 100644 (file)
index 0000000..aed1148
--- /dev/null
@@ -0,0 +1,89 @@
+//===== 
+// 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 "bbvtkExtractVtkImageFilter.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ExtractVtkImageFilter)
+BBTK_BLACK_BOX_IMPLEMENTATION(ExtractVtkImageFilter,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 ExtractVtkImageFilter::Process()
+{
+       int voi[6];
+
+       voi[0] = bbGetInputIndex()[0];
+       voi[1] = bbGetInputIndex()[0]+bbGetInputSize()[0]-1;
+       voi[2] = bbGetInputIndex()[1];
+       voi[3] = bbGetInputIndex()[1]+bbGetInputSize()[1]-1;
+       voi[4] = bbGetInputIndex()[2];
+       voi[5] = bbGetInputIndex()[2]+bbGetInputSize()[2]-1;
+       
+       _extract->SetInput( bbGetInputIn() );
+       _extract->SetVOI(voi);  
+       _extract->UpdateWholeExtent();
+       _extract->Update();
+       bbSetOutputOut(_extract->GetOutput());
+}
+       
+//===== 
+// 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 ExtractVtkImageFilter::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+       
+       _extract =NULL;
+
+   bbSetInputIn(0);
+       
+       std::vector<int> tmpIndex;
+       tmpIndex.push_back(0);
+       tmpIndex.push_back(0);
+       tmpIndex.push_back(0);
+       std::vector<int> tmpSize;
+       tmpSize.push_back(1);
+       tmpSize.push_back(1);
+       tmpSize.push_back(1);
+       bbSetInputIndex(tmpIndex);
+       bbSetInputSize(tmpSize);
+       
+       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)
+//===== 
+void ExtractVtkImageFilter::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+       _extract = vtkExtractVOI::New();
+
+  
+}
+//===== 
+// 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 ExtractVtkImageFilter::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+
+       _extract->Delete();
+}
+}
+// EO namespace bbvtk
+
+
diff --git a/packages/vtk/src/bbvtkExtractVtkImageFilter.h b/packages/vtk/src/bbvtkExtractVtkImageFilter.h
new file mode 100644 (file)
index 0000000..8d8d2f5
--- /dev/null
@@ -0,0 +1,58 @@
+//===== 
+// 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 __bbvtkExtractVtkImageFilter_h_INCLUDED__
+#define __bbvtkExtractVtkImageFilter_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+
+
+#include <vtkImageData.h>
+#include <vtkExtractVOI.h>
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT ExtractVtkImageFilter
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(ExtractVtkImageFilter,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(Index,std::vector<int>);
+       BBTK_DECLARE_INPUT(Size,std::vector<int>);
+       BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+  BBTK_PROCESS(Process);
+  void Process();
+       
+private:       
+       vtkExtractVOI*  _extract;
+
+//===== 
+// 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(ExtractVtkImageFilter,bbtk::AtomicBlackBox);
+       BBTK_NAME("ExtractVtkImageFilter");
+       BBTK_AUTHOR("Info-Dev Creatis");
+       BBTK_DESCRIPTION("crop vtkImageData");
+       BBTK_CATEGORY("filter");
+       BBTK_INPUT(ExtractVtkImageFilter,In,"Input image",vtkImageData*,"");
+       BBTK_INPUT(ExtractVtkImageFilter,Index,"Index (start point of the region to be extracted)",std::vector<int>,"");
+       BBTK_INPUT(ExtractVtkImageFilter,Size,"Size of the region to be extracted",std::vector<int>,"");
+       BBTK_OUTPUT(ExtractVtkImageFilter,Out,"Output image",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ExtractVtkImageFilter);
+//===== 
+// 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 // __bbvtkExtractVtkImageFilter_h_INCLUDED__
+
diff --git a/packages/vtk/src/bbvtkImageBoundaries.cxx b/packages/vtk/src/bbvtkImageBoundaries.cxx
new file mode 100644 (file)
index 0000000..4f70560
--- /dev/null
@@ -0,0 +1,133 @@
+//===== 
+// 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 "bbvtkImageBoundaries.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImageBoundaries)
+BBTK_BLACK_BOX_IMPLEMENTATION(ImageBoundaries,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 ImageBoundaries::Process()
+{
+       printf("bbtk:vtk::ImageBoundaries::Process start\n");
+       if (bbGetInputIn()!=NULL){
+               int i,j,k;      
+               int ext[6];
+               double value;
+               
+               bbGetInputIn()->GetWholeExtent(ext);
+               int maxX        = ext[1]-ext[0]+1;
+               int maxY        = ext[3]-ext[2]+1;
+               int maxZ        = ext[5]-ext[4]+1;
+                               
+               int bXMax       = 0;
+               int bYMax       = 0;
+               int bZMax       = 0;
+               int bXMin       = maxX-1;
+               int bYMin       = maxY-1;
+               int bZMin       = maxZ-1;
+               
+               for (i=0 ; i<maxX ; i++)
+               {
+                       for (j=0 ; j<maxY ; j++)
+                       {
+                               for (k=0 ; k<maxZ ; k++)
+                               {
+                                       value = bbGetInputIn()->GetScalarComponentAsDouble(i, j, k,0);
+                                       if ( (value>=bbGetInputLowerValue()) && (value<=bbGetInputUpperValue())  )
+                                       {
+                                               if (i<bXMin) bXMin=i;
+                                               if (j<bYMin) bYMin=j;
+                                               if (k<bZMin) bZMin=k;
+                                               if (i>bXMax) bXMax=i;
+                                               if (j>bYMax) bYMax=j;
+                                               if (k>bZMax) bZMax=k;
+                                       }
+                               } // for k
+                       } // for j
+               } // i
+                       
+               std::vector<int> tmpIndex;              
+               std::vector<int> tmpSize;
+               
+               if (bXMin>bXMax){
+                       tmpIndex.push_back(0);
+                       tmpIndex.push_back(0);
+                       tmpIndex.push_back(0);
+                       tmpSize.push_back(1);
+                       tmpSize.push_back(1);
+                       tmpSize.push_back(1);
+               } else {
+                       tmpIndex.push_back(bXMin);
+                       tmpIndex.push_back(bYMin);
+                       tmpIndex.push_back(bZMin);
+                       tmpSize.push_back(bXMax-bXMin+1);
+                       tmpSize.push_back(bYMax-bYMin+1);
+                       tmpSize.push_back(bZMax-bZMin+1);
+               }
+                       
+               bbSetOutputIndex(tmpIndex);
+               bbSetOutputSize(tmpSize);
+       } else {
+               printf("bbtk warnning: bbtk:vtk:ImageBoundaries box, Input image (In) not initialized..\n");
+       }
+       printf("bbtk:vtk::ImageBoundaries::Process end\n");
+}
+//===== 
+// 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 ImageBoundaries::bbUserSetDefaultValues()
+{
+       
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+   bbSetInputIn(NULL);
+       bbSetInputLowerValue(0);
+       bbSetInputUpperValue(5000);
+  
+       std::vector<int> tmpIndex;
+       tmpIndex.push_back(0);
+       tmpIndex.push_back(0);
+       tmpIndex.push_back(0);
+
+       std::vector<int> tmpSize;
+       tmpSize.push_back(1);
+       tmpSize.push_back(1);
+       tmpSize.push_back(1);
+
+       bbSetOutputIndex(tmpIndex);
+       bbSetOutputSize(tmpSize);
+}
+//===== 
+// 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 ImageBoundaries::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 ImageBoundaries::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/bbvtkImageBoundaries.h b/packages/vtk/src/bbvtkImageBoundaries.h
new file mode 100644 (file)
index 0000000..b8b8590
--- /dev/null
@@ -0,0 +1,56 @@
+//===== 
+// 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 __bbvtkImageBoundaries_h_INCLUDED__
+#define __bbvtkImageBoundaries_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+
+#include <vtkImageData.h>
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT ImageBoundaries
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(ImageBoundaries,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(LowerValue,double);
+       BBTK_DECLARE_INPUT(UpperValue,double);
+       BBTK_DECLARE_OUTPUT(Index,std::vector<int>);
+       BBTK_DECLARE_OUTPUT(Size,std::vector<int>);
+  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(ImageBoundaries,bbtk::AtomicBlackBox);
+       BBTK_NAME("ImageBoundaries");
+       BBTK_AUTHOR("Info-Dev");
+       BBTK_DESCRIPTION("Get gray level boundaries of an vtkImageData");
+       BBTK_CATEGORY("filter");
+       BBTK_INPUT(ImageBoundaries,In,"Input image",vtkImageData*,"");
+       BBTK_INPUT(ImageBoundaries,LowerValue,"0 default. Lower gray level",double,"");
+       BBTK_INPUT(ImageBoundaries,UpperValue,"5000 default. Upper gray level",double,"");
+       BBTK_OUTPUT(ImageBoundaries,Index,"Start point of the boundarie",std::vector<int>,"");
+       BBTK_OUTPUT(ImageBoundaries,Size,"Size of the boundarie from start",std::vector<int>,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ImageBoundaries);
+//===== 
+// 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 // __bbvtkImageBoundaries_h_INCLUDED__
+