From: regrain Date: Fri, 28 Jan 2005 10:07:34 +0000 (+0000) Subject: * vtk/vtkGdcmWriter.[h|cxx] : add the gestion of UID X-Git-Tag: Version1.0.bp~167 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=02163588f1fa2bb0af4b45455b6f9d08ec64f7b3;p=gdcm.git * vtk/vtkGdcmWriter.[h|cxx] : add the gestion of UID -- BeNours --- diff --git a/ChangeLog b/ChangeLog index d4cd467c..ed1691c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2005-01-28 Benoit Regrain + * vtk/vtkGdcmWriter.[h|cxx] : add the gestion of UID + 2005-01-28 Benoit Regrain * src/gdcmUtil.cxx : compilation fix on Win32 * src/gdcmUtil.[h|cxx] : Set the default GDCM UID in a static constant diff --git a/vtk/vtkGdcmWriter.cxx b/vtk/vtkGdcmWriter.cxx index 1652c3c6..4d016878 100644 --- a/vtk/vtkGdcmWriter.cxx +++ b/vtk/vtkGdcmWriter.cxx @@ -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 @@ -26,7 +27,7 @@ #include #include -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); diff --git a/vtk/vtkGdcmWriter.h b/vtk/vtkGdcmWriter.h index 1124a58a..3de9c069 100644 --- a/vtk/vtkGdcmWriter.h +++ b/vtk/vtkGdcmWriter.h @@ -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 #include -#include #include //----------------------------------------------------------------------------- @@ -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 -