X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FmanualPaint%2FFillFilter.cpp;h=1139e035b0bf9c263c438db85202891587b1225f;hb=b90d2dce776b27c95bd59251ee83d10a42b0cae5;hp=c12e1f9c89491bb8c249af66b52b131c00627638;hpb=f4bdb751aba1f5fce1d4305365d6309f993d9c32;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp index c12e1f9..1139e03 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp @@ -1,14 +1,41 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + #include "FillFilter.h" -FillFilter::FillFilter() { - _tolerancefill = 50; - _distancefill = 500; +FillFilter::FillFilter() +{ + _tolerancefill = 50; + _distancefill = 500; _limitRecursionFill = 50000; - _auxImageFill = NULL; + _auxImageFill = NULL; } //--------------------------------------------------------------------------- -FillFilter::~FillFilter() { +FillFilter::~FillFilter() +{ if (_auxImageFill != NULL) { _auxImageFill->Delete(); @@ -16,9 +43,9 @@ FillFilter::~FillFilter() { } //--------------------------------------------------------------------------- -void FillFilter::SetImage(vtkImageData *image) // virtual - { - baseFilterManualPaint::SetImage(image); +void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual +{ + baseFilterManualPaint::SetImages(image,image2); if (_auxImageFill != NULL) { _auxImageFill->Delete(); @@ -52,7 +79,7 @@ void FillFilter::Run() // virtual memset(pImage, 0, _maxX * _maxY * _maxZ); FillToolRecursive(_px, _py, _pz); - printf("--\n"); +// printf("--\n"); int ii, jj, kk; while (_countRecursiveFillProblem != 0) { @@ -70,32 +97,43 @@ void FillFilter::Run() // virtual } // for kk } // for jj } //for ii - printf("-\n"); +// 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) +{ _countRecursiveFill++; _countProgressingFill++; - if (_countProgressingFill > 200000) { + if (_countProgressingFill > 200000) + { printf("R %ld \n", _countRecursiveFill); _countProgressingFill = 0; } if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY) - && (pz >= _minZ) && (pz <= _maxZ)) { - if (_usingAuxImageFill == true) { + && (pz >= _minZ) && (pz <= _maxZ)) + { + if (_usingAuxImageFill == true) + { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0); } _tmpDistfill = (px - _pxfill) * (px - _pxfill) + (py - _pyfill) * (py - _pyfill) + (pz - _pzfill) * (pz - _pzfill); - _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0); + _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0); + + if (_image2!=NULL) + { + _tmpiglfill2 = _image2->GetScalarComponentAsDouble(px, py, pz, 0); + } else { + _tmpiglfill2 = _tmpiglfill; + } float grayLBFMTOL = _graylevelbasefill - _tolerancefill; float grayLBFPTOL = _graylevelbasefill + _tolerancefill; @@ -119,31 +157,40 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) { isInRange = true; } //fi esle - if (isInRange) { + if (isInRange) + { _auxGrayLevelValidationFill = (_tmpiglfill != _graylevel) + && (_tmpiglfill2 != _graylevel) && (_tmpiglfill >= grayLBFMTOL) && (_tmpiglfill <= grayLBFPTOL) && (_tmpDistfill <= _distbasefill); //DFCH - } //fi - else { + } else { _auxGrayLevelValidationFill = false; - } //esle + } // if isInRange + //DFCH /*_auxGrayLevelValidationFill = (_tmpiglfill!=_graylevel) && (_tmpiglfill>=_graylevelbasefill-_tolerancefill) && (_tmpiglfill<=_graylevelbasefill+_tolerancefill) && (_tmpDistfill<=_distbasefill);*/ //DFCH - if (_auxGrayLevelValidationFill == true) { + + if (_auxGrayLevelValidationFill == true) + { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH - _image->SetScalarComponentFromFloat(px, py, pz, 0, - (float) _graylevel); + if (_image2!=NULL) + { + _image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); + } else { + _image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); + } - if (_countRecursiveFill < _limitRecursionFill) { + if (_countRecursiveFill < _limitRecursionFill) + { if (_2D3D == 0) //2D - { + { if (_direction == 0) // YZ - { + { //FillToolRecursive(px+1,py,pz); //FillToolRecursive(px-1,py,pz); FillToolRecursive(px, py + 1, pz); @@ -183,7 +230,8 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) { } // _graylevel if ((_auxGrayLevelValidationFill == true) - && (_countRecursiveFill >= _limitRecursionFill)) { + && (_countRecursiveFill >= _limitRecursionFill)) + { _countRecursiveFillProblem++; if (_2D3D == 0) //2D @@ -234,7 +282,8 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) { } //--------------------------------------------------------------------------- -void FillFilter::SetAuxImageFill(int px, int py, int pz) { +void FillFilter::SetAuxImageFill(int px, int py, int pz) +{ if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY) && (pz >= _minZ) && (pz <= _maxZ)) { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH @@ -243,31 +292,15 @@ void FillFilter::SetAuxImageFill(int px, int py, int pz) { } //--------------------------------------------------------------------------- -void FillFilter::SetToleranceFill(double tolerancefill) { +void FillFilter::SetToleranceFill(double tolerancefill) +{ _tolerancefill = tolerancefill; } //--------------------------------------------------------------------------- -void FillFilter::SetDistanceFill(int distancefill) { +void FillFilter::SetDistanceFill(int distancefill) +{ _distancefill = distancefill; } -//--------------------------------------------------------------------------- -void FillFilter::SetRangeMin(int min) { - _RangeMin = min; -} -//--------------------------------------------------------------------------- -void FillFilter::SetRangeMax(int max) { - _RangeMax = max; -} - -//--------------------------------------------------------------------------- -int FillFilter::GetRangeMin() { - return (_RangeMin); -} - -//--------------------------------------------------------------------------- -int FillFilter::GetRangeMax() { - return (_RangeMax); -}