From c6fea780dac325eca6315ac9b297080952e53589 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Fri, 29 Dec 2017 15:12:35 +0100 Subject: [PATCH] #3166 creaMaracasVisu Feature New Normal - Manual Paint optimization --- .../bbcreaMaracasVisuManualPaint_Model.cxx | 120 +++++++- .../bbmaracasvisuImageChangeInformation.cxx | 10 +- .../widgets/manualPaint/FillFilter.cpp | 268 ++++++++++-------- .../widgets/manualPaint/FillFilter.h | 10 +- .../manualPaint/baseFilterManualPaint.cpp | 71 ++--- .../manualPaint/baseFilterManualPaint.h | 52 ++++ 6 files changed, 361 insertions(+), 170 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx index e364134..0320735 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx @@ -11,6 +11,9 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint_Model,bbtk::AtomicBlackBox); //===== // 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) //===== + + +/* void ManualPaint_Model::Process() { @@ -58,7 +61,8 @@ void ManualPaint_Model::Process() if (bbGetInputByImagePoints()!=NULL) { - int i,j,k; + int i,ii=0; +// int i,j,k; // int ia,ja,ka; // int ii,jj,kk; int ext[6]; @@ -66,11 +70,16 @@ void ManualPaint_Model::Process() int dimX=ext[1]-ext[0]+1; int dimY=ext[3]-ext[2]+1; int dimZ=ext[5]-ext[4]+1; +// char *pByImagePoints = bbGetInputByImagePoints->GetScalarComponent(i,j,k,0); +// int sizeData; +//#pragma omp parallel for for (i=0;i0) + { + GETVALUE_MANUALPAINT(vI2,pI2,sTI2) + if (vI2==0) + { + manualpaintmodel->PaintImage(i,j,k); + } // vI2 + } // vBIP + pBIP = pBIP + sSBIP; + pI2 = pI2 + sSI2; + }// for i + }// for j + }// for k + + printf("ManualPaint_Model %d%\n", 100 ); + } // if ByImagePoints + } else { + printf("EED Warning: Image not set. Box creaMaracasVisu::ManualPaint_Model (BBTK) \n"); + } // if + + if (bbGetInputImage2()!=NULL) + { + bbSetOutputOut( bbGetInputImage2() ); + } else if (bbGetInputImage()!=NULL) { + bbSetOutputOut( bbGetInputImage() ); + } else { + bbSetOutputOut( NULL ); + } +} //===== // 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) //===== diff --git a/bbtk/src/bbmaracasvisuImageChangeInformation.cxx b/bbtk/src/bbmaracasvisuImageChangeInformation.cxx index e0b3f1c..3ced61e 100644 --- a/bbtk/src/bbmaracasvisuImageChangeInformation.cxx +++ b/bbtk/src/bbmaracasvisuImageChangeInformation.cxx @@ -42,11 +42,11 @@ void ImageChangeInformation::Process() } mchange = vtkImageChangeInformation::New(); img->GetExtent( ext ); - double origin[3]; - origin[0] = 0.0; - origin[1] = 0.0; - origin[2] = 0.0; - img->SetOrigin(origin); +// double origin[3]; +// origin[0] = 0.0; +// origin[1] = 0.0; +// origin[2] = 0.0; +// img->SetOrigin(origin); mchange->SetInput( img ); //EED 2016 15 06 // mchange->SetExtentTranslation( -ext[0], -ext[2], -ext[4] ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp index 1139e03..3f9c7ad 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp @@ -31,6 +31,9 @@ FillFilter::FillFilter() _distancefill = 500; _limitRecursionFill = 50000; _auxImageFill = NULL; + _maxXback = 0; + _maxYback = 0; + _maxZback = 0; } //--------------------------------------------------------------------------- @@ -46,68 +49,86 @@ FillFilter::~FillFilter() void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual { baseFilterManualPaint::SetImages(image,image2); - if (_auxImageFill != NULL) + + if ((_maxX!=_maxXback) || (_maxY!=_maxYback) || (_maxZ!=_maxZback)) { - _auxImageFill->Delete(); + if (_auxImageFill != NULL) + { + _auxImageFill->Delete(); + } + _auxImageFill = vtkImageData::New(); + _auxImageFill->SetDimensions(_maxX + 1, _maxY + 1, _maxZ + 1); + _auxImageFill->SetOrigin(0, 0, 0); + _auxImageFill->SetExtent(0, _maxX, 0, _maxY, 0, _maxZ); + _auxImageFill->SetWholeExtent(0, _maxX, 0, _maxY, 0, _maxZ); + _auxImageFill->SetScalarTypeToUnsignedChar(); + _auxImageFill->AllocateScalars(); + _ptrAuxImageFill = (unsigned char *)_auxImageFill->GetScalarPointer(); + memset(_ptrAuxImageFill, 0, (_maxX+1) * (_maxY+1) * (_maxZ+1) ); } - _auxImageFill = vtkImageData::New(); - _auxImageFill->SetDimensions(_maxX + 1, _maxY + 1, _maxZ + 1); - _auxImageFill->SetOrigin(0, 0, 0); - _auxImageFill->SetExtent(0, _maxX, 0, _maxY, 0, _maxZ); - _auxImageFill->SetWholeExtent(0, _maxX, 0, _maxY, 0, _maxZ); - _auxImageFill->SetScalarTypeToUnsignedChar(); - _auxImageFill->AllocateScalars(); + _maxXback=_maxX; + _maxYback=_maxY; + _maxYback=_maxZ; } + //--------------------------------------------------------------------------- void FillFilter::Run() // virtual { + long int ivi; if ((_px >= _minX) && (_px <= _maxX) && (_py >= _minY) && (_py <= _maxY) - && (_pz >= _minZ) && (_pz <= _maxZ)) { - _graylevelbasefill = _image->GetScalarComponentAsDouble(_px, _py, _pz, - 0); - _pxfill = _px; - _pyfill = _py; - _pzfill = _pz; - _distbasefill = _distancefill * _distancefill; - _countRecursiveFill = 0; - _countRecursiveFillProblem = 0; - _countProgressingFill = 0; - unsigned char *pImage = - (unsigned char *) _auxImageFill->GetScalarPointer(); - _usingAuxImageFill = false; - memset(pImage, 0, _maxX * _maxY * _maxZ); - - FillToolRecursive(_px, _py, _pz); -// printf("--\n"); - + && (_pz >= _minZ) && (_pz <= _maxZ)) + { + _graylevelbasefill = _image->GetScalarComponentAsDouble(_px, _py, _pz,0); + _pxfill = _px; + _pyfill = _py; + _pzfill = _pz; + _distbasefill = _distancefill * _distancefill; + _countRecursiveFill = 0; + _countRecursiveFillProblem = 0; + _countProgressingFill = 0; + _usingAuxImageFill = false; + ivi = _px + _py*(_maxX+1) + _pz*(_maxX+1)*(_maxY+1); // index vector image +//EED01 +// FillToolRecursive(_px, _py, _pz); + FillToolRecursive(_px, _py, _pz, ivi); + + unsigned char *pImage; + pImage = (unsigned char *) _auxImageFill->GetScalarPointer(); int ii, jj, kk; - while (_countRecursiveFillProblem != 0) { - _countRecursiveFillProblem = 0; - _usingAuxImageFill = true; - for (ii = 0; ii <= _maxX; ii++) { - for (jj = 0; jj <= _maxY; jj++) { - for (kk = 0; kk <= _maxZ; kk++) { - pImage = - (unsigned char *) _auxImageFill->GetScalarPointer( - ii, jj, kk); - if ((*pImage) == 1) { - FillToolRecursive(ii, jj, kk); - } - } // for kk + ivi = 0; + while (_countRecursiveFillProblem != 0) + { + _countRecursiveFillProblem = 0; + _usingAuxImageFill = true; + for (kk = 0; kk <= _maxZ; kk++) + { + for (jj = 0; jj <= _maxY; jj++) + { + for (ii = 0; ii <= _maxX; ii++) + { + if (pImage[ivi] == 1) + { +//EED01 +// FillToolRecursive(ii, jj, kk); + FillToolRecursive(ii, jj, kk, ivi); + } // if + ivi++; + } // for ii } // for jj - } //for ii + } //for kk // printf("-\n"); } // while - } //if _minX _maxX _minY _maxY _minZ _maxZ } //--------------------------------------------------------------------------- -void FillFilter::FillToolRecursive(int px, int py, int pz) +void FillFilter::FillToolRecursive(int px, int py, int pz,long int ivi) { - _countRecursiveFill++; +DEFINEPOINTERIMAGE_MANUALPAINT(v_image,ss_image,p_image,st_image,_image) +DEFINEPOINTERIMAGE_MANUALPAINT(v_image2,ss_image2,p_image2,st_image2,_image2) + _countRecursiveFill++; _countProgressingFill++; if (_countProgressingFill > 200000) { @@ -121,41 +142,53 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) if (_usingAuxImageFill == true) { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH - _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0); +//EED01 +// _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0); + _ptrAuxImageFill[ ivi ]=0; } - _tmpDistfill = (px - _pxfill) * (px - _pxfill) - + (py - _pyfill) * (py - _pyfill) - + (pz - _pzfill) * (pz - _pzfill); - _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0); + _tmpDistfill = (px-_pxfill)*(px-_pxfill) + + (py-_pyfill)*(py-_pyfill) + + (pz-_pzfill)*(pz-_pzfill); + +//if (_countRecursiveFill >1 ) +//{ +// printf(" -> %d %d %d cr=%ld r=%f\n", px,py,pz,_countRecursiveFill , _tmpDistfill); +//} + + +//EED01 +// _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0); +GETVALUE2_MANUALPAINT(_tmpiglfill,p_image,st_image,ivi) if (_image2!=NULL) { - _tmpiglfill2 = _image2->GetScalarComponentAsDouble(px, py, pz, 0); +//EED01 +// _tmpiglfill2 = _image2->GetScalarComponentAsDouble(px, py, pz, 0); +GETVALUE2_MANUALPAINT(_tmpiglfill2,p_image2,st_image2,ivi) } else { _tmpiglfill2 = _tmpiglfill; } - float grayLBFMTOL = _graylevelbasefill - _tolerancefill; - float grayLBFPTOL = _graylevelbasefill + _tolerancefill; - bool isInRange = false; + float grayLBFMTOL = _graylevelbasefill - _tolerancefill; + float grayLBFPTOL = _graylevelbasefill + _tolerancefill; + bool isInRange = false; //DFCH if (_RangeMin <= grayLBFMTOL && _RangeMax >= grayLBFPTOL) { - isInRange = true; + isInRange = true; } //fi esle else if (_RangeMin > grayLBFMTOL && _RangeMax >= grayLBFPTOL) { - grayLBFMTOL = _RangeMin; - isInRange = true; + grayLBFMTOL = _RangeMin; + isInRange = true; } //fi esle else if (_RangeMin <= grayLBFMTOL && _RangeMax < grayLBFPTOL) { - grayLBFPTOL = _RangeMax; - isInRange = true; - } //fi esle - else if ((_RangeMin <= _graylevelbasefill) - && (_graylevelbasefill <= _RangeMax)) { - grayLBFMTOL = _RangeMin; - grayLBFPTOL = _RangeMax; - isInRange = true; + grayLBFPTOL = _RangeMax; + isInRange = true; } //fi esle + else if ((_RangeMin <= _graylevelbasefill) && (_graylevelbasefill <= _RangeMax)) { + grayLBFMTOL = _RangeMin; + grayLBFPTOL = _RangeMax; + isInRange = true; + } //fi Range if (isInRange) { @@ -179,9 +212,13 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH if (_image2!=NULL) { - _image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); +//EED01 +// _image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); +SETVALUE2_MANUALPAINT(_graylevel,p_image2,st_image2,ivi) } else { - _image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); +//EED01 +// _image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); +SETVALUE2_MANUALPAINT(_graylevel,p_image,st_image,ivi) } if (_countRecursiveFill < _limitRecursionFill) @@ -193,102 +230,99 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) { //FillToolRecursive(px+1,py,pz); //FillToolRecursive(px-1,py,pz); - FillToolRecursive(px, py + 1, pz); - FillToolRecursive(px, py - 1, pz); - FillToolRecursive(px, py, pz - 1); - FillToolRecursive(px, py, pz + 1); + FillToolRecursive(px, py + 1, pz, ivi+_OneLine ); + FillToolRecursive(px, py - 1, pz, ivi-_OneLine ); + FillToolRecursive(px, py, pz - 1, ivi-_OnePlane ); + FillToolRecursive(px, py, pz + 1, ivi+_OnePlane ); } if (_direction == 1) // XZ { - FillToolRecursive(px + 1, py, pz); - FillToolRecursive(px - 1, py, pz); + FillToolRecursive(px + 1, py, pz, ivi+_OneColumn); + FillToolRecursive(px - 1, py, pz, ivi-_OneColumn); //FillToolRecursive(px,py+1,pz); //FillToolRecursive(px,py-1,pz); - FillToolRecursive(px, py, pz - 1); - FillToolRecursive(px, py, pz + 1); + FillToolRecursive(px, py, pz - 1, ivi-_OnePlane ); + FillToolRecursive(px, py, pz + 1, ivi+_OnePlane ); } if (_direction == 2) // XY { - FillToolRecursive(px + 1, py, pz); - FillToolRecursive(px, py + 1, pz); - FillToolRecursive(px - 1, py, pz); - FillToolRecursive(px, py - 1, pz); + FillToolRecursive(px + 1, py, pz, ivi+_OneColumn); + FillToolRecursive(px, py + 1, pz, ivi+_OneLine); + FillToolRecursive(px - 1, py, pz, ivi-_OneColumn); + FillToolRecursive(px, py - 1, pz, ivi-_OneLine); //FillToolRecursive(px,py,pz-1); //FillToolRecursive(px,py,pz+1); } } else { // 3D - - FillToolRecursive(px + 1, py, pz); - FillToolRecursive(px - 1, py, pz); - FillToolRecursive(px, py + 1, pz); - FillToolRecursive(px, py - 1, pz); - FillToolRecursive(px, py, pz - 1); - FillToolRecursive(px, py, pz + 1); + FillToolRecursive(px + 1, py, pz, ivi+_OneColumn ); + FillToolRecursive(px - 1, py, pz, ivi-_OneColumn ); + FillToolRecursive(px, py + 1, pz, ivi+_OneLine ); + FillToolRecursive(px, py - 1, pz, ivi-_OneLine ); + FillToolRecursive(px, py, pz - 1, ivi-_OnePlane ); + FillToolRecursive(px, py, pz + 1, ivi+_OnePlane ); } // 2D 3D } //_countRecursiveFill } // _graylevel - if ((_auxGrayLevelValidationFill == true) - && (_countRecursiveFill >= _limitRecursionFill)) + if ((_auxGrayLevelValidationFill == true) && (_countRecursiveFill >= _limitRecursionFill)) { _countRecursiveFillProblem++; - if (_2D3D == 0) //2D - { + { if (_direction == 0) // YZ - { + { //SetAuxImageFill(px+1,py,pz); //SetAuxImageFill(px-1,py,pz); - SetAuxImageFill(px, py + 1, pz); - SetAuxImageFill(px, py - 1, pz); - SetAuxImageFill(px, py, pz - 1); - SetAuxImageFill(px, py, pz + 1); + SetAuxImageFill(px, py + 1, pz,ivi+_OneLine); + SetAuxImageFill(px, py - 1, pz,ivi-_OneLine); + SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane); + SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane); } if (_direction == 1) // XZ - { - SetAuxImageFill(px + 1, py, pz); - SetAuxImageFill(px - 1, py, pz); + { + SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn); + SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn); //SetAuxImageFill(px,py+1,pz); //SetAuxImageFill(px,py-1,pz); - SetAuxImageFill(px, py, pz - 1); - SetAuxImageFill(px, py, pz + 1); + SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane); + SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane); } if (_direction == 2) // XY - { - SetAuxImageFill(px + 1, py, pz); - SetAuxImageFill(px - 1, py, pz); - SetAuxImageFill(px, py + 1, pz); - SetAuxImageFill(px, py - 1, pz); + { + SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn); + SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn); + SetAuxImageFill(px, py + 1, pz,ivi+_OneLine); + SetAuxImageFill(px, py - 1, pz,ivi-_OneLine); //SetAuxImageFill(px,py,pz-1); //SetAuxImageFill(px,py,pz+1); } } else { // 3D - - SetAuxImageFill(px + 1, py, pz); - SetAuxImageFill(px - 1, py, pz); - SetAuxImageFill(px, py + 1, pz); - SetAuxImageFill(px, py - 1, pz); - SetAuxImageFill(px, py, pz - 1); - SetAuxImageFill(px, py, pz + 1); + SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn); + SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn); + SetAuxImageFill(px, py + 1, pz,ivi+_OneLine); + SetAuxImageFill(px, py - 1, pz,ivi-_OneLine); + SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane); + SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane); } // 2D 3D } // _graylevel //_limitRecursionFill } //if _minX _maxX _minY _maxY _minZ _maxZ - _countRecursiveFill--; - } //--------------------------------------------------------------------------- -void FillFilter::SetAuxImageFill(int px, int py, int pz) +void FillFilter::SetAuxImageFill(int px, int py, int pz, long int ivi) { if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY) - && (pz >= _minZ) && (pz <= _maxZ)) { + && (pz >= _minZ) && (pz <= _maxZ)) + { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH - _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 1); - } +//EED01 +// _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 1); + _ptrAuxImageFill[ ivi ]=1; + } // if px py pz } //--------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h index dc118a8..3482b2a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h @@ -34,7 +34,7 @@ public: virtual ~FillFilter(); void Run(); - void FillToolRecursive(int px,int py, int pz); + void FillToolRecursive(int px,int py, int pz, long int ivi); void SetToleranceFill(double tolerancefill); void SetDistanceFill(int distancefill); @@ -55,13 +55,19 @@ private: long int _countRecursiveFill; long int _countRecursiveFillProblem; vtkImageData *_auxImageFill; +//EED01 + unsigned char *_ptrAuxImageFill; + bool _usingAuxImageFill; bool _auxGrayLevelValidationFill; long int _countProgressingFill; long int _limitRecursionFill; - void SetAuxImageFill(int px,int py, int pz); + void SetAuxImageFill(int px,int py, int pz,long int ivi); + int _maxXback; + int _maxYback; + int _maxZback; protected: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp index 0a9f995..3941e84 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp @@ -40,14 +40,12 @@ baseFilterManualPaint::baseFilterManualPaint() _maxX = 0; _maxY = 0; _maxZ = 0; - _pMinX = 0; _pMinY = 0; _pMinZ = 0; _pMaxX = 0; _pMaxY = 0; _pMaxZ = 0; - _RangeMin = 0; _RangeMax = 6000; } @@ -63,22 +61,26 @@ void baseFilterManualPaint::Run() // virtual } //--------------------------------------------------------------------------- -void baseFilterManualPaint::SetGrayLevel(double graylevel) { +void baseFilterManualPaint::SetGrayLevel(double graylevel) +{ _graylevel = graylevel; } //--------------------------------------------------------------------------- -void baseFilterManualPaint::Set2D3D(int dim2D3D) { +void baseFilterManualPaint::Set2D3D(int dim2D3D) +{ _2D3D = dim2D3D; } //--------------------------------------------------------------------------- -void baseFilterManualPaint::SetDirection(int direction) { +void baseFilterManualPaint::SetDirection(int direction) +{ _direction = direction; } //--------------------------------------------------------------------------- -void baseFilterManualPaint::SetPoint(int px, int py, int pz) { +void baseFilterManualPaint::SetPoint(int px, int py, int pz) +{ _px = px; _py = py; _pz = pz; @@ -89,13 +91,11 @@ void baseFilterManualPaint::SetImages(vtkImageData *image, vtkImageData *image2) { _image = image; _image2 = image2; - int ext[6]; _image->GetWholeExtent(ext); _minX = 0; _minY = 0; _minZ = 0; - if (_image2!=NULL) { int extB[6]; @@ -108,11 +108,16 @@ void baseFilterManualPaint::SetImages(vtkImageData *image, vtkImageData *image2) _maxY = ext[3]-ext[2]; _maxZ = ext[5]-ext[4]; } // if + + _OneColumn = 1; + _OneLine = _maxX+1; + _OnePlane = (_maxX+1)*(_maxY+1); } //--------------------------------------------------------------------------- -void baseFilterManualPaint::ResetGeneralMinMax() { +void baseFilterManualPaint::ResetGeneralMinMax() +{ _pMinX = 10000; _pMinY = 10000; _pMinZ = 10000; @@ -123,51 +128,34 @@ void baseFilterManualPaint::ResetGeneralMinMax() { //--------------------------------------------------------------------------- void baseFilterManualPaint::SetGeneralMinMax(int minX, int maxX, int minY, - int maxY, int minZ, int maxZ) { - if (_pMinX > minX) { - _pMinX = minX; - } - - if (_pMinY > minY) { - _pMinY = minY; - } - - if (_pMinZ > minZ) { - _pMinZ = minZ; - } - - if (_pMaxX < maxX) { - _pMaxX = maxX; - } - - if (_pMaxY < maxY) { - _pMaxY = maxY; - } - - if (_pMaxZ < maxZ) { - _pMaxZ = maxZ; - } - + int maxY, int minZ, int maxZ) +{ + if (_pMinX > minX) { _pMinX = minX; } + if (_pMinY > minY) { _pMinY = minY; } + if (_pMinZ > minZ) { _pMinZ = minZ; } + if (_pMaxX < maxX) { _pMaxX = maxX; } + if (_pMaxY < maxY) { _pMaxY = maxY; } + if (_pMaxZ < maxZ) { _pMaxZ = maxZ; } } //--------------------------------------------------------------------------- -void baseFilterManualPaint::GetScalarRange(double * range) { +void baseFilterManualPaint::GetScalarRange(double * range) +{ range = this->_image->GetScalarRange(); } //--------------------------------------------------------------------------- -ImageMManager* baseFilterManualPaint::GetImageMManager() { +ImageMManager* baseFilterManualPaint::GetImageMManager() +{ return (this->_IMManager); } //DFCH //--------------------------------------------------------------------------- -void baseFilterManualPaint::CleanImageMManager() { +void baseFilterManualPaint::CleanImageMManager() +{ this->_IMManager->CleanModifiedRegion(); } //DFCH - - - //--------------------------------------------------------------------------- void baseFilterManualPaint::SetRangeMin(int min) { @@ -192,6 +180,3 @@ int baseFilterManualPaint::GetRangeMax() return _RangeMax; } - - - diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h index bdb76a4..21d38c5 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h @@ -33,6 +33,55 @@ #include "imageModificationManager.h" +#define GETVALUE_MANUALPAINT(VALUE,POINTER,SCALARTYPE) \ + if (SCALARTYPE==VTK_DOUBLE) { VALUE=(double)*((double*)POINTER); } \ + else if (SCALARTYPE==VTK_FLOAT) { VALUE=(double)*((float*)POINTER); } \ + else if (SCALARTYPE==VTK_CHAR) { VALUE=(double)*((char*)POINTER); } \ + else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { VALUE=(double)*((unsigned char*)POINTER); } \ + else if (SCALARTYPE==VTK_INT) { VALUE=(double)*((int*)POINTER); } \ + else if (SCALARTYPE==VTK_UNSIGNED_INT) { VALUE=(double)*((unsigned int*)POINTER); } \ + else if (SCALARTYPE==VTK_LONG) { VALUE=(double)*((long*)POINTER); } \ + else if (SCALARTYPE==VTK_UNSIGNED_LONG) { VALUE=(double)*((unsigned long*)POINTER); } \ + else if (SCALARTYPE==VTK_SHORT) { VALUE=(double)*((short*)POINTER); } \ + else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ VALUE=(double)*((unsigned short*)POINTER);} \ + else { printf("EED GETVALUE_MANUALPAINT error\n"); } + +#define GETVALUE2_MANUALPAINT(VALUE,POINTER,SCALARTYPE,INDEX) \ + if (SCALARTYPE==VTK_DOUBLE) { VALUE=(double)((double*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_FLOAT) { VALUE=(double)((float*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_CHAR) { VALUE=(double)((char*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { VALUE=(double)((unsigned char*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_INT) { VALUE=(double)((int*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_UNSIGNED_INT) { VALUE=(double)((unsigned int*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_LONG) { VALUE=(double)((long*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_UNSIGNED_LONG) { VALUE=(double)((unsigned long*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_SHORT) { VALUE=(double)((short*)POINTER)[INDEX]; } \ + else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ VALUE=(double)((unsigned short*)POINTER)[INDEX]; } \ + else { printf("EED GETVALUE2_MANUALPAINT error\n"); } + +#define SETVALUE2_MANUALPAINT(VALUE,POINTER,SCALARTYPE,INDEX) \ + if (SCALARTYPE==VTK_DOUBLE) { ((double*)POINTER)[INDEX] = (double)VALUE; } \ + else if (SCALARTYPE==VTK_FLOAT) { ((float*)POINTER)[INDEX] = (float)VALUE; } \ + else if (SCALARTYPE==VTK_CHAR) { ((char*)POINTER)[INDEX] = (char)VALUE; } \ + else if (SCALARTYPE==VTK_UNSIGNED_CHAR) { ((unsigned char*)POINTER)[INDEX] = (unsigned char)VALUE; } \ + else if (SCALARTYPE==VTK_INT) { ((int*)POINTER)[INDEX] = (int)VALUE; } \ + else if (SCALARTYPE==VTK_UNSIGNED_INT) { ((unsigned int*)POINTER)[INDEX] = (unsigned int)VALUE; } \ + else if (SCALARTYPE==VTK_LONG) { ((long*)POINTER)[INDEX] = (long)VALUE; } \ + else if (SCALARTYPE==VTK_UNSIGNED_LONG) { ((unsigned long*)POINTER)[INDEX] = (unsigned long)VALUE; } \ + else if (SCALARTYPE==VTK_SHORT) { ((short*)POINTER)[INDEX] = (short)VALUE; } \ + else if (SCALARTYPE==VTK_UNSIGNED_SHORT){ ((unsigned short*)POINTER)[INDEX] = (unsigned short)VALUE;} \ + else { printf("EED SETVALUE2_MANUALPAINT error\n"); } + + +#define DEFINEPOINTERIMAGE_MANUALPAINT(VALUE,SCALARSIZE,POINTERIMAGE,SCALARTYPE,IMAGE) \ + double VALUE = 0; \ + int SCALARSIZE = IMAGE->GetScalarSize(); \ + char *POINTERIMAGE = (char*)(IMAGE->GetScalarPointer()); \ + int SCALARTYPE = IMAGE->GetScalarType(); + + + + class baseFilterManualPaint { public: @@ -79,6 +128,9 @@ protected: int _maxY; int _minZ; int _maxZ; + long int _OneColumn; + long int _OneLine; + long int _OnePlane; bool _2D3D; double _graylevel; int _RangeMin; -- 2.47.1