]> Creatis software - bbtk.git/commitdiff
#3412 BBTK Feature New Normal - openmp and clean code in PolyDataToActor mechanism...
authorEduardo DAVILA <davila@localhost.localdomain>
Mon, 27 Apr 2020 08:37:20 +0000 (10:37 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Mon, 27 Apr 2020 08:37:20 +0000 (10:37 +0200)
packages/vtk/src/bbvtkImageBoundaries.cxx
packages/vtk/src/bbvtkPolyDataToActor.cxx

index 3275137da798188ab483ae753146d7049f218751..1a2128c2daf62ffdc363fb17222ad63e08852d84 100644 (file)
@@ -52,7 +52,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ImageBoundaries,bbtk::AtomicBlackBox);
 void ImageBoundaries::Process()
 {
        if (bbGetInputIn()!=NULL){
-               int i,j,k;      
                int ext[6];
                double value;
                
@@ -74,54 +73,55 @@ void ImageBoundaries::Process()
                int bYMin       = maxY-1;
                int bZMin       = maxZ-1;
                
-/*
-               #pragma omp parallel for
-               for (int i=0 ; i<maxX ; i++)
-               {
-                       int j;  
-                       int k;
-                       for (j=0 ; j<maxY ; j++)
-                       {
-                               for (k=0 ; k<maxZ ; k++)
-                               {
-                                       double value = bbGetInputIn()->GetScalarComponentAsDouble(i, j, k,0);
-                                       if ( (value>=bbGetInputLowerValue()) && (value<=bbGetInputUpperValue())  )
-                                       {
-                                               if (i<bXMin) bXMin=i;
-                                               if (j<bYMin) bYMin=j;
-                                               if (k<bZMin) bZMin=k;
-                                               if (i>bXMax) bXMax=i;
-                                               if (j>bYMax) bYMax=j;
-                                               if (k>bZMax) bZMax=k;
-                                       }
-                               } // for k
-                       } // for j
-               } // i
-*/
-
+       
+               double lowervalue = bbGetInputLowerValue();
+               double uppervalue = bbGetInputUpperValue();
                DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI,bbGetInputIn())        
                long int index=0;
+
+               //int i,j;
+               int k;  
+
+int k1omp=(double)(maxZ-1)*0.0;
+int k2omp=(double)(maxZ-1)*0.2;
+int k3omp=(double)(maxZ-1)*0.4;
+int k4omp=(double)(maxZ-1)*0.6;
+int k5omp=(double)(maxZ-1)*0.8;
+int k6omp=(double)(maxZ-1)*1.0;
+
+printf("EED ImageBoundaries::Process (with openmp)\n");
+
+// http://jakascorner.com/blog/2016/05/omp-for.html
+#pragma omp parallel shared(maxZ,bXMin,bYMin,bZMin,bXMax,bYMax,bZMax)
+{ 
+               #pragma omp for
                for ( k=0 ; k<maxZ ; k++)
                {
+if ( (k1omp==k) || (k2omp==k) || (k3omp==k) || 
+     (k4omp==k) || (k5omp==k) || (k6omp==k) ) { printf("  %d%\n", (int)(((double)k/(double)(maxZ-1))*100 )); }
+                       int i,j;
+                       double vItmpOMP;
                        for (j=0 ; j<maxY ; j++)
                        {
                                for (i=0 ; i<maxX ; i++)
                                {
 //                                     double value = bbGetInputIn()->GetScalarComponentAsDouble(i, j, k,0);
-                                       GETVALUE2_VTK_CREA(vI,pI,stI,index) 
+                                       GETVALUE2_VTK_CREA(vItmpOMP,pI,stI,index) 
                                        index++;
-                                       if ( (vI>=bbGetInputLowerValue()) && (vI<=bbGetInputUpperValue())  )
+                                       if ( (vItmpOMP>=lowervalue) && (vItmpOMP<=uppervalue)  )
                                        {
-                                               if (i<bXMin) bXMin=i;
-                                               if (j<bYMin) bYMin=j;
-                                               if (k<bZMin) bZMin=k;
-                                               if (i>bXMax) bXMax=i;
-                                               if (j>bYMax) bYMax=j;
-                                               if (k>bZMax) bZMax=k;
+                                               if (i<bXMin) bXMin = i;
+                                               if (j<bYMin) bYMin = j;
+                                               if (k<bZMin) bZMin = k;
+                                               if (i>bXMax) bXMax = i;
+                                               if (j>bYMax) bYMax = j;
+                                               if (k>bZMax) bZMax = k;
                                        }
                                } // for k
                        } // for j
                } // i
+} // #pragma
+
                std::vector<int> tmpIndex;              
                std::vector<int> tmpSize;
                if (bXMin>bXMax){
index 2aad2ec130eb57e7ee73ab1be1e5634a342df18a..b76c1142f6dad08bd29ff15d18f68916a784a894 100644 (file)
@@ -108,23 +108,6 @@ namespace bbvtk
 
 void PolyDataToActor::DoProcess()
 {
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-printf("EED WARNNIN!!!!! PolyDataToActor::DoProcess For better transparent ...  Clean this code in the correct part ..........\n");
-//https://stackoverflow.com/questions/47528086/problems-with-rendering-transparent-objects-in-vtk
-//https://itk.org/Wiki/VTK/Depth_Peeling
-bbGetInputRenderer()->SetUseDepthPeeling(1);
-bbGetInputRenderer()->SetOcclusionRatio(0.1);
-bbGetInputRenderer()->SetMaximumNumberOfPeels(100);
-bbGetInputRenderer()->GetRenderWindow()->SetMultiSamples(0);
-bbGetInputRenderer()->GetRenderWindow()->SetAlphaBitPlanes(1);
-
-
                if (bbGetInputRenderer()==NULL)
                {
                        printf("EED Warnning! PolyDataToActor::DoProcess  missing Renderer.\n");