From 8be3b211dce6990f90e29a200d8101d95b1d5d28 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Fri, 3 Oct 2025 13:42:25 +0200 Subject: [PATCH] #3535 Bug bbcreaVtkImageConnectivityFilter --- .../src/bbcreaVtkImageConnectivityFilter.cxx | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageConnectivityFilter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageConnectivityFilter.cxx index d9c051c..c633b6f 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageConnectivityFilter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageConnectivityFilter.cxx @@ -31,29 +31,43 @@ void ImageConnectivityFilter::Process() // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') + vtkImageData *result=NULL; + if (bbGetInputIn()!=NULL) { if (imgConnfilter) {imgConnfilter->Delete();} imgConnfilter=vtkImageConnectivityFilter::New(); imgConnfilter->SetInputData( bbGetInputIn() ); + if (bbGetInputScalarRange().size()==2) + { + imgConnfilter->SetScalarRange( bbGetInputScalarRange()[0], bbGetInputScalarRange()[1] ); + printf("EED ImageConnectivityFilter Scalar Range %f %f \n", bbGetInputScalarRange()[0], bbGetInputScalarRange()[1]); + } // Range + if (bbGetInputExtractionMode()==0) // LargestRegion { imgConnfilter->SetExtractionModeToLargestRegion(); - } // ExtractionMode + imgConnfilter->Update( ); + result = imgConnfilter->GetOutput(); + } // ExtractionMode 0 if (bbGetInputExtractionMode()==1) // AllRegions { - printf("EED Warning!!!! ImageConnectivityFilter - AllRegions Not Implemented\n "); - } // ExtractionMode + printf("EED Warning!!!! ImageConnectivityFilter - AllRegions Not Implemented\n"); + imgConnfilter->Update( ); + result = imgConnfilter->GetOutput(); + } // ExtractionMode 1 if (bbGetInputExtractionMode()==2) // SeedRegions { + printf("EED ImageConnectivityFilter 1\n"); + imgConnfilter->SetExtractionModeToSeededRegions(); std::vector lstX = bbGetInputLstX(); std::vector lstY = bbGetInputLstY(); std::vector lstZ = bbGetInputLstZ(); - int size = lstX.size(); if ( (lstX.size()>0) && (lstX.size()==lstY.size()) && (lstX.size()==lstZ.size()) ) { - int i; + printf("EED ImageConnectivityFilter 2\n"); + int i,size = lstX.size(); double p[3]; vtkPoints *points = vtkPoints::New(); for (i=0; iInsertNextPoint(p); } // for i vtkPolyData *seedData = vtkPolyData::New(); @@ -70,63 +85,54 @@ void ImageConnectivityFilter::Process() // seedData->GetPointData()->SetScalars(seedScalars); seedData->GetPointData()->SetScalars(nullptr); - imgConnfilter->SetExtractionModeToSeededRegions(); imgConnfilter->SetSeedData( seedData ); // imgConnfilter->SetSizeRange(0, 99); + imgConnfilter->Update( ); + printf("EED ImageConnectivityFilter 3\n"); + result = imgConnfilter->GetOutput(); } // if lst - - } // ExtractionMode - - if (bbGetInputScalarRange().size()==2) - { - imgConnfilter->SetScalarRange( bbGetInputScalarRange()[0], bbGetInputScalarRange()[1] ); - } // Range - imgConnfilter->Update( ); - bbSetOutputOut( imgConnfilter->GetOutput() ); + } // ExtractionMode 2 + bbSetOutputOut( result ); } else { - printf("EED Warning!!!! ImageConnectivityFilter - Input image not defined.\n "); + printf("EED Warning!!!! ImageConnectivityFilter - Input image not defined.\n "); }// In } -//===== + +//===== // 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 ImageConnectivityFilter::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputIn(NULL); // bbSetInputScalarRange(); imgConnfilter=NULL; bbSetInputExtractionMode(0); - } -//===== + +//===== // 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 ImageConnectivityFilter::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// if any } -//===== + +//===== // 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 ImageConnectivityFilter::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } -} -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk -- 2.51.0