]> Creatis software - gdcm.git/commitdiff
ENH: Commiting 1/2 patch from Jean Michel Rouet, for better DICOM writting support
authormalaterre <malaterre>
Wed, 10 Nov 2004 18:27:23 +0000 (18:27 +0000)
committermalaterre <malaterre>
Wed, 10 Nov 2004 18:27:23 +0000 (18:27 +0000)
src/gdcmDocEntry.cxx
src/gdcmDocument.cxx
src/gdcmFile.cxx
src/gdcmHeader.cxx
src/gdcmPixelConvert.cxx
src/gdcmSQItem.cxx
src/gdcmUtil.cxx
src/gdcmUtil.h

index 46b77b93f267d3caf8c4a30e2524e89ec3112062..5dfb6a3a62ea306f52bad281fdaddfecb7b6d071 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/09 22:15:36 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2004/11/10 18:27:23 $
+  Version:   $Revision: 1.31 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -43,6 +43,11 @@ DocEntry::DocEntry(DictEntry* in)
    DicomDict  = in;
    SetKey( in->GetKey( ) );
    Offset     = 0 ; // To avoid further missprinting
+
+   // init some variables
+   ReadLength = 0;
+   UsableLength = 0;
+   PrintLevel = 0;
 }
 
 //-----------------------------------------------------------------------------
index f2c4fb9585f8350f347c00480f1800ccf41e05c9..df8bd9fcb4721a03cbfe7b0c9a538938deee062b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/10 16:13:18 $
-  Version:   $Revision: 1.120 $
+  Date:      $Date: 2004/11/10 18:27:23 $
+  Version:   $Revision: 1.121 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -186,6 +186,8 @@ Document::Document() : ElementSet(-1)
 
    SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE);
    Initialise();
+   SwapCode = 0;
+   Filetype = ExplicitVR;
    PrintLevel = 1;  // 'Medium' print level by default
 }
 
@@ -416,6 +418,7 @@ FileType Document::GetFileType()
  */
 std::ifstream* Document::OpenFile()
 {
+   if (Filename.length() == 0) return 0;
    if(Fp)
    {
       dbg.Verbose( 0,
index 6276a5bcd1f5dad974f59d271a14636f6d06621a..955e0989b60e93ab2a41a5869d248ef7c3af5b7f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/05 21:23:46 $
-  Version:   $Revision: 1.152 $
+  Date:      $Date: 2004/11/10 18:27:23 $
+  Version:   $Revision: 1.153 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -513,7 +513,7 @@ uint8_t* File::GetDecompressed()
       // The decompressed image migth not be loaded yet:
       std::ifstream* fp = HeaderInternal->OpenFile();
       PixelConverter->ReadAndDecompressPixelData( fp );
-      HeaderInternal->CloseFile();
+      if(fp) HeaderInternal->CloseFile();
       decompressed = PixelConverter->GetDecompressed();
       if ( ! decompressed )
       {
index 13e90a3e44e66a1e66c174e3dd529190f89fbb98..bf44c55c4a62c94b0a0d325b642481731431fc38 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/09 21:55:55 $
-  Version:   $Revision: 1.199 $
+  Date:      $Date: 2004/11/10 18:27:23 $
+  Version:   $Revision: 1.200 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -373,12 +373,12 @@ float Header::GetZSpacing()
          // we assume slices join together
          // (no overlapping, no interslice gap)
          // if they don't, we're fucked up
-         return atof( strSliceThickness.c_str() );
+         return (float)atof( strSliceThickness.c_str() );
       }
    }
    else
    {
-      return atof( strSpacingBSlices.c_str() );
+      return (float)atof( strSpacingBSlices.c_str() );
    }
 }
 
index 73ca0e8b04b686cec22f73515b19c6450a9fa98c..cf3c240aa84d1134816a5367a65cac50fe475bd8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/10 16:22:02 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2004/11/10 18:27:23 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -902,7 +902,7 @@ void PixelConvert::GrabInformationsFromHeader( Header* header )
       }
    }
                                                                                 
-   header->CloseFile();
+   if(fp) header->CloseFile();
 }
 
 /**
index d7c29e5e4e0aa9fee103be946285f5729072a93f..166fd40a7e93247d13bed96db53da4365ecf0cb0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/04 15:08:50 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2004/11/10 18:27:23 $
+  Version:   $Revision: 1.36 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -109,13 +109,13 @@ void SQItem::Write(std::ofstream* fp, FileType filetype)
       binary_write( *fp, item[j]);  // fffe e000 ffff ffff 
    }
      
-   for (ListDocEntry::iterator i = DocEntries.begin();  
-                              i != DocEntries.end();
-                             ++i)
+   for (ListDocEntry::iterator it = DocEntries.begin();  
+                              it != DocEntries.end();
+                             ++it)
    {   
       // we skip delimitors (start and end one) because 
       // we force them as 'no length'
-      if ( (*i)->GetGroup() == 0xfffe )
+      if ( (*it)->GetGroup() == 0xfffe )
       {
          continue;
       }
@@ -123,12 +123,12 @@ void SQItem::Write(std::ofstream* fp, FileType filetype)
       // Fix in order to make some MR PHILIPS images e-film readable
       // see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
       // we just *always* ignore spurious fffe|0000 tag ! 
-      if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0x0000 )
+      if ( (*it)->GetGroup() == 0xfffe && (*it)->GetElement() == 0x0000 )
       {
          break; // FIXME : continue; ?!?
       }
 
-      (*i)->Write(fp, filetype);
+      (*it)->Write(fp, filetype);
    }
       
     //we force the writting of an 'Item Delimitation' item
index ebb8191d56b9cba8ba022c84109a29df7af67a4b..d0359f8be4ad844395cb613504a8597ebcc34c0b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/05 20:23:14 $
-  Version:   $Revision: 1.60 $
+  Date:      $Date: 2004/11/10 18:27:24 $
+  Version:   $Revision: 1.61 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
 
+// For GetCurrentDate, GetCurrentTime
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #include <stdarg.h>  //only included in implementation file
 #include <stdio.h>   //only included in implementation file
 
@@ -210,6 +215,34 @@ std::string Util::DicomString(const char* s)
    return r;
 }
 
+/**
+ * \ingroup Util
+ * \brief   Get the current date of the system in a dicom string
+ */
+std::string Util::GetCurrentDate()
+{
+    char tmp[512];
+    time_t tloc;
+    time (&tloc);    
+    strftime(tmp,512,"%Y%m%d", localtime(&tloc) );
+    return tmp;
+}
+
+/**
+ * \ingroup Util
+ * \brief   Get the current time of the system in a dicom string
+ */
+std::string Util::GetCurrentTime()
+{
+    char tmp[512];
+    time_t tloc;
+    time (&tloc);
+    strftime(tmp,512,"%H%M%S", localtime(&tloc) );
+    return tmp;  
+}
+
+
+
 /**
  * \ingroup Util
  * \brief Create a /DICOM/ string:
index 110a7fadd46e23ce10ff935892e5c38449217525..764369364e85697963deff4fe3e2f88341273bfe 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.h,v $
   Language:  C++
-  Date:      $Date: 2004/11/09 11:21:32 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2004/11/10 18:27:24 $
+  Version:   $Revision: 1.42 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -48,6 +48,8 @@ public:
    static std::string NormalizePath(std::string const & name);
    static std::string GetPath(std::string const &fullName);
    static std::string GetName(std::string const &fullName);
+   static std::string GetCurrentDate();
+   static std::string GetCurrentTime();
 
    static std::string DicomString(const char* s, size_t l);
    static std::string DicomString(const char* s);