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
* \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
// 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 )
{
entry->SetDictEntry( newEntry );
}
-
}
/**
* \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;
}
// 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);
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.;
}
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 );
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.;
}
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 )
{
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");
}
}
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");
}
}
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.;
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.;
{
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
}
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
{
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
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
return zImPos;
}
}
- dbg.Verbose(0, "Header::GetYImagePosition: unfound Location (0020,0050)");
+ Debug::Verbose(0, "Header::GetYImagePosition: unfound Location (0020,0050)");
return 0.; // Hopeless
}
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
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;
}
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;
}
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
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
}
if ( PhotometricInterp == GDCM_UNFOUND )
{
- dbg.Verbose(0, "Header::IsMonochrome: absent Photometric "
+ Debug::Verbose(0, "Header::IsMonochrome: absent Photometric "
"Interpretation");
}
return false;
}
if ( PhotometricInterp == GDCM_UNFOUND )
{
- dbg.Verbose(0, "Header::IsPaletteColor: absent Photometric "
+ Debug::Verbose(0, "Header::IsPaletteColor: absent Photometric "
"Interpretation");
}
return false;
}
if ( PhotometricInterp == GDCM_UNFOUND )
{
- dbg.Verbose(0, "Header::IsYBRFull: absent Photometric "
+ Debug::Verbose(0, "Header::IsYBRFull: absent Photometric "
"Interpretation");
}
return false;
{
return 8;
}
- dbg.Verbose(0, "Header::GetPixelSize: Unknown pixel type");
+ Debug::Verbose(0, "Header::GetPixelSize: Unknown pixel type");
return 0;
}
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";
}
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" )
}
if ( transfertSyntax == GDCM_UNFOUND )
{
- dbg.Verbose(0, "Header::GetTransfertSyntaxName:"
+ Debug::Verbose(0, "Header::GetTransfertSyntaxName:"
" unfound Transfert Syntax (0002,0010)");
return "Uncompressed ACR-NEMA";
}
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)");
}
}
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)");
}
}