From 5aadf601c2cac6a4b998840f66fef9ba26ae67cd Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Mon, 18 Apr 2011 20:35:59 +0000 Subject: [PATCH] no message --- packages/vtk/src/bbvtkCreateImage.cxx | 131 ++++++++++++++++++ packages/vtk/src/bbvtkCreateImage.h | 64 +++++++++ .../vtk/src/bbvtkRescaleSlopeIntercept.cxx | 2 +- packages/vtk/src/bbvtkRescaleSlopeIntercept.h | 2 +- 4 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 packages/vtk/src/bbvtkCreateImage.cxx create mode 100644 packages/vtk/src/bbvtkCreateImage.h diff --git a/packages/vtk/src/bbvtkCreateImage.cxx b/packages/vtk/src/bbvtkCreateImage.cxx new file mode 100644 index 0000000..f4fff37 --- /dev/null +++ b/packages/vtk/src/bbvtkCreateImage.cxx @@ -0,0 +1,131 @@ +//===== +// 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 "bbvtkCreateImage.h" +#include "bbvtkPackage.h" +namespace bbvtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,CreateImage) +BBTK_BLACK_BOX_IMPLEMENTATION(CreateImage,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 CreateImage::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') + + + double spc[6]; + int dim[3]; + int outputformat = VTK_UNSIGNED_SHORT; + + if (bbGetInputOutputFormat()=="VTK_BIT") outputformat = VTK_BIT; + else if (bbGetInputOutputFormat()=="VTK_CHAR") outputformat = VTK_CHAR; + else if (bbGetInputOutputFormat()=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR; + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR; + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT; + else if (bbGetInputOutputFormat()=="VTK_INT") outputformat = VTK_INT; + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT; + else if (bbGetInputOutputFormat()=="VTK_LONG") outputformat = VTK_LONG; + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG; + else if (bbGetInputOutputFormat()=="VTK_FLOAT") outputformat = VTK_FLOAT; + else if (bbGetInputOutputFormat()=="VTK_DOUBLE") outputformat = VTK_DOUBLE; + + spc[0] = bbGetInputSpacing()[0]; + spc[1] = bbGetInputSpacing()[1]; + spc[2] = bbGetInputSpacing()[2]; + + dim[0] = bbGetInputDimensions()[0]; + dim[1] = bbGetInputDimensions()[1]; + dim[2] = bbGetInputDimensions()[2]; + + imageoutput->Initialize(); + imageoutput->SetScalarType( outputformat ); + imageoutput->SetSpacing( spc ); + imageoutput->SetDimensions( dim[0], dim[1], dim[2] ); + imageoutput->AllocateScalars(); + + + int i,j,k; + for (i=0; iSetScalarComponentFromDouble(i,j,k, 0, bbGetInputInitialValue() ); + } // for k + } // for j + } // for i + + bbSetOutputOut(imageoutput); + +} + +//===== +// 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 CreateImage::bbUserSetDefaultValues() +{ + imageoutput=NULL; + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX + std::vector dim; + dim.push_back(250); + dim.push_back(250); + dim.push_back(250); + std::vector spc; + dim.push_back(1.0); + dim.push_back(1.0); + dim.push_back(1.0); + + bbSetInputDimensions(dim); + bbSetInputSpacing(spc); + bbSetInputOutputFormat("VTK_UNSIGNED_SHORT"); + bbSetInputInitialValue(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 CreateImage::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + imageoutput = vtkImageData::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 CreateImage::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + imageoutput->Delete(); + +} +} +// EO namespace bbvtk + + diff --git a/packages/vtk/src/bbvtkCreateImage.h b/packages/vtk/src/bbvtkCreateImage.h new file mode 100644 index 0000000..4d23d1c --- /dev/null +++ b/packages/vtk/src/bbvtkCreateImage.h @@ -0,0 +1,64 @@ +//===== +// 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 __bbvtkCreateImage_h_INCLUDED__ +#define __bbvtkCreateImage_h_INCLUDED__ +#include "bbvtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include +#include + + +#include "vtkImageData.h" + +namespace bbvtk +{ + +class bbvtk_EXPORT CreateImage + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(CreateImage,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(Dimensions,std::vector); + BBTK_DECLARE_INPUT(Spacing,std::vector); + BBTK_DECLARE_INPUT(OutputFormat,std::string); + BBTK_DECLARE_INPUT(InitialValue,double); + BBTK_DECLARE_OUTPUT(Out,vtkImageData *); + BBTK_PROCESS(Process); + void Process(); + + vtkImageData* imageoutput; + + +//===== +// 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(CreateImage,bbtk::AtomicBlackBox); + + BBTK_NAME("CreateImage"); + BBTK_AUTHOR("Info-Dev"); + BBTK_DESCRIPTION("Create a new vtkImageData"); + BBTK_CATEGORY("Filter"); + + BBTK_INPUT(CreateImage,Dimensions,"[SizeX SizeY SizeZ] of the image ([250 250 250] default)",std::vector,""); + BBTK_INPUT(CreateImage,Spacing,"[SpcX SpcY SpcZ] of the image ([1 1 1] default)",std::vector,""); + BBTK_INPUT(CreateImage,OutputFormat,"Image output format: VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR, VTK_SHORT VTK_UNSIGNED_SHORT (default), VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_FLOAT, VTK_DOUBLE",std::string,""); + BBTK_INPUT(CreateImage,InitialValue,"Initial value inside the image (0 default)",double,""); + + BBTK_OUTPUT(CreateImage,Out,"Output vtkImageData",vtkImageData*,""); + +BBTK_END_DESCRIBE_BLACK_BOX(CreateImage); +//===== +// 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 // __bbvtkCreateImage_h_INCLUDED__ + diff --git a/packages/vtk/src/bbvtkRescaleSlopeIntercept.cxx b/packages/vtk/src/bbvtkRescaleSlopeIntercept.cxx index 3fcedd1..8e9ea4c 100644 --- a/packages/vtk/src/bbvtkRescaleSlopeIntercept.cxx +++ b/packages/vtk/src/bbvtkRescaleSlopeIntercept.cxx @@ -146,7 +146,7 @@ void RescaleSlopeIntercept::bbUserFinalizeProcessing() // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - + imageoutput->Delete(); } } // EO namespace bbvtk diff --git a/packages/vtk/src/bbvtkRescaleSlopeIntercept.h b/packages/vtk/src/bbvtkRescaleSlopeIntercept.h index 58d535e..e782963 100644 --- a/packages/vtk/src/bbvtkRescaleSlopeIntercept.h +++ b/packages/vtk/src/bbvtkRescaleSlopeIntercept.h @@ -47,7 +47,7 @@ BBTK_INPUT(RescaleSlopeIntercept,In,"Image input",vtkImageData*,""); BBTK_INPUT(RescaleSlopeIntercept,Type,"type of operation: 0 (default) SlopeIntercept np=p*A+B, 1 Invert, 2 Redimension A=newMin B=newMax, 3 InvertRedimension A=newMin B=newMax",int,""); BBTK_INPUT(RescaleSlopeIntercept,A,"(1 default) see Type description",double,""); BBTK_INPUT(RescaleSlopeIntercept,B,"(0 default) see Type description",double,""); -BBTK_INPUT(RescaleSlopeIntercept,OutputFormat,"Image output format: SAME (default), VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR VTK_SHORT VTK_UNSIGNED_SHORT, VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_FLOAT, VTK_DOUBLE",std::string,""); +BBTK_INPUT(RescaleSlopeIntercept,OutputFormat,"Image output format: SAME (default), VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR, VTK_SHORT VTK_UNSIGNED_SHORT, VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_FLOAT, VTK_DOUBLE",std::string,""); BBTK_OUTPUT(RescaleSlopeIntercept,Out,"Image output",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(RescaleSlopeIntercept); //===== -- 2.45.1