-
- _thresh = vtkImageThreshold::New();
- _thresh->SetInput(_imagedata);
- //_thresh->ReleaseDataFlagOff();
- _thresh->SetInValue(255);
- _thresh->SetOutputScalarTypeToUnsignedShort();
- _thresh->SetOutValue(0);
- //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
- //SIL//
- _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());
-
- vtkImageCast *cast = vtkImageCast::New();
- cast->SetInput(_thresh->GetOutput());
- cast->SetOutputScalarTypeToUnsignedChar();
- cast->Update();
-
-
- _connect = vtkImageSeedConnectivity::New();
- _connect->SetInput(cast->GetOutput());
- _connect->SetInputConnectValue(255);
- _connect->SetOutputConnectedValue(255);
- _connect->SetOutputUnconnectedValue(0);
+
+ if(_thresh==NULL){
+ _thresh = vtkImageThreshold::New();
+ //_thresh->ReleaseDataFlagOff();
+ _thresh->SetInValue(255);
+ _thresh->SetOutputScalarTypeToUnsignedShort();
+ _thresh->SetOutValue(0);
+ //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
+ //SIL//
+ _cast = vtkImageCast::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ _cast->SetInput(_thresh->GetOutput());
+#else
+ _cast->SetInputData(_thresh->GetOutput());
+#endif
+
+ _cast->SetOutputScalarTypeToUnsignedChar();
+
+ _connect = vtkImageSeedConnectivity::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ _connect->SetInput(_cast->GetOutput());
+#else
+ _connect->SetInputData(_cast->GetOutput());
+#endif
+ _connect->SetInputConnectValue(255);
+ _connect->SetOutputConnectedValue(255);
+ _connect->SetOutputUnconnectedValue(0);
+
+ cast3 = vtkImageCast::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ cast3->SetInput(_connect->GetOutput());
+#else
+ cast3->SetInputData(_connect->GetOutput());
+#endif
+ cast3->SetOutputScalarTypeToUnsignedShort();
+
+ _thresh2 = vtkImageThreshold::New();
+ //_thresh2->ReleaseDataFlagOff();
+ _thresh2->SetInValue(255);
+ _thresh2->SetOutputScalarTypeToUnsignedShort();
+ _thresh2->SetOutValue(0);
+ //SIL//_thresh2->ThresholdBetween(_sl_minSize->GetValue(), _sl_maxSize->GetValue());
+
+ cast2 = vtkImageCast::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ cast2->SetInput(_thresh2->GetOutput());
+#else
+ cast2->SetInputData(_thresh2->GetOutput());
+#endif
+ cast2->SetOutputScalarTypeToUnsignedChar();
+ _connect2 = vtkImageSeedConnectivity::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ _connect2->SetInput(cast2->GetOutput());
+#else
+ _connect2->SetInputData(cast2->GetOutput());
+#endif
+ _connect2->SetInputConnectValue(255);
+ _connect2->SetOutputConnectedValue(255);
+ _connect2->SetOutputUnconnectedValue(0);
+
+ cast4 = vtkImageCast::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ cast4->SetInput(_connect2->GetOutput());
+#else
+ cast4->SetInputData(_connect2->GetOutput());
+#endif
+ cast4->SetOutputScalarTypeToUnsignedShort();
+ }
+ _thresh->RemoveAllInputs();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ _thresh->SetInput(_imagedata);
+#else
+ _thresh->SetInputData(_imagedata);
+#endif
+ _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());
+ _thresh->Update();
+
+ _cast->Update();
+
+
+ _connect->RemoveAllSeeds();