BBTK_ADD_BLACK_BOX_TO_PACKAGE(gdcmvtk,GetXCoherentInfoGdcmReader)
BBTK_BLACK_BOX_IMPLEMENTATION(GetXCoherentInfoGdcmReader,bbtk::AtomicBlackBox);
+
+
+vtkImageData* GetXCoherentInfoGdcmReader::CreateDefaultImage()
+{
+ int i;
+ int sizeX, sizeY, sizeZ;
+ sizeX = 200;
+ sizeY = sizeX;
+ sizeZ = 1;
+ vtkImageData *newImage = vtkImageData::New();
+ newImage->Initialize();
+ newImage->SetSpacing( 1,1,1 );
+ newImage->SetDimensions( sizeX,sizeY,sizeZ );
+ newImage->SetExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ newImage->SetWholeExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 );
+ newImage->SetScalarTypeToUnsignedChar();
+ newImage->SetNumberOfScalarComponents(1);
+ newImage->AllocateScalars();
+ newImage->Update();
+#else
+ newImage->AllocateScalars(VTK_UNSIGNED_CHAR,1);
+#endif
+
+ memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*1 );
+ for (i=0; i<sizeX; i++)
+ {
+ newImage->SetScalarComponentFromDouble(i,i,0, 0, 255 );
+ newImage->SetScalarComponentFromDouble(i,sizeY-1-i,0, 0, 255 );
+ } // for i
+ return newImage;
+}
+
+
#if defined USE_GDCM
void GetXCoherentInfoGdcmReader::Process()
{
+
// Read the *first* image file (a SET of file names is given as input)
f = GDCM_NAME_SPACE::File::New();
- f->SetFileName( bbGetInputIn()[0] );
+
+ if ( bbGetInputIn().size()!=0 )
+ {
+ f->SetFileName( bbGetInputIn()[0] );
+ } else {
+ f->SetFileName( "" );
+ }
+
bool res = f->Load();
if ( !res )
{
- f->Delete();
- bbSetOutputOut(0);
- return;
+ printf("EED GetXCoherentInfoGdcmReader::Process resultImage NULL\n");
+ f->Delete();
+ bbSetOutputOut( CreateDefaultImage() );
+ return;
}
// Get info from the first image file
int i;
sh->AddFileName(*it);
}
+
GDCM_NAME_SPACE::FileList::const_iterator it;
GDCM_NAME_SPACE::FileList *l;
//reader->SetFileName( bbGetInputIn().c_str() );
reader->SetCoherentFileList(l);
reader->Update();
- reader->GetOutput();
-
bbSetOutputOut( reader->GetOutput() );
}
#endif
if ( !res )
{
delete read;
- printf("EED GetXCoherentInfoGdcmReader::Process resultImage NULL\n");
bbSetOutputOut(NULL);
return;
}