- std::string transferSyntaxName = e1->GetTransfertSyntaxName();
- std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
-
- if ( transferSyntaxName != "Implicit VR - Little Endian"
- && transferSyntaxName != "Explicit VR - Little Endian"
- && transferSyntaxName != "Deflated Explicit VR - Little Endian"
- && transferSyntaxName != "Explicit VR - Big Endian"
- && transferSyntaxName != "Uncompressed ACR-NEMA" )
- {
- std::cout << std::endl << "==========================================="
- << std::endl;
- f1->GetPixelConverter()->Print();
- std::cout << std::endl << "==========================================="
- << std::endl;
- }
-
- if(e1->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 e1;
+ GDCM_NAME_SPACE::SeqEntry *modLutSeq = f->GetSeqEntry(0x0028,0x3000);
+ if ( modLutSeq !=0 )
+ {
+ GDCM_NAME_SPACE::SQItem *sqi= modLutSeq->GetFirstSQItem();
+ if ( !sqi )
+ {
+ std::string lutDescriptor = sqi->GetEntryString(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 )
+ {
+ std::cout << "Wrong LUT descriptor" << std::endl;
+ }
+ GDCM_NAME_SPACE::DataEntry *b = sqi->GetDataEntry(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);
+ }
+
+ // Parsability of the GDCM_NAME_SPACE::Document already checked, after Load() !
+
+ if ( f->IsReadable() )
+ {
+ std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
+ }
+ else if ( f->GetSeqEntry(0x0041,0x1010) )
+ {
+ std::cout <<std::endl<<fileName<<" looks like a 'PAPYRUS image' file"
+ <<std::endl;
+ }
+ else if ( f->GetSeqEntry(0x0004,0x1220) )
+ {
+ std::cout <<std::endl<<fileName<<" looks like a 'DICOMDIR file'"
+ <<std::endl;
+ }
+ else
+ {
+ std::cout <<std::endl<<fileName<<" doesn't look like an image file "
+ <<std::endl;
+ }
+
+ std::cout<<std::flush;
+ f->Delete();
+ fh->Delete();
+ }
+ // ===========================================================================
+ else // =============================== Deal with a Directory =====================
+ { // ===========================================================================
+ std::cout << "dirName [" << dirName << "]" << std::endl;
+
+ GDCM_NAME_SPACE::DirList dirList(dirName,rec); // gets recursively (or not) the file list
+ GDCM_NAME_SPACE::DirListType fileList = dirList.GetFilenames();
+ GDCM_NAME_SPACE::File *f;
+ bool res;
+
+ if (fileList.size() == 0)
+ {
+ std::cout << "No file found in : [" << dirName << "]" << std::endl;
+ }
+
+ for( GDCM_NAME_SPACE::DirListType::iterator it = fileList.begin();
+ it != fileList.end();
+ ++it )
+ {
+ std::cout << std::endl<<" Start processing :[" << it->c_str() << "]"
+ << std::endl;
+ f = GDCM_NAME_SPACE::File::New();
+ 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;
+ f->Delete();
+ continue;
+ }
+
+ GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
+ fh->SetPrintLevel( level );
+ fh->Print();