]> Creatis software - creaVtk.git/commitdiff
#3535 Bug bbcreaVtkImageConnectivityFilter vtk9itk5wx3-macos
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 3 Oct 2025 11:42:25 +0000 (13:42 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 3 Oct 2025 11:42:25 +0000 (13:42 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkImageConnectivityFilter.cxx

index d9c051c9b297b9d94a06254097c35188d1355b7c..c633b6fd89d60d320fb6102c8907e6f32e8a769d 100644 (file)
@@ -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<double> lstX = bbGetInputLstX();
             std::vector<double> lstY = bbGetInputLstY();
             std::vector<double> 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; i<size; i++)
@@ -61,6 +75,7 @@ void ImageConnectivityFilter::Process()
                     p[0] = lstX[i];
                     p[1] = lstY[i];
                     p[2] = lstZ[i];
+                    printf("EED ImageConnectivityFilter 3   %f  %f  %f\n", p[0], p[1], p[2] );
                     points->InsertNextPoint(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