Program: gdcm
Module: $RCSfile: gdcmHeader.cxx,v $
Language: C++
- Date: $Date: 2004/11/16 05:03:35 $
- Version: $Revision: 1.201 $
+ Date: $Date: 2004/11/26 10:55:04 $
+ Version: $Revision: 1.208 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Note: this IS the right place for the code
// Image Location
- std::string imgLocation = GetEntryByNumber(0x0028, 0x0200);
+ const std::string &imgLocation = GetEntryByNumber(0x0028, 0x0200);
if ( imgLocation == GDCM_UNFOUND )
{
// default value
* @param filetype Type of the File to be written
* (ACR-NEMA, ExplicitVR, ImplicitVR)
*/
-void Header::Write(std::ofstream* fp,FileType filetype)
+bool Header::Write(std::string fileName,FileType filetype)
{
+ 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());
+ return false;
+ }
+
// Bits Allocated
if ( GetEntryByNumber(0x0028,0x0100) == "12")
{
RemoveEntryNoDestroy(e);
}
}
- Document::Write(fp,filetype);
+ Document::WriteContent(fp,filetype);
+
+ fp->close();
+ delete fp;
+
+ return true;
}
//-----------------------------------------------------------------------------
return false;
}
- std::string res = GetEntryByNumber(0x0028, 0x0005);
+ const std::string &res = GetEntryByNumber(0x0028, 0x0005);
if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 )
{
return false; // Image Dimensions
*/
int Header::GetXSize()
{
- std::string strSize;
- strSize = GetEntryByNumber(0x0028,0x0011);
+ const std::string &strSize = GetEntryByNumber(0x0028,0x0011);
if ( strSize == GDCM_UNFOUND )
{
return 0;
*/
int Header::GetYSize()
{
- std::string strSize = GetEntryByNumber(0x0028,0x0010);
+ const std::string &strSize = GetEntryByNumber(0x0028,0x0010);
if ( strSize != GDCM_UNFOUND )
{
return atoi( strSize.c_str() );
{
// Both DicomV3 and ACR/Nema consider the "Number of Frames"
// as the third dimension.
- std::string strSize = GetEntryByNumber(0x0028,0x0008);
+ const std::string &strSize = GetEntryByNumber(0x0028,0x0008);
if ( strSize != GDCM_UNFOUND )
{
return atoi( strSize.c_str() );
}
// We then consider the "Planes" entry as the third dimension
- strSize = GetEntryByNumber(0x0028,0x0012);
- if ( strSize != GDCM_UNFOUND )
+ const std::string &strSize2 = GetEntryByNumber(0x0028,0x0012);
+ if ( strSize2 != GDCM_UNFOUND )
{
- return atoi( strSize.c_str() );
+ return atoi( strSize2.c_str() );
}
return 1;
float Header::GetXSpacing()
{
float xspacing, yspacing;
- std::string strSpacing = GetEntryByNumber(0x0028,0x0030);
+ const std::string &strSpacing = GetEntryByNumber(0x0028,0x0030);
if ( strSpacing == GDCM_UNFOUND )
{
{
return (float)atof( strSpacingBSlices.c_str() );
}
+ return 1.;
}
/**
return "Uncompressed ACR-NEMA";
}
- while ( ! isdigit(transfertSyntax[transfertSyntax.length()-1]) )
+ while ( ! isdigit((unsigned char)transfertSyntax[transfertSyntax.length()-1]) )
{
transfertSyntax.erase(transfertSyntax.length()-1, 1);
}
return tsName;
}
-/**
- * \brief Sets the Pixel Area size in the Header
- * --> not-for-rats function
- * @param ImageDataSize new Pixel Area Size
- * warning : nothing else is checked
- */
-void Header::SetImageDataSize(size_t ImageDataSize)
-{
- ///FIXME I don't understand this code why do we set two times 'car' ?
- std::string car = Util::Format("%d", ImageDataSize);
-
- DocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel);
- a->SetLength(ImageDataSize);
-
- ImageDataSize += 8;
- car = Util::Format("%d", ImageDataSize);
- car = Util::DicomString( car.c_str() );
-
- SetEntryByNumber(car, GrPixel, NumPixel);
-}
-
//-----------------------------------------------------------------------------
// Protected