+
+ 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= ["
+ << f->GetEntryValue(0x0028,0x0004)
+ << "] "<< std::endl;
+
+ int numberOfScalarComponents=f->GetNumberOfScalarComponents();
+ std::cout << " NumberOfScalarComponents = " << numberOfScalarComponents
+ <<std::endl
+ << " LUT = " << (f->HasLUT() ? "TRUE" : "FALSE")
+ << std::endl;
+
+ if ( f->GetEntryValue(0x0002,0x0010) == gdcm::GDCM_NOTLOADED )
+ {
+ std::cout << "Transfer Syntax not loaded. " << std::endl
+ << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
+ << std::endl;
+ return 0;
+ }
+
+ std::string transferSyntaxName = f->GetTransferSyntaxName();
+ std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]"
+ << std::endl;
+ std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
+ std::cout << " ------" << std::endl;
+ //std::cout << "\n\n" << std::endl;
+ //std::cout << "X spacing " << f->GetXSpacing() << std::endl;
+ //std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
+ //std::cout << "Z spacing " << f->GetZSpacing() << std::endl;
+
+ // Lets's get and print some usefull fields about 'Orientation'
+ // ------------------------------------------------------------
+
+ std::string strPatientPosition =
+ f->GetEntryValue(0x0018,0x5100);
+ if ( strPatientPosition != gdcm::GDCM_UNFOUND
+ && strPatientPosition != "" )
+ std::cout << "PatientPosition (0x0010,0x5100)= ["
+ << strPatientPosition << "]" << std::endl;
+
+ std::string strPatientOrientation =
+ f->GetEntryValue(0x0020,0x0020);
+ if ( strPatientOrientation != gdcm::GDCM_UNFOUND
+ && strPatientOrientation != "")
+ std::cout << "PatientOrientation (0x0020,0x0020)= ["
+ << strPatientOrientation << "]" << std::endl;
+
+ std::string strImageOrientationPatient =
+ f->GetEntryValue(0x0020,0x0037);
+ if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND
+ && strImageOrientationPatient != "" )
+ std::cout << "ImageOrientationPatient (0x0020,0x0037)= ["
+ << strImageOrientationPatient << "]" << std::endl;
+
+ std::string strImageOrientationRET =
+ f->GetEntryValue(0x0020,0x0035);
+ if ( strImageOrientationRET != gdcm::GDCM_UNFOUND
+ && strImageOrientationRET != "" )
+ std::cout << "ImageOrientationRET (0x0020,0x0035)= ["
+ << strImageOrientationRET << "]" << std::endl;
+
+ // Let's compute 'user friendly' results about 'Orientation'
+ // ---------------------------------------------------------
+
+ gdcm::Orientation o;
+
+ if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND ||
+ strImageOrientationRET != gdcm::GDCM_UNFOUND )
+ {