]> Creatis software - creaMaracasVisu.git/commitdiff
#3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp
authorEduardo DAVILA <davila@localhost.localdomain>
Fri, 1 May 2020 14:25:05 +0000 (16:25 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Fri, 1 May 2020 14:25:05 +0000 (16:25 +0200)
bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h

index aabc509c1236ab907a37503ff8bf75ddf716e288..19945fbdfae42f69833c6d9afb40ba3f5623b452 100644 (file)
@@ -19,6 +19,15 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint_Model,bbtk::AtomicBlackBox);
 //-- Alternativa con openmp --
 void ManualPaint_Model::LstPointOMPAnalice()
 {
+
+printf("EED ManualPaint_Model::LstPointOMPAnalice\n" );
+printf("EED FillFilter::Run ojo toca limpiar bien el codigo  _px  px  ...... \n"); 
+printf("EED FillFilter::Run ojo toca limpiar bien el codigo  _px  px  ...... \n"); 
+printf("EED FillFilter::Run ojo toca limpiar bien el codigo  _px  px  ...... \n"); 
+printf("EED FillFilter::Run ojo toca limpiar bien el codigo  _px  px  ...... \n"); 
+
+
+printf("EED ManualPaint_Model::LstPointOMPAnalice Start \n");
 //-- Alternativa con openmp --
 // A. Create copie of index original list => lst1
 // B. if list1 es not empty do..
@@ -85,16 +94,16 @@ printf("EED ManualPaint_Model::LstPointOMPAnalice (with openmp)  size=%d\n",size
 #pragma omp parallel for 
                for (i2=0;i2<size2;i2++)
                {
-if ( (k1omp==i2) || (k2omp==i2) || (k3omp==i2) || 
-     (k4omp==i2) || (k5omp==i2) || (k6omp==i2) ) 
-{ 
-       if (size2==1) 
-       { 
-               printf("  100% (just one element)\n"); 
-       } else {
-               printf("  %d%\n", (int)(((double)i2/(double)(size2-1))*100 )); 
-       } 
-}// if K#omp
+                       if ( (k1omp==i2) || (k2omp==i2) || (k3omp==i2) || 
+                                (k4omp==i2) || (k5omp==i2) || (k6omp==i2) ) 
+                       
+                               if (size2==1) 
+                               
+                                       printf("  100% (just one element)\n"); 
+                               } else {
+                                       printf("  %d% \n", (int)(((double)i2/(double)(size2-1))*100 )); 
+                               
+                       }// if K#omp
                        manualpaintmodel->PaintImage(   bbGetInputByLstPointsX()[ lst2[i2] ] , 
                                                                                        bbGetInputByLstPointsY()[ lst2[i2] ] , 
                                                                                        bbGetInputByLstPointsZ()[ lst2[i2] ] );
@@ -115,13 +124,14 @@ if ( (k1omp==i2) || (k2omp==i2) || (k3omp==i2) ||
                } // for i2
 
        } // while
+printf("EED ManualPaint_Model::LstPointOMPAnalice End\n");
 
 }
 
 
 void ManualPaint_Model::Process()
 {
-
+printf("EED ManualPaint_Model::Process Start\n");
 /* Notas
 0. Quitar comentarion ByLstPoints openmp
 1. Falta openmp ByImagePoints
@@ -135,12 +145,16 @@ void ManualPaint_Model::Process()
 */ 
        if (bbGetInputActive()==true)
        {
+printf("EED ManualPaint_Model::Process 1\n");
                if (bbGetInputImage()!=NULL)
                {  
+printf("EED ManualPaint_Model::Process 2\n");
                        manualpaintmodel->SetActive( bbGetInputActive() );
                        manualpaintmodel->SetTool( bbGetInputTool() );
                        manualpaintmodel->Set2D3D( bbGetInput2D3D() );
+printf("EED ManualPaint_Model::Process 2.1\n");
                        manualpaintmodel->SetImages( bbGetInputImage(),bbGetInputImage2() );
+printf("EED ManualPaint_Model::Process 2.2\n");
                        manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() );                                        
                        manualpaintmodel->SetDirection( bbGetInputDirection() );
                        manualpaintmodel->SetBrushSize( bbGetInputBrushSize() );
@@ -151,24 +165,46 @@ void ManualPaint_Model::Process()
                        manualpaintmodel->SetRangeMax( bbGetInputRange()[1] );
                        if (bbGetInputPoint().size()==3)
                        {
+printf("EED ManualPaint_Model::Process 3\n");
                                manualpaintmodel->PaintImage( bbGetInputPoint()[0] , bbGetInputPoint()[1] , bbGetInputPoint()[2] );
                                manualpaintmodel->SetUndoImage();
                        } // if Points
                        if ( bbGetInputByLstPointsX().size()!=0 )
                        {
+printf("EED ManualPaint_Model::Process 4\n");
                                //-- Alternativa con openmp --
-                               LstPointOMPAnalice();
+//                             LstPointOMPAnalice();
 
-  /* -- Original ByLstPoints sin openmp --
+// /* -- 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;i<size;i++)
                                {
+                                       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 --*/
+//  -- Original ByLstPoints sin openmp --*/
+
+                               manualpaintmodel->Copy_GeneralAuxFill_to_Results();
 
                        }// if ByLstPointsX
                        if ((bbGetInputByImagePoints()!=NULL) && (bbGetInputImage2()!=NULL) )
@@ -194,14 +230,52 @@ 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());
+
+                               long int index, size=dimX*dimY*dimZ;
+
+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\n",size);
+#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% \n", (int)(((double)index/(double)(size-1))*100 )); 
+                                               } 
+                                       }// 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(i,j,k);
+//                                                             manualpaintmodel->SetUndoImage();     // Probably needed.   Here is ok.
+                                               } // vI2                
+                                       } // vBIP 
+                               } // for index
+                               manualpaintmodel->Copy_GeneralAuxFill_to_Results();
+
+/*
                                int i,j,k;
        //#pragma omp parallel for
                                for (k=0;k<dimZ;k++) 
                                {
-                                       if (k%50==0)
-                                       {
-                                               printf("ManualPaint_Model %d%\n", (int)(k*100.0/dimZ) );
-                                       }
                                        for (j=0;j<dimY;j++) 
                                        {
                                                for (i=0;i<dimX;i++) 
@@ -221,8 +295,9 @@ void ManualPaint_Model::Process()
                                                }// for i
                                        }// for j
                                }// for k
-                               printf("ManualPaint_Model %d%\n", 100 );
 //-------  Original ByImagePoints sin openmp--------  */
+
+
                        } // if ByImagePoints
 
                 } else {
@@ -239,6 +314,8 @@ void ManualPaint_Model::Process()
                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)
@@ -261,10 +338,10 @@ void ManualPaint_Model::bbUserSetDefaultValues()
        bbSetInputToleranceFill(50);
        bbSetInputDistanceFill(25);
        std::vector<int> 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<double> range;
        range.push_back(0);
        range.push_back(200);
index e76dc6cf0391e0fce8f387d08e96f5fa267090f0..fb8d867b97a73294dd4bb4eb7a7b678961576ab6 100644 (file)
@@ -32,8 +32,8 @@
 
 FillFilter::FillFilter() 
 {
-       _tolerancefill          = 125;
-
+       _tolerancefill           = 125;
+       _GeneralAuxImageFill = NULL;
 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
 //     _auxImageFill           = NULL;
 //     _maxXback                       = 0;
@@ -85,34 +85,47 @@ void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual
        _maxZback = _maxZ;      
 */
 
+               if (_GeneralAuxImageFill != NULL)
+               {
+                       _GeneralAuxImageFill->Delete();
+               }
+               _GeneralAuxImageFill = vtkImageData::New();
+               _GeneralAuxImageFill->SetDimensions(_dimX,_dimY,_dimZ );
+               _GeneralAuxImageFill->SetOrigin(0, 0, 0);
+               _GeneralAuxImageFill->SetExtent(0, _dimX-1, 0, _dimY-1, 0, _dimZ-1);
+               _GeneralAuxImageFill->AllocateScalars(VTK_UNSIGNED_CHAR,1);
+               unsigned char *ptrAuxImageFill = (unsigned char*)_GeneralAuxImageFill->GetScalarPointer();
+               memset(ptrAuxImageFill, 0, _dimX*_dimY*_dimZ*sizeof(unsigned char) );
 }
 
-
-
-
 //---------------------------------------------------------------------------
-void FillFilter::Run() // virtual
+void FillFilter::Run(int px, int py, int pz) // virtual
 {
        long int ivi;
        if ((_px >= _minX) && (_px < _dimX) && (_py >= _minY) && (_py < _dimY)
                        && (_pz >= _minZ) && (_pz < _dimZ)) 
        {
                this->_IMManager->BaseInitialPoint(_px, _py ,_pz);
-               FillToolLoop(_px, _py, _pz);
-       } //if _minX _maxX _minY _maxY _minZ _maxZ
+//             FillToolLoop(_px, _py, _pz);
+               FillToolLoop(px, py, pz);
+
+
+
+       } //if _minX _maxX _minY _maxY _minZ _maxZ
 }
 
 
 //---------------------------------------------------------------------------
-vtkImageData* FillFilter::GenerateAuxImageFill(        long int &OneColumnAux, long int &OneLineAux , long int &OnePlaneAux, 
-                                                                                               int px,int py,int pz, 
-                                                                                               int &pxAux, int &pyAux, int &pzAux )
+vtkImageData* FillFilter::CreateAuxImageFill(  long int &OneColumnAux, long int &OneLineAux , long int &OnePlaneAux, 
+                                                                                               int px,                 int py,                 int pz, 
+                                                                                               int &pxAux,             int &pyAux,     int &pzAux,
+                                                                                               int &minXAux,   int &minYAux,   int &minZAux )
 {
        // _2D3D = 1     3D
 
-       int minXAux = px-_distancefill;  if (minXAux>=0) { pxAux=px-minXAux; } else { pxAux=px; minXAux=0; }
-       int minYAux = py-_distancefill;  if (minYAux>=0) { pyAux=py-minYAux; } else { pyAux=py; minYAux=0; }
-       int minZAux = pz-_distancefill;  if (minZAux>=0) { pzAux=pz-minZAux; } else { pzAux=pz; minZAux=0; }
+       minXAux = px-_distancefill;  if (minXAux>=0) { pxAux=px-minXAux; } else { pxAux=px; minXAux=0; }
+       minYAux = py-_distancefill;  if (minYAux>=0) { pyAux=py-minYAux; } else { pyAux=py; minYAux=0; }
+       minZAux = pz-_distancefill;  if (minZAux>=0) { pzAux=pz-minZAux; } else { pzAux=pz; minZAux=0; }
 
        int maxXAux = px+_distancefill;  if (maxXAux>_dimX) { maxXAux=_dimX; }
        int maxYAux = py+_distancefill;  if (maxYAux>_dimY) { maxYAux=_dimY; }
@@ -148,19 +161,96 @@ vtkImageData* FillFilter::GenerateAuxImageFill(   long int &OneColumnAux, long int
        auxImageFill = vtkImageData::New();
        auxImageFill->SetDimensions(auxDimX, auxDimY, auxDimZ);
        auxImageFill->SetOrigin(0, 0, 0);
-       auxImageFill->SetExtent(0, auxDimX, 0, auxDimY, 0, auxDimZ);
+       auxImageFill->SetExtent(0, auxDimX-1, 0, auxDimY-1, 0, auxDimZ-1);
        auxImageFill->AllocateScalars(VTK_UNSIGNED_CHAR,1);
        unsigned char   * ptrAuxImageFill = (unsigned char      *)auxImageFill->GetScalarPointer();
        memset( ptrAuxImageFill, 0, auxDimX*auxDimY*auxDimZ );
        return auxImageFill;
 }
 
+void FillFilter::Copy_AuxImageFill_To_GeneralAuxFill(int minXAux, int minYAux, int minZAux, vtkImageData *auxImageFill)
+{
+       // copy information from the litle image auxImageFill to the big image _GeneralAuxImageFill
+       DEF_POINTER_IMAGE_VTK_CREA(vAuxImageFill,ssAuxImageFill,pAuxImageFill,stAuxImageFill,auxImageFill)
+       DEF_POINTER_IMAGE_VTK_CREA(v_GeneralAuxImageFill,ss_GeneralAuxImageFill,p_GeneralAuxImageFill,st_GeneralAuxImageFill,_GeneralAuxImageFill)
+       int ext[6];
+       auxImageFill->GetExtent(ext);
+       int auxDimX = ext[1]-ext[0]+1;
+       int auxDimY = ext[3]-ext[2]+1;
+       int auxDimZ = ext[5]-ext[4]+1;
+       int i,j,k;      
+       long int indexAux=0;
+       long int indexGeneralAux;
+       for (k=0;k<auxDimZ;k++)
+       {
+               for (j=0;j<auxDimY;j++)
+               {
+                       indexGeneralAux=minXAux + (minYAux+j)*_OneLine + (minZAux+k)*_OnePlane;
+//                     indexAux = j*OneLineAux + k*OnePlaneAux;
+                       for (i=0;i<auxDimX;i++)
+                       {
+                               GETVALUE2_VTK_CREA(vAuxImageFill,pAuxImageFill,stAuxImageFill,indexAux)         
+                               indexAux++;
+                               if (vAuxImageFill==1) 
+                               {
+                                       SETVALUE2_VTK_CREA(vAuxImageFill,p_GeneralAuxImageFill,st_GeneralAuxImageFill,indexGeneralAux)
+                               } // if vAuxImageFill
+                               indexGeneralAux = indexGeneralAux+_OneColumn;
+                       } //  for i
+               } // for j
+       } // for k
+}
+
+void FillFilter::Copy_GeneralAuxFill_to_Results()
+{
+       DEF_POINTER_IMAGE_VTK_CREA(v_GeneralAuxImageFill,ss_GeneralAuxImageFill,p_GeneralAuxImageFill,st_GeneralAuxImageFill,_GeneralAuxImageFill)
+       long int i,size = _dimX*_dimY*_dimZ;
+       if (_image2==NULL)
+       {
+                       DEF_POINTER_IMAGE_VTK_CREA(v_image,ss_image,p_image,st_image,_image)
+//                     DEF_POINTER_IMAGE_VTK_CREA_set(v_image,ss_image,p_image,st_image,_image)                
+#pragma omp parallel for 
+                       for (i=0;i<size;i++)
+                       {
+                               int value;
+                               GETVALUE2_VTK_CREA(value,p_GeneralAuxImageFill,st_GeneralAuxImageFill,i)
+                               if (value!=0) 
+                               {
+                                       SETVALUE2_VTK_CREA(_graylevel,p_image,st_image,i)
+                               } // if v_GeneralAuxImageFill
+                       } // for        
+       }  else {
+                       DEF_POINTER_IMAGE_VTK_CREA(v_image2,ss_image2,p_image2,st_image2,_image2)
+//                     DEF_POINTER_IMAGE_VTK_CREA_set(v_image2,ss_image2,p_image2,st_image2,_image2)           
+#pragma omp parallel for 
+                       for (i=0;i<size;i++)
+                       {
+                               int value;
+                               GETVALUE2_VTK_CREA(value,p_GeneralAuxImageFill,st_GeneralAuxImageFill,i)
+                               if (value!=0) 
+                               {
+                                       SETVALUE2_VTK_CREA(_graylevel,p_image2,st_image2,i)
+                               } // if v_GeneralAuxImageFill
+                       } // for        
+       }// if _image2
+       
+
+}
+
 
 
 //---------------------------------------------------------------------------
 void FillFilter::FillToolLoop(int px, int py, int pz) 
 {
-       _distbasefill                           = _distancefill * _distancefill;
+    double          distbasefill;
+    double          graylevelbasefill;
+    double          tmpiglfill;
+    double          tmpiglfill2;
+    bool            auxGrayLevelValidationFill;
+
+
+
+       distbasefill                            = _distancefill * _distancefill;
        double difX,difY,difZ,_tmpDistfill;
        std::vector<int> lstX;
        std::vector<int> lstY;
@@ -171,22 +261,32 @@ void FillFilter::FillToolLoop(int px, int py, int pz)
        std::vector<long long int> lstivi;
        lstivi.push_back( px + py*_OneLine+ pz*_OnePlane );
 
-       long int OneColumnAux, OneLineAux, OnePlaneAux;
-       int pxAux, pyAux, pzAux;
-       vtkImageData* auxImageFill = GenerateAuxImageFill(      OneColumnAux,OneLineAux,OnePlaneAux,
+       long int OneColumnAux, OneLineAux, OnePlaneAux;  // how to jump in the little image auxImageFill
+       int pxAux, pyAux, pzAux;                                                 // position inside little image auxImageFill
+       int minXAux, minYAux, minZAux;                                   // Where start the little image auxImageFill in the big image
+       vtkImageData* auxImageFill = CreateAuxImageFill(        OneColumnAux,OneLineAux,OnePlaneAux,
                                                                                                                px,py,pz,
-                                                                                                               pxAux,pyAux,pzAux );
+                                                                                                               pxAux,pyAux,pzAux, 
+                                                                                                               minXAux,minYAux,minZAux );
        std::vector<long long int> lstiviAux;
        lstiviAux.push_back( pxAux + pyAux*OneLineAux + pzAux*OnePlaneAux );
 
+       DEF_POINTER_IMAGE_VTK_CREA(v_image,ss_image,p_image,st_image,_image)
+//     DEF_POINTER_IMAGE_VTK_CREA_set(v_image,ss_image,p_image,st_image,_image)                
+
+       double                  v_image2;
+       int                     ss_image2;
+       char               *p_image2;
+       int                             st_image2;
+
 
-       DEF_POINTER_IMAGE_VTK_CREA_set(v_image,ss_image,p_image,st_image,_image)                
        if (_image2!=NULL)
        {
+//             DEF_POINTER_IMAGE_VTK_CREA(v_image2,ss_image2,p_image2,st_image2,_image2)               
                DEF_POINTER_IMAGE_VTK_CREA_set(v_image2,ss_image2,p_image2,st_image2,_image2)           
        } // if _image2
 
-       GETVALUE2_VTK_CREA(_graylevelbasefill,p_image,st_image,lstivi[0])       
+       GETVALUE2_VTK_CREA(graylevelbasefill,p_image,st_image,lstivi[0])        
 
 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
 //     DEF_POINTER_IMAGE_VTK_CREA(v_auxImageFill,ss_auxImageFill,p_auxImageFill,st_auxImageFill,_auxImageFill)         
@@ -202,7 +302,7 @@ void FillFilter::FillToolLoop(int px, int py, int pz)
                        difZ = pz-lstZ[0];
                        _tmpDistfill = difX*difX + difY*difY + difZ*difZ;
                        // if distance of center point
-                       if (_tmpDistfill<=_distbasefill)
+                       if (_tmpDistfill<=distbasefill)
                        {
                                // if point not visited
                                GETVALUE2_VTK_CREA(vAuxImageFill,pAuxImageFill,stAuxImageFill,lstiviAux[0] );   
@@ -211,20 +311,20 @@ void FillFilter::FillToolLoop(int px, int py, int pz)
                                        // If Gray Level valid
 
                                        //EED01 
-                                       //              _tmpiglfill     = _image->GetScalarComponentAsDouble(px, py, pz, 0);
-                                       GETVALUE2_VTK_CREA(_tmpiglfill,p_image,st_image,lstivi[0])      
+                                       //              tmpiglfill      = _image->GetScalarComponentAsDouble(px, py, pz, 0);
+                                       GETVALUE2_VTK_CREA(tmpiglfill,p_image,st_image,lstivi[0])       
 
                                        if (_image2!=NULL)
                                        {
                                                //EED01
-                                               //                      _tmpiglfill2    =       _image2->GetScalarComponentAsDouble(px, py, pz, 0);
-                                               GETVALUE2_VTK_CREA(_tmpiglfill2,p_image2,st_image2,lstivi[0])   
+                                               //                      tmpiglfill2     =       _image2->GetScalarComponentAsDouble(px, py, pz, 0);
+                                               GETVALUE2_VTK_CREA(tmpiglfill2,p_image2,st_image2,lstivi[0])    
                                        } else {
-                                               _tmpiglfill2    =       _tmpiglfill;
+                                               tmpiglfill2     =       tmpiglfill;
                                        }
 
-                                       float grayLBFMTOL       = _graylevelbasefill - _tolerancefill;
-                                       float grayLBFPTOL       = _graylevelbasefill + _tolerancefill;
+                                       float grayLBFMTOL       = graylevelbasefill - _tolerancefill;
+                                       float grayLBFPTOL       = graylevelbasefill + _tolerancefill;
                                        bool isInRange          = false;
                                        //DFCH
                                        if (_RangeMin <= grayLBFMTOL && _RangeMax >= grayLBFPTOL) {
@@ -238,7 +338,7 @@ void FillFilter::FillToolLoop(int px, int py, int pz)
                                                grayLBFPTOL     = _RangeMax;
                                                isInRange               = true;
                                        } //fi esle
-                                       else if ((_RangeMin <= _graylevelbasefill) && (_graylevelbasefill <= _RangeMax)) {
+                                       else if ((_RangeMin <= graylevelbasefill) && (graylevelbasefill <= _RangeMax)) {
                                                grayLBFMTOL     = _RangeMin;
                                                grayLBFPTOL     = _RangeMax;
                                                isInRange               = true;
@@ -246,18 +346,19 @@ void FillFilter::FillToolLoop(int px, int py, int pz)
 
                                        if (isInRange) 
                                        {
-                                               _auxGrayLevelValidationFill =   (_tmpiglfill  != _graylevel)    && 
-                                                                                                               (_tmpiglfill2 != _graylevel)    && 
-                                                                                                               (_tmpiglfill  >= grayLBFMTOL)   && 
-                                                                                                               (_tmpiglfill  <= grayLBFPTOL)   && 
-                                                                                                               (_tmpDistfill <= _distbasefill) ; //DFCH
+                                               auxGrayLevelValidationFill =    (tmpiglfill  != _graylevel)     && 
+                                                                                                               (tmpiglfill2 != _graylevel)     && 
+                                                                                                               (tmpiglfill  >= grayLBFMTOL)    && 
+                                                                                                               (tmpiglfill  <= grayLBFPTOL)    && 
+                                                                                                               (_tmpDistfill <= distbasefill) ; //DFCH
                                        } else {
-                                               _auxGrayLevelValidationFill = false;
+                                               auxGrayLevelValidationFill = false;
                                        } // if isInRange
 
-                                       if (_auxGrayLevelValidationFill==true)  
+                                       if (auxGrayLevelValidationFill==true)  
                                        {
                                                this->_IMManager->AddModifiedPixel(lstX[0], lstY[0], lstZ[0]); //DFCH
+/*
                                                // Modifie image
                                                if (_image2!=NULL)
                                                {
@@ -268,10 +369,12 @@ void FillFilter::FillToolLoop(int px, int py, int pz)
                                                        SETVALUE2_VTK_CREA(_graylevel,p_image,st_image,lstivi[0])
                                                } // if _image2
 
+*/
+                                               // Add point to already visited
+                                               SETVALUE2_VTK_CREA(1,pAuxImageFill,stAuxImageFill,lstiviAux[0]);
+
                                                // Add neighborhood points in the list 
 
-                               // Add point to already visited
-                               SETVALUE2_VTK_CREA(1,pAuxImageFill,stAuxImageFill,lstiviAux[0]);
 
                                                if (_2D3D == 0) //2D
                                                {
@@ -310,9 +413,9 @@ lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]);   lstZ.push_back(lstZ[0]);
   lstX.push_back(lstX[0]  ); lstY.push_back(lstY[0]  ); lstZ.push_back(lstZ[0]+1); lstivi.push_back(lstivi[0]+_OnePlane);  lstiviAux.push_back(lstiviAux[0]+OnePlaneAux);
   lstX.push_back(lstX[0]  ); lstY.push_back(lstY[0]  ); lstZ.push_back(lstZ[0]-1); lstivi.push_back(lstivi[0]-_OnePlane);  lstiviAux.push_back(lstiviAux[0]-OnePlaneAux);
                                                } // 2D 3D
-                                       } // if gray level valid      _auxGrayLevelValidationFill
+                                       } // if gray level valid      auxGrayLevelValidationFill
                                } // if point not visited
-                       } // if distance of center point
+                       } // if distance of center point        
                } // if point inside image
                // Remove point from the list
                lstX.erase( lstX.begin() );
@@ -321,6 +424,9 @@ lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]);   lstZ.push_back(lstZ[0]);
                lstivi.erase( lstivi.begin() );
                lstiviAux.erase( lstiviAux.begin() );
        } // while _lstX.size
+
+       Copy_AuxImageFill_To_GeneralAuxFill( minXAux, minYAux, minZAux, auxImageFill );
+       
        auxImageFill->Delete();
 }
 
index 0be4fd8d23cce53066303d8ab8a5ca96fdb19a1f..bcf22e92ef0d329728f03e36cca315d5bc484608 100644 (file)
@@ -33,48 +33,57 @@ class FillFilter : public baseFilterManualPaint {
 public:
        FillFilter();
        virtual ~FillFilter();
-    void                       Run();
+    void                       Run(int px, int py, int pz);
        void                    FillToolLoop(int px, int py, int pz);
     void                       SetToleranceFill(double tolerancefill);
     void                       SetDistanceFill(int distancefill);
     virtual void       SetImages(vtkImageData *image,vtkImageData *image2);
 //     vtkImageData*   GetAuxImageFill();
+void                   Copy_GeneralAuxFill_to_Results();
+
+
 private:
     double          _tolerancefill;
     int             _distancefill;
-    double          _graylevelbasefill;
-    double          _distbasefill;
-    double          _tmpiglfill;
-    double          _tmpiglfill2;
-    bool            _auxGrayLevelValidationFill;
+
+//EED 2020-04-28  BORRAME Change to local variables to use with openmp
+//    double          _distbasefill;
+//    double          _graylevelbasefill;
+//    double          _tmpiglfill;
+//    double          _tmpiglfill2;
+//    bool            _auxGrayLevelValidationFill;
 
 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
 //   vtkImageData    *_auxImageFill;
 //     int                     _maxXback;
 //     int                     _maxYback;
 //     int                     _maxZback;
+   vtkImageData    *_GeneralAuxImageFill;
 
-vtkImageData* GenerateAuxImageFill(    long int &OneColumnAux, long int &OneLineAux , long int &OnePlaneAux, 
-                                                                       int px,int py,int pz, 
-                                                                       int &pxAux, int &pyAux, int &pzAux );
+vtkImageData*  CreateAuxImageFill(     long int &OneColumnAux, long int &OneLineAux , long int &OnePlaneAux, 
+                                                                       int px,                 int py,                 int pz, 
+                                                                       int &pxAux,     int &pyAux,     int &pzAux, 
+                                                                       int &minXAux,   int &minYAux,   int &minZAux   );
+void                   Copy_AuxImageFill_To_GeneralAuxFill(int minXAux, int minYAux, int minZAux, vtkImageData *auxImageFill);
 
 
 protected:
 
 
+
 //Change to local variables to use with openmp
 // DEF_POINTER_IMAGE_VTK_CREA_definition( v_image , ss_image , p_image , st_image )            
-       double                  v_image;
-       int                     ss_image;
-       char                    *p_image;
-       int                             st_image;
+//     double                  v_image;
+//     int                     ss_image;
+//     char                    *p_image;
+//     int                             st_image;
 
 // //macro not working ???    
 // DEF_POINTER_IMAGE_VTK_CREA_definition(v_image2,ss_image2,p_image2,st_image2)                
-       double                  v_image2;
-       int                     ss_image2;
-       char                    *p_image2;
-       int                             st_image2;
+//     double                  v_image2;
+//     int                     ss_image2;
+//     char                    *p_image2;
+//     int                             st_image2;
 
 };
 
index fd1bc124d509393de79c95c8bd5bb7beb2f35809..c74dfdfce0818dde2d0d95801958a199b139a605 100644 (file)
@@ -63,7 +63,7 @@ void ManualPaintModel::PaintImage(int px, int py, int pz)
        if (_tool == 1) 
        {
                _fillfilter->SetPoint(px, py, pz);
-               _fillfilter->Run();
+               _fillfilter->Run(px,py,pz);
        } // _tool 1
   } // _active
 }
@@ -84,21 +84,28 @@ void ManualPaintModel::Set2D3D(int dim2D3D)
 //---------------------------------------------------------------------------
 void ManualPaintModel::SetImages(vtkImageData *image,vtkImageData *image2) 
 {
+printf("EED ManualPaintModel::SetImage Start\n ");
        if (image!=NULL)
        {
+printf("EED ManualPaintModel::SetImage 1\n ");
                _brushfilter -> SetImages(image,image2);
+printf("EED ManualPaintModel::SetImage 2\n ");
                _fillfilter  -> SetImages(image,image2);
+printf("EED ManualPaintModel::SetImage 3\n ");
                if (image2!=NULL)
                {
                        _imageUndoRedo->SetImage(image2);
+printf("EED ManualPaintModel::SetImage 4\n ");
                } else {
                        _imageUndoRedo->SetImage(image);
+printf("EED ManualPaintModel::SetImage 5\n ");
                }
 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
 //             _imageUndoRedo_visited->SetImage( _fillfilter->GetAuxImageFill() );
        } else {
-               printf("EED Warning image=NULL in ManualPaintModel::SetImage(image)\n ");
+               printf("EED Warning image=NULL in ManualPaintModel::SetImages(image,image2)\n ");
        }
+printf("EED ManualPaintModel::SetImage End\n ");
 }
 
 //---------------------------------------------------------------------------
@@ -209,3 +216,15 @@ int ManualPaintModel::GetRestorBaseInitialPointZ()
        return  this->_imageUndoRedo->GetRestorBaseInitialPointZ();
 }
 
+void ManualPaintModel::Copy_GeneralAuxFill_to_Results()
+{
+       if (_tool == 0) 
+       {
+               //
+       } // if 0
+       if (_tool == 1)   // fillfilter
+       {
+               this->_fillfilter->Copy_GeneralAuxFill_to_Results();
+       } // if 1
+}
+
index a99749abce977d42e0d357ededac2dad877b3b07..aeebad7a0bef59757db2eee3db0c1a54f6a4edf1 100644 (file)
@@ -58,6 +58,8 @@ public:
        int GetRestorBaseInitialPointY();
        int GetRestorBaseInitialPointZ();
 
+       void Copy_GeneralAuxFill_to_Results();
+
 private:
        int                     _tool;
        bool                    _active;