From 18672dfb84adfa7bc4f6c8cce678b7c78e1d90bf Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Mon, 9 Jul 2012 16:15:06 +0000 Subject: [PATCH] 1500 Feature TemporaryPicker box --- packages/vtk/src/bbvtkTemporalPicker.cxx | 126 +++++++++++++++++++++++ packages/vtk/src/bbvtkTemporalPicker.h | 53 ++++++++++ 2 files changed, 179 insertions(+) create mode 100644 packages/vtk/src/bbvtkTemporalPicker.cxx create mode 100644 packages/vtk/src/bbvtkTemporalPicker.h diff --git a/packages/vtk/src/bbvtkTemporalPicker.cxx b/packages/vtk/src/bbvtkTemporalPicker.cxx new file mode 100644 index 0000000..1633304 --- /dev/null +++ b/packages/vtk/src/bbvtkTemporalPicker.cxx @@ -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 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=0) && (py=0) && (i=0) && (jGetScalarComponentAsDouble(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 index 0000000..170336b --- /dev/null +++ b/packages/vtk/src/bbvtkTemporalPicker.h @@ -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); + BBTK_DECLARE_OUTPUT(Out,std::vector); + 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,""); + BBTK_OUTPUT(TemporalPicker,Out,"Output vector with Z information",std::vector,""); +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__ + + -- 2.47.1