]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorreyes <reyes>
Tue, 14 Jun 2011 16:48:03 +0000 (16:48 +0000)
committerreyes <reyes>
Tue, 14 Jun 2011 16:48:03 +0000 (16:48 +0000)
17 files changed:
packages/vtk/src/bbvtkBinaryOperations.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkBinaryOperations.h [new file with mode: 0644]
packages/vtk/src/bbvtkCSVReader.cxx [new file with mode: 0755]
packages/vtk/src/bbvtkCSVReader.h [new file with mode: 0755]
packages/vtk/src/bbvtkElementTypeChanger.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkImageToPlainText.cxx [new file with mode: 0755]
packages/vtk/src/bbvtkImageToPlainText.h [new file with mode: 0755]
packages/vtk/src/bbvtkPolyDataReaderPlus.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkPolyDataReaderPlus.h [new file with mode: 0644]
packages/vtk/src/bbvtkPolyDataWriterPlus.cxx [new file with mode: 0755]
packages/vtk/src/bbvtkPolyDataWriterPlus.cxx~ [new file with mode: 0644]
packages/vtk/src/bbvtkPolyDataWriterPlus.h [new file with mode: 0755]
packages/vtk/src/bbvtkPolyDataWriterPlus.h~ [new file with mode: 0644]
packages/vtk/src/bbvtkSliceImage.cxx [new file with mode: 0755]
packages/vtk/src/bbvtkSliceImage.h [new file with mode: 0755]
packages/vtk/src/bbvtkUnaryOperations.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkUnaryOperations.h [new file with mode: 0644]

diff --git a/packages/vtk/src/bbvtkBinaryOperations.cxx b/packages/vtk/src/bbvtkBinaryOperations.cxx
new file mode 100644 (file)
index 0000000..748357b
--- /dev/null
@@ -0,0 +1,137 @@
+#include "bbvtkBinaryOperations.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,BinaryOperations)
+BBTK_BLACK_BOX_IMPLEMENTATION(BinaryOperations,bbtk::AtomicBlackBox);
+void BinaryOperations::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')
+
+       if (bbGetInputIn1() == NULL)
+       {
+               std::cout << "Set In1 at least" << std::endl;
+               return;
+       }
+
+       ope->SetInput1((vtkDataObject*)bbGetInputIn1());
+
+       if (bbGetInputIn2() != NULL)
+       {
+               ope->SetInput2((vtkDataObject*)bbGetInputIn2());
+
+       }
+       else
+       {
+           std::cout << "Set In2" << std::endl;
+        return;
+       }
+
+
+
+       switch (bbGetInputOperation())
+       {
+               case 0:
+                               ope->SetOperationToAdd();
+               break;
+               case 1:
+                               ope->SetOperationToSubtract();
+
+               break;
+               case 2:
+                               ope->SetOperationToMultiply();
+               break;
+               case 3:
+                               ope->SetOperationToDivide();
+               break;
+               default:
+                       std::cout << "Invalid Operation" << std::endl;
+                       return;
+               break;
+       }
+
+       ope->Update();
+       vtkImageData* salida = ope->GetOutput();
+
+       bbSetOutputOut(salida);
+       bbSignalOutputModification();
+
+}
+void BinaryOperations::crearPredeterminado()
+{
+       int ext[6];
+       vtkImageData* inicial = bbGetInputIn1();
+
+
+       if (constante == NULL)
+       {
+               inicial->GetExtent(ext);
+               constante = vtkImageData::New();
+               constante->SetExtent(ext);
+               constante->SetScalarType(inicial->GetScalarType());
+               constante->AllocateScalars();
+               constante->Update();
+       }
+
+       for (int i=ext[0]; i<=ext[1]; i++)
+       {
+               for (int j=ext[2]; j<=ext[3]; j++)
+               {
+                       for (int k=ext[4]; k<=ext[5]; k++)
+                       {
+                               unsigned short* value = (unsigned short*)constante->GetScalarPointer(i,j,k);
+                               *value = bbGetInputInConstant();
+                       }
+               }
+       }
+}
+
+
+void BinaryOperations::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+//    Here we initialize the input 'In' to 0
+   bbSetInputIn1(NULL);
+   bbSetInputIn2(NULL);
+   bbSetOutputOut(NULL);
+   bbSetInputInConstant(0);
+   ope = vtkImageMathematics::New();
+   constante = NULL;
+}
+void BinaryOperations::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+void BinaryOperations::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/bbvtkBinaryOperations.h b/packages/vtk/src/bbvtkBinaryOperations.h
new file mode 100644 (file)
index 0000000..54c642e
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __bbvtkBinaryOperations_h_INCLUDED__
+#define __bbvtkBinaryOperations_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+#include "bbtkStaticLecture.h"
+
+
+#include <vtkImageMathematics.h>
+#include <vtkImageData.h>
+#include <vtkType.h>
+#include <vtkImageData.h>
+
+
+namespace bbvtk
+{
+
+
+
+class bbvtk_EXPORT BinaryOperations
+ :
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(BinaryOperations,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(In1,vtkImageData*);
+  BBTK_DECLARE_INPUT(In2,vtkImageData*);
+  BBTK_DECLARE_INPUT(Operation,int);
+  BBTK_DECLARE_INPUT(InConstant,double);
+  BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  void crearPredeterminado();
+  void substractWithMinimum();
+  void MultiplyBy();
+
+  bbtkStaticLecture lector;
+
+  vtkImageMathematics* ope;
+  vtkImageData* constante;
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryOperations,bbtk::AtomicBlackBox);
+BBTK_NAME("BinaryOperations");
+BBTK_AUTHOR("_author_");
+BBTK_DESCRIPTION("_description_");
+BBTK_CATEGORY("__CATEGORY__");
+BBTK_INPUT(BinaryOperations,In1,"",vtkImageData*,"");
+BBTK_INPUT(BinaryOperations,In2,"",vtkImageData*,"");
+BBTK_INPUT(BinaryOperations,Operation,"0:Add, 1:subtract, 2:multiply, 3:divide",int,"");
+BBTK_OUTPUT(BinaryOperations,Out,"",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(BinaryOperations);
+}
+// EO namespace bbSimpleProcessing
+
+#endif // __bbvtkBinaryOperations_h_INCLUDED__
+
+
diff --git a/packages/vtk/src/bbvtkCSVReader.cxx b/packages/vtk/src/bbvtkCSVReader.cxx
new file mode 100755 (executable)
index 0000000..bc30305
--- /dev/null
@@ -0,0 +1,174 @@
+#include "bbvtkCSVReader.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,CSVReader)
+BBTK_BLACK_BOX_IMPLEMENTATION(CSVReader,bbtk::AtomicBlackBox);
+void CSVReader::Process()
+{
+    if (bbGetInputIn().size() == 0)
+       {
+               std::cout << "Set In with the file path to the csv file" << std::endl;
+               return;
+       }
+
+       std::vector< std::vector< double > > matrix;
+       int tamaniox = 0;
+       int tamanioy = 0;
+
+       std::string line;
+       std::ifstream myfile (bbGetInputIn().c_str());
+       if (myfile.is_open())
+       {
+               while (! myfile.eof() )
+               {
+                       getline (myfile,line);
+                       if (line.size() > 0)
+                       {
+                           bbtk::translate t;
+                               std::vector< double > numeros = t.stringTovectorDelimited(line, ",");
+                               if (numeros.size() > 0)
+                               {
+                                       tamanioy = numeros.size();
+                                       matrix.push_back(numeros);
+                                       tamaniox++;
+                               }
+                       }
+               }
+               myfile.close();
+
+               //Se arma la imagen vtk
+
+               vtkImageData* ans = createImage(matrix, tamaniox, tamanioy, bbGetInputInType());
+
+               bbSetOutputOut(ans);
+       }
+       else
+       {
+
+       }
+
+}
+void CSVReader::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+//    Here we initialize the input 'In' to 0
+   std::string path = "";
+   bbSetInputIn(path);
+
+   bbSetOutputOut(NULL);
+
+}
+void CSVReader::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+void CSVReader::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should desallocate the internal/output pointers
+//    if any
+
+}
+vtkImageData* CSVReader::createImage(std::vector< std::vector<double> > info, int x, int y, int scalar_type)
+{
+       vtkImageData* final = vtkImageData::New();
+
+       int ext[6];
+       int newDim[3];
+       //double space[3];
+       double origin[3];
+
+       //original->GetSpacing(space);
+       //original->GetExtent(ext);
+       //original->GetOrigin(origin);
+       //original->GetDimensions(newDim);
+
+       final->SetScalarType(scalar_type);
+
+       //final->SetSpacing(space);
+       newDim[0] = x;
+       newDim[1] = y;
+       newDim[2] = 1;
+       final->SetDimensions(newDim);
+       origin[0] = 0;
+       origin[1] = 0;
+       origin[2] = 0;
+       final->SetOrigin(origin);
+
+       final->AllocateScalars();
+       final->Update();
+
+       for (int i=0; i<newDim[0]; i++){
+               for (int j=0; j<newDim[1]; j++){
+                       switch (scalar_type)
+                       {
+                               case VTK_CHAR:
+                                       char * ap2;
+                                       ap2 = (char *) final->GetScalarPointer(i,j,0);
+                                       *ap2 = (char)info.at(i).at(j);
+                               break;
+                               case VTK_UNSIGNED_CHAR:
+                                       unsigned char * ap3;
+                                       ap3 = (unsigned char *) final->GetScalarPointer(i,j,0);
+                                       *ap3 = (unsigned char)info.at(i).at(j);
+                               break;
+                               case VTK_SHORT:
+                                       short * ap4;
+                                       ap4 = (short *) final->GetScalarPointer(i,j,0);
+                                       *ap4 = (short)info.at(i).at(j);
+                               break;
+                               case VTK_UNSIGNED_SHORT:
+                                       unsigned short * ap5;
+                                       ap5 = (unsigned short *) final->GetScalarPointer(i,j,0);
+                                       *ap5 = (unsigned short)info.at(i).at(j);
+                               break;
+                               case VTK_INT:
+                                       int * ap6;
+                                       ap6 = (int *) final->GetScalarPointer(i,j,0);
+                                       *ap6 = (int)info.at(i).at(j);
+                               break;
+                               case VTK_UNSIGNED_INT:
+                                       unsigned int * ap7;
+                                       ap7 = (unsigned int *) final->GetScalarPointer(i,j,0);
+                                       *ap7 = (unsigned int)info.at(i).at(j);
+                               break;
+                               case VTK_LONG:
+                                       long * ap8;
+                                       ap8 = (long *) final->GetScalarPointer(i,j,0);
+                                       *ap8 = (long)info.at(i).at(j);
+                               break;
+                               case VTK_UNSIGNED_LONG:
+                                       unsigned long * ap9;
+                                       ap9 = (unsigned long *) final->GetScalarPointer(i,j,0);
+                                       *ap9 = (unsigned long)info.at(i).at(j);
+                               break;
+                               case VTK_FLOAT:
+                                       float * ap10;
+                                       ap10 = (float *) final->GetScalarPointer(i,j,0);
+                                       *ap10 = (float)info.at(i).at(j);
+                               break;
+                               case VTK_DOUBLE:
+                                       double * ap11;
+                                       ap11 = (double *) final->GetScalarPointer(i,j,0);
+                                       *ap11 = (double)info.at(i).at(j);
+                               break;
+                       }
+               }
+       }
+       return final;
+}
+}
+// EO namespace bbPersistence
+
+
diff --git a/packages/vtk/src/bbvtkCSVReader.h b/packages/vtk/src/bbvtkCSVReader.h
new file mode 100755 (executable)
index 0000000..1ae2279
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef __bbPersistenceCSVReader_h_INCLUDED__
+#define __bbPersistenceCSVReader_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include <vtkImageData.h>
+#include "bbtkSimpleUtilities.h"
+#include <fstream>
+#include <iostream>
+#include <vtkType.h>
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT CSVReader
+ :
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(CSVReader,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(In,std::string);
+  BBTK_DECLARE_INPUT(InType,int);
+  BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  vtkImageData* createImage(std::vector< std::vector<double> >, int x, int y, int type);
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(CSVReader,bbtk::AtomicBlackBox);
+BBTK_NAME("CSVReader");
+BBTK_AUTHOR("_author_");
+BBTK_DESCRIPTION("_description_");
+BBTK_CATEGORY("__CATEGORY__");
+BBTK_INPUT(CSVReader,In,"First input",std::string,"");
+BBTK_INPUT(CSVReader,InType,"/Common/vtkType.h",int,"");
+BBTK_OUTPUT(CSVReader,Out,"First output",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(CSVReader);
+}
+// EO namespace bbvtk
+
+#endif // __bbPersistenceCSVReader_h_INCLUDED__
+
diff --git a/packages/vtk/src/bbvtkElementTypeChanger.cxx b/packages/vtk/src/bbvtkElementTypeChanger.cxx
new file mode 100644 (file)
index 0000000..bdb48b5
--- /dev/null
@@ -0,0 +1,134 @@
+#include "bbTranslationElementTypeChanger.h"
+#include "bbTranslationPackage.h"
+namespace bbTranslation
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(Translation,ElementTypeChanger)
+BBTK_BLACK_BOX_IMPLEMENTATION(ElementTypeChanger,bbtk::AtomicBlackBox);
+void ElementTypeChanger::Process()
+{
+
+
+       vtkImageData* ans = NULL;
+       vtkImageData* src = bbGetInputIn();
+       if (src == NULL){
+               return;
+       }
+
+       if (bbGetInputIsFLOATToUSHORT())
+       {
+               ans = myOwnCast(src, bbGetInputInType());
+       }
+       else
+       {
+               caster->SetOutputScalarType(bbGetInputInType());
+               //caster->SetOutputScalarTypeToUnsignedShort();
+               caster->SetClampOverflow(bbGetInputClampOverflow());
+               caster->SetInput(src);
+               caster->Update();
+               ans = caster->GetOutput();
+
+               double typeMin = ans->GetScalarTypeMin();
+               double typeMax = ans->GetScalarTypeMax();
+
+               std::cout << typeMin << "," << typeMax << std::endl;
+
+               /*
+               vtkStructuredPoints* stPoints = vtkStructuredPoints::New( );
+               vtkImageChangeInformation* change = vtkImageChangeInformation::New();
+
+               vtkDataArray* apt2 = filtro->GetOutput()->GetPointData()->GetScalars();
+
+               stPoints->GetPointData( )->SetScalars(apt2);
+               stPoints->SetDimensions( sizeIma, sizeIma, 1 );
+               stPoints->SetScalarType( volume->GetScalarType( ) );
+               stPoints->Update();
+
+               change->SetInput( stPoints );
+               change->Update();    //important
+
+               return change->GetOutput();
+               */
+
+       }
+       bbSetOutputOut(ans);
+}
+vtkImageData* ElementTypeChanger::myOwnCast(vtkImageData* original, int type)
+{
+       vtkImageData* final = vtkImageData::New();
+
+       int ext[6];
+       int newDim[3];
+       double space[3];
+       double origin[3];
+
+       original->GetSpacing(space);
+       original->GetExtent(ext);
+       original->GetOrigin(origin);
+       original->GetDimensions(newDim);
+
+       final->SetScalarTypeToUnsignedShort();
+
+       final->SetSpacing(space);
+       final->SetDimensions(newDim);
+       final->SetOrigin(origin);
+
+       final->AllocateScalars();
+       final->Update();
+
+       float * ap1;
+       unsigned short * ap2;
+
+       float max_value = 0;
+       float max_value2 = 0;
+       //double min_value = GetScalarTypeMin();
+       //double max_value = GetScalarTypeMax();
+       for (int i=0; i<newDim[0]; i++){
+               for (int j=0; j<newDim[1]; j++){
+                       for (int k=0; k<newDim[2]; k++){
+                               ap1 = (float *) original->GetScalarPointer(i,j,k);
+
+                               ap2 = (unsigned short *) final->GetScalarPointer(i,j,k);
+                               *ap2 = (((float) *ap1)*(bbGetInputScale()));
+                       }
+               }
+       }
+
+       return final;
+}
+
+void ElementTypeChanger::bbUserSetDefaultValues()
+{
+
+       bbSetInputClampOverflow(1);
+    bbSetInputIn(NULL);
+       bbSetInputScale(1);
+       bbSetOutputOut(NULL);
+       bbSetInputInType(VTK_UNSIGNED_SHORT);
+       bbSetInputIsFLOATToUSHORT(false);
+       caster = vtkImageCast::New();
+
+}
+void ElementTypeChanger::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+void ElementTypeChanger::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should desallocate the internal/output pointers
+//    if any
+
+}
+}
+// EO namespace bbTranslation
+
+
diff --git a/packages/vtk/src/bbvtkImageToPlainText.cxx b/packages/vtk/src/bbvtkImageToPlainText.cxx
new file mode 100755 (executable)
index 0000000..4d79b85
--- /dev/null
@@ -0,0 +1,123 @@
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+#include "bbvtkImageToPlainText.h"
+#include "bbvtkPackage.h"
+
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImageToPlainText)
+BBTK_BLACK_BOX_IMPLEMENTATION(ImageToPlainText,bbtk::AtomicBlackBox);
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImageToPlainText::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')
+if (bbGetInputIn() == NULL || bbGetInputInPath().size() == 0)
+{
+       std::cout << "Set In and InPath" << std::endl;
+       return;
+}
+
+ejecutar(bbGetInputInPath(), bbGetInputIn());
+
+}
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImageToPlainText::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+//    Here we initialize the input 'In' to 0
+       std::string vacio = "";
+       bbSetInputInPath(vacio);
+   bbSetInputIn(NULL);
+
+}
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImageToPlainText::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+void ImageToPlainText::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should desallocate the internal/output pointers
+//    if any
+
+}
+
+void ImageToPlainText::ejecutar(std::string path, vtkImageData* image)
+{
+       int ext[6];
+    std::ofstream outFile;
+    outFile.open(path.data(), std::ios::out);
+    image->GetExtent(ext);
+    if (outFile)
+    {
+       outFile << (ext[1]-ext[0]+1) << std::endl;
+       std::cout << (ext[1]-ext[0]+1) << std::endl;
+       outFile << (ext[3]-ext[2]+1) << std::endl;
+       std::cout << (ext[3]-ext[2]+1) << std::endl;
+       outFile << (ext[5]-ext[4]+1) << std::endl;
+       std::cout << (ext[5]-ext[4]+1) << std::endl;
+
+       for (int i=ext[0]; i<=ext[1]; i++)
+       {
+               for (int j=ext[2]; j<=ext[3]; j++)
+               {
+                       for (int k=ext[4]; k<=ext[5]; k++)
+                       {
+                               double valor = lector.getPixelValue(i,j,k, image);
+                               if (valor > 0)
+                               {
+                                       outFile << "1";
+                                       //std::cout << "1";
+                               }
+                               else
+                               {
+                                       outFile << "0";
+                                       //std::cout << "0";
+                               }
+                       }
+               }
+       }
+       outFile.close();
+    }
+    else
+    {
+       std::cout << "No pudo escribir en " << path << std::endl;
+    }
+}
+
+}
+// EO namespace bbvtk
+
+
diff --git a/packages/vtk/src/bbvtkImageToPlainText.h b/packages/vtk/src/bbvtkImageToPlainText.h
new file mode 100755 (executable)
index 0000000..8119118
--- /dev/null
@@ -0,0 +1,57 @@
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+#ifndef __bbvtkImageToPlainText_h_INCLUDED__
+#define __bbvtkImageToPlainText_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "bbtkStaticLecture.h"
+
+#include <vtkImageData.h>
+#include <string>
+
+#include <fstream>
+#include <sstream>
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT ImageToPlainText
+ :
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(ImageToPlainText,bbtk::AtomicBlackBox);
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+  BBTK_DECLARE_INPUT(In,vtkImageData*);
+  BBTK_DECLARE_INPUT(InPath,std::string);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  bbtkStaticLecture lector;
+
+  void ejecutar(std::string path, vtkImageData* image);
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageToPlainText,bbtk::AtomicBlackBox);
+BBTK_NAME("ImageToPlainText");
+BBTK_AUTHOR("ed-delga@uniandes.edu.co");
+BBTK_DESCRIPTION("It will receive a binary image and will save it as a text/plain file.");
+BBTK_CATEGORY("");
+BBTK_INPUT(ImageToPlainText,In,"Expected a binary image",vtkImageData*,"");
+BBTK_INPUT(ImageToPlainText,InPath,"File path where to place the text/plain file",std::string,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ImageToPlainText);
+//=====
+// Don't edit this file. This file is generated from xml description..
+//=====
+}
+// EO namespace bbvtk
+
+#endif // __bbvtkImageToPlainText_h_INCLUDED__
+
diff --git a/packages/vtk/src/bbvtkPolyDataReaderPlus.cxx b/packages/vtk/src/bbvtkPolyDataReaderPlus.cxx
new file mode 100644 (file)
index 0000000..ab887e2
--- /dev/null
@@ -0,0 +1,121 @@
+#include "bbvtkPolyDataReaderPlus.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataReaderPlus)
+BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataReaderPlus,bbtk::AtomicBlackBox);
+void PolyDataReaderPlus::Process()
+{
+
+    std::cout << "[" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl;
+       //Review the observers...
+
+       if (!HasObserver(OBS_POST_READER_1) && bbGetInputInPostReadObs1() != NULL)
+               AddObserver(OBS_POST_READER_1, bbGetInputInPostReadObs1());
+
+       if (bbGetInputInPath().size()==0)
+       {
+               std::cout << "Set InPath." << std::endl;
+               return;
+       }
+
+       //Read!
+       if (!readed)
+       {
+               std::vector< std::string > partes = StringSplit(bbGetInputInPath(), ".");
+               std::string extension = partes.at(partes.size()-1);
+
+               std::cout << "Extension (vtk o vtp?) = " << extension << std::endl;
+
+               if (extension.compare("vtk") == 0)
+               {
+                       //vtkPolyDataReader* reader = vtkPolyDataReader::New();
+                       vtkGenericDataObjectReader* reader = vtkGenericDataObjectReader::New();
+                       reader->SetFileName(bbGetInputInPath().data());
+                       informacion = (vtkPolyData*)reader->GetOutput();
+                       reader->CloseVTKFile();
+                       vtkPolyData* old = bbGetOutputOut();
+                       bbSetOutputOut(informacion);
+                       readed = true;
+               }
+
+               if (extension.compare("vtp") == 0)
+               {
+                       vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();
+                       reader->SetFileName(bbGetInputInPath().data());
+                       informacion = reader->GetOutput();
+
+                       vtkPolyData* old = bbGetOutputOut();
+                       bbSetOutputOut(informacion);
+                       readed = true;
+               }
+       }
+
+       vtkActor *actor = (vtkActor*)bbGetOutputOutActor();
+       vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
+
+       mapper->SetInput(informacion);
+       actor->SetMapper(mapper);
+
+       bbSetOutputOutActor(actor);
+
+       if (bbGetInputInColor().size()  >= 3)
+       {
+               actor->GetProperty()->SetColor(bbGetInputInColor()[0],bbGetInputInColor()[1],bbGetInputInColor()[2]);
+       }
+       else
+       {
+               actor->GetProperty()->SetColor(1,1,1);
+       }
+       actor->GetProperty()->SetOpacity(bbGetInputInOpacity()/100);
+
+       //old->Delete();
+
+       InvokeEvent(OBS_POST_READER_1, informacion);
+
+       std::cout << "END [" << this << "]" << "PolyDataReaderPlus::Process()..." << std::endl;
+
+}
+void PolyDataReaderPlus::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+//    Here we initialize the input 'In' to 0
+       vtkPolyData* empty = vtkPolyData::New();
+       vtkActor *actor = vtkActor::New();
+    bbSetOutputOut(empty);
+       bbSetInputInPostReadObs1(NULL);
+       std::string nada = "";
+       bbSetInputInPath(nada);
+       bbSetOutputOutActor(actor);
+       bbSetInputInOpacity(50);
+
+       readed = false;
+
+}
+void PolyDataReaderPlus::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+void PolyDataReaderPlus::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/bbvtkPolyDataReaderPlus.h b/packages/vtk/src/bbvtkPolyDataReaderPlus.h
new file mode 100644 (file)
index 0000000..6c8ee59
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef __bbvtkPolyDataReaderPlus_h_INCLUDED__
+#define __bbvtkPolyDataReaderPlus_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include <vtkGenericDataObjectReader.h>
+#include <vtkUnstructuredGridReader.h>
+#include <vtkXMLPolyDataReader.h>
+#include <vtkProperty.h>
+#include <vtkObject.h>
+#include <vtkCommand.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyDataReader.h>
+#include <vtkActor.h>
+#include <vtkProp3D.h>
+#include "names.h"
+
+namespace bbvtk
+{
+
+#define OBS_POST_READER_1 1401
+
+class bbvtk_EXPORT PolyDataReaderPlus
+ :
+   public bbtk::AtomicBlackBox,
+   public vtkObject
+{
+  BBTK_BLACK_BOX_INTERFACE(PolyDataReaderPlus,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(InPath, std::string);
+  BBTK_DECLARE_INPUT(InOpacity, double);
+  BBTK_DECLARE_INPUT(InColor, std::vector<double>);
+  BBTK_DECLARE_INPUT(InPostReadObs1, vtkCommand*);
+  BBTK_DECLARE_OUTPUT(Out,vtkPolyData*);
+  BBTK_DECLARE_OUTPUT(OutActor,vtkProp3D*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  vtkPolyData* informacion;
+
+  bool readed;
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(PolyDataReaderPlus,bbtk::AtomicBlackBox);
+BBTK_NAME("PolyDataReaderPlus");
+BBTK_AUTHOR("_author_");
+BBTK_DESCRIPTION("_description_");
+BBTK_CATEGORY("__CATEGORY__");
+BBTK_INPUT(PolyDataReaderPlus,InPath,"Path to the file to be readed",std::string,"");
+BBTK_INPUT(PolyDataReaderPlus,InOpacity,"",double,"");
+BBTK_INPUT(PolyDataReaderPlus,InColor,"",std::vector<double>,"");
+BBTK_INPUT(PolyDataReaderPlus,InPostReadObs1,"Who will be notified after persist", vtkCommand*,"");
+BBTK_OUTPUT(PolyDataReaderPlus,Out,"Information readed", vtkPolyData*,"");
+BBTK_OUTPUT(PolyDataReaderPlus,OutActor,"Information as an actor", vtkProp3D*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(PolyDataReaderPlus);
+}
+// EO namespace bbvtk
+
+#endif // __bbvtkPolyDataReaderPlus_h_INCLUDED__
+
+
diff --git a/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx b/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx
new file mode 100755 (executable)
index 0000000..969254d
--- /dev/null
@@ -0,0 +1,143 @@
+#include "bbvtkPolyDataWriterPlus.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataWriterPlus)
+BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataWriterPlus,bbtk::AtomicBlackBox);
+void PolyDataWriterPlus::Process()
+{
+       std::cout << "[" << this << "]" << "PolyDataWriterPlus::Process()..." << std::endl;
+       //Review the observers...
+
+       if (!HasObserver(OBS_PRE_WRITER_1) && bbGetInputInPrePersistObs1() != NULL)
+               AddObserver(OBS_PRE_WRITER_1, bbGetInputInPrePersistObs1());
+
+       if (!HasObserver(OBS_POST_WRITER_1) == NULL && bbGetInputInPostPersistObs1() != NULL)
+               AddObserver(OBS_POST_WRITER_1, bbGetInputInPostPersistObs1());
+
+       InvokeEvent(OBS_PRE_WRITER_1);
+
+       if (bbGetInputInPath().size()==0)
+       {
+               std::cout << "Set InPath." << std::endl;
+               return;
+       }
+
+       vtkPolyData* cosa;
+
+       if (bbGetInputIn()==NULL)
+       {
+               if (bbGetInputIn2()==NULL)
+               {
+                       std::cout << "Set In." << std::endl;
+                       return;
+               }
+               else
+               {
+                       vtkProp3D* actor = bbGetInputIn2();
+                       vtkPolyDataMapper* mapper = ((vtkPolyDataMapper*)((vtkActor*)actor)->GetMapper());
+                       cosa = mapper->GetInput();
+               }
+       }
+       else
+       {
+               cosa = bbGetInputIn();
+       }
+
+       std::string nuevo_nombre = guessName(bbGetInputInPath());
+
+
+       vtkPolyData* entrada = cosa;
+       std::cout << "Before writing" << std::endl;
+       entrada->Print(std::cout);
+
+       std::vector< std::string > partes = StringSplit(nuevo_nombre, ".");
+       std::string extension = partes.at(partes.size()-1);
+
+       std::cout << "Extension (vtk, vtp o stl?) => " << extension << std::endl;
+
+
+
+       vtkDataSetSurfaceFilter* surfaceFilter = vtkDataSetSurfaceFilter::New();
+       surfaceFilter->SetInput(entrada);
+       surfaceFilter->Update();
+       //vtkPolyData* polydata = surfaceFilter->GetOutput();
+       entrada = surfaceFilter->GetOutput();
+
+       if (extension.compare("vtk") == 0)
+       {
+               vtkPolyDataWriter* writer = vtkPolyDataWriter::New();
+               writer->SetInput(entrada);
+               writer->SetFileName(nuevo_nombre.data());
+               writer->Write();
+               writer->Delete();
+       }
+
+       if (extension.compare("vtp") == 0)
+       {
+               vtkXMLPolyDataWriter* writer = vtkXMLPolyDataWriter::New();
+               writer->SetFileName ( nuevo_nombre.data() );
+               writer->SetInput ( entrada );
+               writer->Write();
+               writer->Delete();
+       }
+
+       if (extension.compare("stl") == 0)
+       {
+               vtkSTLWriter* writer = vtkSTLWriter::New();
+               writer->SetFileName ( nuevo_nombre.data() );
+               writer->SetInput ( entrada );
+               writer->Write();
+               writer->Print(std::cout);
+               writer->Delete();
+       }
+
+
+       std::cout << "Saving Ok!" << std::endl;
+
+       InvokeEvent(OBS_POST_WRITER_1);
+}
+void PolyDataWriterPlus::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+//    Here we initialize the input 'In' to 0
+    bbSetInputIn(NULL);
+       bbSetInputIn2(NULL);
+       bbSetInputInPrePersistObs1(NULL);
+       bbSetInputInPostPersistObs1(NULL);
+       std::string nada = "";
+       std::string prefixDefault = "Data";
+       bbSetInputInPath(nada);
+       bbSetInputInFilePrefix(prefixDefault);
+
+}
+void PolyDataWriterPlus::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+void PolyDataWriterPlus::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should desallocate the internal/output pointers
+//    if any
+       RemoveAllObservers();
+
+       if (bbGetInputInPrePersistObs1() != NULL && bbGetInputInPrePersistObs1()->GetReferenceCount() > 0)
+               bbGetInputInPrePersistObs1()->SetReferenceCount(bbGetInputInPrePersistObs1()->GetReferenceCount()-1);
+       if (bbGetInputInPostPersistObs1() != NULL)
+               bbGetInputInPostPersistObs1()->SetReferenceCount(bbGetInputInPostPersistObs1()->GetReferenceCount()-1);
+}
+}
+// EO namespace bbvtk
+
+
diff --git a/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx~ b/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx~
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/vtk/src/bbvtkPolyDataWriterPlus.h b/packages/vtk/src/bbvtkPolyDataWriterPlus.h
new file mode 100755 (executable)
index 0000000..b803d8e
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __bbvtkPolyDataWriterPlus_h_INCLUDED__
+#define __bbvtkPolyDataWriterPlus_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include <vtkDataSetSurfaceFilter.h>
+#include <vtkUnstructuredGridReader.h>
+#include <vtkSTLWriter.h>
+#include <vtkMapper.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkActor.h>
+#include <vtkProp3D.h>
+#include <vtkObject.h>
+#include <vtkCommand.h>
+#include <vtkPolyData.h>
+#include <vtkXMLPolyDataWriter.h>
+#include <vtkPolyDataWriter.h>
+#include "names.h"
+
+namespace bbvtk
+{
+#define OBS_PRE_WRITER_1 1201
+
+#define OBS_POST_WRITER_1 1301
+
+class bbvtk_EXPORT PolyDataWriterPlus
+ :
+   public bbtk::AtomicBlackBox,
+   public vtkObject
+{
+  BBTK_BLACK_BOX_INTERFACE(PolyDataWriterPlus,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(InPrePersistObs1, vtkCommand*);
+  BBTK_DECLARE_INPUT(InPostPersistObs1, vtkCommand*);
+  BBTK_DECLARE_INPUT(InPath, std::string);
+  BBTK_DECLARE_INPUT(In, vtkPolyData*);
+  BBTK_DECLARE_INPUT(In2, vtkProp3D*);
+  BBTK_DECLARE_INPUT(InFilePrefix, std::string);
+  BBTK_PROCESS(Process);
+  void Process();
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(PolyDataWriterPlus,bbtk::AtomicBlackBox);
+BBTK_NAME("PolyDataWriterPlus");
+BBTK_AUTHOR("_author_");
+BBTK_DESCRIPTION("_description_");
+BBTK_CATEGORY("__CATEGORY__");
+BBTK_INPUT(PolyDataWriterPlus,InPrePersistObs1,"Who will be notified before persist", vtkCommand*,"");
+BBTK_INPUT(PolyDataWriterPlus,InPostPersistObs1,"Who will be notified after persist", vtkCommand*,"");
+BBTK_INPUT(PolyDataWriterPlus,InPath,"Path to the file to be created or rewrited",std::string,"");
+BBTK_INPUT(PolyDataWriterPlus,In,"Information to be saved", vtkPolyData*,"");
+BBTK_INPUT(PolyDataWriterPlus,In2,"Information to be saved", vtkProp3D*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(PolyDataWriterPlus);
+}
+// EO namespace bbvtk
+
+#endif // __bbPersistenceVTKWriter_h_INCLUDED__
+
diff --git a/packages/vtk/src/bbvtkPolyDataWriterPlus.h~ b/packages/vtk/src/bbvtkPolyDataWriterPlus.h~
new file mode 100644 (file)
index 0000000..d648a97
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef __bbPersistenceVTKReader_h_INCLUDED__
+#define __bbPersistenceVTKReader_h_INCLUDED__
+#include "bbPersistence_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include <vtkGenericDataObjectReader.h>
+#include <vtkUnstructuredGridReader.h>
+#include <vtkXMLPolyDataReader.h>
+#include <vtkProperty.h>
+#include <vtkObject.h>
+#include <vtkCommand.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyDataReader.h>
+#include <vtkActor.h>
+#include <vtkProp3D.h>
+#include "names.h"
+
+namespace bbPersistence
+{
+
+#define OBS_POST_READER_1 1401
+
+class bbPersistence_EXPORT VTKReader
+ : 
+   public bbtk::AtomicBlackBox,
+   public vtkObject
+{
+  BBTK_BLACK_BOX_INTERFACE(VTKReader,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(InPath, std::string);
+  BBTK_DECLARE_INPUT(InOpacity, double);
+  BBTK_DECLARE_INPUT(InColor, std::vector<double>);
+  BBTK_DECLARE_INPUT(InPostReadObs1, vtkCommand*);
+  BBTK_DECLARE_OUTPUT(Out,vtkPolyData*);
+  BBTK_DECLARE_OUTPUT(OutActor,vtkProp3D*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  vtkPolyData* informacion;
+
+  bool readed;
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(VTKReader,bbtk::AtomicBlackBox);
+BBTK_NAME("VTKReader");
+BBTK_AUTHOR("_author_");
+BBTK_DESCRIPTION("_description_");
+BBTK_CATEGORY("__CATEGORY__");
+BBTK_INPUT(VTKReader,InPath,"Path to the file to be readed",std::string,"");
+BBTK_INPUT(VTKReader,InOpacity,"",double,"");
+BBTK_INPUT(VTKReader,InColor,"",std::vector<double>,"");
+BBTK_INPUT(VTKReader,InPostReadObs1,"Who will be notified after persist", vtkCommand*,"");
+BBTK_OUTPUT(VTKReader,Out,"Information readed", vtkPolyData*,"");
+BBTK_OUTPUT(VTKReader,OutActor,"Information as an actor", vtkProp3D*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(VTKReader);
+}
+// EO namespace bbPersistence
+
+#endif // __bbPersistenceVTKReader_h_INCLUDED__
+
+
diff --git a/packages/vtk/src/bbvtkSliceImage.cxx b/packages/vtk/src/bbvtkSliceImage.cxx
new file mode 100755 (executable)
index 0000000..5116d7b
--- /dev/null
@@ -0,0 +1,158 @@
+#include "bbvtkSliceImage.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SliceImage)
+BBTK_BLACK_BOX_IMPLEMENTATION(SliceImage,bbtk::AtomicBlackBox);
+void SliceImage::Process()
+{
+       vtkImageData* original = bbGetInputIn();
+
+       if (original == NULL)
+       {
+               std::cout << "Set In" << std::endl;
+               return;
+       }
+
+       //if (lastId == bbGetInputZ())
+       //      return;
+
+       int z = bbGetInputZ();
+       int max_z;
+
+       int ext[6];
+       int newDim[3];
+       double space[3];
+       double origin[3];
+
+       original->GetSpacing(space);
+       original->GetExtent(ext);
+       original->GetOrigin(origin);
+       original->GetDimensions(newDim);
+       max_z = newDim[2];
+       newDim[2] = 1;
+
+       int scalar_type = original->GetScalarType();
+
+       if (final == NULL)
+       {
+               final = vtkImageData::New();
+               final->SetSpacing(space);
+               final->SetDimensions(newDim);
+               final->SetScalarType(scalar_type);
+               final->AllocateScalars();
+               final->Update();
+
+
+       }
+
+       bbSetOutputMax(max_z);
+
+       if (z>=max_z)
+       {
+               z = max_z-1;
+       }
+
+       for (int i=0; i<newDim[0]; i++){
+               for (int j=0; j<newDim[1]; j++){
+                       switch (scalar_type)
+                       {
+                               case VTK_CHAR:
+                                       char * ap2;
+                                       ap2 = (char *) final->GetScalarPointer(i,j,0);
+                                       *ap2 = *((char*) (original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_UNSIGNED_CHAR:
+                                       unsigned char * ap3;
+                                       ap3 = (unsigned char *) final->GetScalarPointer(i,j,0);
+                                       *ap3 = *((unsigned char *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_SHORT:
+                                       short * ap4;
+                                       ap4 = (short *) final->GetScalarPointer(i,j,0);
+                                       *ap4 = *((short *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_UNSIGNED_SHORT:
+                                       unsigned short * ap5;
+                                       ap5 = (unsigned short *) final->GetScalarPointer(i,j,0);
+                                       *ap5 = *((unsigned short *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_INT:
+                                       int * ap6;
+                                       ap6 = (int *) final->GetScalarPointer(i,j,0);
+                                       *ap6 = *((int *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_UNSIGNED_INT:
+                                       unsigned int * ap7;
+                                       ap7 = (unsigned int *) final->GetScalarPointer(i,j,0);
+                                       *ap7 = *((unsigned int *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_LONG:
+                                       long * ap8;
+                                       ap8 = (long *) final->GetScalarPointer(i,j,0);
+                                       *ap8 = *((long *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_UNSIGNED_LONG:
+                                       unsigned long * ap9;
+                                       ap9 = (unsigned long *) final->GetScalarPointer(i,j,0);
+                                       *ap9 = *((unsigned long *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_FLOAT:
+                                       float * ap10;
+                                       ap10 = (float *) final->GetScalarPointer(i,j,0);
+                                       *ap10 = *((float *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                               case VTK_DOUBLE:
+                                       double * ap11;
+                                       ap11 = (double *) final->GetScalarPointer(i,j,0);
+                                       *ap11 = *((double *)(original->GetScalarPointer(i,j,z)));
+                               break;
+                       }
+               }
+       }
+
+       caster = vtkImageCast::New();
+       caster->SetInput(final);
+       caster->SetOutputScalarTypeToShort();
+       caster->Update();
+
+       bbSetOutputOut(caster->GetOutput());
+
+       std::cout << "updated slice " << z << std::endl;
+       bbSignalOutputModification();
+       lastId = bbGetInputZ();
+}
+void SliceImage::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+//    Here we initialize the input 'In' to 0
+   bbSetInputIn(NULL);
+   bbSetOutputOut(NULL);
+   final = NULL;
+
+}
+void SliceImage::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+void SliceImage::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/bbvtkSliceImage.h b/packages/vtk/src/bbvtkSliceImage.h
new file mode 100755 (executable)
index 0000000..719c76b
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef __bbvtkSliceImage_h_INCLUDED__
+#define __bbvtkSliceImage_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "vtkImageCast.h"
+#include <vtkType.h>
+#include <vtkImageData.h>
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT SliceImage
+ :
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(SliceImage,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(In,vtkImageData*);
+  BBTK_DECLARE_INPUT(Z,int);
+  BBTK_DECLARE_OUTPUT(Out,vtkImageData *);
+  BBTK_DECLARE_OUTPUT(Max,int);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  int lastId;
+
+  vtkImageData* final;
+
+  vtkImageCast* caster;
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(SliceImage,bbtk::AtomicBlackBox);
+BBTK_NAME("SliceImage");
+BBTK_AUTHOR("_author_");
+BBTK_DESCRIPTION("_description_");
+BBTK_CATEGORY("__CATEGORY__");
+BBTK_INPUT(SliceImage,In,"3D Image",vtkImageData*,"");
+BBTK_INPUT(SliceImage,Z,"shoice",int,"");
+BBTK_OUTPUT(SliceImage,Out,"2D Slice",vtkImageData*,"");
+BBTK_OUTPUT(SliceImage,Max,"Maximum",int,"");
+BBTK_END_DESCRIBE_BLACK_BOX(SliceImage);
+}
+// EO namespace bbvtk
+
+#endif // __bbvtkSliceImage_h_INCLUDED__
+
diff --git a/packages/vtk/src/bbvtkUnaryOperations.cxx b/packages/vtk/src/bbvtkUnaryOperations.cxx
new file mode 100644 (file)
index 0000000..488f175
--- /dev/null
@@ -0,0 +1,236 @@
+#include "bbvtkUnaryOperations.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,UnaryOperations)
+BBTK_BLACK_BOX_IMPLEMENTATION(UnaryOperations,bbtk::AtomicBlackBox);
+void UnaryOperations::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')
+
+       if (bbGetInputIn1() == NULL)
+       {
+               std::cout << "Set In1 at least" << std::endl;
+               return;
+       }
+
+       ope->SetInput1((vtkDataObject*)bbGetInputIn1());
+
+
+       ope->SetConstantK(bbGetInputInConstant());
+       ope->SetConstantC(bbGetInputInConstant());
+
+       switch (bbGetInputOperation())
+       {
+               case 0:
+                               ope->SetOperationToAddConstant();
+
+               break;
+               case 1:
+                               crearPredeterminado();
+                               ope->SetInput2((vtkDataSet*) constante);
+                               ope->SetOperationToSubtract();
+               break;
+               case 2:
+                ope->SetInput2((vtkDataSet*) constante);
+                               ope->SetOperationToMultiply();
+
+               break;
+               case 3:
+
+                               ope->SetOperationToDivide();
+               break;
+               case 4:
+                        ope->SetOperationToInvert();
+               break;
+               case 9:
+                        ope->SetOperationToAbsoluteValue();
+               break;
+               case 5:
+
+                               ope->SetOperationToSin();
+               break;
+               case 6:
+
+                       ope->SetOperationToCos();
+
+               break;
+               case 7:
+
+                               ope->SetOperationToExp();
+               break;
+               case 8:
+
+                               ope->SetOperationToLog();
+               break;
+               case 10:
+                       substractWithMinimum();
+                       bbSetOutputOut(constante);
+                       return;
+               break;
+               case 11:
+                       MultiplyBy();
+                       bbSetOutputOut(constante);
+                       return;
+               break;
+               default:
+                       std::cout << "Invalid Operation" << std::endl;
+                       return;
+               break;
+       }
+
+       ope->Update();
+       vtkImageData* salida = ope->GetOutput();
+
+       bbSetOutputOut(salida);
+       bbSignalOutputModification();
+
+}
+void UnaryOperations::crearPredeterminado()
+{
+       int ext[6];
+       vtkImageData* inicial = bbGetInputIn1();
+
+
+       if (constante == NULL)
+       {
+               inicial->GetExtent(ext);
+               constante = vtkImageData::New();
+               constante->SetExtent(ext);
+               constante->SetScalarType(inicial->GetScalarType());
+               constante->AllocateScalars();
+               constante->Update();
+       }
+
+       for (int i=ext[0]; i<=ext[1]; i++)
+       {
+               for (int j=ext[2]; j<=ext[3]; j++)
+               {
+                       for (int k=ext[4]; k<=ext[5]; k++)
+                       {
+                               unsigned short* value = (unsigned short*)constante->GetScalarPointer(i,j,k);
+                               *value = bbGetInputInConstant();
+                       }
+               }
+       }
+}
+void UnaryOperations::substractWithMinimum()
+{
+       int ext[6];
+       double spc[3];
+       vtkImageData* inicial = bbGetInputIn1();
+
+
+       if (constante == NULL)
+       {
+               inicial->GetExtent(ext);
+               inicial->GetSpacing(spc);
+               constante = vtkImageData::New();
+               constante->SetExtent(ext);
+               constante->SetSpacing(spc);
+               constante->SetOrigin(inicial->GetOrigin());
+               constante->SetScalarType(inicial->GetScalarType());
+               constante->AllocateScalars();
+               constante->Update();
+       }
+
+       for (int i=ext[0]; i<=ext[1]; i++)
+       {
+               for (int j=ext[2]; j<=ext[3]; j++)
+               {
+                       for (int k=ext[4]; k<=ext[5]; k++)
+                       {
+                               double temp1 = lector.getPixelValue(i,j,k,inicial);
+                               double temp = temp1 - bbGetInputInConstant();
+                               if (temp < 0)
+                                       temp = 0;
+                               lector.setPixelValue(i,j,k,constante,temp);
+                       }
+               }
+       }
+}
+
+void UnaryOperations::MultiplyBy()
+{
+       int ext[6];
+       double spc[3];
+       vtkImageData* inicial = bbGetInputIn1();
+
+
+       if (constante == NULL)
+       {
+               inicial->GetExtent(ext);
+               inicial->GetSpacing(spc);
+               constante = vtkImageData::New();
+               constante->SetExtent(ext);
+               constante->SetSpacing(spc);
+               constante->SetOrigin(inicial->GetOrigin());
+               constante->SetScalarType(inicial->GetScalarType());
+               constante->AllocateScalars();
+               constante->Update();
+       }
+
+       for (int i=ext[0]; i<=ext[1]; i++)
+       {
+               for (int j=ext[2]; j<=ext[3]; j++)
+               {
+                       for (int k=ext[4]; k<=ext[5]; k++)
+                       {
+                               double temp1 = lector.getPixelValue(i,j,k,inicial);
+                               double temp = temp1 * bbGetInputInConstant();
+                               if (temp < 0)
+                                       temp = 0;
+                               lector.setPixelValue(i,j,k,constante,temp);
+                       }
+               }
+       }
+}
+
+void UnaryOperations::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+//    Here we initialize the input 'In' to 0
+   bbSetInputIn1(NULL);
+//   bbSetInputIn2(NULL);
+   bbSetOutputOut(NULL);
+   bbSetInputInConstant(0);
+   ope = vtkImageMathematics::New();
+   constante = NULL;
+}
+void UnaryOperations::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing
+//    but this is where you should allocate the internal/output pointers
+//    if any
+
+
+}
+void UnaryOperations::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/bbvtkUnaryOperations.h b/packages/vtk/src/bbvtkUnaryOperations.h
new file mode 100644 (file)
index 0000000..08f7515
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __bbvtkUnaryOperations_h_INCLUDED__
+#define __bbvtkUnaryOperations_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+
+#include <vtkImageMathematics.h>
+#include <vtkImageData.h>
+#include <vtkType.h>
+#include <vtkImageData.h>
+#include <bbtkStaticLecture.h>
+
+
+namespace bbvtk
+{
+
+
+
+
+class bbvtk_EXPORT UnaryOperations
+ :
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(UnaryOperations,bbtk::AtomicBlackBox);
+  BBTK_DECLARE_INPUT(In1,vtkImageData*);
+  BBTK_DECLARE_INPUT(Operation,int);
+  BBTK_DECLARE_INPUT(InConstant,double);
+  BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+  void crearPredeterminado();
+  void substractWithMinimum();
+  void MultiplyBy();
+
+  bbtkStaticLecture lector;
+
+  vtkImageMathematics* ope;
+  vtkImageData* constante;
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(UnaryOperations,bbtk::AtomicBlackBox);
+BBTK_NAME("UnaryOperations");
+BBTK_AUTHOR("_author_");
+BBTK_DESCRIPTION("_description_");
+BBTK_CATEGORY("__CATEGORY__");
+BBTK_INPUT(UnaryOperations,In1,"",vtkImageData*,"");
+BBTK_INPUT(UnaryOperations,InConstant,"",double,"");
+BBTK_INPUT(UnaryOperations,Operation,"0:Add, 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs",int,"");
+BBTK_OUTPUT(UnaryOperations,Out,"",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(UnaryOperations);
+}
+// EO namespace bbSimpleProcessing
+
+#endif // __bbvtkUnaryOperations_h_INCLUDED__
+
+