- vtkImageData *imagedata = bbGetInputIn();
- imagedata->UpdateInformation();
- imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
- imagedata->Update();
- thresh2->ThresholdBetween(3000, 3001);
- thresh2->SetInput(imagedata);
- thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
- thresh2->Update();
- cast2->Update();
- connect2->RemoveAllSeeds ();
- connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
- connect2->Update();
- cast4->Update();
-
- bbSetOutputOut(cast4->GetOutput() );
- }
-
+
+ int x,y,z;
+ int i,numPoints = bbGetInputPositionXYZ().size()/3;
+ int verif = (bbGetInputPositionXYZ().size()-1) % 3;
+ if (( numPoints>=1) && (verif==2) && (bbGetInputIn()!=NULL))
+ {
+ int outputformat = bbtkStaticLecture::GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() );
+ vtkImageData *imagedata = bbGetInputIn();
+ imagedata->UpdateInformation();
+ imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
+ imagedata->Update();
+ thresh2->ThresholdBetween(3000, 3001);
+ thresh2->SetInput(imagedata);
+ thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
+ thresh2->Modified();
+ thresh2->Update();
+ connect2->RemoveAllSeeds ();
+
+ int ext[6];
+ imagedata->GetWholeExtent(ext);
+ int maxX = ext[1]-ext[0]+1;
+ int maxY = ext[3]-ext[2]+1;
+ int maxZ = ext[5]-ext[4]+1;
+
+ for (i=0;i<numPoints;i++)
+ {
+ x=bbGetInputPositionXYZ()[i*3+0];
+ y=bbGetInputPositionXYZ()[i*3+1];
+ z=bbGetInputPositionXYZ()[i*3+2];
+ if ( (x>=0) || (x<maxX) || (y>=0) || (y<maxY) || (z>=0) || (z<maxZ) )
+ {
+ connect2->AddSeed( x,y,z );
+ } else {
+ printf("EED WARNNIG! In box: SegmentationConnectivity point out of range \n");
+ } // if point inside image
+
+ } // for i
+ connect2->SetOutputConnectedValue( bbGetInputValue() );
+ cast4->SetOutputScalarType( outputformat );
+ connect2->Modified();
+ connect2->Update();
+ cast4->Update();
+ bbSetOutputOut(cast4->GetOutput() );
+ } else {
+ printf("EED WARNNIG! In box: SegmentationConnectivity List of points are not coherent. \n");
+ bbSetOutputOut( NULL );
+ }// if numPoints verif
+
+}