1 #include "bbvtkUnaryOperations.h"
2 #include "bbvtkPackage.h"
7 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,UnaryOperations)
8 BBTK_BLACK_BOX_IMPLEMENTATION(UnaryOperations,bbtk::AtomicBlackBox);
9 void UnaryOperations::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());
33 ope->SetConstantK(bbGetInputInConstant());
34 ope->SetConstantC(bbGetInputInConstant());
36 switch (bbGetInputOperation())
39 ope->SetOperationToAddConstant();
43 //EED Borrame crearPredeterminado();
44 ope->SetInput2((vtkDataSet*) constante);
45 ope->SetOperationToSubtract();
48 ope->SetInput2((vtkDataSet*) constante);
49 ope->SetOperationToMultiply();
54 ope->SetOperationToDivide();
57 ope->SetOperationToInvert();
60 ope->SetOperationToAbsoluteValue();
64 ope->SetOperationToSin();
68 ope->SetOperationToCos();
73 ope->SetOperationToExp();
77 ope->SetOperationToLog();
81 /* EED 21Juin 2011 Borrame
83 substractWithMinimum();
84 bbSetOutputOut(constante);
89 bbSetOutputOut(constante);
95 std::cout << "Invalid Operation" << std::endl;
101 vtkImageData* salida = ope->GetOutput();
103 bbSetOutputOut(salida);
104 bbSignalOutputModification();
108 /* Borrame Eduardo - Juan Pablo
109 void UnaryOperations::crearPredeterminado()
112 vtkImageData* inicial = bbGetInputIn1();
115 if (constante == NULL)
117 inicial->GetExtent(ext);
118 constante = vtkImageData::New();
119 constante->SetExtent(ext);
120 constante->SetScalarType(inicial->GetScalarType());
121 constante->AllocateScalars();
125 for (int i=ext[0]; i<=ext[1]; i++)
127 for (int j=ext[2]; j<=ext[3]; j++)
129 for (int k=ext[4]; k<=ext[5]; k++)
131 unsigned short* value = (unsigned short*)constante->GetScalarPointer(i,j,k);
132 *value = bbGetInputInConstant();
140 void UnaryOperations::substractWithMinimum()
144 vtkImageData* inicial = bbGetInputIn1();
147 if (constante == NULL)
149 inicial->GetExtent(ext);
150 inicial->GetSpacing(spc);
151 constante = vtkImageData::New();
152 constante->SetExtent(ext);
153 constante->SetSpacing(spc);
154 constante->SetOrigin(inicial->GetOrigin());
155 constante->SetScalarType(inicial->GetScalarType());
156 constante->AllocateScalars();
160 for (int i=ext[0]; i<=ext[1]; i++)
162 for (int j=ext[2]; j<=ext[3]; j++)
164 for (int k=ext[4]; k<=ext[5]; k++)
166 double temp1 = lector.getPixelValue(i,j,k,inicial);
167 double temp = temp1 - bbGetInputInConstant();
170 lector.setPixelValue(i,j,k,constante,temp);
177 void UnaryOperations::bbUserSetDefaultValues()
180 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
181 // Here we initialize the input 'In' to 0
183 bbSetOutputOut(NULL);
184 bbSetInputInConstant(0);
185 bbSetInputOperation(0);
186 ope = vtkImageMathematics::New();
189 void UnaryOperations::bbUserInitializeProcessing()
192 // THE INITIALIZATION METHOD BODY :
194 // but this is where you should allocate the internal/output pointers
199 void UnaryOperations::bbUserFinalizeProcessing()
202 // THE FINALIZATION METHOD BODY :
204 // but this is where you should desallocate the internal/output pointers
209 // EO namespace bbvtk