]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkBinaryOperations.cxx
cedf22e6a39f99a8b59294475ca0ba9ea93f99a2
[bbtk.git] / packages / vtk / src / bbvtkBinaryOperations.cxx
1 #include "bbvtkBinaryOperations.h"
2 #include "bbvtkPackage.h"
3 namespace bbvtk
4 {
5
6
7 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,BinaryOperations)
8 BBTK_BLACK_BOX_IMPLEMENTATION(BinaryOperations,bbtk::AtomicBlackBox);
9 void BinaryOperations::Process()
10 {
11
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
18 //    Where :
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')
23
24         if (bbGetInputIn1() == NULL)
25         {
26                 std::cout << "Set In1 at least" << std::endl;
27                 return;
28         }
29
30         ope->SetInput1((vtkDataObject*)bbGetInputIn1());
31
32         if (bbGetInputIn2() != NULL)
33         {
34                 ope->SetInput2((vtkDataObject*)bbGetInputIn2());
35
36         }
37         else
38         {
39             std::cout << "Set In2" << std::endl;
40         return;
41         }
42
43
44
45         switch (bbGetInputOperation())
46         {
47                 case 0:
48                                 ope->SetOperationToAdd();
49                 break;
50                 case 1:
51                                 ope->SetOperationToSubtract();
52
53                 break;
54                 case 2:
55                                 ope->SetOperationToMultiply();
56                 break;
57                 case 3:
58                                 ope->SetOperationToDivide();
59                 break;
60                 default:
61                         std::cout << "Invalid Operation" << std::endl;
62                         return;
63                 break;
64         }
65
66         ope->Update();
67         vtkImageData* salida = ope->GetOutput();
68
69         bbSetOutputOut(salida);
70         bbSignalOutputModification();
71
72 }
73
74
75 void BinaryOperations::bbUserSetDefaultValues()
76 {
77
78 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
79 //    Here we initialize the input 'In' to 0
80    bbSetInputIn1(NULL);
81    bbSetInputIn2(NULL);
82    bbSetOutputOut(NULL);
83    bbSetInputOperation(0);
84    ope = vtkImageMathematics::New();
85 }
86
87
88 void BinaryOperations::bbUserInitializeProcessing()
89 {
90
91 //  THE INITIALIZATION METHOD BODY :
92 //    Here does nothing
93 //    but this is where you should allocate the internal/output pointers
94 //    if any
95
96 }
97
98
99 void BinaryOperations::bbUserFinalizeProcessing()
100 {
101
102 //  THE FINALIZATION METHOD BODY :
103 //    Here does nothing
104 //    but this is where you should desallocate the internal/output pointers
105 //    if any
106
107 }
108 }
109 // EO namespace bbvtk
110
111