2 // 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)
4 #include "bbcreaVtkImageConnectivityFilter.h"
5 #include "bbcreaVtkPackage.h"
7 #include <vtkPolyData.h>
9 #include <vtkPointData.h>
14 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageConnectivityFilter)
15 BBTK_BLACK_BOX_IMPLEMENTATION(ImageConnectivityFilter,bbtk::AtomicBlackBox);
17 // 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)
19 void ImageConnectivityFilter::Process()
22 // THE MAIN PROCESSING METHOD BODY
23 // Here we simply set the input 'In' value to the output 'Out'
24 // And print out the output value
25 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
26 // void bbSet{Input|Output}NAME(const TYPE&)
27 // const TYPE& bbGet{Input|Output}NAME() const
29 // * NAME is the name of the input/output
30 // (the one provided in the attribute 'name' of the tag 'input')
31 // * TYPE is the C++ type of the input/output
32 // (the one provided in the attribute 'type' of the tag 'input')
34 if (bbGetInputIn()!=NULL)
36 if (imgConnfilter) {imgConnfilter->Delete();}
37 imgConnfilter=vtkImageConnectivityFilter::New();
38 imgConnfilter->SetInputData( bbGetInputIn() );
39 if (bbGetInputExtractionMode()==0) // LargestRegion
41 imgConnfilter->SetExtractionModeToLargestRegion();
44 if (bbGetInputExtractionMode()==1) // AllRegions
46 printf("EED Warning!!!! ImageConnectivityFilter - AllRegions Not Implemented\n ");
48 if (bbGetInputExtractionMode()==2) // SeedRegions
50 std::vector<double> lstX = bbGetInputLstX();
51 std::vector<double> lstY = bbGetInputLstY();
52 std::vector<double> lstZ = bbGetInputLstZ();
53 int size = lstX.size();
54 if ( (lstX.size()>0) && (lstX.size()==lstY.size()) && (lstX.size()==lstZ.size()) )
58 vtkPoints *points = vtkPoints::New();
59 for (i=0; i<size; i++)
64 points->InsertNextPoint(p);
66 vtkPolyData *seedData = vtkPolyData::New();
67 seedData->SetPoints( points );
68 // vtkUnsignedCharArray *seedScalars = vtkUnsignedCharArray::New();
69 // seedScalars->InsertNextValue(100);
70 // seedData->GetPointData()->SetScalars(seedScalars);
71 seedData->GetPointData()->SetScalars(nullptr);
73 imgConnfilter->SetExtractionModeToSeededRegions();
74 imgConnfilter->SetSeedData( seedData );
75 // imgConnfilter->SetSizeRange(0, 99);
80 if (bbGetInputScalarRange().size()==2)
82 imgConnfilter->SetScalarRange( bbGetInputScalarRange()[0], bbGetInputScalarRange()[1] );
84 imgConnfilter->Update( );
85 bbSetOutputOut( imgConnfilter->GetOutput() );
87 printf("EED Warning!!!! ImageConnectivityFilter - Input image not defined.\n ");
91 // 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)
93 void ImageConnectivityFilter::bbUserSetDefaultValues()
96 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
97 // Here we initialize the input 'In' to 0
99 // bbSetInputScalarRange();
101 bbSetInputExtractionMode(0);
105 // 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)
107 void ImageConnectivityFilter::bbUserInitializeProcessing()
110 // THE INITIALIZATION METHOD BODY :
112 // but this is where you should allocate the internal/output pointers
118 // 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)
120 void ImageConnectivityFilter::bbUserFinalizeProcessing()
123 // THE FINALIZATION METHOD BODY :
125 // but this is where you should desallocate the internal/output pointers
130 // EO namespace bbcreaVtk