+ 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 )
+ {
+
+ gdcm::OrientationType orient = o.GetOrientationType( f );
+
+ std::cout << "TypeOrientation = " << orient << " (-> "
+ << o.GetOrientationTypeString(orient) << " )" << std::endl;
+ }
+
+ std::string ori = o.GetOrientation ( f );
+ if (ori != "\\" )
+ std::cout << "Orientation [" << ori << "]" << 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->gdcm::Document::IsReadable())
+ // Try downcast to please MSVC
+ if ( !((gdcm::Document *)f)->IsReadable() )
+ {
+ std::cout <<std::endl<<fileName<<" is NOT 'gdcm parsable'"<<std::endl;
+ }
+
+ 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;
+ delete f;
+ delete fh;