From 0d5215ddb4f879862e52ed4910e78f0fd0cb8863 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 29 Jan 2020 11:53:07 +0100 Subject: [PATCH] #3353 creaVtk Feature New Normal - box MultipleOperations --- .../src/bbcreaVtkMultipleOperations.cxx | 120 ++++++++++++++++++ .../src/bbcreaVtkMultipleOperations.h | 50 ++++++++ 2 files changed, 170 insertions(+) create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.h diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.cxx new file mode 100644 index 0000000..edd549d --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.cxx @@ -0,0 +1,120 @@ +//===== +// 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 "bbcreaVtkMultipleOperations.h" +#include "bbcreaVtkPackage.h" + +#include "creaVtk_MACROS.h" + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MultipleOperations) +BBTK_BLACK_BOX_IMPLEMENTATION(MultipleOperations,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 MultipleOperations::Process() +{ +printf("EED MultipleOperations::Process Start\n"); +// 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 ( bbGetInputInLst().size()>0 ) + { + int extImage[6]; + vtkImageData *resultImage=NULL; + bbGetInputInLst()[0]->GetExtent( extImage ); + int dimXImage = extImage[1]-extImage[0]+1; + int dimYImage = extImage[3]-extImage[2]+1; + int dimZImage = extImage[5]-extImage[4]+1; + int iLst,sizeLst= bbGetInputInLst().size(); + if (bbGetOutputOut()!=NULL) + { + bbGetOutputOut()->Delete(); + } + resultImage = vtkImageData::New(); + resultImage->Initialize(); + resultImage->SetSpacing( bbGetInputInLst()[0]->GetSpacing() ); + resultImage->SetDimensions( dimXImage, dimYImage, dimZImage ); + resultImage->AllocateScalars( bbGetInputInLst()[0]->GetScalarType(),1 ); + long int index,size=dimXImage*dimYImage*dimZImage; + if (bbGetInputType()==20) + { + DEF_POINTER_IMAGE_VTK_CREA(vIn ,ssIn ,pIn ,stIn ,bbGetInputInLst()[0] ) + DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,resultImage ) + double vInBack,acumDiff; +// #pragma omp parallel for + for (index=0;indexGetScalarPointer() ); + GETVALUE2_VTK_CREA(vIn,pIn,stIn,index) + if (iLst!=0) + { + acumDiff = acumDiff+abs(vIn-vInBack); + } + vInBack=vIn; + } // for iLst + acumDiff = acumDiff/sizeLst; + SETVALUE2_VTK_CREA(acumDiff,pOut,stOut,index) + } // for index + } // if Type==20 + bbSetOutputOut( resultImage ); + } // if InLst size +printf("EED MultipleOperations::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 MultipleOperations::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + + bbSetInputType(0); + bbSetOutputOut(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 MultipleOperations::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 MultipleOperations::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.h new file mode 100644 index 0000000..44fc699 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.h @@ -0,0 +1,50 @@ +//===== +// 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 __bbcreaVtkMultipleOperations_h_INCLUDED__ +#define __bbcreaVtkMultipleOperations_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT MultipleOperations + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(MultipleOperations,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(InLst,std::vector); + BBTK_DECLARE_INPUT(Type,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(MultipleOperations,bbtk::AtomicBlackBox); + BBTK_NAME("MultipleOperations"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(MultipleOperations,InLst,"List input images ",std::vector,""); + BBTK_INPUT(MultipleOperations,Type,"(default 0) 0, 20 diff ",int,""); + BBTK_OUTPUT(MultipleOperations,Out,"Output image",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(MultipleOperations); +//===== +// 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 // __bbcreaVtkMultipleOperations_h_INCLUDED__ + -- 2.47.1