]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkImageConnectivityFilter.cxx
#3498 Connectivity Filter Threshold
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkImageConnectivityFilter.cxx
index 2f5c9e96745aa9fc6330f817bd3fa3b5d56ab20a..d9c051c9b297b9d94a06254097c35188d1355b7c 100644 (file)
@@ -4,6 +4,10 @@
 #include "bbcreaVtkImageConnectivityFilter.h"
 #include "bbcreaVtkPackage.h"
 
+#include <vtkPolyData.h>
+#include <vtkPoints.h>
+#include <vtkPointData.h>
+
 namespace bbcreaVtk
 {
 
@@ -26,12 +30,12 @@ void ImageConnectivityFilter::Process()
 //      (the one provided in the attribute 'name' of the tag 'input')
 //    * TYPE is the C++ type of the input/output
 //      (the one provided in the attribute 'type' of the tag 'input')
-
-
-       if (bbGetInputIn()!=NULL){
+    
+       if (bbGetInputIn()!=NULL)
+    {
                if (imgConnfilter) {imgConnfilter->Delete();}
                imgConnfilter=vtkImageConnectivityFilter::New();
-               imgConnfilter->SetInputData( bbGetInputIn() );
+        imgConnfilter->SetInputData( bbGetInputIn() );
                if (bbGetInputExtractionMode()==0)  // LargestRegion
                {
                        imgConnfilter->SetExtractionModeToLargestRegion();
@@ -41,21 +45,47 @@ void ImageConnectivityFilter::Process()
                {
                        printf("EED Warning!!!! ImageConnectivityFilter - AllRegions Not Implemented\n ");
                } // ExtractionMode
-               if (bbGetInputExtractionMode()==2)  // SeededRegions
+               if (bbGetInputExtractionMode()==2)  // SeedRegions
                {
-                       printf("EED Warning!!!! ImageConnectivityFilter  - SeededRegions Not Implemented\n ");
+            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;
+                double p[3];
+                vtkPoints *points = vtkPoints::New();
+                for (i=0; i<size; i++)
+                {
+                    p[0] = lstX[i];
+                    p[1] = lstY[i];
+                    p[2] = lstZ[i];
+                    points->InsertNextPoint(p);
+                } // for i
+                vtkPolyData *seedData =  vtkPolyData::New();
+                seedData->SetPoints( points );
+//              vtkUnsignedCharArray  *seedScalars = vtkUnsignedCharArray::New();
+//              seedScalars->InsertNextValue(100);
+//              seedData->GetPointData()->SetScalars(seedScalars);
+                seedData->GetPointData()->SetScalars(nullptr);
+                
+                imgConnfilter->SetExtractionModeToSeededRegions();
+                imgConnfilter->SetSeedData( seedData );
+//              imgConnfilter->SetSizeRange(0, 99);
+            } // if lst
+
                } // ExtractionMode
 
                if (bbGetInputScalarRange().size()==2)  
                {
                        imgConnfilter->SetScalarRange( bbGetInputScalarRange()[0], bbGetInputScalarRange()[1] );
                } // Range
-               imgConnfilter->Update();
+               imgConnfilter->Update( );
                bbSetOutputOut( imgConnfilter->GetOutput() );
        } else {
                        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)