--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.6 BBG BlackBox Diagram file
+# - /Users/davila/Creatis/C24/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleImageSlabFilter.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+EXPORTFORMAT:0
+COMPLEXBOX:FALSE
+COMPLEXINPUTS:0
+BOXES:8
+BOX
+vtk:LoadHola:Box00
+ISEXEC:FALSE
+-13.385127:34.077248:-900.000000
+8.164873:31.577248:-900.000000
+FIN_BOX
+BOX
+creaVtk:ImageSlabFilter:Box01
+ISEXEC:FALSE
+4.760729:5.017080:-900.000000
+26.885729:2.517080:-900.000000
+PORT
+Size:"5"
+PORT
+Type:"3"
+FIN_BOX
+BOX
+wx:LayoutLine:Box02
+ISEXEC:FALSE
+-22.836297:-21.138336:-900.000000
+12.243703:-23.638336:-900.000000
+PORT
+Orientation:"H"
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box03
+ISEXEC:FALSE
+-43.199653:-2.361547:-900.000000
+0.680347:-4.861547:-900.000000
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box04
+ISEXEC:FALSE
+19.294175:-10.455184:-900.000000
+63.174175:-12.955184:-900.000000
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+wx:LayoutSplit:Box05
+ISEXEC:TRUE
+-0.843323:-38.207923:-900.000000
+23.676677:-40.707923:-900.000000
+PORT
+Orientation:"H"
+FIN_BOX
+BOX
+wx:LayoutLine:Box06
+ISEXEC:FALSE
+24.851805:-20.430932:-900.000000
+59.931805:-22.930932:-900.000000
+FIN_BOX
+BOX
+wx:Slider:Box07
+ISEXEC:FALSE
+27.335926:24.671393:-900.000000
+58.895926:22.171393:-900.000000
+PORT
+In:"2"
+PORT
+Label:"true"
+PORT
+Max:"20"
+PORT
+Min:"0"
+PORT
+ReactiveOnTrack:"true"
+PORT
+Title:"Mip size"
+FIN_BOX
+CONNECTIONS:10
+CONNECTION
+Box00:Out:Box01:In
+NumberOfControlPoints:0
+CONNECTION
+Box03:Widget:Box02:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box04:Widget:Box02:Widget4
+NumberOfControlPoints:0
+CONNECTION
+Box00:Out:Box03:In
+NumberOfControlPoints:0
+CONNECTION
+Box01:Out:Box04:In
+NumberOfControlPoints:0
+CONNECTION
+Box02:Widget:Box05:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box06:Widget:Box05:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box07:Widget:Box06:Widget3
+NumberOfControlPoints:0
+CONNECTION
+Box07:Out:Box01:Size
+NumberOfControlPoints:0
+CONNECTION
+Box07:BoxChange:Box04:BoxExecute
+NumberOfControlPoints:0
+APP_END
--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.6 BBS BlackBox Script
+# - /Users/davila/Creatis/C24/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleImageSlabFilter.bbs
+# ----------------------------------
+
+# BBTK GEditor Script
+# ----------------------
+
+include std
+include itkvtk
+include vtk
+include creaVtk
+include wx
+include creaMaracasVisu
+
+author "Author ??"
+description "Description ??"
+category "<VOID>"
+
+new vtk:LoadHola Box00
+
+new creaVtk:ImageSlabFilter Box01
+ set Box01.Size "5"
+ set Box01.Type "3"
+
+new wx:LayoutLine Box02
+ set Box02.Orientation "H"
+
+new creaMaracasVisu:ViewerNV Box03
+ set Box03.nTypeView "6 1 2 0"
+
+new creaMaracasVisu:ViewerNV Box04
+ set Box04.nTypeView "6 1 2 0"
+
+new wx:LayoutSplit Box05
+ set Box05.Orientation "H"
+
+new wx:LayoutLine Box06
+
+new wx:Slider Box07
+ set Box07.In "2"
+ set Box07.Label "true"
+ set Box07.Max "20"
+ set Box07.Min "0"
+ set Box07.ReactiveOnTrack "true"
+ set Box07.Title "Mip size"
+
+
+connect Box00.Out Box01.In
+
+connect Box03.Widget Box02.Widget2
+
+connect Box04.Widget Box02.Widget4
+
+connect Box00.Out Box03.In
+
+connect Box01.Out Box04.In
+
+connect Box02.Widget Box05.Widget1
+
+connect Box06.Widget Box05.Widget2
+
+connect Box07.Widget Box06.Widget3
+
+connect Box07.Out Box01.Size
+
+connect Box07.BoxChange Box04.BoxExecute
+
+
+
+# Complex input ports
+exec Box05
BBTK_DECLARE_OUTPUT(VoxelCount,int);
BBTK_PROCESS(Process);
void Process();
-
- vtkImageAccumulate *acc;
-
+ vtkImageAccumulate *acc;
//=====
// 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_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageSlab)
BBTK_BLACK_BOX_IMPLEMENTATION(ImageSlab,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 ImageSlab::Process()
{
-
// THE MAIN PROCESSING METHOD BODY
// Here we simply set the input 'In' value to the output 'Out'
// And print out the output value
// (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')
-
-// bbSetOutputOut( bbGetInputIn() );
-// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
-
if (firsttime==true)
{
firsttime=false;
imageSlab = vtkImageSlab::New();
}
-
if (bbGetInputType()==0) { imageSlab->SetOperationToMean(); }
if (bbGetInputType()==1) { imageSlab->SetOperationToSum(); }
if (bbGetInputType()==2) { imageSlab->SetOperationToMin(); }
if (bbGetInputType()==3) { imageSlab->SetOperationToMax(); }
imageSlab->MultiSliceOutputOff();
imageSlab->SetOutputScalarTypeToInputScalarType();
-
//EED 2017-01-01 Migration VTK7
#if VTK_MAJOR_VERSION <= 5
imageSlab->SetInput( bbGetInputIn() );
imageSlab->Update();
#endif
bbSetOutputOut( imageSlab->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 ImageSlab::bbUserSetDefaultValues()
{
-
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
-
firsttime=true;
bbSetInputIn(NULL);
bbSetInputType(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 ImageSlab::bbUserInitializeProcessing()
{
-
// THE INITIALIZATION METHOD BODY :
// Here does nothing
// but this is where you should allocate the internal/output pointers
-// if any
-
-
+// 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 ImageSlab::bbUserFinalizeProcessing()
{
-
// THE FINALIZATION METHOD BODY :
// Here does nothing
// but this is where you should desallocate the internal/output pointers
// if any
-
}
-}
-// EO namespace bbcreaVtk
+
+}// EO namespace bbcreaVtk
--- /dev/null
+//=====
+// 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 "bbcreaVtkImageSlabFilter.h"
+#include "bbcreaVtkPackage.h"
+
+#include <vtkExtractVOI.h>
+#include <vtkImageSlab.h>
+
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageSlabFilter)
+BBTK_BLACK_BOX_IMPLEMENTATION(ImageSlabFilter,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 ImageSlabFilter::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 (bbGetInputIn() != NULL)
+ {
+ int ext[6];
+ bbGetInputIn()->GetExtent(ext);
+ int dim[3];
+ dim[0] = ext[1]-ext[0]+1;
+ dim[1] = ext[3]-ext[2]+1;
+ dim[2] = ext[5]-ext[4]+1;
+ double spc[3];
+ bbGetInputIn()->GetSpacing(spc);
+
+ // Create resultImage
+ vtkImageData *imageoutput = vtkImageData::New();
+ imageoutput->Initialize();
+ imageoutput->SetSpacing( spc );
+ imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
+ imageoutput->AllocateScalars( bbGetInputIn()->GetScalarType(),1 );
+ imageoutput->Modified();
+
+ int start,end;
+ int i,sizeImg=dim[2];
+ for (i=0; i<sizeImg; i++)
+ {
+ // Define depth
+ start = i-bbGetInputSize();
+ end = i+bbGetInputSize();
+ if (start<0){ start=0; }
+ if (end>=sizeImg){ end=sizeImg-1; }
+
+ // voi
+ vtkExtractVOI *VOIfilter = vtkExtractVOI::New();
+ VOIfilter->SetInputData( bbGetInputIn() );
+ VOIfilter->SetVOI(0,dim[0],0,dim[1],start,end);
+ VOIfilter->Update();
+
+ // slab
+ vtkImageSlab *slabFilter = vtkImageSlab::New();
+ if (bbGetInputType()==0) { slabFilter->SetOperationToMean(); }
+ if (bbGetInputType()==1) { slabFilter->SetOperationToSum(); }
+ if (bbGetInputType()==2) { slabFilter->SetOperationToMin(); }
+ if (bbGetInputType()==3) { slabFilter->SetOperationToMax(); }
+ slabFilter->MultiSliceOutputOff();
+ slabFilter->SetOutputScalarTypeToInputScalarType();
+ slabFilter->SetInputData( VOIfilter->GetOutput() );
+ slabFilter->Update();
+ vtkImageData *slabImage= slabFilter->GetOutput();
+ // replace slice with slap
+ memcpy( (void*)imageoutput->GetScalarPointer(0,0,i) , (void*)slabImage->GetScalarPointer(0,0,0), dim[0] * dim[1] * imageoutput->GetScalarSize() );
+
+ // clean memory
+ VOIfilter->Delete();
+ slabFilter->Delete();
+ } // for i
+ bbSetOutputOut( imageoutput );
+ } // if In !=NULL
+
+}
+//=====
+// 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 ImageSlabFilter::bbUserSetDefaultValues()
+{
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputIn(NULL);
+ bbSetInputType(0);
+ bbSetInputSize(2);
+}
+
+//=====
+// 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 ImageSlabFilter::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 ImageSlabFilter::bbUserFinalizeProcessing()
+{
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+}
+
+}// EO namespace bbcreaVtk
+
+
--- /dev/null
+//=====
+// 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 __bbcreaVtkImageSlabFilter_h_INCLUDED__
+#define __bbcreaVtkImageSlabFilter_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include <vtkVersionMacros.h>
+#include <vtkImageData.h>
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT ImageSlabFilter
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(ImageSlabFilter,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(Type,int);
+ BBTK_DECLARE_INPUT(Size,int);
+ BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+ 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(ImageSlabFilter,bbtk::AtomicBlackBox);
+ BBTK_NAME("ImageSlabFilter");
+ BBTK_AUTHOR("Info-Dev");
+ BBTK_DESCRIPTION("Each slice is the result of the slab depth");
+ BBTK_CATEGORY("empty");
+ BBTK_INPUT(ImageSlabFilter,In,"Input image",vtkImageData*,"");
+ BBTK_INPUT(ImageSlabFilter,Type,"(0 default) 0 Mean, 1 Sum, 2 Min, 3 Max",int,"");
+ BBTK_INPUT(ImageSlabFilter,Size,"(2 default) depth=2*Size+1",int,"");
+ BBTK_OUTPUT(ImageSlabFilter,Out,"Output image",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ImageSlabFilter);
+//=====
+// 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 bbcreaVtk
+
+#endif // __bbcreaVtkImageSlabFilter_h_INCLUDED__
+