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)
4 #include "bbcreaVtkVoiMPR.h"
5 #include "bbcreaVtkPackage.h"
10 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,VoiMPR)
11 BBTK_BLACK_BOX_IMPLEMENTATION(VoiMPR,bbtk::AtomicBlackBox);
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)
15 void VoiMPR::Process()
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
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;
32 if (bbGetInputIn().size()!=6)
34 printf("EED Warning box not defined.\n");
40 std::vector<int> vecVOI = bbGetInputIn();
41 std::vector<double> spc = bbGetInputSpacing();
42 vecVOI[0] = vecVOI[0]*spc[0];
43 vecVOI[1] = vecVOI[1]*spc[0];
44 vecVOI[2] = vecVOI[2]*spc[1];
45 vecVOI[3] = vecVOI[3]*spc[1];
46 vecVOI[4] = vecVOI[4]*spc[2];
47 vecVOI[5] = vecVOI[5]*spc[2];
49 std::vector<int> vecPoint = bbGetInputActualPoint();
50 vecPoint[0] = vecPoint[0]*spc[0];
51 vecPoint[1] = vecPoint[1]*spc[1];
52 vecPoint[2] = vecPoint[2]*spc[2];
54 if (vecPoint.size()==3)
56 if ((vecPoint[0]>=vecVOI[0]) && (vecPoint[0]<=vecVOI[1]) )
58 showActorYZ=bbGetInputActive() && true;
60 showActorYZ=bbGetInputActive() && false;
62 if ((vecPoint[1]>=vecVOI[2]) && (vecPoint[1]<=vecVOI[3]) )
64 showActorXZ=bbGetInputActive() && true;
66 showActorXZ=bbGetInputActive() && false;
68 if ((vecPoint[2]>=vecVOI[4]) && (vecPoint[2]<=vecVOI[5]) )
70 showActorXY=bbGetInputActive() && true;
72 showActorXY=bbGetInputActive() && false;
76 showActorXY=bbGetInputActive();
77 showActorYZ=bbGetInputActive();
78 showActorXZ=bbGetInputActive();
81 if (bbGetInputXYrender()!=NULL)
84 pointsXY->SetPoint(0, vecVOI[0], vecVOI[2], dep);
85 pointsXY->SetPoint(1, vecVOI[0], vecVOI[3], dep);
86 pointsXY->SetPoint(2, vecVOI[1], vecVOI[3], dep);
87 pointsXY->SetPoint(3, vecVOI[1], vecVOI[2], dep);
88 pointsXY-> Modified();
89 if ( showActorXY==true )
91 if (actorAddedXY==false)
93 bbGetInputXYrender()->AddActor(polygonActorXY);
97 if (actorAddedXY==true)
99 bbGetInputXYrender()->RemoveActor(polygonActorXY);
104 if (bbGetInputYZrender()!=NULL)
107 pointsYZ->SetPoint(0, dep,vecVOI[2], vecVOI[4] );
108 pointsYZ->SetPoint(1, dep,vecVOI[2], vecVOI[5] );
109 pointsYZ->SetPoint(2, dep,vecVOI[3], vecVOI[5] );
110 pointsYZ->SetPoint(3, dep,vecVOI[3], vecVOI[4] );
111 pointsYZ-> Modified();
112 if ( showActorYZ==true )
114 if (actorAddedYZ==false)
116 bbGetInputYZrender()->AddActor(polygonActorYZ);
120 if (actorAddedYZ==true)
122 bbGetInputYZrender()->RemoveActor(polygonActorYZ);
127 if (bbGetInputXZrender()!=NULL)
130 pointsXZ->SetPoint(0, vecVOI[0],dep, vecVOI[4] );
131 pointsXZ->SetPoint(1, vecVOI[0],dep, vecVOI[5] );
132 pointsXZ->SetPoint(2, vecVOI[1],dep, vecVOI[5] );
133 pointsXZ->SetPoint(3, vecVOI[1],dep, vecVOI[4] );
134 pointsXZ-> Modified();
135 if ( showActorXZ==true )
137 if (actorAddedXZ==false)
139 bbGetInputXZrender()->AddActor(polygonActorXZ);
143 if (actorAddedXZ==true)
145 bbGetInputXZrender()->RemoveActor(polygonActorXZ);
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)
155 void VoiMPR::bbUserSetDefaultValues()
158 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
159 // Here we initialize the input 'In' to 0
160 actorAddedXY = false;
161 actorAddedXZ = false;
162 actorAddedYZ = false;
163 bbSetInputActive(true);
164 bbSetInputXYrender(NULL);
165 bbSetInputYZrender(NULL);
166 bbSetInputXZrender(NULL);
168 std::vector<double> spc;
172 bbSetInputSpacing(spc);
175 // 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)
177 void VoiMPR::bbUserInitializeProcessing()
180 // THE INITIALIZATION METHOD BODY :
182 // but this is where you should allocate the internal/output pointers
186 pointsXY = vtkPoints ::New();
187 linesXY = vtkCellArray ::New();
188 polygonXY = vtkPolyData ::New();
189 polygonMapperXY = vtkPolyDataMapper ::New();
190 polygonActorXY = vtkActor ::New();
191 pointsXY -> SetNumberOfPoints(4);
192 pointsXY -> SetPoint(0, 0, 0, 0);
193 pointsXY -> SetPoint(1, 0, 0, 0);
194 pointsXY -> SetPoint(2, 0, 0, 0);
195 pointsXY -> SetPoint(3, 0, 0, 0);
196 linesXY -> InsertNextCell(5);
197 linesXY -> InsertCellPoint(0);
198 linesXY -> InsertCellPoint(1);
199 linesXY -> InsertCellPoint(2);
200 linesXY -> InsertCellPoint(3);
201 linesXY -> InsertCellPoint(0);
202 polygonXY -> SetPoints(pointsXY);
203 polygonXY -> SetLines(linesXY);
204 polygonMapperXY -> SetInputData(polygonXY);
205 polygonMapperXY -> Update();
206 polygonActorXY -> SetMapper(polygonMapperXY);
209 pointsXZ = vtkPoints ::New();
210 linesXZ = vtkCellArray ::New();
211 polygonXZ = vtkPolyData ::New();
212 polygonMapperXZ = vtkPolyDataMapper ::New();
213 polygonActorXZ = vtkActor ::New();
214 pointsXZ -> SetNumberOfPoints(4);
215 pointsXZ -> SetPoint(0, 0, 0, 0);
216 pointsXZ -> SetPoint(1, 0, 0, 0);
217 pointsXZ -> SetPoint(2, 0, 0, 0);
218 pointsXZ -> SetPoint(3, 0, 0, 0);
219 linesXZ -> InsertNextCell(5);
220 linesXZ -> InsertCellPoint(0);
221 linesXZ -> InsertCellPoint(1);
222 linesXZ -> InsertCellPoint(2);
223 linesXZ -> InsertCellPoint(3);
224 linesXZ -> InsertCellPoint(0);
225 polygonXZ -> SetPoints(pointsXZ);
226 polygonXZ -> SetLines(linesXZ);
227 polygonMapperXZ -> SetInputData(polygonXZ);
228 polygonMapperXZ -> Update();
229 polygonActorXZ -> SetMapper(polygonMapperXZ);
231 pointsYZ = vtkPoints ::New();
232 linesYZ = vtkCellArray ::New();
233 polygonYZ = vtkPolyData ::New();
234 polygonMapperYZ = vtkPolyDataMapper ::New();
235 polygonActorYZ = vtkActor ::New();
236 pointsYZ ->SetNumberOfPoints(4);
237 pointsYZ ->SetPoint(0, 0, 0, 0);
238 pointsYZ ->SetPoint(1, 0, 0, 0);
239 pointsYZ ->SetPoint(2, 0, 0, 0);
240 pointsYZ ->SetPoint(3, 0, 0, 0);
241 linesYZ ->InsertNextCell(5);
242 linesYZ ->InsertCellPoint(0);
243 linesYZ ->InsertCellPoint(1);
244 linesYZ ->InsertCellPoint(2);
245 linesYZ ->InsertCellPoint(3);
246 linesYZ ->InsertCellPoint(0);
247 polygonYZ -> SetPoints(pointsYZ);
248 polygonYZ -> SetLines(linesYZ);
249 polygonMapperYZ -> SetInputData(polygonYZ);
250 polygonMapperYZ -> Update();
251 polygonActorYZ -> SetMapper(polygonMapperYZ);
254 // 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)
256 void VoiMPR::bbUserFinalizeProcessing()
259 // THE FINALIZATION METHOD BODY :
261 // but this is where you should desallocate the internal/output pointers
266 // EO namespace bbcreaVtk