Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/01/18 18:03:16 $
- Version: $Revision: 1.198 $
+ Date: $Date: 2005/01/20 11:37:37 $
+ Version: $Revision: 1.203 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
Document::Document( std::string const &filename ) : ElementSet(-1)
{
+ RLEInfo = NULL;
+ JPEGInfo = NULL;
+
SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE);
Filename = filename;
- Initialise();
+ Initialize();
Fp = 0;
if ( !OpenFile() )
*/
Document::Document() : ElementSet(-1)
{
+ RLEInfo = NULL;
+ JPEGInfo = NULL;
+
Fp = 0;
SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE);
- Initialise();
+ Initialize();
SwapCode = 1234;
Filetype = ExplicitVR;
Group0002Parsed = false;
RefPubDict = NULL;
RefShaDict = NULL;
- delete RLEInfo;
- delete JPEGInfo;
+ if( RLEInfo )
+ delete RLEInfo;
+ if( JPEGInfo )
+ delete JPEGInfo;
}
//-----------------------------------------------------------------------------
Fp = 0;
}
- return true; //FIXME how do we detect a non-close ifstream ?
+ return true; //FIXME how do we detect a non-closed ifstream ?
}
/**
}
}
}
-
// Create a new seqEntry if necessary
if (!seqEntry)
{
return NULL;
}
}
-
return seqEntry;
}
}
/**
- * \brief Loads (from disk) the element content
- * when a string is not suitable
+ * \brief Loads (from disk) the element content
+ * when a string is not suitable
* @param group group number of the Entry
* @param elem element number of the Entry
*/
}
/**
- * \brief Loads (from disk) the element content
- * when a string is not suitable
+ * \brief Loads (from disk) the element content
+ * when a string is not suitable
* @param elem Entry whose binArea is going to be loaded
*/
void Document::LoadEntryBinArea(BinEntry *elem)
return false;
}*/
-/**
- * \brief retrieves a Dicom Element using (group, element)
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return
- */
-DocEntry *Document::GetDocEntry(uint16_t group, uint16_t elem)
-{
- TagKey key = DictEntry::TranslateToKey(group, elem);
- if ( !TagHT.count(key))
- {
- return NULL;
- }
- return TagHT.find(key)->second;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * ValEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding ValEntry.
- */
-ValEntry *Document::GetValEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( ValEntry *entry = dynamic_cast<ValEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound ValEntry.");
-
- return 0;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * BinEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding BinEntry.
- */
-BinEntry *Document::GetBinEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( BinEntry *entry = dynamic_cast<BinEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound BinEntry.");
-
- return 0;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * SeqEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding SeqEntry.
- */
-SeqEntry *Document::GetSeqEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( SeqEntry *entry = dynamic_cast<SeqEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound SeqEntry.");
-
- return 0;
-}
-
/**
* \brief Loads the element while preserving the current
{
if ( newDocEntry->IsSequenceDelimitor() )
{
- seqEntry->SetSequenceDelimitationItem( newDocEntry );
+ seqEntry->SetDelimitationItem( newDocEntry );
break;
}
}
offsetStartCurrentSQItem = Fp->tellg();
// end try -----------------
- seqEntry->AddEntry( itemSQ, SQItemNumber );
+ seqEntry->AddSQItem( itemSQ, SQItemNumber );
SQItemNumber++;
if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max )
{
// hands on a big endian encoded file: we switch the swap code to
// big endian and proceed...
- //
- // if ( element == 0x0000 && length16 == 0x0400 )
- // {
- // std::string ts = GetTransferSyntax();
- // if ( Global::GetTS()->GetSpecialTransferSyntax(ts)
- // != TS::ExplicitVRBigEndian )
- // {
- // throw FormatError( "Document::FindDocEntryLength()",
- // " not explicit VR." );
- // return;
- // }
- // length16 = 4;
- // SwitchByteSwapCode();
-
- // Restore the unproperly loaded values i.e. the group, the element
- // and the dictionary entry depending on them.
-// uint16_t correctGroup = SwapShort( entry->GetGroup() );
+// if ( element == 0x0000 && length16 == 0x0400 )
+// {
+// std::string ts = GetTransferSyntax();
+// if ( Global::GetTS()->GetSpecialTransferSyntax(ts)
+// != TS::ExplicitVRBigEndian )
+// {
+// throw FormatError( "Document::FindDocEntryLength()",
+// " not explicit VR." );
+// return;
+// }
+// length16 = 4;
+// SwitchByteSwapCode();
+//
+// // Restore the unproperly loaded values i.e. the group, the element
+// // and the dictionary entry depending on them.
+// uint16_t correctGroup = SwapShort( entry->GetGroup() );
// uint16_t correctElem = SwapShort( entry->GetElement() );
-// DictEntry *newTag = GetDictEntry( correctGroup, correctElem ); if ( !newTag )
+// DictEntry *newTag = GetDictEntry( correctGroup, correctElem );
+// if ( !newTag )
// {
- // This correct tag is not in the dictionary. Create a new one.
+// // This correct tag is not in the dictionary. Create a new one.
// newTag = NewVirtualDictEntry(correctGroup, correctElem);
// }
- // FIXME this can create a memory leaks on the old entry that be
- // left unreferenced.
+// // FIXME this can create a memory leaks on the old entry that be
+// // left unreferenced.
// entry->SetDictEntry( newTag );
// }
-
// 0xffff means that we deal with 'No Length' Sequence
// or 'No Length' SQItem
* \brief Loads all the needed Dictionaries
* \warning NOT end user intended method !
*/
-void Document::Initialise()
+void Document::Initialize()
{
RefPubDict = Global::GetDicts()->GetDefaultPubDict();
RefShaDict = NULL;