+ std::string transferSyntaxName = f->GetTransferSyntaxName();
+ std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]"
+ << std::endl;
+ std::cout << " SwapCode= " << f->GetSwapCode() << 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;
+
+ // Display the LUT as an int array (for debugging purpose)
+ if ( f->HasLUT() && showlut )
+ {
+ uint8_t* lutrgba = fh->GetLutRGBA();
+ if ( lutrgba == 0 )
+ {
+ std::cout << "Lut RGBA (Palette Color) not built " << std::endl;
+
+ // Nothing is written yet to get LUT Data user friendly
+ // The following is to be moved into a PixelRedaConvert method
+
+ gdcm::SeqEntry *modLutSeq = f->GetSeqEntry(0x0028,0x3000);
+ if ( modLutSeq !=0 )
+ {
+ gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem();
+ if ( !sqi )
+ {
+ std::string lutDescriptor = sqi->GetEntryValue(0x0028,0x3002);
+ int length; // LUT length in Bytes
+ int deb; // Subscript of the first Lut Value
+ int nbits; // Lut item size (in Bits)
+ int nbRead; // nb of items in LUT descriptor (must be = 3)
+
+ nbRead = sscanf( lutDescriptor.c_str(),
+ "%d\\%d\\%d",
+ &length, &deb, &nbits );
+ if ( nbRead != 3 )
+ {
+ //gdcmWarningMacro( "Wrong LUT descriptor" );
+ std::cout << "Wrong LUT descriptor" << std::endl;
+ }
+ gdcm::BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
+ if ( b != 0 )
+ {
+ if ( b->GetLength() != 0 )
+ {
+ std::cout << "---------------------------------------"
+ << " We should never reach this point "
+ << std::endl;
+ //LoadEntryBinArea(b); //LUT Data (CTX dependent)
+ }
+ }
+ }
+ }
+ else
+ std::cout << "No LUT Data (0x0028,0x3000) found " << std::endl;
+ }
+ else
+ {
+ if ( fh->GetLutItemSize() == 8 )
+ {
+ for (int i=0;i<fh->GetLutItemNumber();i++)
+ std::cout << i << " : \t"
+ << (int)(lutrgba[i*4]) << " "
+ << (int)(lutrgba[i*4+1]) << " "
+ << (int)(lutrgba[i*4+2]) << std::endl;
+ }
+ else // LutItemSize assumed to be = 16
+ {
+ uint16_t* lutrgba16 = (uint16_t*)lutrgba;
+ for (int i=0;i<fh->GetLutItemNumber();i++)
+ std::cout << i << " : \t"
+ << (int)(lutrgba16[i*4]) << " "
+ << (int)(lutrgba16[i*4+1]) << " "
+ << (int)(lutrgba16[i*4+2]) << std::endl;
+ }
+ }
+ }
+ else if (showlut)
+ {
+ std::cout << "Try LUT Data "<< std::endl;
+ ShowLutData(f);
+ }
+
+ if (f->IsReadable())
+ std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
+ else
+ std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
+ std::cout<<std::flush;
+ delete f;
+ delete fh;
+ return 0;
+ }
+ else // ====== Deal with a Directory ======
+ {
+ std::cout << "dirName [" << dirName << "]" << std::endl;
+ gdcm::DirList dirList(dirName,1); // gets recursively the file list
+ gdcm::DirListType fileList = dirList.GetFilenames();
+ gdcm::File *f;
+ bool res;
+ for( gdcm::DirListType::iterator it = fileList.begin();
+ it != fileList.end();
+ ++it )
+ {
+ f = new gdcm::File();
+ f->SetLoadMode(loadMode);
+ f->SetFileName( it->c_str() );
+
+ for (int ri=0; ri<forceLoadNb; ri++)
+ {
+ printf("%04x,%04x\n",elemsToForceLoad[2*ri], elemsToForceLoad[2*ri+1]);
+ f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri],
+ (uint32_t)elemsToForceLoad[2*ri+1]);
+ }
+ res = f->Load();
+
+ if ( !res )
+ {
+ std::cout << "Cannot process file [" << it->c_str() << "]"
+ << 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;
+ continue;
+ }
+
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+ fh->SetPrintLevel( level );
+
+ fh->Print();
+
+ if (f->IsReadable())
+ std::cout <<std::endl<<it->c_str()<<" is Readable"<<std::endl;
+ else
+ std::cout <<std::endl<<it->c_str()<<" is NOT Readable"<<std::endl;
+ std::cout << "\n\n" << std::endl;
+ delete f;
+ delete fh;
+ }
+ std::cout<<std::flush;
+ }