+// Special case:
+// ts["1.2.840.10008.5.1.4.1.1.4.1"] = "Enhanced MR Image Storage";
+bool File::GetSpacing(float &xspacing, float &yspacing, float &zspacing)
+{
+ xspacing = yspacing = zspacing = 1.0;
+ TS *ts = Global::GetTS();
+ std::string sopclassuid_used;
+ // D 0002|0002 [UI] [Media Storage SOP Class UID]
+
+ //const std::string &mediastoragesopclassuid_str = GetEntryValue(0x0002,0x0002);
+ const std::string &mediastoragesopclassuid_str = GetEntryString(0x0002,0x0002);
+ const std::string &mediastoragesopclassuid = ts->GetValue(mediastoragesopclassuid_str);
+ //D 0008|0016 [UI] [SOP Class UID]
+ const std::string &sopclassuid_str = GetEntryString(0x0008,0x0016);
+ const std::string &sopclassuid = ts->GetValue(sopclassuid_str);
+ if ( mediastoragesopclassuid == GDCM_UNFOUND && sopclassuid == GDCM_UNFOUND )
+ {
+ return false;
+ }
+ else
+ {
+ if( mediastoragesopclassuid == sopclassuid )
+ {
+ sopclassuid_used = mediastoragesopclassuid;
+ }
+ else
+ {
+ gdcmWarningMacro( "Inconsistant SOP Class UID: "
+ << mediastoragesopclassuid << " and " << sopclassuid );
+ return false;
+ }
+ }
+ // ok we have now the correc SOP Class UID
+ if( sopclassuid_used == "Enhanced MR Image Storage" )
+ {
+ SeqEntry *PerframeFunctionalGroupsSequence = GetSeqEntry(0x5200,0x9230);
+ unsigned int n = PerframeFunctionalGroupsSequence->GetNumberOfSQItems();
+ if( !n ) return false;
+ SQItem *item1 = PerframeFunctionalGroupsSequence->GetFirstSQItem();
+ DocEntry *p = item1->GetDocEntry(0x0028,0x9110);
+ if( !p ) return false;
+ SeqEntry *seq = dynamic_cast<SeqEntry*>(p);
+ unsigned int n1 = seq->GetNumberOfSQItems();
+ if( !n1 ) return false;
+ SQItem *item2 = seq->GetFirstSQItem();
+ // D 0028|0030 [DS] [Pixel Spacing] [0.83333331346511\0.83333331346511 ]
+ DocEntry *p2 = item2->GetDocEntry(0x0028,0x0030);
+ if( !p2 ) return false;
+ DataEntry *entry = dynamic_cast<DataEntry *>(p2);
+ std::string spacing = entry->GetString();
+ if ( sscanf( spacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2 )
+ {
+ xspacing = yspacing = 1.;
+ return false;
+ }
+ // D 0018|0050 [DS] [Slice Thickness] [1 ]
+ DocEntry *p3 = item2->GetDocEntry(0x0018,0x0050);
+ if( !p3 ) return false;
+ DataEntry *entry2 = dynamic_cast<DataEntry *>(p3);
+ std::string thickness = entry2->GetString();
+ if ( sscanf( thickness.c_str(), "%f", &zspacing) != 1 )
+ {
+ zspacing = 1.;
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+