X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vtk%2FvtkGdcmWriter.cxx;h=eacec2afa9045981adda3e171a5e4257d39038bd;hb=50106abe04f943dd37865e9454942aaa02e4b023;hp=7cf38df6b24379457f5dd64b6da56167630af2c0;hpb=7e8825e60d3550d5d8541d0ccc50c7c4a677e4c9;p=gdcm.git diff --git a/vtk/vtkGdcmWriter.cxx b/vtk/vtkGdcmWriter.cxx index 7cf38df6..eacec2af 100644 --- a/vtk/vtkGdcmWriter.cxx +++ b/vtk/vtkGdcmWriter.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmWriter.cxx,v $ Language: C++ - Date: $Date: 2006/05/02 11:11:00 $ - Version: $Revision: 1.30 $ + Date: $Date: 2006/05/11 15:12:00 $ + Version: $Revision: 1.33 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -33,7 +33,7 @@ #define vtkFloatingPointType float #endif -vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.30 $") +vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.33 $") vtkStandardNewMacro(vtkGdcmWriter) vtkCxxSetObjectMacro(vtkGdcmWriter,LookupTable,vtkLookupTable); @@ -45,7 +45,7 @@ vtkCxxSetObjectMacro(vtkGdcmWriter,MedicalImageProperties,vtkMedicalImagePropert vtkGdcmWriter::vtkGdcmWriter() { this->LookupTable = NULL; - this->MedicalImageProperties = NULL; + this->MedicalImageProperties = NULL; this->FileDimensionality = 3; this->WriteType = VTK_GDCM_WRITE_TYPE_EXPLICIT_VR; this->GdcmFile = 0; @@ -94,7 +94,11 @@ const char *vtkGdcmWriter::GetWriteTypeAsString() // The output data must be deleted by the user of the method !!! size_t ReverseData(vtkImageData *image,unsigned char **data) { +#if (VTK_MAJOR_VERSION >= 5) + vtkIdType inc[3]; +#else int inc[3]; +#endif int *extent = image->GetUpdateExtent(); int dim[3] = {extent[1]-extent[0]+1, extent[3]-extent[2]+1, @@ -133,47 +137,60 @@ size_t ReverseData(vtkImageData *image,unsigned char **data) return size; } - /** - * Set the medical informations in the file, based on the user passed - * vtkMedicalImageProperties - */ -#if (VTK_MAJOR_VERSION >= 5) +/** + * Set the medical informations in the file, based on the user passed + * vtkMedicalImageProperties + */ +#if (VTK_MAJOR_VERSION >= 5) void SetMedicalImageInformation(gdcm::FileHelper *file, vtkMedicalImageProperties *medprop) { // For now only do: // PatientName, PatientID, PatientAge, PatientSex, PatientBirthDate, StudyID - std::ostringstream str; + std::ostringstream str; if( medprop ) - { - str.str(""); - str << medprop->GetPatientName(); - file->InsertEntryString(str.str(),0x0010,0x0010,"PN"); // PN 1 Patient's Name - - str.str(""); - str << medprop->GetPatientID(); - file->InsertEntryString(str.str(),0x0010,0x0020,"LO"); // LO 1 Patient ID - - str.str(""); - str << medprop->GetPatientAge(); - file->InsertEntryString(str.str(),0x0010,0x1010,"AS"); // AS 1 Patient's Age - - str.str(""); - str << medprop->GetPatientSex(); - file->InsertEntryString(str.str(),0x0010,0x0040,"CS"); // CS 1 Patient's Sex - - str.str(""); - str << medprop->GetPatientBirthDate(); - file->InsertEntryString(str.str(),0x0010,0x0030,"DA"); // DA 1 Patient's Birth Date - - str.str(""); - str << medprop->GetStudyID(); - file->InsertEntryString(str.str(),0x0020,0x0010,"SH"); // SH 1 Study ID - } - } - -#else -void SetMedicalImageInformation(gdcm::FileHelper *, vtkMedicalImageProperties *) -{ + { + if (medprop->GetPatientName()) + { + str.str(""); + str << medprop->GetPatientName(); + file->InsertEntryString(str.str(),0x0010,0x0010,"PN"); // PN 1 Patient's Name + } + + if (medprop->GetPatientID()) + { + str.str(""); + str << medprop->GetPatientID(); + file->InsertEntryString(str.str(),0x0010,0x0020,"LO"); // LO 1 Patient ID + } + + if (medprop->GetPatientAge()) + { + str.str(""); + str << medprop->GetPatientAge(); + file->InsertEntryString(str.str(),0x0010,0x1010,"AS"); // AS 1 Patient's Age + } + + if (medprop->GetPatientSex()) + { + str.str(""); + str << medprop->GetPatientSex(); + file->InsertEntryString(str.str(),0x0010,0x0040,"CS"); // CS 1 Patient's Sex + } + + if (medprop->GetPatientBirthDate()) + { + str.str(""); + str << medprop->GetPatientBirthDate(); + file->InsertEntryString(str.str(),0x0010,0x0030,"DA"); // DA 1 Patient's Birth Date + } + + if (medprop->GetStudyID()) + { + str.str(""); + str << medprop->GetStudyID(); + file->InsertEntryString(str.str(),0x0020,0x0010,"SH"); // SH 1 Study ID + } + } } #endif @@ -394,10 +411,11 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName, vtkImageData *image) // From here, the write of the file begins - // Set the medical informations: +#if (VTK_MAJOR_VERSION >= 5) SetMedicalImageInformation(dcmFile, this->MedicalImageProperties); - +#endif + // Set the image informations SetImageInformation(dcmFile, image);