]> Creatis software - gdcm.git/commitdiff
* vtk/vtkGdcmWriter.[h|cxx] : add the gestion of UID
authorregrain <regrain>
Fri, 28 Jan 2005 10:07:34 +0000 (10:07 +0000)
committerregrain <regrain>
Fri, 28 Jan 2005 10:07:34 +0000 (10:07 +0000)
   -- BeNours

ChangeLog
vtk/vtkGdcmWriter.cxx
vtk/vtkGdcmWriter.h

index d4cd467cfd44d4690413c04094e3c98746a5339a..ed1691c7a6ad97c45aacf7b496ec8982fb741b75 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2005-01-28 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * vtk/vtkGdcmWriter.[h|cxx] : add the gestion of UID
+
 2005-01-28 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
    * src/gdcmUtil.cxx : compilation fix on Win32
    * src/gdcmUtil.[h|cxx] : Set the default GDCM UID in a static constant
index 1652c3c6c28801edd1f0f2f16f56d2fd5b29713c..4d0168780397b00aba09bb2ca9e0d774ef05adb8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmWriter.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 15:44:25 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2005/01/28 10:07:35 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,6 +19,7 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDebug.h"
+#include "gdcmUtil.h"
 #include "vtkGdcmWriter.h"
 
 #include <vtkObjectFactory.h>
@@ -26,7 +27,7 @@
 #include <vtkPointData.h>
 #include <vtkLookupTable.h>
 
-vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.15 $");
+vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.16 $");
 vtkStandardNewMacro(vtkGdcmWriter);
 
 //-----------------------------------------------------------------------------
@@ -36,6 +37,11 @@ vtkGdcmWriter::vtkGdcmWriter()
    this->LookupTable = NULL;
    this->FileDimensionality = 3;
    this->WriteType = VTK_GDCM_WRITE_TYPE_EXPLICIT_VR;
+
+   UIDPrefix = "";
+   StudyInstanceUID = "";
+   SeriesInstanceUID = "";
+   FrameOfReferenceInstanceUID = "";
 }
 
 vtkGdcmWriter::~vtkGdcmWriter()
@@ -70,6 +76,31 @@ const char *vtkGdcmWriter::GetWriteTypeAsString()
    }
 }
 
+void vtkGdcmWriter::SetUIDPrefix(const char *prefix)
+{
+   UIDPrefix = prefix;
+}
+
+const char *vtkGdcmWriter::GetUIDPrefix()
+{
+   return UIDPrefix.c_str();
+}
+
+void vtkGdcmWriter::NewStudyInstanceUID()
+{
+   StudyInstanceUID = "";
+}
+
+void vtkGdcmWriter::NewSeriesInstanceUID()
+{
+   SeriesInstanceUID = "";
+}
+
+void vtkGdcmWriter::NewFrameOfReferenceInstanceUID()
+{
+   FrameOfReferenceInstanceUID = "";
+}
+
 //-----------------------------------------------------------------------------
 // Protected
 /**
@@ -314,6 +345,21 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName,vtkImageData *image)
    // From here, the write of the file begins
    gdcm::FileHelper *dcmFile = new gdcm::FileHelper();
 
+   // Set the image UID
+   if( StudyInstanceUID.empty() )
+      StudyInstanceUID = gdcm::Util::CreateUniqueUID( UIDPrefix );
+   if( SeriesInstanceUID.empty() )
+      SeriesInstanceUID = gdcm::Util::CreateUniqueUID( UIDPrefix );
+   if( FrameOfReferenceInstanceUID.empty() )
+      FrameOfReferenceInstanceUID = gdcm::Util::CreateUniqueUID( UIDPrefix );
+   std::string uid = gdcm::Util::CreateUniqueUID( UIDPrefix );
+
+   dcmFile->InsertValEntry(uid,0x0008,0x0018); //[SOP Instance UID]
+   dcmFile->InsertValEntry(uid,0x0002,0x0003); //[Media Stored SOP Instance UID]
+   dcmFile->InsertValEntry(StudyInstanceUID,0x0020,0x000d); //[Study Instance UID]
+   dcmFile->InsertValEntry(SeriesInstanceUID,0x0020,0x000e); //[Series Instance UID]
+   dcmFile->InsertValEntry(FrameOfReferenceInstanceUID,0x0020, 0x0052); //[Frame of Reference UID] 
+
    // Set the image informations
    SetImageInformation(dcmFile,image);
 
index 1124a58a8187211c26d3892261d2e0bb70e4168f..3de9c069d8ad371a6be3e1bb1004ab7f1cac8434 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmWriter.h,v $
   Language:  C++
-  Date:      $Date: 2004/12/10 13:49:08 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/01/28 10:07:35 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,7 +23,6 @@
 
 #include <vtkImageWriter.h>
 #include <vtkLookupTable.h>
-#include <list>
 #include <string>
 
 //-----------------------------------------------------------------------------
@@ -52,6 +51,13 @@ public:
    vtkGetMacro(WriteType,int);
    const char *GetWriteTypeAsString();
 
+   void SetUIDPrefix(const char *prefix);
+   const char *GetUIDPrefix();
+
+   void NewStudyInstanceUID();
+   void NewSeriesInstanceUID();
+   void NewFrameOfReferenceInstanceUID();
+
 protected:
    vtkGdcmWriter();
    ~vtkGdcmWriter();
@@ -65,8 +71,14 @@ private:
 // Variables
    vtkLookupTable *LookupTable;
    int WriteType;
+
+   //BTX
+   std::string UIDPrefix;
+   std::string StudyInstanceUID;
+   std::string SeriesInstanceUID;
+   std::string FrameOfReferenceInstanceUID;
+   //ETX
 };
 
 //-----------------------------------------------------------------------------
 #endif
-