//===== // 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 "bbcreaVtkApplyMask.h" #include "bbcreaVtkPackage.h" #include "creaVtk_MACROS.h" namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ApplyMask) BBTK_BLACK_BOX_IMPLEMENTATION(ApplyMask,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 ApplyMask::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') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <GetExtent( extImage ); int dimXImage = extImage[1]-extImage[0]+1; int dimYImage = extImage[3]-extImage[2]+1; int dimZImage = extImage[5]-extImage[4]+1; int extMask[6]; bbGetInputImage()->GetExtent( extMask ); int dimXMask = extMask[1]-extMask[0]+1; int dimYMask = extMask[3]-extMask[2]+1; int dimZMask = extMask[5]-extMask[4]+1; if (bbGetOutputOut()!=NULL) { bbGetOutputOut()->Delete(); } vtkImageData *resultImage=NULL; resultImage = vtkImageData::New(); resultImage->Initialize(); resultImage->SetSpacing( bbGetInputImage()->GetSpacing() ); resultImage->SetDimensions( dimXImage, dimYImage, dimZImage ); resultImage->AllocateScalars( bbGetInputImage()->GetScalarType(),1 ); if ((dimXImage==dimXMask) && (dimYImage==dimYMask) && (dimZImage==dimZMask)) { long int i, size = dimXImage * dimYImage * dimZImage; #pragma omp parallel for for (i=0; i