1 #include "bbvtkBinaryOperations.h"
2 #include "bbvtkPackage.h"
7 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,BinaryOperations)
8 BBTK_BLACK_BOX_IMPLEMENTATION(BinaryOperations,bbtk::AtomicBlackBox);
9 void BinaryOperations::Process()
12 // THE MAIN PROCESSING METHOD BODY
13 // Here we simply set the input 'In' value to the output 'Out'
14 // And print out the output value
15 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
16 // void bbSet{Input|Output}NAME(const TYPE&)
17 // const TYPE& bbGet{Input|Output}NAME() const
19 // * NAME is the name of the input/output
20 // (the one provided in the attribute 'name' of the tag 'input')
21 // * TYPE is the C++ type of the input/output
22 // (the one provided in the attribute 'type' of the tag 'input')
24 if (bbGetInputIn1() == NULL)
26 std::cout << "Set In1 at least" << std::endl;
30 ope->SetInput1((vtkDataObject*)bbGetInputIn1());
32 if (bbGetInputIn2() != NULL)
34 ope->SetInput2((vtkDataObject*)bbGetInputIn2());
39 std::cout << "Set In2" << std::endl;
45 switch (bbGetInputOperation())
48 ope->SetOperationToAdd();
51 ope->SetOperationToSubtract();
55 ope->SetOperationToMultiply();
58 ope->SetOperationToDivide();
61 std::cout << "Invalid Operation" << std::endl;
67 vtkImageData* salida = ope->GetOutput();
69 bbSetOutputOut(salida);
70 bbSignalOutputModification();
73 void BinaryOperations::crearPredeterminado()
76 vtkImageData* inicial = bbGetInputIn1();
79 if (constante == NULL)
81 inicial->GetExtent(ext);
82 constante = vtkImageData::New();
83 constante->SetExtent(ext);
84 constante->SetScalarType(inicial->GetScalarType());
85 constante->AllocateScalars();
89 for (int i=ext[0]; i<=ext[1]; i++)
91 for (int j=ext[2]; j<=ext[3]; j++)
93 for (int k=ext[4]; k<=ext[5]; k++)
95 unsigned short* value = (unsigned short*)constante->GetScalarPointer(i,j,k);
96 *value = bbGetInputInConstant();
103 void BinaryOperations::bbUserSetDefaultValues()
106 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
107 // Here we initialize the input 'In' to 0
110 bbSetOutputOut(NULL);
111 bbSetInputInConstant(0);
112 ope = vtkImageMathematics::New();
115 void BinaryOperations::bbUserInitializeProcessing()
118 // THE INITIALIZATION METHOD BODY :
120 // but this is where you should allocate the internal/output pointers
125 void BinaryOperations::bbUserFinalizeProcessing()
128 // THE FINALIZATION METHOD BODY :
130 // but this is where you should desallocate the internal/output pointers
135 // EO namespace bbvtk