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)
5 #include "bbcreaVtkVoiMPR.h"
6 #include "bbcreaVtkPackage.h"
8 #include <vtkProperty.h>
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,VoiMPR)
14 BBTK_BLACK_BOX_IMPLEMENTATION(VoiMPR,bbtk::AtomicBlackBox);
16 // 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)
18 void VoiMPR::Process()
21 // THE MAIN PROCESSING METHOD BODY
22 // Here we simply set the input 'In' value to the output 'Out'
23 // And print out the output value
24 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
25 // void bbSet{Input|Output}NAME(const TYPE&)
26 // const TYPE& bbGet{Input|Output}NAME() const
28 // * NAME is the name of the input/output
29 // (the one provided in the attribute 'name' of the tag 'input')
30 // * TYPE is the C++ type of the input/output
31 // (the one provided in the attribute 'type' of the tag 'input')
32 // bbSetOutputOut( bbGetInputIn() );
33 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35 if (bbGetInputIn().size()!=6)
37 printf("EED Warning box not defined.\n");
43 std::vector<int> vecVOI = bbGetInputIn();
44 std::vector<double> spc = bbGetInputSpacing();
45 vecVOI[0] = vecVOI[0]*spc[0];
46 vecVOI[1] = vecVOI[1]*spc[0];
47 vecVOI[2] = vecVOI[2]*spc[1];
48 vecVOI[3] = vecVOI[3]*spc[1];
49 vecVOI[4] = vecVOI[4]*spc[2];
50 vecVOI[5] = vecVOI[5]*spc[2];
52 std::vector<int> vecPoint = bbGetInputActualPoint();
53 vecPoint[0] = vecPoint[0]*spc[0];
54 vecPoint[1] = vecPoint[1]*spc[1];
55 vecPoint[2] = vecPoint[2]*spc[2];
57 if (vecPoint.size()==3)
59 if ((vecPoint[0]>=vecVOI[0]) && (vecPoint[0]<=vecVOI[1]) )
61 showActorYZ=bbGetInputActive() && true;
63 showActorYZ=bbGetInputActive() && false;
65 if ((vecPoint[1]>=vecVOI[2]) && (vecPoint[1]<=vecVOI[3]) )
67 showActorXZ=bbGetInputActive() && true;
69 showActorXZ=bbGetInputActive() && false;
71 if ((vecPoint[2]>=vecVOI[4]) && (vecPoint[2]<=vecVOI[5]) )
73 showActorXY=bbGetInputActive() && true;
75 showActorXY=bbGetInputActive() && false;
79 showActorXY=bbGetInputActive();
80 showActorYZ=bbGetInputActive();
81 showActorXZ=bbGetInputActive();
84 if (bbGetInputXYrender()!=NULL)
87 pointsXY->SetPoint(0, vecVOI[0], vecVOI[2], dep);
88 pointsXY->SetPoint(1, vecVOI[0], vecVOI[3], dep);
89 pointsXY->SetPoint(2, vecVOI[1], vecVOI[3], dep);
90 pointsXY->SetPoint(3, vecVOI[1], vecVOI[2], dep);
91 pointsXY-> Modified();
92 if ( showActorXY==true )
94 if (actorAddedXY==false)
96 bbGetInputXYrender()->AddActor(polygonActorXY);
100 if (actorAddedXY==true)
102 bbGetInputXYrender()->RemoveActor(polygonActorXY);
107 if (bbGetInputYZrender()!=NULL)
110 pointsYZ->SetPoint(0, dep,vecVOI[2], vecVOI[4] );
111 pointsYZ->SetPoint(1, dep,vecVOI[2], vecVOI[5] );
112 pointsYZ->SetPoint(2, dep,vecVOI[3], vecVOI[5] );
113 pointsYZ->SetPoint(3, dep,vecVOI[3], vecVOI[4] );
114 pointsYZ-> Modified();
115 if ( showActorYZ==true )
117 if (actorAddedYZ==false)
119 bbGetInputYZrender()->AddActor(polygonActorYZ);
123 if (actorAddedYZ==true)
125 bbGetInputYZrender()->RemoveActor(polygonActorYZ);
130 if (bbGetInputXZrender()!=NULL)
133 pointsXZ->SetPoint(0, vecVOI[0],dep, vecVOI[4] );
134 pointsXZ->SetPoint(1, vecVOI[0],dep, vecVOI[5] );
135 pointsXZ->SetPoint(2, vecVOI[1],dep, vecVOI[5] );
136 pointsXZ->SetPoint(3, vecVOI[1],dep, vecVOI[4] );
137 pointsXZ-> Modified();
138 if ( showActorXZ==true )
140 if (actorAddedXZ==false)
142 bbGetInputXZrender()->AddActor(polygonActorXZ);
146 if (actorAddedXZ==true)
148 bbGetInputXZrender()->RemoveActor(polygonActorXZ);
156 // 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)
158 void VoiMPR::bbUserSetDefaultValues()
161 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
162 // Here we initialize the input 'In' to 0
163 actorAddedXY = false;
164 actorAddedXZ = false;
165 actorAddedYZ = false;
166 bbSetInputActive(true);
167 bbSetInputXYrender(NULL);
168 bbSetInputYZrender(NULL);
169 bbSetInputXZrender(NULL);
171 std::vector<double> spc;
175 bbSetInputSpacing(spc);
178 // 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)
180 void VoiMPR::bbUserInitializeProcessing()
183 // THE INITIALIZATION METHOD BODY :
185 // but this is where you should allocate the internal/output pointers
189 pointsXY = vtkPoints ::New();
190 linesXY = vtkCellArray ::New();
191 polygonXY = vtkPolyData ::New();
192 polygonMapperXY = vtkPolyDataMapper ::New();
193 polygonActorXY = vtkActor ::New();
195 polygonActorXY->GetProperty()->SetOpacity(0.9999);
196 pointsXY -> SetNumberOfPoints(4);
197 pointsXY -> SetPoint(0, 0, 0, 0);
198 pointsXY -> SetPoint(1, 0, 0, 0);
199 pointsXY -> SetPoint(2, 0, 0, 0);
200 pointsXY -> SetPoint(3, 0, 0, 0);
201 linesXY -> InsertNextCell(5);
202 linesXY -> InsertCellPoint(0);
203 linesXY -> InsertCellPoint(1);
204 linesXY -> InsertCellPoint(2);
205 linesXY -> InsertCellPoint(3);
206 linesXY -> InsertCellPoint(0);
207 polygonXY -> SetPoints(pointsXY);
208 polygonXY -> SetLines(linesXY);
209 polygonMapperXY -> SetInputData(polygonXY);
210 polygonMapperXY -> Update();
211 polygonActorXY -> SetMapper(polygonMapperXY);
212 polygonActorXY -> GetProperty()->SetOpacity(0.99);
213 polygonActorXY -> GetProperty()->SetLineWidth(2);
215 pointsXZ = vtkPoints ::New();
216 linesXZ = vtkCellArray ::New();
217 polygonXZ = vtkPolyData ::New();
218 polygonMapperXZ = vtkPolyDataMapper ::New();
219 polygonActorXZ = vtkActor ::New();
221 polygonActorXZ->GetProperty()->SetOpacity(0.9999);
222 pointsXZ -> SetNumberOfPoints(4);
223 pointsXZ -> SetPoint(0, 0, 0, 0);
224 pointsXZ -> SetPoint(1, 0, 0, 0);
225 pointsXZ -> SetPoint(2, 0, 0, 0);
226 pointsXZ -> SetPoint(3, 0, 0, 0);
227 linesXZ -> InsertNextCell(5);
228 linesXZ -> InsertCellPoint(0);
229 linesXZ -> InsertCellPoint(1);
230 linesXZ -> InsertCellPoint(2);
231 linesXZ -> InsertCellPoint(3);
232 linesXZ -> InsertCellPoint(0);
233 polygonXZ -> SetPoints(pointsXZ);
234 polygonXZ -> SetLines(linesXZ);
235 polygonMapperXZ -> SetInputData(polygonXZ);
236 polygonMapperXZ -> Update();
237 polygonActorXZ -> SetMapper(polygonMapperXZ);
238 polygonActorXZ -> GetProperty()->SetOpacity(0.99);
239 polygonActorXZ -> GetProperty()->SetLineWidth(2);
241 pointsYZ = vtkPoints ::New();
242 linesYZ = vtkCellArray ::New();
243 polygonYZ = vtkPolyData ::New();
244 polygonMapperYZ = vtkPolyDataMapper ::New();
245 polygonActorYZ = vtkActor ::New();
247 polygonActorYZ->GetProperty()->SetOpacity(0.9999);
248 pointsYZ ->SetNumberOfPoints(4);
249 pointsYZ ->SetPoint(0, 0, 0, 0);
250 pointsYZ ->SetPoint(1, 0, 0, 0);
251 pointsYZ ->SetPoint(2, 0, 0, 0);
252 pointsYZ ->SetPoint(3, 0, 0, 0);
253 linesYZ ->InsertNextCell(5);
254 linesYZ ->InsertCellPoint(0);
255 linesYZ ->InsertCellPoint(1);
256 linesYZ ->InsertCellPoint(2);
257 linesYZ ->InsertCellPoint(3);
258 linesYZ ->InsertCellPoint(0);
259 polygonYZ -> SetPoints(pointsYZ);
260 polygonYZ -> SetLines(linesYZ);
261 polygonMapperYZ -> SetInputData(polygonYZ);
262 polygonMapperYZ -> Update();
263 polygonActorYZ -> SetMapper(polygonMapperYZ);
264 polygonActorYZ -> GetProperty()->SetOpacity(0.99);
265 polygonActorXY -> GetProperty()->SetLineWidth(2);
269 // 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)
271 void VoiMPR::bbUserFinalizeProcessing()
273 // THE FINALIZATION METHOD BODY :
275 // but this is where you should desallocate the internal/output pointers
279 }// EO namespace bbcreaVtk