X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk%2Fsrc%2FbbcreaMaracasVisuManualPaint_Model.cxx;h=aba4fc8bf54805e111a86d1bf00efdab3750eba9;hb=d79fc05657cfa43ed1cd6937a5acaeaf70e09b45;hp=58df16c3523c4da7bea3f11f4ab15842e33051f4;hpb=bbb19bdd8a8eb66baed150fc60a37976ecc4a67c;p=creaMaracasVisu.git diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx index 58df16c..aba4fc8 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx @@ -6,6 +6,8 @@ #include "bbcreaMaracasVisuManualPaint_Model.h" #include "bbcreaMaracasVisuPackage.h" +#include + namespace bbcreaMaracasVisu { @@ -16,24 +18,132 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint_Model,bbtk::AtomicBlackBox); // 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) //===== - -void ManualPaint_Model::Process() +//-- Alternativa con openmp -- +void ManualPaint_Model::LstPointOMPAnalice() { -// THE MAIN PROCESSING METHOD BODY -// Here we simply set the input 'In' value to the output 'Out' -// And print out the output value -// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : -// void bbSet{Input|Output}NAME(const TYPE&) -// const TYPE& bbGet{Input|Output}NAME() const -// Where : -// * NAME is the name of the input/output -// (the one provided in the attribute 'name' of the tag 'input') -// * TYPE is the C++ type of the input/output -// (the one provided in the attribute 'type' of the tag 'input') -// bbSetOutputOut( bbGetInputIn() ); -// std::cout << "Output value = " < lst1 +// B. if list1 es not empty do.. +// B.1. Create copy of lst1 to lst2 +// B.2. For each element of lst2 (incrimental) check the distance of the rest of the list (decremental) and take it out +// B.3. openmp sobre la La lst2 que queda (PaintImage) +// B.4. Quitar los elementos de lst2 en lst1 y recomenzar desde el punto B; + + double distMin,dist2Min; + if (bbGetInputTool()==0) + { + distMin=bbGetInputBrushSize(); + } else { + distMin=bbGetInputDistanceFill(); + } + dist2Min=distMin*distMin*1.2; + +// A. Create copie of index original list => lst1 + std::vector lst1; + int i1,size1 = bbGetInputByLstPointsX().size(); + for (i1=0;i1 lst2; + for (i1=0;i1i2 ; i3-- ) + { + dx = bbGetInputByLstPointsX()[ lst2[i2] ]-bbGetInputByLstPointsX()[ lst2[i3] ]; + dy = bbGetInputByLstPointsY()[ lst2[i2] ]-bbGetInputByLstPointsY()[ lst2[i3] ]; + dz = bbGetInputByLstPointsZ()[ lst2[i2] ]-bbGetInputByLstPointsZ()[ lst2[i3] ]; + dist2 = dx*dx +dy*dy + dz*dz ; + if (dist2PaintImage( bbGetInputByLstPointsX()[ lst2[i2] ] , + bbGetInputByLstPointsY()[ lst2[i2] ] , + bbGetInputByLstPointsZ()[ lst2[i2] ] ); + } // for i2 +// B.4. Quitar los elementos de lst2 en lst1 y recomenzar desde el punto B; + for (i2=0;i2SetTool( bbGetInputTool() ); manualpaintmodel->Set2D3D( bbGetInput2D3D() ); manualpaintmodel->SetImages( bbGetInputImage(),bbGetInputImage2() ); - manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() ); + manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() ); manualpaintmodel->SetDirection( bbGetInputDirection() ); manualpaintmodel->SetBrushSize( bbGetInputBrushSize() ); manualpaintmodel->SetBrushForm( bbGetInputBrushForm() ); manualpaintmodel->SetToleranceFill( bbGetInputToleranceFill() ); - manualpaintmodel->SetDistanceFill( bbGetInputDistanceFill() ); + manualpaintmodel->SetDistanceFill( bbGetInputDistanceFill() ); manualpaintmodel->SetRangeMin( bbGetInputRange()[0] ); manualpaintmodel->SetRangeMax( bbGetInputRange()[1] ); if (bbGetInputPoint().size()==3) { manualpaintmodel->PaintImage( bbGetInputPoint()[0] , bbGetInputPoint()[1] , bbGetInputPoint()[2] ); manualpaintmodel->SetUndoImage(); + manualpaintmodel->Copy_GeneralAuxFill_to_Results(); } // if Points if ( bbGetInputByLstPointsX().size()!=0 ) { + //-- Alternativa con openmp -- +// LstPointOMPAnalice(); + +// /* -- Original ByLstPoints sin openmp -- int i,size = bbGetInputByLstPointsX().size(); +long int k1omp=(double)(size-1)*0.0; +long int k2omp=(double)(size-1)*0.2; +long int k3omp=(double)(size-1)*0.4; +long int k4omp=(double)(size-1)*0.6; +long int k5omp=(double)(size-1)*0.8; +long int k6omp=(double)(size-1)*1.0; +printf("EED ManualPaint_Model::Process list of points (with openmp) size=%d\n",size); +#pragma omp parallel for for (i=0;iPaintImage( bbGetInputByLstPointsX()[i] , bbGetInputByLstPointsY()[i] , bbGetInputByLstPointsZ()[i] ); - // _manualPaintModel->SetUndoImage(); // Probably needed. Here is ok. + if ( (k1omp==i) || (k2omp==i) || (k3omp==i) || + (k4omp==i) || (k5omp==i) || (k6omp==i) ) + { + if (size==1) + { + printf(" 100% (just one element)\n"); + } else { + printf(" %d% \n", (int)(((double)i/(double)(size-1))*100 )); + } + }// if K#omp + manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[i] , + bbGetInputByLstPointsY()[i] , + bbGetInputByLstPointsZ()[i] ); + //_manualPaintModel->SetUndoImage(); // Probably needed. Here is ok. } // for +// -- Original ByLstPoints sin openmp --*/ + + manualpaintmodel->Copy_GeneralAuxFill_to_Results(); + }// if ByLstPointsX if ((bbGetInputByImagePoints()!=NULL) && (bbGetInputImage2()!=NULL) ) { + // -- Alternativa con openmp -- + // Calcular numero de cuadrantes + // Recorrer el primer cuadrante + // Sacar la lista de todos los cuadrantes con el iElement Listo para analizar + // Recorrer la lista con openmp y ejecutar PaintImage + +///* -------------------- Original ByImagePoints sin openmp---------------------------- // int ia,ja,ka; // int ii,jj,kk; int ext[6]; @@ -80,14 +226,127 @@ void ManualPaint_Model::Process() int dimZ=ext[5]-ext[4]+1; DEF_POINTER_IMAGE_VTK_CREA(vBIP,sSBIP,pBIP,sTBIP,bbGetInputByImagePoints()); DEF_POINTER_IMAGE_VTK_CREA(vI2,sSI2,pI2,sTI2,bbGetInputImage2()); - //#pragma omp parallel for + + long int index, size=dimX*dimY*dimZ; + +printf("EED ManualPaint_Model::Process A.start\n"); +std::vector lstX; +std::vector lstY; +std::vector lstZ; int i,j,k; - for (k=0;k0) { - printf("ManualPaint_Model %d%\n", (int)(k*100.0/dimZ) ); - } + GETVALUE2_VTK_CREA(value2,pI2,sTI2,index) + if (value2==0) + { + i = index % dimX; + j = (index % (dimX*dimY)) / dimX; + k = index / (dimX*dimY); + lstX.push_back(i); + lstY.push_back(j); + lstZ.push_back(k); + } // if value2 + } // if value1 + } // for +printf("EED ManualPaint_Model::Process B.end\n"); + +size=lstX.size(); +long int k1omp=(double)(size-1)*0.0; +long int k2omp=(double)(size-1)*0.2; +long int k3omp=(double)(size-1)*0.4; +long int k4omp=(double)(size-1)*0.6; +long int k5omp=(double)(size-1)*0.8; +long int k6omp=(double)(size-1)*1.0; +printf("EED ManualPaint_Model::Process ByImagePoints (with openmp) size=%d GrayLevel=%f this=%p\n",size,(double)bbGetInputGrayLevel(),this); +//omp_set_num_threads( omp_get_max_threads()-1 ); +#pragma omp parallel for + for (index=0; index0) +// { +// double value2; +// GETVALUE2_VTK_CREA(value2,pI2,sTI2,index) +// if (value2==0) +// { +// int i = index % dimX; +// int j = (index % (dimX*dimY)) / dimX; +// int k = index / (dimX*dimY); + manualpaintmodel->PaintImage(lstX[index],lstY[index],lstZ[index]); +// // manualpaintmodel->SetUndoImage(); // Probably needed. Here is ok. +// } // vI2 +// } // vBIP + } // for index END openmp + manualpaintmodel->Copy_GeneralAuxFill_to_Results(); + + + + + + + +/* openmp +long int k1omp=(double)(size-1)*0.0; +long int k2omp=(double)(size-1)*0.2; +long int k3omp=(double)(size-1)*0.4; +long int k4omp=(double)(size-1)*0.6; +long int k5omp=(double)(size-1)*0.8; +long int k6omp=(double)(size-1)*1.0; +printf("EED ManualPaint_Model::Process ByImagePoints (with openmp) size=%d GrayLevel=%f this=%p\n",size,(double)bbGetInputGrayLevel(),this); +omp_set_num_threads( omp_get_max_threads()-1 ); +#pragma omp parallel for + for (index=0; index0) + { + double value2; + GETVALUE2_VTK_CREA(value2,pI2,sTI2,index) + if (value2==0) + { + int i = index % dimX; + int j = (index % (dimX*dimY)) / dimX; + int k = index / (dimX*dimY); + manualpaintmodel->PaintImage(i,j,k); +// manualpaintmodel->SetUndoImage(); // Probably needed. Here is ok. + } // vI2 + } // vBIP + } // for index END openmp + manualpaintmodel->Copy_GeneralAuxFill_to_Results(); +*/ + +/* + int i,j,k; + //#pragma omp parallel for + for (k=0;k point; - point.push_back(0); - point.push_back(0); - point.push_back(0); - bbSetInputPoint(point); +// point.push_back(0); +// point.push_back(0); +// point.push_back(0); +// bbSetInputPoint(point); std::vector range; range.push_back(0); range.push_back(200);