From: Eduardo DAVILA Date: Wed, 8 Mar 2017 09:07:04 +0000 (+0100) Subject: #3069 creaVtk Feature New Normal - new box bbcreaVtkImageExtractComponents X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e4e46361bd0186fcf85cc2b17e54cf65f0b0cca8;p=creaVtk.git #3069 creaVtk Feature New Normal - new box bbcreaVtkImageExtractComponents --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.cxx new file mode 100644 index 0000000..d899905 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.cxx @@ -0,0 +1,124 @@ +//===== +// 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 "bbcreaVtkImageExtractComponents.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageExtractComponents) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageExtractComponents,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 ImageExtractComponents::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 = " <SetInput( bbGetInputIn() ); + IEC0->SetComponents( bbGetInputComponent0() ); + IEC0->Update(); + bbSetOutputOut0( IEC0->GetOutput() ); + } + + if (bbGetInputComponent1()!=-1) + { + IEC1->SetInput( bbGetInputIn() ); + IEC1->SetComponents( bbGetInputComponent1() ); + IEC1->Update(); + bbSetOutputOut1( IEC1->GetOutput() ); + } + + if (bbGetInputComponent2()!=-1) + { + IEC2->SetInput( bbGetInputIn() ); + IEC2->SetComponents( bbGetInputComponent2() ); + IEC2->Update(); + bbSetOutputOut2( IEC2->GetOutput() ); + } + + if (bbGetInputComponent3()!=-1) + { + IEC3->SetInput( bbGetInputIn() ); + IEC3->SetComponents( bbGetInputComponent2() ); + IEC3->Update(); + bbSetOutputOut3( IEC3->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 ImageExtractComponents::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(NULL); + bbSetInputComponent0(-1); + bbSetInputComponent1(-1); + bbSetInputComponent2(-1); + bbSetInputComponent3(-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 ImageExtractComponents::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + IEC0=vtkImageExtractComponents::New(); + IEC1=vtkImageExtractComponents::New(); + IEC2=vtkImageExtractComponents::New(); + IEC3=vtkImageExtractComponents::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 ImageExtractComponents::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + + IEC0->Delete(); + IEC1->Delete(); + IEC2->Delete(); + IEC3->Delete(); + +} + + +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.h new file mode 100644 index 0000000..674e114 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.h @@ -0,0 +1,68 @@ +//===== +// 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 __bbcreaVtkImageExtractComponents_h_INCLUDED__ +#define __bbcreaVtkImageExtractComponents_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ImageExtractComponents + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageExtractComponents,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(Component0,int); + BBTK_DECLARE_INPUT(Component1,int); + BBTK_DECLARE_INPUT(Component2,int); + BBTK_DECLARE_INPUT(Component3,int); + BBTK_DECLARE_OUTPUT(Out0,vtkImageData *); + BBTK_DECLARE_OUTPUT(Out1,vtkImageData *); + BBTK_DECLARE_OUTPUT(Out2,vtkImageData *); + BBTK_DECLARE_OUTPUT(Out3,vtkImageData *); + BBTK_PROCESS(Process); + void Process(); + + + vtkImageExtractComponents* IEC0; + vtkImageExtractComponents* IEC1; + vtkImageExtractComponents* IEC2; + vtkImageExtractComponents* IEC3; +//===== +// 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(ImageExtractComponents,bbtk::AtomicBlackBox); + BBTK_NAME("ImageExtractComponents"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ImageExtractComponents,In,"Input image",vtkImageData*,""); + BBTK_INPUT(ImageExtractComponents,Component0,"Component 0 (default -1)",int,""); + BBTK_INPUT(ImageExtractComponents,Component1,"Component 1 (default -1)",int,""); + BBTK_INPUT(ImageExtractComponents,Component2,"Component 2 (default -1)",int,""); + BBTK_INPUT(ImageExtractComponents,Component3,"Component 3 (default -1)",int,""); + BBTK_OUTPUT(ImageExtractComponents,Out0,"Output image 0",vtkImageData*,""); + BBTK_OUTPUT(ImageExtractComponents,Out1,"Output image 1",vtkImageData*,""); + BBTK_OUTPUT(ImageExtractComponents,Out2,"Output image 2",vtkImageData*,""); + BBTK_OUTPUT(ImageExtractComponents,Out3,"Output image 3",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageExtractComponents); +//===== +// 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 // __bbcreaVtkImageExtractComponents_h_INCLUDED__ + diff --git a/lib/creaVtk/vtkImageDataStrucPoints.cpp b/lib/creaVtk/vtkImageDataStrucPoints.cpp index 44c33a3..5ccc9d8 100644 --- a/lib/creaVtk/vtkImageDataStrucPoints.cpp +++ b/lib/creaVtk/vtkImageDataStrucPoints.cpp @@ -52,9 +52,9 @@ void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX, vtkImageData* imageY->GetSpacing(spc); - double *ptrUCharX = (double *)imageX->GetScalarPointer(); - double *ptrUCharY = (double *)imageY->GetScalarPointer(); - double *ptrUCharZ = (double *)imageZ->GetScalarPointer(); + double *ptrX = (double *)imageX->GetScalarPointer(); + double *ptrY = (double *)imageY->GetScalarPointer(); + double *ptrZ = (double *)imageZ->GetScalarPointer(); long int sizeimage = dim[0]*dim[1]*dim[2]; @@ -70,16 +70,16 @@ void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX, vtkImageData* int i; -printf("EED vtkImageDataStrucPoints::joinComponents sizeimage%d\n", sizeimage ); +printf("EED vtkImageDataStrucPoints::joinComponents sizeimage %d\n", sizeimage ); for( i = 0 ; i < sizeimage ; i++ ) { - vx = *ptrUCharX; - vy = *ptrUCharY; - vz = *ptrUCharZ; - ptrUCharX++; - ptrUCharY++; - ptrUCharZ++; - array->SetTuple3(i,vx, vy , vz ); + vx = *ptrX; + vy = *ptrY; + vz = *ptrZ; + ptrX++; + ptrY++; + ptrZ++; + array->SetTuple3(i,vx, vy , vz ); } // for i _structuredPoints = vtkStructuredPoints::New(); @@ -94,7 +94,6 @@ printf("EED vtkImageDataStrucPoints::joinComponents sizeimage%d\n", sizeimage /* _structuredPoints->Print(cout); - vtkStructuredPointsWriter *writer2 = vtkStructuredPointsWriter::New(); writer2->SetFileName("/home/davila/tmp/VectorfromCal_EED_ups.vtk"); //writer->SetFileTypeToBinary();