From f9901e756bb82bd333310b47607875331616bb29 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 29 Apr 2020 17:58:09 +0200 Subject: [PATCH] #3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp --- .../bbcreaMaracasVisuManualPaint_Model.cxx | 12 +- .../widgets/manualPaint/BrushFilter.cpp | 8 +- .../widgets/manualPaint/FillFilter.cpp | 191 ++++++++++++------ .../widgets/manualPaint/FillFilter.h | 28 ++- .../widgets/manualPaint/ManualPaintModel.cpp | 15 +- .../manualPaint/baseFilterManualPaint.cpp | 45 +++-- .../manualPaint/baseFilterManualPaint.h | 34 ++-- 7 files changed, 224 insertions(+), 109 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx index 7167f6c..2a64b94 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx @@ -81,7 +81,7 @@ long int k3omp=(double)(size2-1)*0.4; long int k4omp=(double)(size2-1)*0.6; long int k5omp=(double)(size2-1)*0.8; long int k6omp=(double)(size2-1)*1.0; -printf("EED ManualPaint_Model::LstPointOMPAnalice (with openmp)\n"); +printf("EED ManualPaint_Model::LstPointOMPAnalice (with openmp) size=%ld\n",size2); #pragma omp parallel for 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) @@ -159,11 +159,13 @@ void ManualPaint_Model::Process() //-- Alternativa con openmp -- LstPointOMPAnalice(); -/* -- Original ByLstPoints sin openmp -- + /* -- Original ByLstPoints sin openmp -- int i,size = bbGetInputByLstPointsX().size(); for (i=0;iPaintImage( bbGetInputByLstPointsX()[i] , bbGetInputByLstPointsY()[i] , bbGetInputByLstPointsZ()[i] ); + manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[i] , + bbGetInputByLstPointsY()[i] , + bbGetInputByLstPointsZ()[i] ); //_manualPaintModel->SetUndoImage(); // Probably needed. Here is ok. } // for -- Original ByLstPoints sin openmp --*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp index f7feac9..0f359e6 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp @@ -72,11 +72,11 @@ void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY, if (minX < _minX) { minX = _minX; } if (minY < _minY) { minY = _minY; } - if (minZ < _minZ) { minZ = _minZ; } - if (maxX > _maxX) { maxX = _maxX; } - if (maxY > _maxY) { maxY = _maxY; } - if (maxZ > _maxZ) { maxZ = _maxZ; } + + if (maxX >= _dimX) { maxX = _dimX-1; } + if (maxY >= _dimY) { maxY = _dimY-1; } + if (maxZ >= _dimZ) { maxZ = _dimZ-1; } //-- SetGeneralMinMax(minX, maxX, minY, maxY, minZ, maxZ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp index 0bf97b9..e76dc6c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp @@ -33,26 +33,32 @@ FillFilter::FillFilter() { _tolerancefill = 125; - _distancefill = 5; - _auxImageFill = NULL; - _maxXback = 0; - _maxYback = 0; - _maxZback = 0; + +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// _auxImageFill = NULL; +// _maxXback = 0; +// _maxYback = 0; +// _maxZback = 0; + SetDistanceFill(5); } //--------------------------------------------------------------------------- FillFilter::~FillFilter() { +/*//EED 2020-04-28 BORRAME Change to local variables to use with openmp if (_auxImageFill != NULL) { _auxImageFill->Delete(); }//_auxImageFill +*/ } //--------------------------------------------------------------------------- void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual { baseFilterManualPaint::SetImages(image,image2); + +/* //EED 2020-04-28 BORRAME Change to local variables to use with openmp if ((_maxX!=_maxXback) || (_maxY!=_maxYback) || (_maxZ!=_maxZback)) { if (_auxImageFill != NULL) @@ -74,9 +80,11 @@ void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual } unsigned char * ptrAuxImageFill = (unsigned char *)_auxImageFill->GetScalarPointer(); memset(ptrAuxImageFill, 0, (_maxX+1) * (_maxY+1) * (_maxZ+1) ); - _maxXback=_maxX; - _maxYback=_maxY; - _maxZback=_maxZ; + _maxXback = _maxX; + _maxYback = _maxY; + _maxZback = _maxZ; +*/ + } @@ -86,29 +94,91 @@ void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual void FillFilter::Run() // virtual { long int ivi; - if ((_px >= _minX) && (_px <= _maxX) && (_py >= _minY) && (_py <= _maxY) - && (_pz >= _minZ) && (_pz <= _maxZ)) + if ((_px >= _minX) && (_px < _dimX) && (_py >= _minY) && (_py < _dimY) + && (_pz >= _minZ) && (_pz < _dimZ)) { this->_IMManager->BaseInitialPoint(_px, _py ,_pz); - _graylevelbasefill = _image->GetScalarComponentAsDouble(_px, _py, _pz,0); - _distbasefill = _distancefill * _distancefill; - ivi = _px + _py*(_maxX+1) + _pz*(_maxX+1)*(_maxY+1); // index vector image - FillToolLoop(_px, _py, _pz, ivi); + FillToolLoop(_px, _py, _pz); } //if _minX _maxX _minY _maxY _minZ _maxZ } + //--------------------------------------------------------------------------- -void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) +vtkImageData* FillFilter::GenerateAuxImageFill( long int &OneColumnAux, long int &OneLineAux , long int &OnePlaneAux, + int px,int py,int pz, + int &pxAux, int &pyAux, int &pzAux ) { + // _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; } + + int maxXAux = px+_distancefill; if (maxXAux>_dimX) { maxXAux=_dimX; } + int maxYAux = py+_distancefill; if (maxYAux>_dimY) { maxYAux=_dimY; } + int maxZAux = pz+_distancefill; if (maxZAux>_dimZ) { maxZAux=_dimZ; } + + + int auxDimX = maxXAux-minXAux+1; + int auxDimY = maxYAux-minYAux+1; + int auxDimZ = maxZAux-minZAux+1; + + // new vtkImageData + if (_2D3D==0) // 2D + { + if (_direction==0) // YZ + { + auxDimX = 1; + } + if (_direction==1) // XZ + { + auxDimY = 1; + } + if (_direction==2) // XY + { + auxDimZ = 1; + } + } // if 2D + + OneColumnAux = 1; + OneLineAux = auxDimX; + OnePlaneAux = auxDimX*auxDimY; + + vtkImageData *auxImageFill; + auxImageFill = vtkImageData::New(); + auxImageFill->SetDimensions(auxDimX, auxDimY, auxDimZ); + auxImageFill->SetOrigin(0, 0, 0); + auxImageFill->SetExtent(0, auxDimX, 0, auxDimY, 0, auxDimZ); + auxImageFill->AllocateScalars(VTK_UNSIGNED_CHAR,1); + unsigned char * ptrAuxImageFill = (unsigned char *)auxImageFill->GetScalarPointer(); + memset( ptrAuxImageFill, 0, auxDimX*auxDimY*auxDimZ ); + return auxImageFill; +} + + + +//--------------------------------------------------------------------------- +void FillFilter::FillToolLoop(int px, int py, int pz) +{ + _distbasefill = _distancefill * _distancefill; double difX,difY,difZ,_tmpDistfill; std::vector lstX; std::vector lstY; std::vector lstZ; - std::vector lstivi; lstX.push_back(px); lstY.push_back(py); lstZ.push_back(pz); - lstivi.push_back( iviA ); + std::vector lstivi; + lstivi.push_back( px + py*_OneLine+ pz*_OnePlane ); + + long int OneColumnAux, OneLineAux, OnePlaneAux; + int pxAux, pyAux, pzAux; + vtkImageData* auxImageFill = GenerateAuxImageFill( OneColumnAux,OneLineAux,OnePlaneAux, + px,py,pz, + pxAux,pyAux,pzAux ); + std::vector lstiviAux; + lstiviAux.push_back( pxAux + pyAux*OneLineAux + pzAux*OnePlaneAux ); + DEF_POINTER_IMAGE_VTK_CREA_set(v_image,ss_image,p_image,st_image,_image) if (_image2!=NULL) @@ -116,11 +186,16 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) DEF_POINTER_IMAGE_VTK_CREA_set(v_image2,ss_image2,p_image2,st_image2,_image2) } // if _image2 - DEF_POINTER_IMAGE_VTK_CREA(v_auxImageFill,ss_auxImageFill,p_auxImageFill,st_auxImageFill,_auxImageFill) + 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) + DEF_POINTER_IMAGE_VTK_CREA(vAuxImageFill,ssAuxImageFill,pAuxImageFill,stAuxImageFill,auxImageFill) + while ( lstX.size()!=0 ) { // if point inside image - if ((lstX[0] >= _minX) && (lstX[0] <= _maxX) && (lstY[0] >= _minY) && (lstY[0] <= _maxY) && (lstZ[0] >= _minZ) && (lstZ[0] <= _maxZ)) + if ((lstX[0] >= _minX) && (lstX[0] < _dimX) && (lstY[0] >= _minY) && (lstY[0] < _dimY) && (lstZ[0] >= _minZ) && (lstZ[0] < _dimZ)) { difX = px-lstX[0]; difY = py-lstY[0]; @@ -130,8 +205,8 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) if (_tmpDistfill<=_distbasefill) { // if point not visited - GETVALUE2_VTK_CREA(v_auxImageFill,p_auxImageFill,st_auxImageFill,lstivi[0] ); - if (v_auxImageFill==0) + GETVALUE2_VTK_CREA(vAuxImageFill,pAuxImageFill,stAuxImageFill,lstiviAux[0] ); + if (vAuxImageFill==0) { // If Gray Level valid @@ -171,20 +246,18 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) 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; } // if isInRange - if (_auxGrayLevelValidationFill) + if (_auxGrayLevelValidationFill==true) { - this->_IMManager->AddModifiedPixel(lstX[0], lstY[0], lstZ[0]); //DFCH - // Modifie image if (_image2!=NULL) { @@ -196,47 +269,49 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) } // if _image2 // Add neighborhood points in the list + + // Add point to already visited + SETVALUE2_VTK_CREA(1,pAuxImageFill,stAuxImageFill,lstiviAux[0]); + if (_2D3D == 0) //2D { if (_direction == 0) // YZ { - //lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn); - //lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane); +//lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux); +//lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux); + lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux); + lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux); + 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); } if (_direction == 1) // XZ { - lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn); - lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn); - // lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine); - // lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane); + lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux); + lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux); +// lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux); +// lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux); + 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); } if (_direction == 2) // XY { - lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn); - lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine); - //lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane); - //lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane); +lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux); +lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux); + lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux); + lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux); +//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); } } else { // 3D - lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn); - lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane); - lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane); + lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux); + lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux); + lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux); + lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux); + 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 point not visited - // Add point to already visited - SETVALUE2_VTK_CREA(1,p_auxImageFill,st_auxImageFill,lstivi[0]); } // if distance of center point } // if point inside image // Remove point from the list @@ -244,7 +319,9 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) lstY.erase( lstY.begin() ); lstZ.erase( lstZ.begin() ); lstivi.erase( lstivi.begin() ); + lstiviAux.erase( lstiviAux.begin() ); } // while _lstX.size + auxImageFill->Delete(); } //--------------------------------------------------------------------------- @@ -259,11 +336,11 @@ void FillFilter::SetDistanceFill(int distancefill) _distancefill = distancefill; } +/*//EED 2020-04-28 BORRAME Change to local variables to use with openmp //--------------------------------------------------------------------------- vtkImageData* FillFilter::GetAuxImageFill() { return _auxImageFill; } - - +*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h index 03ac7a3..0be4fd8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h @@ -34,11 +34,11 @@ public: FillFilter(); virtual ~FillFilter(); void Run(); - void FillToolLoop(int px, int py, int pz,long int iviA) ; + 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(); +// vtkImageData* GetAuxImageFill(); private: double _tolerancefill; int _distancefill; @@ -46,21 +46,31 @@ private: double _distbasefill; double _tmpiglfill; double _tmpiglfill2; - vtkImageData *_auxImageFill; bool _auxGrayLevelValidationFill; - int _maxXback; - int _maxYback; - int _maxZback; + +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// vtkImageData *_auxImageFill; +// int _maxXback; +// int _maxYback; +// int _maxZback; + +vtkImageData* GenerateAuxImageFill( long int &OneColumnAux, long int &OneLineAux , long int &OnePlaneAux, + int px,int py,int pz, + int &pxAux, int &pyAux, int &pzAux ); + + protected: -//DEF_POINTER_IMAGE_VTK_CREA_definition( v_image , ss_image , p_image , st_image ) + +//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; -//macro not working ??? -// DEF_POINTER_IMAGE_VTK_CREA_definition(v_image2,ss_image2,p_image2,st_image2) +// //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; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp index e57d3eb..868583a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp @@ -32,7 +32,8 @@ ManualPaintModel::ManualPaintModel() _brushfilter = new BrushFilter(); _fillfilter = new FillFilter(); _imageUndoRedo = new ImageUndoRedo(); - _imageUndoRedo_visited = new ImageUndoRedo(); +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// _imageUndoRedo_visited = new ImageUndoRedo(); } //--------------------------------------------------------------------------- @@ -93,7 +94,8 @@ void ManualPaintModel::SetImages(vtkImageData *image,vtkImageData *image2) } else { _imageUndoRedo->SetImage(image); } - _imageUndoRedo_visited->SetImage( _fillfilter->GetAuxImageFill() ); +//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 "); } @@ -170,7 +172,8 @@ void ManualPaintModel::SetUndoImage() imMManager = this->_fillfilter->GetImageMManager(); } // if 1 this->_imageUndoRedo -> SetURImages(imMManager); - this->_imageUndoRedo_visited -> SetURImages(imMManager); +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// this->_imageUndoRedo_visited -> SetURImages(imMManager); this->_brushfilter -> CleanImageMManager(); this->_fillfilter -> CleanImageMManager(); } @@ -179,13 +182,15 @@ void ManualPaintModel::SetUndoImage() void ManualPaintModel::Undo() { this->_imageUndoRedo->Undo(); - this->_imageUndoRedo_visited->Undo(); +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// this->_imageUndoRedo_visited->Undo(); } void ManualPaintModel::Redo() { this->_imageUndoRedo->Redo(); - this->_imageUndoRedo_visited->Redo(); +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// this->_imageUndoRedo_visited->Redo(); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp index 909db02..2db1c0f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp @@ -37,15 +37,21 @@ baseFilterManualPaint::baseFilterManualPaint() _minX = 0; _minY = 0; _minZ = 0; - _maxX = 0; - _maxY = 0; - _maxZ = 0; - _pMinX = 0; - _pMinY = 0; - _pMinZ = 0; - _pMaxX = 0; - _pMaxY = 0; - _pMaxZ = 0; + +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// _maxX = 0; +// _maxY = 0; +// _maxZ = 0; +// _pMinX = 0; +// _pMinY = 0; +// _pMinZ = 0; +// _pMaxX = 0; +// _pMaxY = 0; +// _pMaxZ = 0; + + _dimX = 0; + _dimY = 0; + _dimZ = 0; _RangeMin = 0; _RangeMax = 6000; } @@ -112,21 +118,24 @@ void baseFilterManualPaint::SetImages(vtkImageData *image, vtkImageData *image2) _image2->GetExtent(extB); #endif - _maxX = std::min( ext[1]-ext[0] , extB[1]-extB[0] ); - _maxY = std::min( ext[3]-ext[2] , extB[3]-extB[2] ); - _maxZ = std::min( ext[5]-ext[4] , extB[5]-extB[4] ); + _dimX = std::min( ext[1]-ext[0]+1 , extB[1]-extB[0]+1 ); + _dimY = std::min( ext[3]-ext[2]+1 , extB[3]-extB[2]+1 ); + _dimZ = std::min( ext[5]-ext[4]+1 , extB[5]-extB[4]+1 ); } else { - _maxX = ext[1]-ext[0]; - _maxY = ext[3]-ext[2]; - _maxZ = ext[5]-ext[4]; + _dimX = ext[1]-ext[0]+1; + _dimY = ext[3]-ext[2]+1; + _dimZ = ext[5]-ext[4]+1; } // if _OneColumn = 1; - _OneLine = _maxX+1; - _OnePlane = (_maxX+1)*(_maxY+1); + _OneLine = _dimX; + _OnePlane = _dimX*_dimY; } + +/*//EED 2020-04-28 BORRAME Change to local variables to use with openmp + //--------------------------------------------------------------------------- void baseFilterManualPaint::ResetGeneralMinMax() { @@ -149,6 +158,8 @@ void baseFilterManualPaint::SetGeneralMinMax(int minX, int maxX, int minY, if (_pMaxY < maxY) { _pMaxY = maxY; } if (_pMaxZ < maxZ) { _pMaxZ = maxZ; } } +*/ + //--------------------------------------------------------------------------- void baseFilterManualPaint::GetScalarRange(double * range) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h index 4bd2c34..76afc3f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h @@ -62,25 +62,35 @@ protected: int _px; // start point of the brush int _py; int _pz; - int _pMinX; // General min max of many brush actions - int _pMinY; - int _pMinZ; - int _pMaxX; - int _pMaxY; - int _pMaxZ; int _minX; // min max of the image - int _maxX; int _minY; - int _maxY; int _minZ; - int _maxZ; - long int _OneColumn; - long int _OneLine; - long int _OnePlane; + +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// int _maxX; +// int _maxY; +// int _maxZ; +// int _pMinX; // General min max of many brush actions +// int _pMinY; +// int _pMinZ; +// int _pMaxX; +// int _pMaxY; +// int _pMaxZ; + + int _dimX; + int _dimY; + int _dimZ; bool _2D3D; double _graylevel; int _RangeMin; int _RangeMax; + +//EED 2020-04-28 BORRAME Change to local variables to use with openmp + long int _OneColumn; + long int _OneLine; + long int _OnePlane; + + }; #endif // _BASE_FILTER_MANUAL_PAINT_H_ -- 2.47.1