+ DataEntry *entry = GetDataEntry(0x0020,0x0032);
+ if( entry )
+ {
+ if( entry->GetValueCount() == 3 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)");
+ return 0.0f;
+ }
+/* float xImPos, yImPos, zImPos;
+ std::string strImPos = GetEntryString(0x0020,0x0032);
+
+ if ( strImPos != GDCM_UNFOUND )
+ {
+ if ( sscanf( strImPos.c_str(), "%f \\%f \\%f ", &xImPos, &yImPos, &zImPos) != 3)
+ {
+ gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)");
+ return 0.; // bug in the element 0x0020,0x0032
+ }
+ else
+ {
+ return zImPos;
+ }
+ }*/
+
+ entry = GetDataEntry(0x0020,0x0030);
+ if( entry )
+ {
+ if( entry->GetValueCount() == 3 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)");
+ return 0.0f;
+ }
+/* strImPos = GetEntryString(0x0020,0x0030); // For ACR-NEMA images
+ if ( strImPos != GDCM_UNFOUND )
+ {
+ if ( sscanf( strImPos.c_str(),
+ "%f \\%f \\%f ", &xImPos, &yImPos, &zImPos ) != 3 )
+ {
+ gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)");
+ return 0.; // bug in the element 0x0020,0x0032
+ }
+ else
+ {
+ return zImPos;
+ }
+ }*/
+
+ // for *very* old ACR-NEMA images
+ entry = GetDataEntry(0x0020,0x1041);
+ if( entry )
+ {
+ if( entry->GetValueCount() == 1 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Slice Location (0020,1041)");
+ return 0.0f;
+ }
+/* std::string strSliceLocation = GetEntryString(0x0020,0x1041);
+ if ( strSliceLocation != GDCM_UNFOUND )
+ {
+ if ( sscanf( strSliceLocation.c_str(), "%f ", &zImPos) != 1)
+ {
+ gdcmWarningMacro( "Wrong Slice Location (0020,1041)");
+ return 0.; // bug in the element 0x0020,0x1041
+ }
+ else
+ {
+ return zImPos;
+ }
+ }
+ gdcmWarningMacro( "Unfound Slice Location (0020,1041)");*/
+
+ entry = GetDataEntry(0x0020,0x0050);
+ if( entry )
+ {
+ gdcmWarningMacro( "Unfound Location (0020,0050)");
+ if( entry->GetValueCount() == 1 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Location (0020,0050)");
+ return 0.0f;
+ }
+/* std::string strLocation = GetEntryString(0x0020,0x0050);
+ if ( strLocation != GDCM_UNFOUND )
+ {
+ if ( sscanf( strLocation.c_str(), "%f ", &zImPos) != 1 )
+ {
+ gdcmWarningMacro( "Wrong Location (0020,0050)");
+ return 0.; // bug in the element 0x0020,0x0050
+ }
+ else
+ {
+ return zImPos;
+ }
+ }
+ gdcmWarningMacro( "Unfound Location (0020,0050)");*/
+
+ return 0.; // Hopeless