]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
#
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuManualPaint_Model.cxx
index b9c230335036086654d0138b978f45afeffcc977..aba4fc8bf54805e111a86d1bf00efdab3750eba9 100644 (file)
@@ -6,6 +6,8 @@
 #include "bbcreaMaracasVisuManualPaint_Model.h"
 #include "bbcreaMaracasVisuPackage.h"
 
+#include <omp.h>
+
 
 namespace bbcreaMaracasVisu
 {
@@ -227,14 +229,88 @@ printf("EED ManualPaint_Model::Process  list of points (with openmp)  size=%d\n"
 
                                long int index, size=dimX*dimY*dimZ;
 
+printf("EED ManualPaint_Model::Process A.start\n");
+std::vector<int> lstX;
+std::vector<int> lstY;
+std::vector<int> lstZ;
+                               int i,j,k;
+                               double value1;
+                               double value2;
+                               for (index=0; index<size; index++)
+                               {
+                                       GETVALUE2_VTK_CREA(value1,pBIP,sTBIP,index)
+                                       if (value1>0)
+                                       {
+                                               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; index<size; index++)
+                               {
+                                       if ( (k1omp==index) || (k2omp==index) || (k3omp==index) || 
+                                                (k4omp==index) || (k5omp==index) || (k6omp==index) ) 
+                                       { 
+                                               if (size==1) 
+                                               { 
+                                                       printf("  100% (just one element)\n"); 
+                                               } else {
+                                                       printf("  %d%%  omp_get_num_threads=%d\n", (int)(((double)index/(double)(size-1))*100 ),  omp_get_num_threads() ); 
+                                               } 
+                                       }// if K#omp
+//                                     double value1;
+//                                     GETVALUE2_VTK_CREA(value1,pBIP,sTBIP,index)
+//                                     if (value1>0)
+//                                     {
+//                                             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\n",size,(double)bbGetInputGrayLevel());
-#pragma omp parallel for
+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; index<size; index++)
                                {
                                        if ( (k1omp==index) || (k2omp==index) || (k3omp==index) || 
@@ -244,7 +320,7 @@ printf("EED ManualPaint_Model::Process  ByImagePoints (with openmp)  size=%d
                                                { 
                                                        printf("  100% (just one element)\n"); 
                                                } else {
-                                                       printf("  %d% \n", (int)(((double)index/(double)(size-1))*100 )); 
+                                                       printf("  %d%%  omp_get_num_threads=%d\n", (int)(((double)index/(double)(size-1))*100 ),  omp_get_num_threads() ); 
                                                } 
                                        }// if K#omp
                                        double value1;
@@ -262,8 +338,9 @@ printf("EED ManualPaint_Model::Process  ByImagePoints (with openmp)  size=%d
 //                                                             manualpaintmodel->SetUndoImage();     // Probably needed.   Here is ok.
                                                } // vI2                
                                        } // vBIP 
-                               } // for index
+                               } // for index    END openmp
                                manualpaintmodel->Copy_GeneralAuxFill_to_Results();
+*/
 
 /*
                                int i,j,k;
@@ -308,8 +385,6 @@ printf("EED ManualPaint_Model::Process  ByImagePoints (with openmp)  size=%d
                bbSetOutputOut( NULL );
        } 
        bbSetOutputManualpaintmodel( manualpaintmodel );
-
-printf("EED ManualPaint_Model::Process End\n");
 }
 //===== 
 // 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)