Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/08/29 13:05:01 $
- Version: $Revision: 1.270 $
+ Date: $Date: 2005/09/07 08:55:22 $
+ Version: $Revision: 1.275 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
Group0002Parsed = false;
IsDocumentAlreadyLoaded = false;
IsDocumentModified = true;
- LoadMode = 0x00000000; // default : load everything, later
+ LoadMode = LD_ALL; // default : load everything, later
SetFileName("");
}
SwapCode = 1234;
Filetype = ExplicitVR;
Group0002Parsed = false;
- LoadMode = 0x00000000; // Load everything, later
+ LoadMode = LD_ALL; // Load everything, later
// Load will set it to true if sucessfull
IsDocumentAlreadyLoaded = false;
*/
Document::~Document ()
{
- RefPubDict = NULL;
- RefShaDict = NULL;
+ CloseFile();
}
//-----------------------------------------------------------------------------
zero == 0x0007 || zero == 0x0700 || zero == 0x0008 || zero == 0x0800 )
{
std::string msg = Util::Format(
- "ACR/DICOM starting at the begining of the file:(%04x)\n", zero);
+ "ACR/DICOM starting at the beginning of the file:(%04x)\n", zero);
gdcmWarningMacro( msg.c_str() );
return Fp;
}
//-- DICOM --
Fp->seekg(126L, std::ios::cur);
- char dicm[4] = {' ',' ',' ',' '};
+ char dicm[4]; // = {' ',' ',' ',' '};
Fp->read(dicm, (size_t)4);
if ( Fp->eof() )
{
*/
void Document::WriteContent(std::ofstream *fp, FileType filetype)
{
- // \TODO move the following lines (and a lot of others, to be written)
- // to a future function CheckAndCorrectHeader
-
- // (necessary if user wants to write a DICOM V3 file
- // starting from an ACR-NEMA (V2) Header
+ // Skip if user wants to write an ACR-NEMA file
if ( filetype == ImplicitVR || filetype == ExplicitVR )
{
uint8_t *a = new uint8_t[l];
if ( !a )
{
- gdcmWarningMacro( "Cannot allocate BinEntry content");
+ gdcmWarningMacro( "Cannot allocate BinEntry content for : "
+ << std::hex << elem->GetGroup()
+ << "|" << elem->GetElement() );
return;
}
/**
* \brief Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader
- * @param filetype Type of the File to be written
*/
-int Document::ComputeGroup0002Length( FileType filetype )
+int Document::ComputeGroup0002Length( /*FileType filetype*/ )
{
uint16_t gr;
std::string vr;
if ( entry->GetElement() != 0x0000 )
{
vr = entry->GetVR();
+
+ // FIXME : group 0x0002 is *always* Explicit VR!
- if ( filetype == ExplicitVR )
- {
- if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || (vr == "UT") )
+ //if ( filetype == ExplicitVR )
+ //{
+ // if ( (vr == "OB") || (vr == "OW") || (vr == "UT") || (vr == "SQ") )
+ // (no SQ, OW, UT in group 0x0002;)
+ if ( vr == "OB" )
{
// explicit VR AND OB, OW, SQ, UT : 4 more bytes
groupLength += 4;
}
- }
+ //}
groupLength += 2 + 2 + 4 + entry->GetLength();
}
}
// When "this" is a Document the Key is simply of the
// form ( group, elem )...
- if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
- {
- newBinEntry->SetKey( newBinEntry->GetKey() );
- }
+ //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
+ //{
+ // newBinEntry->SetKey( newBinEntry->GetKey() );
+ //}
// but when "this" is a SQItem, we are inserting this new
// valEntry in a sequence item, and the key has the
// generalized form (refer to \ref BaseTagKey):
// When "set" is a Document, then we are at the top of the
// hierarchy and the Key is simply of the form ( group, elem )...
- if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
- {
- newValEntry->SetKey( newValEntry->GetKey() );
- }
+ //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
+ //{
+ // newValEntry->SetKey( newValEntry->GetKey() );
+ //}
// ...but when "set" is a SQItem, we are inserting this new
// valEntry in a sequence item. Hence the key has the
// generalized form (refer to \ref BaseTagKey):
{
if ( newValEntry->GetGroup()%2 != 0 ) // if Shadow Group
{
- if ( LoadMode & NO_SHADOW ) // if user asked to skip shad.gr
+ if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr
{
std::string strLgrGroup = newValEntry->GetValue();
int lgrGroup;
}
}
- if ( (LoadMode & NO_SHADOWSEQ) && ! delim_mode_intern )
+ if ( (LoadMode & LD_NOSHADOWSEQ) && ! delim_mode_intern )
{
// User asked to skip SeQuences *only* if they belong to Shadow Group
if ( newDocEntry->GetGroup()%2 != 0 )
continue;
}
}
- if ( (LoadMode & NO_SEQ) && ! delim_mode_intern )
+ if ( (LoadMode & LD_NOSEQ) && ! delim_mode_intern )
{
// User asked to skip *any* SeQuence
Fp->seekg( l, std::ios::cur);
// Hence the SeqEntry we are building simply has a depth
// level of one:
// SQItem *parentSQItem = dynamic_cast< SQItem* > ( set );
- if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
+ if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
{
newSeqEntry->SetDepthLevel( 1 );
- newSeqEntry->SetKey( newSeqEntry->GetKey() );
+ // newSeqEntry->SetKey( newSeqEntry->GetKey() );
}
// But when "set" is already a SQItem, we are building a nested
// sequence, and hence the depth level of the new SeqEntry
}
/**
- * \brief Find the value Length of the passed Header Entry
+ * \brief Find the value Length of the passed Doc Entry
* @param entry Header Entry whose length of the value shall be loaded.
*/
void Document::FindDocEntryLength( DocEntry *entry )
if ( Filetype == ExplicitVR && !entry->IsImplicitVR() )
{
- if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UT" || vr == "UN" )
+ if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UT"
+ /*|| vr == "UN"*/ )
{
// The following reserved two bytes (see PS 3.5-2003, section
// "7.1.2 Data element structure with explicit vr", p 27) must be
// chance to get the pixels by deciding the element goes
// until the end of the file. Hence we artificially fix the
// the length and proceed.
+ gdcmWarningMacro( " Computing the length failed for " <<
+ entry->GetKey() <<" in " <<GetFileName());
+
long currentPosition = Fp->tellg();
Fp->seekg(0L,std::ios::end);