]> Creatis software - gdcm.git/commitdiff
Deal with VR 'OF' (Other Float String)
authorjpr <jpr>
Mon, 21 Nov 2005 12:15:06 +0000 (12:15 +0000)
committerjpr <jpr>
Mon, 21 Nov 2005 12:15:06 +0000 (12:15 +0000)
src/gdcmDataEntry.cxx
src/gdcmDocEntry.cxx
src/gdcmVR.cxx

index a57cb406a7a8cf3e4f0233f4e5fac6a31fa87fd3..f80dd7d290db83810222a52b1334f7b470b2e6af 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/21 09:46:24 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2005/11/21 12:15:06 $
+  Version:   $Revision: 1.23 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -286,14 +286,15 @@ uint32_t DataEntry::GetValueCount( ) const
       return GetLength()/sizeof(uint16_t);
    else if( vr == "UL" || vr == "SL" )
       return GetLength()/sizeof(uint32_t);
-   else if( vr == "FL" )
-      return GetLength()/sizeof(float);
+   else if( vr == "FL" || vr == "OF" )
+      return GetLength()/4 ; // FL has a *4* length! sizeof(float);
    else if( vr == "FD" )
-      return GetLength()/sizeof(double);
+      return GetLength()/8;  // FD has a *8* length! sizeof(double);
    else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
    {
       // Some element in DICOM are allowed to be empty
-      if( !GetLength() ) return 0;
+      if( !GetLength() ) 
+         return 0;
       // Don't use std::string to accelerate processing
       uint32_t count = 1;
       for(uint32_t i=0;i<GetLength();i++)
@@ -303,7 +304,6 @@ uint32_t DataEntry::GetValueCount( ) const
       }
       return count;
    }
-
    return GetLength();
 }
 /**
index 6a9a13ce201aa4ba3c7f86cf0a8a449bacb574e4..706d023c351865c50f1db532d8c6f947a60116e9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/03 08:47:51 $
-  Version:   $Revision: 1.77 $
+  Date:      $Date: 2005/11/21 12:15:06 $
+  Version:   $Revision: 1.78 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -128,10 +128,10 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype)
       else
       {
          binary_write(*fp, vr.str());
-                  
-         if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") /*|| (vr == "UN")*/ )
-// FIXME : what is the status of VR = "UN"
-//         --> uncomment or remove comment !
+
+         // See PS 3.5-2004 page 33, 36                  
+         if ( (vr == "SQ") || (vr == "OB") || (vr == "OW") || (vr == "OF") 
+          ||  (vr == "UN") || (vr == "UT") )
          {
             binary_write(*fp, zero);
             if (vr == "SQ")
index 839e1617096db2da51e5bd36048573b68f9e400a..6db25da4f1d7816b44f08449b364cb8933075505 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmVR.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/26 08:04:16 $
-  Version:   $Revision: 1.47 $
+  Date:      $Date: 2005/11/21 12:15:06 $
+  Version:   $Revision: 1.48 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -108,16 +108,14 @@ bool VR::IsVROfBinaryRepresentable(VRKey const &tested)
  */
 bool VR::IsVROfStringRepresentable(VRKey const &tested)
 {
-   //FIXME : either you consider than US, UL, SS, SL *are* string representable
-   //                            and you have to add FD and FL
-   //        or  you consider they are not, and you have to remove them
-   // (I cannot guess your point, reading gdcmDataEntry code :-( )  JPR
+/*
    return tested == "AE" ||
           tested == "AS" ||
           tested == "CS" ||
           tested == "DA" ||
           tested == "DS" ||
+          tested == "FL" ||
+          tested == "FD" || 
           tested == "IS" || 
           tested == "LO" ||
           tested == "LT" ||
@@ -131,17 +129,15 @@ bool VR::IsVROfStringRepresentable(VRKey const &tested)
           tested == "UL" ||
           tested == "US" ||
           tested == "UT";
+*/
+   // Should be quicker
 
-   // Should be quicker --> But it doesn't work : revert to old code
-/*
-   return tested != "FL" &&
-          tested != "FD" &&
-          tested != "OB" &&
+   return tested != "OB" &&
           tested != "OW" &&
-          tested != "AT" && // Attribute Tag ?!?
+          tested != "OF" &&
+          tested != "AT" && // Attribute Tag ?!? contain no printable character
           tested != "UN" && // UN is an actual VR !
           tested != "SQ" ;
-*/
 }
 /// \brief returns the length of a elementary elem whose VR is passed
 unsigned short VR::GetAtomicElementLength(VRKey const &tested)
@@ -161,6 +157,9 @@ unsigned short VR::GetAtomicElementLength(VRKey const &tested)
    // Word string
    if( tested == "OW" )
       return 2;
+   // Float string
+   if( tested == "OF" )
+      return 4;   
    return 1;
 }