X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmHeader.cxx;h=945f2885fc7abb10ff0e76c222323aea86d2fa86;hb=9ca4fd0ccbfea12ed7760856de3a8faf41625869;hp=2aedf3cda06c7f36dd799bdbc5080e20fb9b40b3;hpb=fc67f3aa1072606f7e088a1d00798a88ddcd90af;p=gdcm.git diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 2aedf3cd..945f2885 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmHeader.cxx,v $ Language: C++ - Date: $Date: 2005/01/05 16:30:50 $ - Version: $Revision: 1.219 $ + Date: $Date: 2005/01/07 16:26:13 $ + Version: $Revision: 1.223 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -34,7 +34,7 @@ namespace gdcm * \brief Constructor * @param filename name of the file whose header we want to analyze */ -Header::Header( std::string const & filename ): +Header::Header( std::string const &filename ): Document( filename ) { // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010 @@ -81,7 +81,7 @@ Header::Header( std::string const & filename ): // Let's create a VirtualDictEntry to allow a further VR modification // and force VR to match with BitsAllocated. - DocEntry* entry = GetDocEntryByNumber(GrPixel, NumPixel); + DocEntry *entry = GetDocEntryByNumber(GrPixel, NumPixel); if ( entry != 0 ) { @@ -99,7 +99,6 @@ Header::Header( std::string const & filename ): entry->SetDictEntry( newEntry ); } - } /** @@ -122,17 +121,17 @@ Header::~Header () * \brief Performs some consistency checking on various 'File related' * (as opposed to 'DicomDir related') entries * then writes in a file all the (Dicom Elements) included the Pixels - * @param fp file pointer on an already open file + * @param fileName file name to write to * @param filetype Type of the File to be written * (ACR-NEMA, ExplicitVR, ImplicitVR) */ bool Header::Write(std::string fileName, FileType filetype) { - std::ofstream* fp = new std::ofstream(fileName.c_str(), + std::ofstream *fp = new std::ofstream(fileName.c_str(), std::ios::out | std::ios::binary); if (*fp == NULL) { - dbg.Verbose(2, "Failed to open (write) File: " , fileName.c_str()); + Debug::Verbose(2, "Failed to open (write) File: " , fileName.c_str()); return false; } @@ -164,7 +163,7 @@ bool Header::Write(std::string fileName, FileType filetype) // Drop 0028|1101, 0028|1102, 0028|1103 // Drop 0028|1201, 0028|1202, 0028|1203 - DocEntry* e = GetDocEntryByNumber(0x0028,0x01101); + DocEntry *e = GetDocEntryByNumber(0x0028,0x01101); if (e) { RemoveEntryNoDestroy(e); @@ -329,7 +328,7 @@ float Header::GetXSpacing() if ( strSpacing == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetXSpacing: unfound Pixel Spacing (0028,0030)"); + Debug::Verbose(0, "Header::GetXSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } @@ -356,7 +355,7 @@ float Header::GetXSpacing() if ( xspacing == 0.) { - dbg.Verbose(0, "Header::GetXSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem"); + Debug::Verbose(0, "Header::GetXSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem"); // seems to be a bug in the header ... nbValues = sscanf( strSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing); assert( nbValues == 2 ); @@ -377,7 +376,7 @@ float Header::GetYSpacing() if ( strSpacing == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetYSpacing: unfound Pixel Spacing (0028,0030)"); + Debug::Verbose(0, "Header::GetYSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } @@ -412,7 +411,7 @@ float Header::GetZSpacing() if ( strSpacingBSlices == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetZSpacing: unfound StrSpacingBSlices"); + Debug::Verbose(0, "Header::GetZSpacing: unfound StrSpacingBSlices"); const std::string &strSliceThickness = GetEntryByNumber(0x0018,0x0050); if ( strSliceThickness == GDCM_UNFOUND ) { @@ -445,7 +444,7 @@ float Header::GetRescaleIntercept() if( sscanf( strRescInter.c_str(), "%f", &resInter) != 1 ) { // bug in the element 0x0028,0x1052 - dbg.Verbose(0, "Header::GetRescaleIntercept: Rescale Slope " + Debug::Verbose(0, "Header::GetRescaleIntercept: Rescale Slope " "is empty"); } } @@ -467,7 +466,7 @@ float Header::GetRescaleSlope() if( sscanf( strRescSlope.c_str(), "%f", &resSlope) != 1) { // bug in the element 0x0028,0x1053 - dbg.Verbose(0, "Header::GetRescaleSlope: Rescale Slope is empty"); + Debug::Verbose(0, "Header::GetRescaleSlope: Rescale Slope is empty"); } } @@ -573,12 +572,12 @@ float Header::GetXOrigin() if ( strImPos == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetXImagePosition: unfound Image " + Debug::Verbose(0, "Header::GetXImagePosition: unfound Image " "Position Patient (0020,0032)"); strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if ( strImPos == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetXImagePosition: unfound Image " + Debug::Verbose(0, "Header::GetXImagePosition: unfound Image " "Position (RET) (0020,0030)"); /// \todo How to tell the caller nothing was found ? return 0.; @@ -606,12 +605,12 @@ float Header::GetYOrigin() if ( strImPos == GDCM_UNFOUND) { - dbg.Verbose(0, "Header::GetYImagePosition: unfound Image " + Debug::Verbose(0, "Header::GetYImagePosition: unfound Image " "Position Patient (0020,0032)"); strImPos = GetEntryByNumber(0x0020,0x0030); // For ACR-NEMA images if ( strImPos == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetYImagePosition: unfound Image " + Debug::Verbose(0, "Header::GetYImagePosition: unfound Image " "Position (RET) (0020,0030)"); /// \todo How to tell the caller nothing was found ? return 0.; @@ -643,7 +642,7 @@ float Header::GetZOrigin() { if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3) { - dbg.Verbose(0, "Header::GetZImagePosition: wrong Image " + Debug::Verbose(0, "Header::GetZImagePosition: wrong Image " "Position Patient (0020,0032)"); return 0.; // bug in the element 0x0020,0x0032 } @@ -659,7 +658,7 @@ float Header::GetZOrigin() if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos ) != 3 ) { - dbg.Verbose(0, "Header::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); + Debug::Verbose(0, "Header::GetZImagePosition: wrong Image Position (RET) (0020,0030)"); return 0.; // bug in the element 0x0020,0x0032 } else @@ -673,7 +672,7 @@ float Header::GetZOrigin() { if( sscanf( strSliceLocation.c_str(), "%f", &zImPos) != 1) { - dbg.Verbose(0, "Header::GetZImagePosition: wrong Slice Location (0020,1041)"); + Debug::Verbose(0, "Header::GetZImagePosition: wrong Slice Location (0020,1041)"); return 0.; // bug in the element 0x0020,0x1041 } else @@ -681,14 +680,14 @@ float Header::GetZOrigin() return zImPos; } } - dbg.Verbose(0, "Header::GetZImagePosition: unfound Slice Location (0020,1041)"); + Debug::Verbose(0, "Header::GetZImagePosition: unfound Slice Location (0020,1041)"); std::string strLocation = GetEntryByNumber(0x0020,0x0050); if ( strLocation != GDCM_UNFOUND ) { if( sscanf( strLocation.c_str(), "%f", &zImPos) != 1) { - dbg.Verbose(0, "Header::GetZImagePosition: wrong Location (0020,0050)"); + Debug::Verbose(0, "Header::GetZImagePosition: wrong Location (0020,0050)"); return 0.; // bug in the element 0x0020,0x0050 } else @@ -696,7 +695,7 @@ float Header::GetZOrigin() return zImPos; } } - dbg.Verbose(0, "Header::GetYImagePosition: unfound Location (0020,0050)"); + Debug::Verbose(0, "Header::GetYImagePosition: unfound Location (0020,0050)"); return 0.; // Hopeless } @@ -795,7 +794,7 @@ int Header::GetBitsStored() std::string strSize = GetEntryByNumber( 0x0028, 0x0101 ); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetBitsStored: this is supposed to " + Debug::Verbose(0, "Header::GetBitsStored: this is supposed to " "be mandatory"); return 0; // It's supposed to be mandatory // the caller will have to check @@ -814,7 +813,7 @@ int Header::GetHighBitPosition() std::string strSize = GetEntryByNumber( 0x0028, 0x0102 ); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetHighBitPosition: this is supposed " + Debug::Verbose(0, "Header::GetHighBitPosition: this is supposed " "to be mandatory"); return 0; } @@ -832,7 +831,7 @@ bool Header::IsSignedPixelData() std::string strSize = GetEntryByNumber( 0x0028, 0x0103 ); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::IsSignedPixelData: this is supposed " + Debug::Verbose(0, "Header::IsSignedPixelData: this is supposed " "to be mandatory"); return false; } @@ -855,7 +854,7 @@ int Header::GetBitsAllocated() std::string strSize = GetEntryByNumber(0x0028,0x0100); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetBitsStored: this is supposed to " + Debug::Verbose(0, "Header::GetBitsStored: this is supposed to " "be mandatory"); return 0; // It's supposed to be mandatory // the caller will have to check @@ -874,7 +873,7 @@ int Header::GetSamplesPerPixel() const std::string& strSize = GetEntryByNumber(0x0028,0x0002); if ( strSize == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetBitsStored: this is supposed to " + Debug::Verbose(0, "Header::GetBitsStored: this is supposed to " "be mandatory"); return 1; // Well, it's supposed to be mandatory ... // but sometimes it's missing : *we* assume Gray pixels @@ -897,7 +896,7 @@ bool Header::IsMonochrome() } if ( PhotometricInterp == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::IsMonochrome: absent Photometric " + Debug::Verbose(0, "Header::IsMonochrome: absent Photometric " "Interpretation"); } return false; @@ -917,7 +916,7 @@ bool Header::IsPaletteColor() } if ( PhotometricInterp == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::IsPaletteColor: absent Photometric " + Debug::Verbose(0, "Header::IsPaletteColor: absent Photometric " "Interpretation"); } return false; @@ -937,7 +936,7 @@ bool Header::IsYBRFull() } if ( PhotometricInterp == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::IsYBRFull: absent Photometric " + Debug::Verbose(0, "Header::IsYBRFull: absent Photometric " "Interpretation"); } return false; @@ -987,7 +986,7 @@ int Header::GetPixelSize() { return 8; } - dbg.Verbose(0, "Header::GetPixelSize: Unknown pixel type"); + Debug::Verbose(0, "Header::GetPixelSize: Unknown pixel type"); return 0; } @@ -1010,7 +1009,7 @@ std::string Header::GetPixelType() std::string bitsAlloc = GetEntryByNumber(0x0028, 0x0100); // Bits Allocated if ( bitsAlloc == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetPixelType: unfound Bits Allocated"); + Debug::Verbose(0, "Header::GetPixelType: unfound Bits Allocated"); bitsAlloc = "16"; } @@ -1033,7 +1032,7 @@ std::string Header::GetPixelType() if (sign == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetPixelType: unfound Pixel Representation"); + Debug::Verbose(0, "Header::GetPixelType: unfound Pixel Representation"); bitsAlloc = "0"; } else if ( sign == "0" ) @@ -1195,7 +1194,7 @@ std::string Header::GetTransfertSyntaxName() } if ( transfertSyntax == GDCM_UNFOUND ) { - dbg.Verbose(0, "Header::GetTransfertSyntaxName:" + Debug::Verbose(0, "Header::GetTransfertSyntaxName:" " unfound Transfert Syntax (0002,0010)"); return "Uncompressed ACR-NEMA"; } @@ -1313,7 +1312,7 @@ void Header::GetImageOrientationPatient( float iop[6] ) if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { - dbg.Verbose(0, "Header::GetImageOrientationPatient: " + Debug::Verbose(0, "Header::GetImageOrientationPatient: " "wrong Image Orientation Patient (0020,0037)"); } } @@ -1324,7 +1323,7 @@ void Header::GetImageOrientationPatient( float iop[6] ) if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { - dbg.Verbose(0, "Header::GetImageOrientationPatient: " + Debug::Verbose(0, "Header::GetImageOrientationPatient: " "wrong Image Orientation Patient (0020,0035)"); } }