]> Creatis software - gdcm.git/blobdiff - src/gdcmSerieHelper.cxx
Remove some useless seekg, tellg.
[gdcm.git] / src / gdcmSerieHelper.cxx
index 3761252f910ed4e0294ac29afa763463654249b9..5d7b6c48dbc236fd25c9f4cbaeeab22fbc9ff5c6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSerieHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/01/18 15:25:07 $
-  Version:   $Revision: 1.42 $
+  Date:      $Date: 2006/02/05 23:13:36 $
+  Version:   $Revision: 1.46 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -953,14 +953,14 @@ std::string SerieHelper::CreateUniqueSeriesIdentifier( File *inFile )
  *        Criterions will be set with AddSeriesDetail.
  *        (Maybe the method should be moved elsewhere 
  *       -File class? FileHelper class?-
- * @return FileIdentifier (Tokenizable on '_')
+ * @return FileIdentifier (Tokenizable on '%%%'. Hope it's enough !)
  */
 std::string SerieHelper::CreateUserDefinedFileIdentifier( File * inFile )
 {
   //     Deal with all user supplied tags.
   //      (user knows more than we do about his images!)
   
-   float converted;
+   double converted;
    std::string id;
    std::string s; 
    char charConverted[17]; 
@@ -971,23 +971,26 @@ std::string SerieHelper::CreateUserDefinedFileIdentifier( File * inFile )
    {
       const ExDetail &r = *it2;
       s = inFile->GetEntryString( r.group, r.elem );
-      
+
       // User is allowed to ask 'convertion', to allow further ordering
       // e.g : 100 would be *before* 20; 000020.00 vs 00100.00 : OK
       if (it2->convert)
       {
-         converted = atof(s.c_str());
-         // probabely something much more complicated is possible, 
-         // using C++ features
-         /// \todo check the behaviour when there are >0 and <0 numbers
-         sprintf(charConverted, "%016.6f",converted);
-         s = charConverted;
+         if ( s != GDCM_UNFOUND) // Don't convert unfound fields !
+         {
+            converted = atof(s.c_str());
+            // probabely something much more complicated is possible, 
+            // using C++ features
+            /// \todo check the behaviour when there are >0 and <0 numbers
+            sprintf(charConverted, "%016.6f",converted);
+            s = charConverted;
+         }
       }
       // Eliminate non-alphanum characters, including whitespace.
       for(unsigned int i=0; i<s.size(); i++)
       {
          while(i<s.size()
-            && !( s[i] == '.' || s[i] == '-'
+            && !( s[i] == '.' || s[i] == '%'
                     || (s[i] >= 'a' && s[i] <= 'z')
                     || (s[i] >= '0' && s[i] <= '9')
                     || (s[i] >= 'A' && s[i] <= 'Z')))
@@ -997,7 +1000,7 @@ std::string SerieHelper::CreateUserDefinedFileIdentifier( File * inFile )
       }
       
       id += s.c_str();
-      id += "_"; // make the FileIdentifier Tokenizable
+      id += "%%%"; // make the FileIdentifier Tokenizable
    }
    
    return id;