]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkVoiMPR.cxx
#3316 creaVtk Feature New Normal - VoiMPR box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkVoiMPR.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 "bbcreaVtkVoiMPR.h"
5 #include "bbcreaVtkPackage.h"
6
7 namespace bbcreaVtk
8 {
9
10 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,VoiMPR)
11 BBTK_BLACK_BOX_IMPLEMENTATION(VoiMPR,bbtk::AtomicBlackBox);
12 //===== 
13 // 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)
14 //===== 
15 void VoiMPR::Process()
16 {
17
18 // THE MAIN PROCESSING METHOD BODY
19 //   Here we simply set the input 'In' value to the output 'Out'
20 //   And print out the output value
21 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
22 //    void bbSet{Input|Output}NAME(const TYPE&)
23 //    const TYPE& bbGet{Input|Output}NAME() const 
24 //    Where :
25 //    * NAME is the name of the input/output
26 //      (the one provided in the attribute 'name' of the tag 'input')
27 //    * TYPE is the C++ type of the input/output
28 //      (the one provided in the attribute 'type' of the tag 'input')
29 //    bbSetOutputOut( bbGetInputIn() );
30 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
31   
32         if (bbGetInputIn().size()!=6)
33         {
34                 printf("EED Warning box not defined.\n");
35         } else {
36                 bool showActorXY;
37                 bool showActorYZ;
38                 bool showActorXZ;
39
40                 std::vector<int> vecP = bbGetInputIn();
41                 int dep;
42                 std::vector<int> vecPoint = bbGetInputActualPoint();
43                 if (vecPoint.size()==3)
44                 {
45                         if ((vecPoint[0]>=vecP[0]) && (vecPoint[0]<=vecP[1]) ) 
46                         {       
47                                 showActorYZ=bbGetInputActive() && true; 
48                         } else {
49                                 showActorYZ=bbGetInputActive() && false;        
50                         }
51                         if ((vecPoint[1]>=vecP[2]) && (vecPoint[1]<=vecP[3]) ) 
52                         {       
53                                 showActorXZ=bbGetInputActive() && true; 
54                         } else {
55                                 showActorXZ=bbGetInputActive() && false;        
56                         }
57                         if ((vecPoint[2]>=vecP[4]) && (vecPoint[2]<=vecP[5]) ) 
58                         {       
59                                 showActorXY=bbGetInputActive() && true; 
60                         } else {
61                                 showActorXY=bbGetInputActive() && false;        
62                         }
63                 
64                 } else {
65                         showActorXY=bbGetInputActive();
66                         showActorYZ=bbGetInputActive();
67                         showActorXZ=bbGetInputActive();
68                 }
69
70                 if (bbGetInputXYrender()!=NULL)
71                 {
72                         dep=-900;
73                         pointsXY->SetPoint(0, vecP[0], vecP[2], dep);
74                         pointsXY->SetPoint(1, vecP[0], vecP[3], dep);
75                         pointsXY->SetPoint(2, vecP[1], vecP[3], dep);
76                         pointsXY->SetPoint(3, vecP[1], vecP[2], dep);
77                         pointsXY-> Modified();
78                         if ( showActorXY==true )
79                         {
80                                 if (actorAddedXY==false)
81                                 {
82                                         bbGetInputXYrender()->AddActor(polygonActorXY);
83                                         actorAddedXY=true;
84                                 } // 
85                         } else {
86                                 if (actorAddedXY==true)
87                                 {
88                                         bbGetInputXYrender()->RemoveActor(polygonActorXY);
89                                         actorAddedXY=false;
90                                 } // 
91                         }// Active
92                 } // if XYrender
93                 if (bbGetInputYZrender()!=NULL)
94                 {
95                         dep=900;
96                         pointsYZ->SetPoint(0, dep,vecP[2], vecP[4] );
97                         pointsYZ->SetPoint(1, dep,vecP[2], vecP[5] );
98                         pointsYZ->SetPoint(2, dep,vecP[3], vecP[5] );
99                         pointsYZ->SetPoint(3, dep,vecP[3], vecP[4] );
100                         pointsYZ-> Modified();
101                         if ( showActorYZ==true )
102                         {
103                                 if (actorAddedYZ==false)
104                                 {
105                                         bbGetInputYZrender()->AddActor(polygonActorYZ);
106                                         actorAddedYZ=true;
107                                 } // 
108                         } else {
109                                 if (actorAddedYZ==true)
110                                 {
111                                         bbGetInputYZrender()->RemoveActor(polygonActorYZ);
112                                         actorAddedYZ=false;
113                                 } // 
114                         }// Active
115                 } // if XYrender
116                 if (bbGetInputXZrender()!=NULL)
117                 {
118                         dep=-900;
119                         pointsXZ->SetPoint(0, vecP[0],dep, vecP[4] );
120                         pointsXZ->SetPoint(1, vecP[0],dep, vecP[5] );
121                         pointsXZ->SetPoint(2, vecP[1],dep, vecP[5] );
122                         pointsXZ->SetPoint(3, vecP[1],dep, vecP[4] );
123                         pointsXZ-> Modified();
124                         if ( showActorXZ==true )
125                         {
126                                 if (actorAddedXZ==false)
127                                 {
128                                         bbGetInputXZrender()->AddActor(polygonActorXZ);
129                                         actorAddedXZ=true;
130                                 } // 
131                         } else {
132                                 if (actorAddedXZ==true)
133                                 {
134                                         bbGetInputXZrender()->RemoveActor(polygonActorXZ);
135                                         actorAddedXZ=false;
136                                 } // 
137                         }// Active
138                 } // if XYrender
139         } // In size
140 }
141 //===== 
142 // 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)
143 //===== 
144 void VoiMPR::bbUserSetDefaultValues()
145 {
146
147 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
148 //    Here we initialize the input 'In' to 0
149         actorAddedXY=false;
150         actorAddedXZ=false;
151         actorAddedYZ=false;
152         bbSetInputActive(true);
153         bbSetInputXYrender(NULL);
154         bbSetInputYZrender(NULL);
155         bbSetInputXZrender(NULL);
156 }
157 //===== 
158 // 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)
159 //===== 
160 void VoiMPR::bbUserInitializeProcessing()
161 {
162
163 //  THE INITIALIZATION METHOD BODY :
164 //    Here does nothing 
165 //    but this is where you should allocate the internal/output pointers 
166 //    if any 
167
168         pointsXY                = vtkPoints                     ::New();
169         linesXY                 = vtkCellArray          ::New();
170         polygonXY               = vtkPolyData           ::New();
171         polygonMapperXY = vtkPolyDataMapper     ::New();
172         polygonActorXY  = vtkActor                      ::New();
173         pointsXY                -> SetNumberOfPoints(4);
174         pointsXY                -> SetPoint(0, 0, 0, 0);
175         pointsXY                -> SetPoint(1, 0, 0, 0);
176         pointsXY                -> SetPoint(2, 0, 0, 0);
177         pointsXY                -> SetPoint(3, 0, 0, 0);
178         linesXY                 -> InsertNextCell(5);
179         linesXY                 -> InsertCellPoint(0);
180         linesXY                 -> InsertCellPoint(1);
181         linesXY                 -> InsertCellPoint(2);
182         linesXY                 -> InsertCellPoint(3);
183         linesXY                 -> InsertCellPoint(0);
184         polygonXY               -> SetPoints(pointsXY);
185         polygonXY               -> SetLines(linesXY);
186         polygonMapperXY -> SetInputData(polygonXY);
187         polygonMapperXY -> Update();
188         polygonActorXY  -> SetMapper(polygonMapperXY);
189
190
191         pointsXZ                = vtkPoints                     ::New();
192         linesXZ                 = vtkCellArray          ::New();
193         polygonXZ               = vtkPolyData           ::New();
194         polygonMapperXZ = vtkPolyDataMapper     ::New();
195         polygonActorXZ  = vtkActor                      ::New();
196         pointsXZ                -> SetNumberOfPoints(4);
197         pointsXZ                -> SetPoint(0, 0, 0, 0);
198         pointsXZ                -> SetPoint(1, 0, 0, 0);
199         pointsXZ                -> SetPoint(2, 0, 0, 0);
200         pointsXZ                -> SetPoint(3, 0, 0, 0);
201         linesXZ                 -> InsertNextCell(5);
202         linesXZ                 -> InsertCellPoint(0);
203         linesXZ                 -> InsertCellPoint(1);
204         linesXZ                 -> InsertCellPoint(2);
205         linesXZ                 -> InsertCellPoint(3);
206         linesXZ                 -> InsertCellPoint(0);
207         polygonXZ               -> SetPoints(pointsXZ);
208         polygonXZ               -> SetLines(linesXZ);
209         polygonMapperXZ -> SetInputData(polygonXZ);
210         polygonMapperXZ -> Update();
211         polygonActorXZ  -> SetMapper(polygonMapperXZ);
212
213         pointsYZ                = vtkPoints                     ::New();
214         linesYZ                 = vtkCellArray          ::New();
215         polygonYZ               = vtkPolyData           ::New();
216         polygonMapperYZ = vtkPolyDataMapper     ::New();
217         polygonActorYZ  = vtkActor                      ::New();
218         pointsYZ                ->SetNumberOfPoints(4);
219         pointsYZ                ->SetPoint(0, 0, 0, 0);
220         pointsYZ                ->SetPoint(1, 0, 0, 0);
221         pointsYZ                ->SetPoint(2, 0, 0, 0);
222         pointsYZ                ->SetPoint(3, 0, 0, 0);
223         linesYZ                 ->InsertNextCell(5);
224         linesYZ                 ->InsertCellPoint(0);
225         linesYZ                 ->InsertCellPoint(1);
226         linesYZ                 ->InsertCellPoint(2);
227         linesYZ                 ->InsertCellPoint(3);
228         linesYZ                 ->InsertCellPoint(0);
229         polygonYZ               -> SetPoints(pointsYZ);
230         polygonYZ               -> SetLines(linesYZ);
231         polygonMapperYZ -> SetInputData(polygonYZ);
232         polygonMapperYZ -> Update();
233         polygonActorYZ  -> SetMapper(polygonMapperYZ);
234 }
235 //===== 
236 // 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)
237 //===== 
238 void VoiMPR::bbUserFinalizeProcessing()
239 {
240
241 //  THE FINALIZATION METHOD BODY :
242 //    Here does nothing 
243 //    but this is where you should desallocate the internal/output pointers 
244 //    if any
245   
246 }
247 }
248 // EO namespace bbcreaVtk
249
250