+ if (nbP != 1)
+ {
+ std::cout << "4DLoc must have 2 and only 2 components!" << std::endl;
+ delete am;
+ return 1;
+ }
+ }
+
+ bool showlut = ( 0 != am->ArgMgrDefined("SHOWLUT") );
+
+ bool ddict = am->ArgMgrDefined("dict") ? true : false;
+ const char *dict = 0;
+
+ if (ddict)
+ {
+ dict = am->ArgMgrGetString("dict",0);
+ }
+
+ /* if unused Param we give up */
+ if ( am->ArgMgrPrintUnusedLabels() )
+ {
+ am->ArgMgrUsage(usage);
+ delete am;
+ return 1;
+ }
+
+ delete am; // we don't need Argument Manager any longer
+
+ // ----------- End Arguments Manager ---------
+
+
+ if (ddict)
+ {
+ GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->AddDict(dict);
+ }
+
+ if ( fileName != 0 ) // ====== Deal with a single file ======
+ {
+ GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
+ 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] );
+ }
+// TODO : find why such a polution
+// To avoid polluting the output with messages
+// 'Last system error was : No such file or directory'
+
+errno = 0;
+
+
+ bool res = f->Load();
+ // GDCM_NAME_SPACE::File::IsReadable() is no usable here, because we deal with
+ // any kind of gdcm-Parsable *document*
+ // not only GDCM_NAME_SPACE::File (as opposed to GDCM_NAME_SPACE::DicomDir)
+ 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;
+ f->Delete();
+ return 0;
+ }
+ if (nbP == 1)
+ f->SetFourthDimensionLocation(FourthDimLoc[0],FourthDimLoc[1]);
+
+ GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(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;
+if (!noex)
+{
+ int nX,nY,nZ,nT,sPP,planarConfig;
+ std::string pixelType;
+ nX=f->GetXSize();
+ nY=f->GetYSize();
+ nZ=f->GetZSize();
+ nT=f->GetTSize();
+ std::cout << " DIMX=" << nX << " DIMY=" << nY
+ << " DIMZ=" << nZ << " DIMT=" << nT
+ << std::endl;
+
+ pixelType = f->GetPixelType();
+ sPP = f->GetSamplesPerPixel();
+ std::cout << " pixelType= [" << pixelType
+ << "] SamplesPerPixel= [" << sPP
+ << "] ";
+
+ if (sPP == 3)
+ {
+ planarConfig = f->GetPlanarConfiguration();
+ std::cout << " PlanarConfiguration= [" << planarConfig
+ << "] "<< std::endl;
+ }
+ std::cout << " PhotometricInterpretation= ["
+ << f->GetEntryString(0x0028,0x0004)
+ << "] "<< std::endl;
+
+ int numberOfScalarComponents=f->GetNumberOfScalarComponents();
+ std::cout << " NumberOfScalarComponents = " << numberOfScalarComponents
+ <<std::endl
+ << " LUT = " << (f->HasLUT() ? "TRUE" : "FALSE")
+ << std::endl;
+
+ if ( f->GetDataEntry(0x0002,0x0010) )
+ if ( f->GetDataEntry(0x0002,0x0010)->IsNotLoaded() )
+ {
+ std::cout << "Transfer Syntax not loaded. " << std::endl
+ << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
+ << std::endl;
+ f->Delete();
+ 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;
+
+//------------------------------
+
+ // Let's get and print some usefull fields about 'Orientation'
+ // ------------------------------------------------------------
+
+ std::string strPatientPosition =
+ f->GetEntryString(0x0018,0x5100);
+ if ( strPatientPosition != GDCM_NAME_SPACE::GDCM_UNFOUND
+ && strPatientPosition != "" )
+ std::cout << "PatientPosition (0x0010,0x5100)= ["
+ << strPatientPosition << "]" << std::endl;
+
+ std::string strViewPosition =
+ f->GetEntryString(0x0018,0x5101);
+ if ( strViewPosition != GDCM_NAME_SPACE::GDCM_UNFOUND
+ && strViewPosition != "" )
+ std::cout << "View Position (0x0018,0x5101)= ["
+ << strViewPosition << "]" << std::endl;
+
+ std::string strPatientOrientation =
+ f->GetEntryString(0x0020,0x0020);
+ if ( strPatientOrientation != GDCM_NAME_SPACE::GDCM_UNFOUND
+ && strPatientOrientation != "")
+ std::cout << "PatientOrientation (0x0020,0x0020)= ["
+ << strPatientOrientation << "]" << std::endl;