]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkSegmentationConnectivity.cxx
.
[bbtk.git] / packages / vtk / src / bbvtkSegmentationConnectivity.cxx
index 550110a21d785b69f9feaa51009b63d87195f0e0..5c33b54c367cfa1aaee0174ac790dd2bc3835348 100644 (file)
@@ -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<int> position;
-    position.push_back(0);
-    position.push_back(0);
-    position.push_back(0);
-    bbSetInputPositionXYZ(position);
-    std::vector<int> 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<int> position;
+         position.push_back(0);
+         position.push_back(0);
+         position.push_back(0);
+         bbSetInputPositionXYZ(position);
+         std::vector<int> 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();