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 "creaVtk_MACROS.h"
6 #include "bbcreaMaracasVisuManualPaint_Model.h"
7 #include "bbcreaMaracasVisuPackage.h"
10 namespace bbcreaMaracasVisu
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualPaint_Model)
14 BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint_Model,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)
19 //-- Alternativa con openmp --
20 void ManualPaint_Model::LstPointOMPAnalice()
22 //-- Alternativa con openmp --
23 // A. Create copie of index original list => lst1
24 // B. if list1 es not empty do..
25 // B.1. Create copy of lst1 to lst2
26 // B.2. For each element of lst2 (incrimental) check the distance of the rest of the list (decremental) and take it out
27 // B.3. openmp sobre la La lst2 que queda (PaintImage)
28 // B.4. Quitar los elementos de lst2 en lst1 y recomenzar desde el punto B;
30 double distMin,dist2Min;
31 if (bbGetInputTool()==0)
33 distMin=bbGetInputBrushSize();
35 distMin=bbGetInputDistanceFill();
37 dist2Min=distMin*distMin*1.2;
39 // A. Create copie of index original list => lst1
40 std::vector<int> lst1;
41 int i1,size1 = bbGetInputByLstPointsX().size();
42 for (i1=0;i1<size1;i1++)
47 // B. if list1 es not empty do..
49 double dist2,dx,dy,dz;
50 while (lst1.size()!=0)
52 // B.1. Create copy of lst1 to lst2
54 std::vector<int> lst2;
55 for (i1=0;i1<size1;i1++)
57 lst2.push_back( lst1[i1] );
60 // B.2. For each element of lst2 (incrimental) check the distance of the rest of the list (decremental) and take it out
61 for (i2=0;i2<lst2.size();i2++)
64 for ( i3=size2-1 ; i3>i2 ; i3-- )
66 dx = bbGetInputByLstPointsX()[ lst2[i2] ]-bbGetInputByLstPointsX()[ lst2[i3] ];
67 dy = bbGetInputByLstPointsY()[ lst2[i2] ]-bbGetInputByLstPointsY()[ lst2[i3] ];
68 dz = bbGetInputByLstPointsZ()[ lst2[i2] ]-bbGetInputByLstPointsZ()[ lst2[i3] ];
69 dist2 = dx*dx +dy*dy + dz*dz ;
72 lst2.erase( lst2.begin()+i3 );
76 // B.3. openmp sobre la La lst2 que queda (PaintImage)
78 long int k1omp=(double)(size2-1)*0.0;
79 long int k2omp=(double)(size2-1)*0.2;
80 long int k3omp=(double)(size2-1)*0.4;
81 long int k4omp=(double)(size2-1)*0.6;
82 long int k5omp=(double)(size2-1)*0.8;
83 long int k6omp=(double)(size2-1)*1.0;
84 printf("EED ManualPaint_Model::LstPointOMPAnalice (with openmp) size=%ld\n",size2);
85 #pragma omp parallel for
86 for (i2=0;i2<size2;i2++)
88 if ( (k1omp==i2) || (k2omp==i2) || (k3omp==i2) ||
89 (k4omp==i2) || (k5omp==i2) || (k6omp==i2) )
93 printf(" 100% (just one element)\n");
95 printf(" %d%\n", (int)(((double)i2/(double)(size2-1))*100 ));
98 manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[ lst2[i2] ] ,
99 bbGetInputByLstPointsY()[ lst2[i2] ] ,
100 bbGetInputByLstPointsZ()[ lst2[i2] ] );
103 // B.4. Quitar los elementos de lst2 en lst1 y recomenzar desde el punto B;
104 for (i2=0;i2<size2;i2++)
107 for (i1=0;i1<size1;i1++)
109 if (lst2[i2]==lst1[i1])
111 lst1.erase( lst1.begin()+i1 );
122 void ManualPaint_Model::Process()
126 0. Quitar comentarion ByLstPoints openmp
127 1. Falta openmp ByImagePoints
128 2. Desligar cada PaintImage de la mascara
129 -pequeno bloque de memoria para cada PaintImage
130 -el resultado volverlo a colocar en la image2 original
131 -Si no existe image2 original y hay que colocarlo en la imagen de origien
132 hay que crear una imagen2 temporal y luego bajar la imagen
133 3. Verificar el mecanismo de undo con ByLstPoints
134 4. Verificar el mecanismo de undo con ByImagePoints
136 if (bbGetInputActive()==true)
138 if (bbGetInputImage()!=NULL)
140 manualpaintmodel->SetActive( bbGetInputActive() );
141 manualpaintmodel->SetTool( bbGetInputTool() );
142 manualpaintmodel->Set2D3D( bbGetInput2D3D() );
143 manualpaintmodel->SetImages( bbGetInputImage(),bbGetInputImage2() );
144 manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() );
145 manualpaintmodel->SetDirection( bbGetInputDirection() );
146 manualpaintmodel->SetBrushSize( bbGetInputBrushSize() );
147 manualpaintmodel->SetBrushForm( bbGetInputBrushForm() );
148 manualpaintmodel->SetToleranceFill( bbGetInputToleranceFill() );
149 manualpaintmodel->SetDistanceFill( bbGetInputDistanceFill() );
150 manualpaintmodel->SetRangeMin( bbGetInputRange()[0] );
151 manualpaintmodel->SetRangeMax( bbGetInputRange()[1] );
152 if (bbGetInputPoint().size()==3)
154 manualpaintmodel->PaintImage( bbGetInputPoint()[0] , bbGetInputPoint()[1] , bbGetInputPoint()[2] );
155 manualpaintmodel->SetUndoImage();
157 if ( bbGetInputByLstPointsX().size()!=0 )
159 //-- Alternativa con openmp --
160 LstPointOMPAnalice();
162 /* -- Original ByLstPoints sin openmp --
163 int i,size = bbGetInputByLstPointsX().size();
166 manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[i] ,
167 bbGetInputByLstPointsY()[i] ,
168 bbGetInputByLstPointsZ()[i] );
169 //_manualPaintModel->SetUndoImage(); // Probably needed. Here is ok.
171 -- Original ByLstPoints sin openmp --*/
174 if ((bbGetInputByImagePoints()!=NULL) && (bbGetInputImage2()!=NULL) )
176 // -- Alternativa con openmp --
177 // Calcular numero de cuadrantes
178 // Recorrer el primer cuadrante
179 // Sacar la lista de todos los cuadrantes con el iElement Listo para analizar
180 // Recorrer la lista con openmp y ejecutar PaintImage
182 ///* -------------------- Original ByImagePoints sin openmp----------------------------
186 //EED 2017-01-01 Migration VTK7
187 #if VTK_MAJOR_VERSION <= 5
188 bbGetInputByImagePoints()->GetWholeExtent(ext);
190 bbGetInputByImagePoints()->GetExtent(ext);
192 int dimX=ext[1]-ext[0]+1;
193 int dimY=ext[3]-ext[2]+1;
194 int dimZ=ext[5]-ext[4]+1;
195 DEF_POINTER_IMAGE_VTK_CREA(vBIP,sSBIP,pBIP,sTBIP,bbGetInputByImagePoints());
196 DEF_POINTER_IMAGE_VTK_CREA(vI2,sSI2,pI2,sTI2,bbGetInputImage2());
198 //#pragma omp parallel for
203 printf("ManualPaint_Model %d%\n", (int)(k*100.0/dimZ) );
209 GETVALUE_VTK_CREA(vBIP,pBIP,sTBIP)
212 GETVALUE_VTK_CREA(vI2,pI2,sTI2)
215 manualpaintmodel->PaintImage(i,j,k);
216 // manualpaintmodel->SetUndoImage(); // Probably needed. Here is ok.
224 printf("ManualPaint_Model %d%\n", 100 );
225 //------- Original ByImagePoints sin openmp-------- */
226 } // if ByImagePoints
229 printf("EED Warning!! creaMaracasVisu::ManualPaint_Model (BBTK) bbInputImage not set. \n");
230 } // if (bbGetInputImage()!=NULL)
233 if (bbGetInputImage2()!=NULL)
235 bbSetOutputOut( bbGetInputImage2() );
236 } else if (bbGetInputImage()!=NULL) {
237 bbSetOutputOut( bbGetInputImage() );
239 bbSetOutputOut( NULL );
241 bbSetOutputManualpaintmodel( manualpaintmodel );
244 // 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)
246 void ManualPaint_Model::bbUserSetDefaultValues()
249 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
250 // Here we initialize the input 'In' to 0
252 bbSetInputActive(true);
253 bbSetInputTool(1); // Paint
254 bbSetInput2D3D(1); // 3D
255 bbSetInputImage(NULL);
256 bbSetInputImage2(NULL);
257 bbSetInputGrayLevel(100);
258 bbSetInputDirection(2); // XY
259 bbSetInputBrushSize(3);
260 bbSetInputBrushForm(1); // sphere
261 bbSetInputToleranceFill(50);
262 bbSetInputDistanceFill(25);
263 std::vector<int> point;
267 bbSetInputPoint(point);
268 std::vector<double> range;
270 range.push_back(200);
271 bbSetInputRange(range);
272 bbSetInputByImagePoints(NULL);
275 // 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)
277 void ManualPaint_Model::bbUserInitializeProcessing()
280 // THE INITIALIZATION METHOD BODY :
282 // but this is where you should allocate the internal/output pointers
284 manualpaintmodel=new ManualPaintModel();
287 // 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)
289 void ManualPaint_Model::bbUserFinalizeProcessing()
292 // THE FINALIZATION METHOD BODY :
294 // but this is where you should desallocate the internal/output pointers
296 delete manualpaintmodel;
301 // EO namespace bbcreaMaracasVisu