From: Eduardo Enrique Davila Serrano Date: Tue, 3 Jan 2023 13:06:28 +0000 (+0100) Subject: Memory bug X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e3ed15fb6292544d9440bfad4e39dc6c74824f51;p=creaVtk.git Memory bug --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx index 2e6d519..a368cc5 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx @@ -46,7 +46,8 @@ void ImageThresholdConnectivity::Process() if ( (bbGetInputIn()!=NULL) && (lstX.size()>0) && (lstX.size()==lstY.size()) && (lstX.size()==lstZ.size()) ) { - vtkImageThresholdConnectivity *filter = vtkImageThresholdConnectivity::New(); + if (filter!=NULL) { filter->Delete(); } + filter = vtkImageThresholdConnectivity::New(); double spc[3]; bbGetInputIn()->GetSpacing(spc); int border = bbGetInputBorder(); @@ -76,7 +77,12 @@ void ImageThresholdConnectivity::Process() filter->SetInputData( bbGetInputIn() ); if (bbGetInputThreshold().size()==2) { - filter->ThresholdBetween( bbGetInputThreshold()[0] , bbGetInputThreshold()[1] ); + if ( bbGetInputThreshold()[0] < bbGetInputThreshold()[1] ) + { + filter->ThresholdBetween( bbGetInputThreshold()[0] , bbGetInputThreshold()[1] ); + } else { + filter->ThresholdBetween( bbGetInputThreshold()[1] , bbGetInputThreshold()[0] ); + }// if Thershold min max } else { filter->ThresholdBetween( 0, 100 ); }// if Thershold size @@ -102,13 +108,13 @@ void ImageThresholdConnectivity::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 + filter=NULL; bbSetInputIn(NULL); bbSetInputBorder(10); std::vector maskValue; maskValue.push_back(0); maskValue.push_back(255); bbSetInputMaskValue(maskValue); - } //===== diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.h index 7ed7bee..8f53fc4 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.h @@ -33,7 +33,7 @@ class bbcreaVtk_EXPORT ImageThresholdConnectivity BBTK_DECLARE_OUTPUT(Out,vtkImageData*); BBTK_PROCESS(Process); void Process(); - + vtkImageThresholdConnectivity *filter; //===== // 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) //=====