From 095cbcb3c9ad1ebf7350ec7399dae23739d914e6 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Sat, 2 May 2020 09:28:17 +0200 Subject: [PATCH] #3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp --- .../widgets/manualPaint/BrushFilter.cpp | 50 ++++++++++++++++--- .../widgets/manualPaint/BrushFilter.h | 4 +- .../widgets/manualPaint/FillFilter.cpp | 19 +++++-- .../widgets/manualPaint/ManualPaintModel.cpp | 13 ++--- .../manualPaint/baseFilterManualPaint.cpp | 6 ++- .../manualPaint/baseFilterManualPaint.h | 8 +-- 6 files changed, 70 insertions(+), 30 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp index 0e1afbb..3e14f4c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp @@ -38,17 +38,18 @@ BrushFilter::~BrushFilter() // virtual } //--------------------------------------------------------------------------- -void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY, +void BrushFilter::FindMinMaxBrush(int px, int py, int pz,int &minX, int &maxX, int &minY, int &maxY, int &minZ, int &maxZ, int &size) { size = _brushsize - 1; +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +/* minX = _px - size; maxX = _px + size; minY = _py - size; maxY = _py + size; minZ = _pz - size; maxZ = _pz + size; - if (_2D3D == 0) //2D { if (_direction == 0) // YZ @@ -67,6 +68,31 @@ void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY, maxZ = _pz; } } // _2D3D +*/ + minX = px - size; + maxX = px + size; + minY = py - size; + maxY = py + size; + minZ = pz - size; + maxZ = pz + size; + if (_2D3D == 0) //2D + { + if (_direction == 0) // YZ + { + minX = px; + maxX = px; + } + if (_direction == 1) // XZ + { + minY = py; + maxY = py; + } + if (_direction == 2) // XY + { + minZ = pz; + maxZ = pz; + } + } // _2D3D if (_2D3D == 1) { } // 3D @@ -83,18 +109,20 @@ void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY, } //--------------------------------------------------------------------------- -void BrushFilter::Run() // virtual +void BrushFilter::Run(int px, int py, int pz) // virtual { if (_image != NULL) { - this->_IMManager->BaseInitialPoint(_px, _py ,_pz); +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// this->_IMManager->BaseInitialPoint(_px, _py ,_pz); + this->_IMManager->BaseInitialPoint(px, py ,pz); float value = (float) _graylevel; int i, j, k; int size; int minX, maxX, minY, maxY, minZ, maxZ; - FindMinMaxBrush(minX, maxX, minY, maxY, minZ, maxZ, size); + FindMinMaxBrush(px,py,pz,minX, maxX, minY, maxY, minZ, maxZ, size); double xx, yy, zz, rr = size * size; float scalarComponent; @@ -102,11 +130,15 @@ void BrushFilter::Run() // virtual for (i = minX; i <= maxX; i++) { - xx = _px - i; +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// xx = _px - i; + xx = px - i; xx = xx * xx; for (j = minY; j <= maxY; j++) { - yy = _py - j; +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// yy = _py - j; + yy = py - j; yy = yy * yy; for (k = minZ; k <= maxZ; k++) { @@ -122,7 +154,9 @@ void BrushFilter::Run() // virtual } // _brushform 0 if (_brushform == 1) { - zz = _pz - k; +//EED 2020-04-28 BORRAME Change to local variables to use with openmp +// zz = _pz - k; + zz = pz - k; zz = zz * zz; if ((xx + yy + zz) <= rr) { pixelModify=true; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h index e851dae..92a2ebe 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h @@ -36,8 +36,8 @@ public: void SetBrushSize( int brushsize ); void SetBrushForm( int brushform ); void SetBrushTool( int brushtool ); - void FindMinMaxBrush(int &minxX,int &maxX,int &minY,int &maxY,int &minZ,int &maxZ,int &size); - virtual void Run(); + void FindMinMaxBrush(int px, int py, int pz,int &minxX,int &maxX,int &minY,int &maxY,int &minZ,int &maxZ,int &size); + virtual void Run(int px, int py, int pz); private: int _brushsize; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp index fb8d867..5b6d3d7 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp @@ -102,16 +102,27 @@ void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // 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)) + +/* //EED 2020-04-28 BORRAME Change to local variables to use with openmp + if ( (_px >= _minX) && (_px < _dimX) && + (_py >= _minY) && (_py < _dimY) && + (_pz >= _minZ) && (_pz < _dimZ) ) { this->_IMManager->BaseInitialPoint(_px, _py ,_pz); -// FillToolLoop(_px, _py, _pz); + FillToolLoop(_px, _py, _pz); + } //if _minX _maxX _minY _maxY _minZ _maxZ +*/ + + 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 - } //if _minX _maxX _minY _maxY _minZ _maxZ } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp index c74dfdf..2820f45 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp @@ -57,12 +57,12 @@ void ManualPaintModel::PaintImage(int px, int py, int pz) { if (_tool == 0) { - _brushfilter->SetPoint(px, py, pz); - _brushfilter->Run(); +// _brushfilter->SetPoint(px, py, pz); + _brushfilter->Run(px,py,pz); } // _tool 2 if (_tool == 1) { - _fillfilter->SetPoint(px, py, pz); +// _fillfilter->SetPoint(px, py, pz); _fillfilter->Run(px,py,pz); } // _tool 1 } // _active @@ -84,28 +84,21 @@ 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::SetImages(image,image2)\n "); } -printf("EED ManualPaintModel::SetImage End\n "); } //--------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp index 2db1c0f..c7f0ad4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp @@ -62,7 +62,7 @@ baseFilterManualPaint::~baseFilterManualPaint() // virtual } //--------------------------------------------------------------------------- -void baseFilterManualPaint::Run() // virtual +void baseFilterManualPaint::Run(int px, int py, int pz) // virtual { } @@ -84,6 +84,7 @@ void baseFilterManualPaint::SetDirection(int direction) _direction = direction; } +/* //EED 2020-04-28 BORRAME Change to local variables to use with openmp //--------------------------------------------------------------------------- void baseFilterManualPaint::SetPoint(int px, int py, int pz) { @@ -91,7 +92,8 @@ void baseFilterManualPaint::SetPoint(int px, int py, int pz) _py = py; _pz = pz; } - +*/ + //--------------------------------------------------------------------------- void baseFilterManualPaint::SetImages(vtkImageData *image, vtkImageData *image2) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h index b5cf4cb..35efd9f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h @@ -53,21 +53,21 @@ public: int GetRangeMax( ); //DFCH ImageMManager* GetImageMManager(); //DFCH void CleanImageMManager(); //DFCH - virtual void Run(); + virtual void Run(int px, int py, int pz); private: protected: ImageMManager *_IMManager; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ). vtkImageData *_image; vtkImageData *_image2; int _direction; - int _px; // start point of the brush - int _py; - int _pz; int _minX; // min max of the image int _minY; int _minZ; //EED 2020-04-28 BORRAME Change to local variables to use with openmp +// int _px; // start point of the brush +// int _py; +// int _pz; // int _maxX; // int _maxY; // int _maxZ; -- 2.47.1