]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkImageExtractComponents.cxx
4d274db6cce66b378c23f577613cb62f390333ab
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkImageExtractComponents.cxx
1 //===== 
2 // 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)
3 //===== 
4 #include "bbcreaVtkImageExtractComponents.h"
5 #include "bbcreaVtkPackage.h"
6 namespace bbcreaVtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageExtractComponents)
10 BBTK_BLACK_BOX_IMPLEMENTATION(ImageExtractComponents,bbtk::AtomicBlackBox);
11 //===== 
12 // 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)
13 //===== 
14 void ImageExtractComponents::Process()
15 {
16
17 // THE MAIN PROCESSING METHOD BODY
18 //   Here we simply set the input 'In' value to the output 'Out'
19 //   And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 //    void bbSet{Input|Output}NAME(const TYPE&)
22 //    const TYPE& bbGet{Input|Output}NAME() const 
23 //    Where :
24 //    * NAME is the name of the input/output
25 //      (the one provided in the attribute 'name' of the tag 'input')
26 //    * TYPE is the C++ type of the input/output
27 //      (the one provided in the attribute 'type' of the tag 'input')
28
29 //    bbSetOutputOut( bbGetInputIn() );
30 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
31   
32         bbSetOutputOut0( NULL ); 
33         bbSetOutputOut1( NULL ); 
34         bbSetOutputOut2( NULL ); 
35         bbSetOutputOut3( NULL ); 
36
37 // InputComponent 0..3
38         if (bbGetInputType()==0)   
39         {    
40         
41                         if (bbGetInputComponent0()!=-1)
42                         {
43                 //EED 2017-01-01 Migration VTK7
44                 #if VTK_MAJOR_VERSION <= 5
45                                 IEC0->SetInput( bbGetInputIn() );
46                 #else
47                                 IEC0->SetInputData( bbGetInputIn() );
48                 #endif
49                                 IEC0->SetComponents( bbGetInputComponent0() );
50                                 IEC0->Update();
51                                 bbSetOutputOut0( IEC0->GetOutput() ); 
52                         } 
53
54                         if (bbGetInputComponent1()!=-1)
55                         {
56                 //EED 2017-01-01 Migration VTK7
57                 #if VTK_MAJOR_VERSION <= 5
58                                 IEC1->SetInput( bbGetInputIn() );
59                 #else
60                                 IEC1->SetInputData( bbGetInputIn() );
61                 #endif
62                                 IEC1->SetComponents( bbGetInputComponent1() );
63                                 IEC1->Update();
64                                 bbSetOutputOut1( IEC1->GetOutput() ); 
65                         }
66
67                         if (bbGetInputComponent2()!=-1)
68                         {
69                 //EED 2017-01-01 Migration VTK7
70                 #if VTK_MAJOR_VERSION <= 5
71                                 IEC2->SetInput( bbGetInputIn() );
72                 #else
73                                 IEC2->SetInputData( bbGetInputIn() );
74                 #endif
75                                 IEC2->SetComponents( bbGetInputComponent2() );
76                                 IEC2->Update();
77                                 bbSetOutputOut2( IEC2->GetOutput() ); 
78                         }
79
80                         if (bbGetInputComponent3()!=-1)
81                         {
82                 //EED 2017-01-01 Migration VTK7
83                 #if VTK_MAJOR_VERSION <= 5
84                                 IEC3->SetInput( bbGetInputIn() );
85                 #else
86                                 IEC3->SetInputData( bbGetInputIn() );
87                 #endif
88                                 IEC3->SetComponents( bbGetInputComponent2() );
89                                 IEC3->Update();
90                                 bbSetOutputOut3( IEC3->GetOutput() ); 
91                         }
92         } // Type 0
93
94 // List of components
95         if (bbGetInputType()==1) 
96         {   
97                 int i,size=lstIEC.size();
98                 for (i=0; i<size; i++)
99                 {
100                         lstIEC[i]->Delete();
101                 } // for i
102                 lstIEC.clear();
103                 lstOut.clear();
104                 int nrCmp = bbGetInputIn()->GetNumberOfScalarComponents();
105                 for (i=0; i<nrCmp; i++)
106                 {
107                         vtkImageExtractComponents* IEC;
108                         IEC=vtkImageExtractComponents::New();  
109                         IEC->SetInputData( bbGetInputIn() );
110                         IEC->SetComponents( bbGetInputComponent2() );
111                         IEC->Update();
112                         lstIEC.push_back( IEC);
113                         lstOut.push_back( IEC->GetOutput() );
114                         IEC->Delete();
115                 } // for i
116                 bbSetOutputLstOut( lstOut ); 
117         } // Type 1
118
119 }
120
121 //===== 
122 // 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)
123 //===== 
124 void ImageExtractComponents::bbUserSetDefaultValues()
125 {
126 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
127 //    Here we initialize the input 'In' to 0
128    bbSetInputIn(NULL);
129    bbSetInputComponent0(-1);
130    bbSetInputComponent1(-1);
131    bbSetInputComponent2(-1);
132    bbSetInputComponent3(-1);
133    bbSetInputType(0);
134 }
135
136 //===== 
137 // 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)
138 //===== 
139 void ImageExtractComponents::bbUserInitializeProcessing()
140 {
141
142 //  THE INITIALIZATION METHOD BODY :
143 //    Here does nothing 
144 //    but this is where you should allocate the internal/output pointers 
145 //    if any 
146
147         IEC0=vtkImageExtractComponents::New();  
148         IEC1=vtkImageExtractComponents::New();  
149         IEC2=vtkImageExtractComponents::New();  
150         IEC3=vtkImageExtractComponents::New();  
151 }
152 //===== 
153 // 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)
154 //===== 
155 void ImageExtractComponents::bbUserFinalizeProcessing()
156 {
157 //  THE FINALIZATION METHOD BODY :
158 //    Here does nothing 
159 //    but this is where you should desallocate the internal/output pointers 
160 //    if any
161         IEC0->Delete();  
162         IEC1->Delete();  
163         IEC2->Delete();  
164         IEC3->Delete();  
165         int i,size=lstIEC.size();
166         for (i=0; i<size; i++)
167         {
168                 lstIEC[i]->Delete();
169         } // for i
170         lstIEC.clear();
171 }
172
173 }
174 // EO namespace bbcreaVtk
175
176