//===== // 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) //===== #include "bbcreaVtkImageConnectivityFilter.h" #include "bbcreaVtkPackage.h" #include #include #include namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageConnectivityFilter) BBTK_BLACK_BOX_IMPLEMENTATION(ImageConnectivityFilter,bbtk::AtomicBlackBox); //===== // 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::Process() { // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value // INPUT/OUTPUT ACCESSORS ARE OF THE FORM : // void bbSet{Input|Output}NAME(const TYPE&) // const TYPE& bbGet{Input|Output}NAME() const // Where : // * NAME is the name of the input/output // (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 (imgConnfilter) {imgConnfilter->Delete();} imgConnfilter=vtkImageConnectivityFilter::New(); imgConnfilter->SetInputData( bbGetInputIn() ); if (bbGetInputExtractionMode()==0) // LargestRegion { imgConnfilter->SetExtractionModeToLargestRegion(); } // ExtractionMode if (bbGetInputExtractionMode()==1) // AllRegions { printf("EED Warning!!!! ImageConnectivityFilter - AllRegions Not Implemented\n "); } // ExtractionMode if (bbGetInputExtractionMode()==2) // SeedRegions { 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; double p[3]; vtkPoints *points = vtkPoints::New(); for (i=0; iInsertNextPoint(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( ); 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) //===== 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 } //===== // 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