X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkSegmentationConnectivity.cxx;h=5c33b54c367cfa1aaee0174ac790dd2bc3835348;hb=01fb8df604fbbe40e30ffd608ad40bca4433f32b;hp=550110a21d785b69f9feaa51009b63d87195f0e0;hpb=6575a389b71b1b85c79e4444885becb76ecf16e4;p=bbtk.git diff --git a/packages/vtk/src/bbvtkSegmentationConnectivity.cxx b/packages/vtk/src/bbvtkSegmentationConnectivity.cxx index 550110a..5c33b54 100644 --- a/packages/vtk/src/bbvtkSegmentationConnectivity.cxx +++ b/packages/vtk/src/bbvtkSegmentationConnectivity.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbvtkSegmentationConnectivity.cxx,v $ Language: C++ - Date: $Date: 2008/10/17 08:18:30 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009/05/15 14:58:01 $ + Version: $Revision: 1.5 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -48,45 +48,74 @@ namespace bbvtk bbtk::AtomicBlackBox); - void SegmentationConnectivity::bbUserConstructor() + // -------------------------------------------------------------- + void SegmentationConnectivity::bbUserSetDefaultValues() { - bbSetInputIn(NULL); - std::vector position; - position.push_back(0); - position.push_back(0); - position.push_back(0); - bbSetInputPositionXYZ(position); - std::vector threshold; - threshold.push_back(0); - threshold.push_back(0); - bbSetInputThresholdMinMax(threshold); - bbSetOutputOut(NULL); - thresh2 = vtkImageThreshold::New(); - thresh2->SetInValue(255); - thresh2->SetOutputScalarTypeToUnsignedShort(); - thresh2->SetOutValue(0); - cast2 = vtkImageCast::New(); - cast2->SetInput(thresh2->GetOutput()); - cast2->SetOutputScalarTypeToUnsignedChar(); - connect2 = vtkImageSeedConnectivity::New(); - connect2->SetInput(cast2->GetOutput()); - connect2->SetInputConnectValue(255); - connect2->SetOutputConnectedValue(255); - connect2->SetOutputUnconnectedValue(0); - cast4 = vtkImageCast::New(); - cast4->SetInput(connect2->GetOutput()); - cast4->SetOutputScalarTypeToUnsignedShort(); + thresh2 = NULL; + cast2 = NULL; + connect2 = NULL; + cast4 = NULL; + + bbSetInputIn(NULL); + std::vector position; + position.push_back(0); + position.push_back(0); + position.push_back(0); + bbSetInputPositionXYZ(position); + std::vector threshold; + threshold.push_back(0); + threshold.push_back(0); + bbSetInputThresholdMinMax(threshold); + bbSetOutputOut(NULL); } - - - void SegmentationConnectivity::bbUserDestructor() + + // -------------------------------------------------------------- + void SegmentationConnectivity::bbUserInitializeProcessing() + { + thresh2 = vtkImageThreshold::New(); + thresh2->SetInValue(255); + thresh2->SetOutputScalarTypeToUnsignedShort(); + thresh2->SetOutValue(0); + cast2 = vtkImageCast::New(); + cast2->SetInput(thresh2->GetOutput()); + cast2->SetOutputScalarTypeToUnsignedChar(); + connect2 = vtkImageSeedConnectivity::New(); + connect2->SetInput(cast2->GetOutput()); + connect2->SetInputConnectValue(255); + connect2->SetOutputConnectedValue(255); + connect2->SetOutputUnconnectedValue(0); + cast4 = vtkImageCast::New(); + cast4->SetInput(connect2->GetOutput()); + cast4->SetOutputScalarTypeToUnsignedShort(); + } + + // -------------------------------------------------------------- + void SegmentationConnectivity::bbUserFinalizeProcessing() { - thresh2->Delete(); - cast2->Delete(); - connect2->Delete(); - cast4->Delete(); + if (thresh2!=NULL) + { + thresh2->Delete(); + thresh2=NULL; + } + if (cast2!=NULL) + { + cast2->Delete(); + cast2=NULL; + } + if (connect2!=NULL) + { + connect2->Delete(); + connect2=NULL; + } + if (cast4!=NULL) + { + cast4->Delete(); + cast4=NULL; + } + } + // -------------------------------------------------------------- void SegmentationConnectivity::DoProcess() { vtkImageData *imagedata = bbGetInputIn();