- gdcm::FileHelper *fh = new gdcm::FileHelper(f);
- fh->SetPrintLevel( level );
-
- fh->Print();
-
- std::cout << "\n\n" << std::endl;
-
- std::cout <<std::endl;
- std::cout <<" dataSize " << fh->GetImageDataSize() << std::endl;
- std::cout <<" dataSizeRaw " << fh->GetImageDataRawSize() << std::endl;
-
- int nX,nY,nZ,sPP,planarConfig;
- std::string pixelType;
- nX=f->GetXSize();
- nY=f->GetYSize();
- nZ=f->GetZSize();
- std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
-
- pixelType = f->GetPixelType();
- sPP = f->GetSamplesPerPixel();
- planarConfig = f->GetPlanarConfiguration();
-
- std::cout << " pixelType= [" << pixelType
- << "] SamplesPerPixel= [" << sPP
- << "] PlanarConfiguration= [" << planarConfig
- << "] "<< std::endl
- << " PhotometricInterpretation= ["
+ if ( fileName != 0 ) // ====== Deal with a single file ======
+ {
+ // gdcm::File::IsReadable() is no usable here, because we deal with
+ // any kind of gdcm-Parsable *document*
+ // not only gdcm::File (as opposed to gdcm::DicomDir)
+
+ gdcm::File *f = new gdcm::File();
+ f->SetLoadMode(loadMode);
+ f->SetFileName( fileName );
+
+ for (int ri=0; ri<forceLoadNb; ri++)
+ {
+ f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri],
+ (uint32_t)elemsToForceLoad[2*ri+1] );
+ }
+
+ bool res = f->Load();
+ if ( !res )
+ {
+ std::cout << "Cannot process file [" << fileName << "]" << std::endl;
+ std::cout << "Either it doesn't exist, or it's read protected "
+ << std::endl;
+ std::cout << "or it's not a Dicom File, or its 'header' is bugged"
+ << std::endl;
+ std::cout << "use 'PrintFile filein=... debug' to try to guess the pb"
+ << std::endl;
+ delete f;
+ return 0;
+ }
+
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+ fh->SetPrintLevel( level );
+
+ fh->Print();
+
+ std::cout << "\n\n" << std::endl;
+
+ std::cout <<std::endl;
+ std::cout <<" dataSize " << fh->GetImageDataSize() << std::endl;
+ std::cout <<" dataSizeRaw " << fh->GetImageDataRawSize() << std::endl;
+
+ int nX,nY,nZ,sPP,planarConfig;
+ std::string pixelType;
+ nX=f->GetXSize();
+ nY=f->GetYSize();
+ nZ=f->GetZSize();
+ std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ
+ << std::endl;
+
+ pixelType = f->GetPixelType();
+ sPP = f->GetSamplesPerPixel();
+ planarConfig = f->GetPlanarConfiguration();
+
+ std::cout << " pixelType= [" << pixelType
+ << "] SamplesPerPixel= [" << sPP
+ << "] PlanarConfiguration= [" << planarConfig
+ << "] "<< std::endl
+ << " PhotometricInterpretation= ["