X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vtk%2FvtkGdcmWriter.cxx;h=e5b3b5197109396c6b1db3db5a2be67d0172b542;hb=6f38e3557850c8eee0c60860dcad4c7c365edea0;hp=d73ddccc8decb526cf072b7bdc72e96e55c8a318;hpb=382ccb2da3319382d7e1f7296b937d60c63dee97;p=gdcm.git diff --git a/vtk/vtkGdcmWriter.cxx b/vtk/vtkGdcmWriter.cxx index d73ddccc..e5b3b519 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/04/11 17:01:16 $ - Version: $Revision: 1.21 $ + Date: $Date: 2005/10/18 08:35:55 $ + Version: $Revision: 1.25 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -27,8 +27,12 @@ #include #include -vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.21 $"); -vtkStandardNewMacro(vtkGdcmWriter); +#ifndef vtkFloatingPointType +#define vtkFloatingPointType float +#endif + +vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.25 $") +vtkStandardNewMacro(vtkGdcmWriter) //----------------------------------------------------------------------------- // Constructor / Destructor @@ -133,37 +137,37 @@ void SetImageInformation(gdcm::FileHelper *file, vtkImageData *image) str.str(""); str << dim[0]; - file->InsertValEntry(str.str(),0x0028,0x0011); // Columns + file->InsertEntryString(str.str(),0x0028,0x0011); // Columns str.str(""); str << dim[1]; - file->InsertValEntry(str.str(),0x0028,0x0010); // Rows + file->InsertEntryString(str.str(),0x0028,0x0010); // Rows if(dim[2]>1) { str.str(""); str << dim[2]; //file->Insert(str.str(),0x0028,0x0012); // Planes - file->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames + file->InsertEntryString(str.str(),0x0028,0x0008); // Number of Frames } // Pixel type str.str(""); str << image->GetScalarSize()*8; - file->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated - file->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored + file->InsertEntryString(str.str(),0x0028,0x0100); // Bits Allocated + file->InsertEntryString(str.str(),0x0028,0x0101); // Bits Stored str.str(""); str << image->GetScalarSize()*8-1; - file->InsertValEntry(str.str(),0x0028,0x0102); // High Bit + file->InsertEntryString(str.str(),0x0028,0x0102); // High Bit // Pixel Repr // FIXME : what do we do when the ScalarType is // VTK_UNSIGNED_INT or VTK_UNSIGNED_LONG str.str(""); - if( image->GetScalarType() == VTK_UNSIGNED_CHAR || + if( image->GetScalarType() == VTK_UNSIGNED_CHAR || image->GetScalarType() == VTK_UNSIGNED_SHORT || - image->GetScalarType() == VTK_UNSIGNED_INT || + image->GetScalarType() == VTK_UNSIGNED_INT || image->GetScalarType() == VTK_UNSIGNED_LONG ) { str << "0"; // Unsigned @@ -172,49 +176,50 @@ void SetImageInformation(gdcm::FileHelper *file, vtkImageData *image) { str << "1"; // Signed } - file->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation + file->InsertEntryString(str.str(),0x0028,0x0103); // Pixel Representation // Samples per pixel str.str(""); str << image->GetNumberOfScalarComponents(); - file->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel + file->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel /// \todo : Spacing Between Slices is meaningfull ONLY for CT an MR modality /// We should perform some checkings before forcing the Entry creation // Spacing - double *sp = image->GetSpacing(); + vtkFloatingPointType *sp = image->GetSpacing(); str.str(""); - // We are about to enter floating point value. By default ostringstream are smart and don't do fixed point + // We are about to enter floating point value. + // By default ostringstream are smart and don't do fixed point // thus forcing to fixed point value str.setf( std::ios::fixed ); str << sp[1] << "\\" << sp[0]; - file->InsertValEntry(str.str(),0x0028,0x0030); // Pixel Spacing + file->InsertEntryString(str.str(),0x0028,0x0030); // Pixel Spacing str.str(""); str << sp[2]; - file->InsertValEntry(str.str(),0x0018,0x0088); // Spacing Between Slices + file->InsertEntryString(str.str(),0x0018,0x0088); // Spacing Between Slices // Origin - double *org = image->GetOrigin(); + vtkFloatingPointType *org = image->GetOrigin(); /// \todo : Image Position Patient is meaningfull ONLY for CT an MR modality /// We should perform some checkings before forcing the Entry creation str.str(""); str << org[0] << "\\" << org[1] << "\\" << org[2]; - file->InsertValEntry(str.str(),0x0020,0x0032); // Image Position Patient + file->InsertEntryString(str.str(),0x0020,0x0032); // Image Position Patient str.unsetf( std::ios::fixed ); //done with floating point values // Window / Level - double *rng=image->GetScalarRange(); + vtkFloatingPointType *rng = image->GetScalarRange(); str.str(""); str << rng[1]-rng[0]; - file->InsertValEntry(str.str(),0x0028,0x1051); // Window Width + file->InsertEntryString(str.str(),0x0028,0x1051); // Window Width str.str(""); str << (rng[1]+rng[0])/2.0; - file->InsertValEntry(str.str(),0x0028,0x1050); // Window Center + file->InsertEntryString(str.str(),0x0028,0x1050); // Window Center // Pixels unsigned char *data; @@ -279,6 +284,8 @@ void vtkGdcmWriter::RecursiveWrite(int axis, vtkImageData *cache, { sprintf(this->InternalFileName, this->FilePattern,this->FileNumber); } +// Remove this code in case user is using VTK 4.2... +#if !(VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION == 2) if (this->FileNumber < this->MinimumFileNumber) { this->MinimumFileNumber = this->FileNumber; @@ -287,6 +294,7 @@ void vtkGdcmWriter::RecursiveWrite(int axis, vtkImageData *cache, { this->MaximumFileNumber = this->FileNumber; } +#endif } // Write the file