]> Creatis software - creaMaracasVisu.git/commitdiff
#3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp
authorEduardo DAVILA <davila@localhost.localdomain>
Mon, 4 May 2020 15:53:45 +0000 (17:53 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Mon, 4 May 2020 15:53:45 +0000 (17:53 +0200)
bbtk/bbs/boxes/ManualPaint2.bbg
bbtk/bbs/boxes/ManualPaint2.bbs
bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx

index a9dc028b2089a4360ba643a7f8369d76b6b78200..292899739152bc8eee0dfe10cf1b98472b29ccf4 100644 (file)
@@ -1,6 +1,6 @@
 # ----------------------------------
 # - BBTKGEditor v 1.4 BBG BlackBox Diagram file
-# - /home/davila/Creatis/C8/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/ManualPaint2.bbg
+# - /home/davila/Creatis/C10/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/ManualPaint2.bbg
 # ----------------------------------
 
 APP_START
@@ -10,11 +10,15 @@ AUTHOR:Author ??
 COMPLEXBOX:TRUE
 COMPLEXBOXNAME:ManualPaint2
 PACKAGENAME:creaMaracasVisu
-COMPLEXOUTPUTS:1
+COMPLEXOUTPUTS:2
 COMPLEX_PORT
 widgetOut
 -94.963421:-185.755112:-900.000000
 FIN_COMPLEX_PORT
+COMPLEX_PORT
+boxChange
+-13.009667:-180.316926:-900.000000
+FIN_COMPLEX_PORT
 COMPLEXINPUTS:15
 COMPLEX_PORT
 TitleOptions
@@ -377,7 +381,7 @@ In1:"XZ"
 PORT
 In2:"XY"
 FIN_BOX
-CONNECTIONS:84
+CONNECTIONS:85
 CONNECTION
 Box01:Out:Box02:In
 NumberOfControlPoints:0
@@ -630,4 +634,7 @@ NumberOfControlPoints:0
 CONNECTION
 Box39:Out:Box00:Direction
 NumberOfControlPoints:0
+CONNECTION
+Box01:BoxChange:boxChange:boxChange
+NumberOfControlPoints:0
 APP_END
index 6fb2bd6046b07ff82fb836bad3998c7945eb95c5..1301012e8f7ee1a83c871d52aff8e7a957ef473b 100644 (file)
@@ -1,6 +1,6 @@
 # ----------------------------------
 # - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box)
-# - /home/davila/Creatis/C8/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/ManualPaint2.bbs
+# - /home/davila/Creatis/C10/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/ManualPaint2.bbs
 # ----------------------------------
 
 include std
@@ -222,6 +222,7 @@ input Point_ManualPaint_Model Box38.In " "
 
 # Complex output ports
 output widgetOut Box09.Widget " "
+output boxChange Box01.BoxChange " "
 
 
 endefine
index b9c230335036086654d0138b978f45afeffcc977..a195bca6e9c3152cf5ea4bf043af670877479bc3 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\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) || 
+                                                (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 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;